Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1 | /** |
Jayamohan Kallickal | 533c165 | 2013-04-05 20:38:34 -0700 | [diff] [blame] | 2 | * Copyright (C) 2005 - 2013 Emulex |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 3 | * All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License version 2 |
| 7 | * as published by the Free Software Foundation. The full GNU General |
| 8 | * Public License is included in this distribution in the file called COPYING. |
| 9 | * |
Jayamohan Kallickal | 255fa9a | 2011-03-25 14:23:57 -0700 | [diff] [blame] | 10 | * Written by: Jayamohan Kallickal (jayamohan.kallickal@emulex.com) |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 11 | * |
| 12 | * Contact Information: |
Jayamohan Kallickal | 255fa9a | 2011-03-25 14:23:57 -0700 | [diff] [blame] | 13 | * linux-drivers@emulex.com |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 14 | * |
Jayamohan Kallickal | 255fa9a | 2011-03-25 14:23:57 -0700 | [diff] [blame] | 15 | * Emulex |
| 16 | * 3333 Susan Street |
| 17 | * Costa Mesa, CA 92626 |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 18 | */ |
| 19 | |
Jayamohan Kallickal | ffce3e2 | 2012-04-03 23:41:50 -0500 | [diff] [blame] | 20 | #include <linux/bsg-lib.h> |
| 21 | #include <scsi/scsi_transport_iscsi.h> |
| 22 | #include <scsi/scsi_bsg_iscsi.h> |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 23 | #include "be_mgmt.h" |
| 24 | #include "be_iscsi.h" |
John Soni Jose | 7a15800 | 2012-10-20 04:45:51 +0530 | [diff] [blame] | 25 | #include "be_main.h" |
| 26 | |
| 27 | /* UE Status Low CSR */ |
| 28 | static const char * const desc_ue_status_low[] = { |
| 29 | "CEV", |
| 30 | "CTX", |
| 31 | "DBUF", |
| 32 | "ERX", |
| 33 | "Host", |
| 34 | "MPU", |
| 35 | "NDMA", |
| 36 | "PTC ", |
| 37 | "RDMA ", |
| 38 | "RXF ", |
| 39 | "RXIPS ", |
| 40 | "RXULP0 ", |
| 41 | "RXULP1 ", |
| 42 | "RXULP2 ", |
| 43 | "TIM ", |
| 44 | "TPOST ", |
| 45 | "TPRE ", |
| 46 | "TXIPS ", |
| 47 | "TXULP0 ", |
| 48 | "TXULP1 ", |
| 49 | "UC ", |
| 50 | "WDMA ", |
| 51 | "TXULP2 ", |
| 52 | "HOST1 ", |
| 53 | "P0_OB_LINK ", |
| 54 | "P1_OB_LINK ", |
| 55 | "HOST_GPIO ", |
| 56 | "MBOX ", |
| 57 | "AXGMAC0", |
| 58 | "AXGMAC1", |
| 59 | "JTAG", |
| 60 | "MPU_INTPEND" |
| 61 | }; |
| 62 | |
| 63 | /* UE Status High CSR */ |
| 64 | static const char * const desc_ue_status_hi[] = { |
| 65 | "LPCMEMHOST", |
| 66 | "MGMT_MAC", |
| 67 | "PCS0ONLINE", |
| 68 | "MPU_IRAM", |
| 69 | "PCS1ONLINE", |
| 70 | "PCTL0", |
| 71 | "PCTL1", |
| 72 | "PMEM", |
| 73 | "RR", |
| 74 | "TXPB", |
| 75 | "RXPP", |
| 76 | "XAUI", |
| 77 | "TXP", |
| 78 | "ARM", |
| 79 | "IPC", |
| 80 | "HOST2", |
| 81 | "HOST3", |
| 82 | "HOST4", |
| 83 | "HOST5", |
| 84 | "HOST6", |
| 85 | "HOST7", |
| 86 | "HOST8", |
| 87 | "HOST9", |
| 88 | "NETC", |
| 89 | "Unknown", |
| 90 | "Unknown", |
| 91 | "Unknown", |
| 92 | "Unknown", |
| 93 | "Unknown", |
| 94 | "Unknown", |
| 95 | "Unknown", |
| 96 | "Unknown" |
| 97 | }; |
| 98 | |
| 99 | /* |
| 100 | * beiscsi_ue_detec()- Detect Unrecoverable Error on adapter |
| 101 | * @phba: Driver priv structure |
| 102 | * |
| 103 | * Read registers linked to UE and check for the UE status |
| 104 | **/ |
| 105 | void beiscsi_ue_detect(struct beiscsi_hba *phba) |
| 106 | { |
| 107 | uint32_t ue_hi = 0, ue_lo = 0; |
| 108 | uint32_t ue_mask_hi = 0, ue_mask_lo = 0; |
| 109 | uint8_t i = 0; |
| 110 | |
| 111 | if (phba->ue_detected) |
| 112 | return; |
| 113 | |
| 114 | pci_read_config_dword(phba->pcidev, |
| 115 | PCICFG_UE_STATUS_LOW, &ue_lo); |
| 116 | pci_read_config_dword(phba->pcidev, |
| 117 | PCICFG_UE_STATUS_MASK_LOW, |
| 118 | &ue_mask_lo); |
| 119 | pci_read_config_dword(phba->pcidev, |
| 120 | PCICFG_UE_STATUS_HIGH, |
| 121 | &ue_hi); |
| 122 | pci_read_config_dword(phba->pcidev, |
| 123 | PCICFG_UE_STATUS_MASK_HI, |
| 124 | &ue_mask_hi); |
| 125 | |
| 126 | ue_lo = (ue_lo & ~ue_mask_lo); |
| 127 | ue_hi = (ue_hi & ~ue_mask_hi); |
| 128 | |
| 129 | |
| 130 | if (ue_lo || ue_hi) { |
| 131 | phba->ue_detected = true; |
| 132 | beiscsi_log(phba, KERN_ERR, |
| 133 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, |
| 134 | "BG_%d : Error detected on the adapter\n"); |
| 135 | } |
| 136 | |
| 137 | if (ue_lo) { |
| 138 | for (i = 0; ue_lo; ue_lo >>= 1, i++) { |
| 139 | if (ue_lo & 1) |
| 140 | beiscsi_log(phba, KERN_ERR, |
| 141 | BEISCSI_LOG_CONFIG, |
| 142 | "BG_%d : UE_LOW %s bit set\n", |
| 143 | desc_ue_status_low[i]); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | if (ue_hi) { |
| 148 | for (i = 0; ue_hi; ue_hi >>= 1, i++) { |
| 149 | if (ue_hi & 1) |
| 150 | beiscsi_log(phba, KERN_ERR, |
| 151 | BEISCSI_LOG_CONFIG, |
| 152 | "BG_%d : UE_HIGH %s bit set\n", |
| 153 | desc_ue_status_hi[i]); |
| 154 | } |
| 155 | } |
| 156 | } |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 157 | |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 158 | /** |
| 159 | * mgmt_reopen_session()- Reopen a session based on reopen_type |
| 160 | * @phba: Device priv structure instance |
| 161 | * @reopen_type: Type of reopen_session FW should do. |
| 162 | * @sess_handle: Session Handle of the session to be re-opened |
| 163 | * |
| 164 | * return |
| 165 | * the TAG used for MBOX Command |
| 166 | * |
| 167 | **/ |
| 168 | unsigned int mgmt_reopen_session(struct beiscsi_hba *phba, |
| 169 | unsigned int reopen_type, |
| 170 | unsigned int sess_handle) |
| 171 | { |
| 172 | struct be_ctrl_info *ctrl = &phba->ctrl; |
| 173 | struct be_mcc_wrb *wrb; |
| 174 | struct be_cmd_reopen_session_req *req; |
| 175 | unsigned int tag = 0; |
| 176 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 177 | beiscsi_log(phba, KERN_INFO, |
| 178 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, |
| 179 | "BG_%d : In bescsi_get_boot_target\n"); |
| 180 | |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 181 | spin_lock(&ctrl->mbox_lock); |
| 182 | tag = alloc_mcc_tag(phba); |
| 183 | if (!tag) { |
| 184 | spin_unlock(&ctrl->mbox_lock); |
| 185 | return tag; |
| 186 | } |
| 187 | |
| 188 | wrb = wrb_from_mccq(phba); |
| 189 | req = embedded_payload(wrb); |
| 190 | wrb->tag0 |= tag; |
| 191 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
| 192 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI, |
| 193 | OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS, |
| 194 | sizeof(struct be_cmd_reopen_session_resp)); |
| 195 | |
| 196 | /* set the reopen_type,sess_handle */ |
| 197 | req->reopen_type = reopen_type; |
| 198 | req->session_handle = sess_handle; |
| 199 | |
| 200 | be_mcc_notify(phba); |
| 201 | spin_unlock(&ctrl->mbox_lock); |
| 202 | return tag; |
| 203 | } |
| 204 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 205 | unsigned int mgmt_get_boot_target(struct beiscsi_hba *phba) |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 206 | { |
| 207 | struct be_ctrl_info *ctrl = &phba->ctrl; |
| 208 | struct be_mcc_wrb *wrb; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 209 | struct be_cmd_get_boot_target_req *req; |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 210 | unsigned int tag = 0; |
| 211 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 212 | beiscsi_log(phba, KERN_INFO, |
| 213 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, |
| 214 | "BG_%d : In bescsi_get_boot_target\n"); |
| 215 | |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 216 | spin_lock(&ctrl->mbox_lock); |
| 217 | tag = alloc_mcc_tag(phba); |
| 218 | if (!tag) { |
| 219 | spin_unlock(&ctrl->mbox_lock); |
| 220 | return tag; |
| 221 | } |
| 222 | |
| 223 | wrb = wrb_from_mccq(phba); |
| 224 | req = embedded_payload(wrb); |
| 225 | wrb->tag0 |= tag; |
| 226 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
| 227 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI, |
| 228 | OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET, |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 229 | sizeof(struct be_cmd_get_boot_target_resp)); |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 230 | |
| 231 | be_mcc_notify(phba); |
| 232 | spin_unlock(&ctrl->mbox_lock); |
| 233 | return tag; |
| 234 | } |
| 235 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 236 | unsigned int mgmt_get_session_info(struct beiscsi_hba *phba, |
| 237 | u32 boot_session_handle, |
| 238 | struct be_dma_mem *nonemb_cmd) |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 239 | { |
| 240 | struct be_ctrl_info *ctrl = &phba->ctrl; |
| 241 | struct be_mcc_wrb *wrb; |
| 242 | unsigned int tag = 0; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 243 | struct be_cmd_get_session_req *req; |
| 244 | struct be_cmd_get_session_resp *resp; |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 245 | struct be_sge *sge; |
| 246 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 247 | beiscsi_log(phba, KERN_INFO, |
| 248 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, |
| 249 | "BG_%d : In beiscsi_get_session_info\n"); |
| 250 | |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 251 | spin_lock(&ctrl->mbox_lock); |
| 252 | tag = alloc_mcc_tag(phba); |
| 253 | if (!tag) { |
| 254 | spin_unlock(&ctrl->mbox_lock); |
| 255 | return tag; |
| 256 | } |
| 257 | |
| 258 | nonemb_cmd->size = sizeof(*resp); |
| 259 | req = nonemb_cmd->va; |
| 260 | memset(req, 0, sizeof(*req)); |
| 261 | wrb = wrb_from_mccq(phba); |
| 262 | sge = nonembedded_sgl(wrb); |
| 263 | wrb->tag0 |= tag; |
| 264 | |
| 265 | |
| 266 | wrb->tag0 |= tag; |
| 267 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1); |
| 268 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI, |
| 269 | OPCODE_ISCSI_INI_SESSION_GET_A_SESSION, |
| 270 | sizeof(*resp)); |
| 271 | req->session_handle = boot_session_handle; |
| 272 | sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma)); |
| 273 | sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); |
| 274 | sge->len = cpu_to_le32(nonemb_cmd->size); |
| 275 | |
| 276 | be_mcc_notify(phba); |
| 277 | spin_unlock(&ctrl->mbox_lock); |
| 278 | return tag; |
| 279 | } |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 280 | |
Jayamohan Kallickal | 843ae75 | 2013-09-28 15:35:44 -0700 | [diff] [blame] | 281 | /** |
| 282 | * mgmt_get_fw_config()- Get the FW config for the function |
| 283 | * @ctrl: ptr to Ctrl Info |
| 284 | * @phba: ptr to the dev priv structure |
| 285 | * |
| 286 | * Get the FW config and resources available for the function. |
| 287 | * The resources are created based on the count received here. |
| 288 | * |
| 289 | * return |
| 290 | * Success: 0 |
| 291 | * Failure: Non-Zero Value |
| 292 | **/ |
Jayamohan Kallickal | 03a1231 | 2010-07-22 04:17:16 +0530 | [diff] [blame] | 293 | int mgmt_get_fw_config(struct be_ctrl_info *ctrl, |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 294 | struct beiscsi_hba *phba) |
| 295 | { |
| 296 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); |
| 297 | struct be_fw_cfg *req = embedded_payload(wrb); |
| 298 | int status = 0; |
| 299 | |
| 300 | spin_lock(&ctrl->mbox_lock); |
| 301 | memset(wrb, 0, sizeof(*wrb)); |
| 302 | |
| 303 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
| 304 | |
| 305 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
Jayamohan Kallickal | 843ae75 | 2013-09-28 15:35:44 -0700 | [diff] [blame] | 306 | OPCODE_COMMON_QUERY_FIRMWARE_CONFIG, |
| 307 | EMBED_MBX_MAX_PAYLOAD_SIZE); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 308 | status = be_mbox_notify(ctrl); |
| 309 | if (!status) { |
Jayamohan Kallickal | 843ae75 | 2013-09-28 15:35:44 -0700 | [diff] [blame] | 310 | uint8_t ulp_num = 0; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 311 | struct be_fw_cfg *pfw_cfg; |
| 312 | pfw_cfg = req; |
Jayamohan Kallickal | 843ae75 | 2013-09-28 15:35:44 -0700 | [diff] [blame] | 313 | |
Jayamohan Kallickal | 68c26a3 | 2013-09-28 15:35:54 -0700 | [diff] [blame^] | 314 | if (!is_chip_be2_be3r(phba)) { |
| 315 | phba->fw_config.eqid_count = pfw_cfg->eqid_count; |
| 316 | phba->fw_config.cqid_count = pfw_cfg->cqid_count; |
| 317 | |
| 318 | beiscsi_log(phba, KERN_INFO, |
| 319 | BEISCSI_LOG_INIT, |
| 320 | "BG_%d : EQ_Count : %d CQ_Count : %d\n", |
| 321 | phba->fw_config.eqid_count, |
| 322 | phba->fw_config.cqid_count); |
| 323 | } |
| 324 | |
Jayamohan Kallickal | 843ae75 | 2013-09-28 15:35:44 -0700 | [diff] [blame] | 325 | for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) |
| 326 | if (pfw_cfg->ulp[ulp_num].ulp_mode & |
| 327 | BEISCSI_ULP_ISCSI_INI_MODE) |
| 328 | set_bit(ulp_num, |
Jayamohan Kallickal | 8a86e83 | 2013-09-28 15:35:45 -0700 | [diff] [blame] | 329 | &phba->fw_config.ulp_supported); |
Jayamohan Kallickal | 843ae75 | 2013-09-28 15:35:44 -0700 | [diff] [blame] | 330 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 331 | phba->fw_config.phys_port = pfw_cfg->phys_port; |
Jayamohan Kallickal | 843ae75 | 2013-09-28 15:35:44 -0700 | [diff] [blame] | 332 | for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) { |
| 333 | if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { |
| 334 | |
| 335 | phba->fw_config.iscsi_cid_start[ulp_num] = |
| 336 | pfw_cfg->ulp[ulp_num].sq_base; |
| 337 | phba->fw_config.iscsi_cid_count[ulp_num] = |
| 338 | pfw_cfg->ulp[ulp_num].sq_count; |
| 339 | |
| 340 | phba->fw_config.iscsi_icd_start[ulp_num] = |
| 341 | pfw_cfg->ulp[ulp_num].icd_base; |
| 342 | phba->fw_config.iscsi_icd_count[ulp_num] = |
| 343 | pfw_cfg->ulp[ulp_num].icd_count; |
| 344 | |
| 345 | phba->fw_config.iscsi_chain_start[ulp_num] = |
| 346 | pfw_cfg->chain_icd[ulp_num].chain_base; |
| 347 | phba->fw_config.iscsi_chain_count[ulp_num] = |
| 348 | pfw_cfg->chain_icd[ulp_num].chain_count; |
| 349 | |
| 350 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, |
| 351 | "BG_%d : Function loaded on ULP : %d\n" |
| 352 | "\tiscsi_cid_count : %d\n" |
| 353 | "\t iscsi_icd_count : %d\n", |
| 354 | ulp_num, |
| 355 | phba->fw_config. |
| 356 | iscsi_cid_count[ulp_num], |
| 357 | phba->fw_config. |
| 358 | iscsi_icd_count[ulp_num]); |
| 359 | } |
Jayamohan Kallickal | 7da5087 | 2010-01-05 05:04:12 +0530 | [diff] [blame] | 360 | } |
Jayamohan Kallickal | 843ae75 | 2013-09-28 15:35:44 -0700 | [diff] [blame] | 361 | |
| 362 | phba->fw_config.dual_ulp_aware = (pfw_cfg->function_mode & |
| 363 | BEISCSI_FUNC_DUA_MODE); |
| 364 | |
| 365 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, |
| 366 | "BG_%d : DUA Mode : 0x%x\n", |
| 367 | phba->fw_config.dual_ulp_aware); |
| 368 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 369 | } else { |
Jayamohan Kallickal | 843ae75 | 2013-09-28 15:35:44 -0700 | [diff] [blame] | 370 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 371 | "BG_%d : Failed in mgmt_get_fw_config\n"); |
Jayamohan Kallickal | 843ae75 | 2013-09-28 15:35:44 -0700 | [diff] [blame] | 372 | status = -EINVAL; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | spin_unlock(&ctrl->mbox_lock); |
| 376 | return status; |
| 377 | } |
| 378 | |
Jayamohan Kallickal | 03a1231 | 2010-07-22 04:17:16 +0530 | [diff] [blame] | 379 | int mgmt_check_supported_fw(struct be_ctrl_info *ctrl, |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 380 | struct beiscsi_hba *phba) |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 381 | { |
| 382 | struct be_dma_mem nonemb_cmd; |
| 383 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); |
| 384 | struct be_mgmt_controller_attributes *req; |
| 385 | struct be_sge *sge = nonembedded_sgl(wrb); |
| 386 | int status = 0; |
| 387 | |
| 388 | nonemb_cmd.va = pci_alloc_consistent(ctrl->pdev, |
| 389 | sizeof(struct be_mgmt_controller_attributes), |
| 390 | &nonemb_cmd.dma); |
| 391 | if (nonemb_cmd.va == NULL) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 392 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, |
| 393 | "BG_%d : Failed to allocate memory for " |
| 394 | "mgmt_check_supported_fw\n"); |
Jayamohan Kallickal | d3ad2bb | 2010-07-22 04:16:38 +0530 | [diff] [blame] | 395 | return -ENOMEM; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 396 | } |
| 397 | nonemb_cmd.size = sizeof(struct be_mgmt_controller_attributes); |
| 398 | req = nonemb_cmd.va; |
Jayamohan Kallickal | f98c96b | 2010-02-11 05:11:15 +0530 | [diff] [blame] | 399 | memset(req, 0, sizeof(*req)); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 400 | spin_lock(&ctrl->mbox_lock); |
| 401 | memset(wrb, 0, sizeof(*wrb)); |
| 402 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1); |
| 403 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 404 | OPCODE_COMMON_GET_CNTL_ATTRIBUTES, sizeof(*req)); |
| 405 | sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd.dma)); |
| 406 | sge->pa_lo = cpu_to_le32(nonemb_cmd.dma & 0xFFFFFFFF); |
| 407 | sge->len = cpu_to_le32(nonemb_cmd.size); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 408 | status = be_mbox_notify(ctrl); |
| 409 | if (!status) { |
| 410 | struct be_mgmt_controller_attributes_resp *resp = nonemb_cmd.va; |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 411 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, |
| 412 | "BG_%d : Firmware Version of CMD : %s\n" |
| 413 | "Firmware Version is : %s\n" |
| 414 | "Developer Build, not performing version check...\n", |
| 415 | resp->params.hba_attribs |
| 416 | .flashrom_version_string, |
| 417 | resp->params.hba_attribs. |
| 418 | firmware_version_string); |
| 419 | |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 420 | phba->fw_config.iscsi_features = |
| 421 | resp->params.hba_attribs.iscsi_features; |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 422 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, |
| 423 | "BM_%d : phba->fw_config.iscsi_features = %d\n", |
| 424 | phba->fw_config.iscsi_features); |
Jayamohan Kallickal | 22661e2 | 2013-04-05 20:38:28 -0700 | [diff] [blame] | 425 | memcpy(phba->fw_ver_str, resp->params.hba_attribs. |
| 426 | firmware_version_string, BEISCSI_VER_STRLEN); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 427 | } else |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 428 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, |
| 429 | "BG_%d : Failed in mgmt_check_supported_fw\n"); |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 430 | spin_unlock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 431 | if (nonemb_cmd.va) |
| 432 | pci_free_consistent(ctrl->pdev, nonemb_cmd.size, |
| 433 | nonemb_cmd.va, nonemb_cmd.dma); |
| 434 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 435 | return status; |
| 436 | } |
| 437 | |
Jayamohan Kallickal | ffce3e2 | 2012-04-03 23:41:50 -0500 | [diff] [blame] | 438 | unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl, |
| 439 | struct beiscsi_hba *phba, |
| 440 | struct bsg_job *job, |
| 441 | struct be_dma_mem *nonemb_cmd) |
| 442 | { |
| 443 | struct be_cmd_resp_hdr *resp; |
| 444 | struct be_mcc_wrb *wrb = wrb_from_mccq(phba); |
| 445 | struct be_sge *mcc_sge = nonembedded_sgl(wrb); |
| 446 | unsigned int tag = 0; |
| 447 | struct iscsi_bsg_request *bsg_req = job->request; |
| 448 | struct be_bsg_vendor_cmd *req = nonemb_cmd->va; |
| 449 | unsigned short region, sector_size, sector, offset; |
| 450 | |
| 451 | nonemb_cmd->size = job->request_payload.payload_len; |
| 452 | memset(nonemb_cmd->va, 0, nonemb_cmd->size); |
| 453 | resp = nonemb_cmd->va; |
| 454 | region = bsg_req->rqst_data.h_vendor.vendor_cmd[1]; |
| 455 | sector_size = bsg_req->rqst_data.h_vendor.vendor_cmd[2]; |
| 456 | sector = bsg_req->rqst_data.h_vendor.vendor_cmd[3]; |
| 457 | offset = bsg_req->rqst_data.h_vendor.vendor_cmd[4]; |
| 458 | req->region = region; |
| 459 | req->sector = sector; |
| 460 | req->offset = offset; |
| 461 | spin_lock(&ctrl->mbox_lock); |
| 462 | memset(wrb, 0, sizeof(*wrb)); |
| 463 | |
| 464 | switch (bsg_req->rqst_data.h_vendor.vendor_cmd[0]) { |
| 465 | case BEISCSI_WRITE_FLASH: |
| 466 | offset = sector * sector_size + offset; |
| 467 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, |
| 468 | OPCODE_COMMON_WRITE_FLASH, sizeof(*req)); |
| 469 | sg_copy_to_buffer(job->request_payload.sg_list, |
| 470 | job->request_payload.sg_cnt, |
| 471 | nonemb_cmd->va + offset, job->request_len); |
| 472 | break; |
| 473 | case BEISCSI_READ_FLASH: |
| 474 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, |
| 475 | OPCODE_COMMON_READ_FLASH, sizeof(*req)); |
| 476 | break; |
| 477 | default: |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 478 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, |
| 479 | "BG_%d : Unsupported cmd = 0x%x\n\n", |
| 480 | bsg_req->rqst_data.h_vendor.vendor_cmd[0]); |
| 481 | |
Jayamohan Kallickal | ffce3e2 | 2012-04-03 23:41:50 -0500 | [diff] [blame] | 482 | spin_unlock(&ctrl->mbox_lock); |
| 483 | return -ENOSYS; |
| 484 | } |
| 485 | |
| 486 | tag = alloc_mcc_tag(phba); |
| 487 | if (!tag) { |
| 488 | spin_unlock(&ctrl->mbox_lock); |
| 489 | return tag; |
| 490 | } |
| 491 | |
| 492 | be_wrb_hdr_prepare(wrb, nonemb_cmd->size, false, |
| 493 | job->request_payload.sg_cnt); |
| 494 | mcc_sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma)); |
| 495 | mcc_sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); |
| 496 | mcc_sge->len = cpu_to_le32(nonemb_cmd->size); |
| 497 | wrb->tag0 |= tag; |
| 498 | |
| 499 | be_mcc_notify(phba); |
| 500 | |
| 501 | spin_unlock(&ctrl->mbox_lock); |
| 502 | return tag; |
| 503 | } |
| 504 | |
Jayamohan Kallickal | bd41c2b | 2013-09-28 15:35:51 -0700 | [diff] [blame] | 505 | /** |
| 506 | * mgmt_epfw_cleanup()- Inform FW to cleanup data structures. |
| 507 | * @phba: pointer to dev priv structure |
| 508 | * @ulp_num: ULP number. |
| 509 | * |
| 510 | * return |
| 511 | * Success: 0 |
| 512 | * Failure: Non-Zero Value |
| 513 | **/ |
| 514 | int mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short ulp_num) |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 515 | { |
| 516 | struct be_ctrl_info *ctrl = &phba->ctrl; |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 517 | struct be_mcc_wrb *wrb = wrb_from_mccq(phba); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 518 | struct iscsi_cleanup_req *req = embedded_payload(wrb); |
| 519 | int status = 0; |
| 520 | |
| 521 | spin_lock(&ctrl->mbox_lock); |
| 522 | memset(wrb, 0, sizeof(*wrb)); |
| 523 | |
| 524 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
| 525 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, |
| 526 | OPCODE_COMMON_ISCSI_CLEANUP, sizeof(*req)); |
| 527 | |
Jayamohan Kallickal | bd41c2b | 2013-09-28 15:35:51 -0700 | [diff] [blame] | 528 | req->chute = (1 << ulp_num); |
| 529 | req->hdr_ring_id = cpu_to_le16(HWI_GET_DEF_HDRQ_ID(phba, ulp_num)); |
| 530 | req->data_ring_id = cpu_to_le16(HWI_GET_DEF_BUFQ_ID(phba, ulp_num)); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 531 | |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 532 | status = be_mcc_notify_wait(phba); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 533 | if (status) |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 534 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, |
| 535 | "BG_%d : mgmt_epfw_cleanup , FAILED\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 536 | spin_unlock(&ctrl->mbox_lock); |
| 537 | return status; |
| 538 | } |
| 539 | |
Jayamohan Kallickal | 03a1231 | 2010-07-22 04:17:16 +0530 | [diff] [blame] | 540 | unsigned int mgmt_invalidate_icds(struct beiscsi_hba *phba, |
Jayamohan Kallickal | 4183122 | 2010-02-20 08:02:39 +0530 | [diff] [blame] | 541 | struct invalidate_command_table *inv_tbl, |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 542 | unsigned int num_invalidate, unsigned int cid, |
| 543 | struct be_dma_mem *nonemb_cmd) |
| 544 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 545 | { |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 546 | struct be_ctrl_info *ctrl = &phba->ctrl; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 547 | struct be_mcc_wrb *wrb; |
| 548 | struct be_sge *sge; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 549 | struct invalidate_commands_params_in *req; |
Jayamohan Kallickal | 4183122 | 2010-02-20 08:02:39 +0530 | [diff] [blame] | 550 | unsigned int i, tag = 0; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 551 | |
| 552 | spin_lock(&ctrl->mbox_lock); |
| 553 | tag = alloc_mcc_tag(phba); |
| 554 | if (!tag) { |
| 555 | spin_unlock(&ctrl->mbox_lock); |
| 556 | return tag; |
| 557 | } |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 558 | |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 559 | req = nonemb_cmd->va; |
Jayamohan Kallickal | f98c96b | 2010-02-11 05:11:15 +0530 | [diff] [blame] | 560 | memset(req, 0, sizeof(*req)); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 561 | wrb = wrb_from_mccq(phba); |
| 562 | sge = nonembedded_sgl(wrb); |
| 563 | wrb->tag0 |= tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 564 | |
| 565 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1); |
| 566 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, |
| 567 | OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS, |
| 568 | sizeof(*req)); |
| 569 | req->ref_handle = 0; |
| 570 | req->cleanup_type = CMD_ISCSI_COMMAND_INVALIDATE; |
Jayamohan Kallickal | 4183122 | 2010-02-20 08:02:39 +0530 | [diff] [blame] | 571 | for (i = 0; i < num_invalidate; i++) { |
| 572 | req->table[i].icd = inv_tbl->icd; |
| 573 | req->table[i].cid = inv_tbl->cid; |
| 574 | req->icd_count++; |
| 575 | inv_tbl++; |
| 576 | } |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 577 | sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma)); |
| 578 | sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); |
| 579 | sge->len = cpu_to_le32(nonemb_cmd->size); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 580 | |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 581 | be_mcc_notify(phba); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 582 | spin_unlock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 583 | return tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 584 | } |
| 585 | |
Jayamohan Kallickal | 03a1231 | 2010-07-22 04:17:16 +0530 | [diff] [blame] | 586 | unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba, |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 587 | struct beiscsi_endpoint *beiscsi_ep, |
| 588 | unsigned short cid, |
| 589 | unsigned short issue_reset, |
| 590 | unsigned short savecfg_flag) |
| 591 | { |
| 592 | struct be_ctrl_info *ctrl = &phba->ctrl; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 593 | struct be_mcc_wrb *wrb; |
| 594 | struct iscsi_invalidate_connection_params_in *req; |
| 595 | unsigned int tag = 0; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 596 | |
| 597 | spin_lock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 598 | tag = alloc_mcc_tag(phba); |
| 599 | if (!tag) { |
| 600 | spin_unlock(&ctrl->mbox_lock); |
| 601 | return tag; |
| 602 | } |
| 603 | wrb = wrb_from_mccq(phba); |
| 604 | wrb->tag0 |= tag; |
| 605 | req = embedded_payload(wrb); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 606 | |
| 607 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
| 608 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI, |
| 609 | OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION, |
| 610 | sizeof(*req)); |
| 611 | req->session_handle = beiscsi_ep->fw_handle; |
| 612 | req->cid = cid; |
| 613 | if (issue_reset) |
| 614 | req->cleanup_type = CMD_ISCSI_CONNECTION_ISSUE_TCP_RST; |
| 615 | else |
| 616 | req->cleanup_type = CMD_ISCSI_CONNECTION_INVALIDATE; |
| 617 | req->save_cfg = savecfg_flag; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 618 | be_mcc_notify(phba); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 619 | spin_unlock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 620 | return tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 621 | } |
| 622 | |
Jayamohan Kallickal | 03a1231 | 2010-07-22 04:17:16 +0530 | [diff] [blame] | 623 | unsigned int mgmt_upload_connection(struct beiscsi_hba *phba, |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 624 | unsigned short cid, unsigned int upload_flag) |
| 625 | { |
| 626 | struct be_ctrl_info *ctrl = &phba->ctrl; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 627 | struct be_mcc_wrb *wrb; |
| 628 | struct tcp_upload_params_in *req; |
| 629 | unsigned int tag = 0; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 630 | |
| 631 | spin_lock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 632 | tag = alloc_mcc_tag(phba); |
| 633 | if (!tag) { |
| 634 | spin_unlock(&ctrl->mbox_lock); |
| 635 | return tag; |
| 636 | } |
| 637 | wrb = wrb_from_mccq(phba); |
| 638 | req = embedded_payload(wrb); |
| 639 | wrb->tag0 |= tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 640 | |
| 641 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
| 642 | be_cmd_hdr_prepare(&req->hdr, CMD_COMMON_TCP_UPLOAD, |
| 643 | OPCODE_COMMON_TCP_UPLOAD, sizeof(*req)); |
| 644 | req->id = (unsigned short)cid; |
| 645 | req->upload_type = (unsigned char)upload_flag; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 646 | be_mcc_notify(phba); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 647 | spin_unlock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 648 | return tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 649 | } |
| 650 | |
Jayamohan Kallickal | 1e4be6f | 2013-09-28 15:35:50 -0700 | [diff] [blame] | 651 | /** |
| 652 | * mgmt_open_connection()- Establish a TCP CXN |
| 653 | * @dst_addr: Destination Address |
| 654 | * @beiscsi_ep: ptr to device endpoint struct |
| 655 | * @nonemb_cmd: ptr to memory allocated for command |
| 656 | * |
| 657 | * return |
| 658 | * Success: Tag number of the MBX Command issued |
| 659 | * Failure: Error code |
| 660 | **/ |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 661 | int mgmt_open_connection(struct beiscsi_hba *phba, |
| 662 | struct sockaddr *dst_addr, |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 663 | struct beiscsi_endpoint *beiscsi_ep, |
| 664 | struct be_dma_mem *nonemb_cmd) |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 665 | { |
| 666 | struct hwi_controller *phwi_ctrlr; |
| 667 | struct hwi_context_memory *phwi_context; |
| 668 | struct sockaddr_in *daddr_in = (struct sockaddr_in *)dst_addr; |
| 669 | struct sockaddr_in6 *daddr_in6 = (struct sockaddr_in6 *)dst_addr; |
| 670 | struct be_ctrl_info *ctrl = &phba->ctrl; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 671 | struct be_mcc_wrb *wrb; |
| 672 | struct tcp_connect_and_offload_in *req; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 673 | unsigned short def_hdr_id; |
| 674 | unsigned short def_data_id; |
| 675 | struct phys_addr template_address = { 0, 0 }; |
| 676 | struct phys_addr *ptemplate_address; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 677 | unsigned int tag = 0; |
Jayamohan Kallickal | 1e4be6f | 2013-09-28 15:35:50 -0700 | [diff] [blame] | 678 | unsigned int i, ulp_num; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 679 | unsigned short cid = beiscsi_ep->ep_cid; |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 680 | struct be_sge *sge; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 681 | |
| 682 | phwi_ctrlr = phba->phwi_ctrlr; |
| 683 | phwi_context = phwi_ctrlr->phwi_ctxt; |
Jayamohan Kallickal | 1e4be6f | 2013-09-28 15:35:50 -0700 | [diff] [blame] | 684 | |
| 685 | ulp_num = phwi_ctrlr->wrb_context[BE_GET_CRI_FROM_CID(cid)].ulp_num; |
| 686 | |
| 687 | def_hdr_id = (unsigned short)HWI_GET_DEF_HDRQ_ID(phba, ulp_num); |
| 688 | def_data_id = (unsigned short)HWI_GET_DEF_BUFQ_ID(phba, ulp_num); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 689 | |
| 690 | ptemplate_address = &template_address; |
| 691 | ISCSI_GET_PDU_TEMPLATE_ADDRESS(phba, ptemplate_address); |
| 692 | spin_lock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 693 | tag = alloc_mcc_tag(phba); |
| 694 | if (!tag) { |
| 695 | spin_unlock(&ctrl->mbox_lock); |
| 696 | return tag; |
| 697 | } |
| 698 | wrb = wrb_from_mccq(phba); |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 699 | memset(wrb, 0, sizeof(*wrb)); |
| 700 | sge = nonembedded_sgl(wrb); |
| 701 | |
| 702 | req = nonemb_cmd->va; |
| 703 | memset(req, 0, sizeof(*req)); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 704 | wrb->tag0 |= tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 705 | |
Jayamohan Kallickal | b15d05b | 2010-08-12 23:36:06 +0530 | [diff] [blame] | 706 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 707 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, |
| 708 | OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD, |
| 709 | sizeof(*req)); |
| 710 | if (dst_addr->sa_family == PF_INET) { |
| 711 | __be32 s_addr = daddr_in->sin_addr.s_addr; |
| 712 | req->ip_address.ip_type = BE2_IPV4; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 713 | req->ip_address.addr[0] = s_addr & 0x000000ff; |
| 714 | req->ip_address.addr[1] = (s_addr & 0x0000ff00) >> 8; |
| 715 | req->ip_address.addr[2] = (s_addr & 0x00ff0000) >> 16; |
| 716 | req->ip_address.addr[3] = (s_addr & 0xff000000) >> 24; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 717 | req->tcp_port = ntohs(daddr_in->sin_port); |
| 718 | beiscsi_ep->dst_addr = daddr_in->sin_addr.s_addr; |
| 719 | beiscsi_ep->dst_tcpport = ntohs(daddr_in->sin_port); |
| 720 | beiscsi_ep->ip_type = BE2_IPV4; |
| 721 | } else if (dst_addr->sa_family == PF_INET6) { |
| 722 | req->ip_address.ip_type = BE2_IPV6; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 723 | memcpy(&req->ip_address.addr, |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 724 | &daddr_in6->sin6_addr.in6_u.u6_addr8, 16); |
| 725 | req->tcp_port = ntohs(daddr_in6->sin6_port); |
| 726 | beiscsi_ep->dst_tcpport = ntohs(daddr_in6->sin6_port); |
| 727 | memcpy(&beiscsi_ep->dst6_addr, |
| 728 | &daddr_in6->sin6_addr.in6_u.u6_addr8, 16); |
| 729 | beiscsi_ep->ip_type = BE2_IPV6; |
| 730 | } else{ |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 731 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 732 | "BG_%d : unknown addr family %d\n", |
| 733 | dst_addr->sa_family); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 734 | spin_unlock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 5db3f33 | 2010-07-22 04:24:22 +0530 | [diff] [blame] | 735 | free_mcc_tag(&phba->ctrl, tag); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 736 | return -EINVAL; |
| 737 | |
| 738 | } |
| 739 | req->cid = cid; |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 740 | i = phba->nxt_cqid++; |
| 741 | if (phba->nxt_cqid == phba->num_cpus) |
| 742 | phba->nxt_cqid = 0; |
| 743 | req->cq_id = phwi_context->be_cq[i].id; |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 744 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 745 | "BG_%d : i=%d cq_id=%d\n", i, req->cq_id); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 746 | req->defq_id = def_hdr_id; |
| 747 | req->hdr_ring_id = def_hdr_id; |
| 748 | req->data_ring_id = def_data_id; |
| 749 | req->do_offload = 1; |
| 750 | req->dataout_template_pa.lo = ptemplate_address->lo; |
| 751 | req->dataout_template_pa.hi = ptemplate_address->hi; |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 752 | sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma)); |
| 753 | sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); |
| 754 | sge->len = cpu_to_le32(nonemb_cmd->size); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 755 | be_mcc_notify(phba); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 756 | spin_unlock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 757 | return tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 758 | } |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 759 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 760 | unsigned int mgmt_get_all_if_id(struct beiscsi_hba *phba) |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 761 | { |
| 762 | struct be_ctrl_info *ctrl = &phba->ctrl; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 763 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); |
| 764 | struct be_cmd_get_all_if_id_req *req = embedded_payload(wrb); |
| 765 | struct be_cmd_get_all_if_id_req *pbe_allid = req; |
| 766 | int status = 0; |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 767 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 768 | memset(wrb, 0, sizeof(*wrb)); |
| 769 | |
| 770 | spin_lock(&ctrl->mbox_lock); |
| 771 | |
| 772 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
| 773 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, |
| 774 | OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID, |
| 775 | sizeof(*req)); |
| 776 | status = be_mbox_notify(ctrl); |
| 777 | if (!status) |
| 778 | phba->interface_handle = pbe_allid->if_hndl_list[0]; |
| 779 | else { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 780 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, |
| 781 | "BG_%d : Failed in mgmt_get_all_if_id\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 782 | } |
| 783 | spin_unlock(&ctrl->mbox_lock); |
| 784 | |
| 785 | return status; |
| 786 | } |
| 787 | |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 788 | /* |
| 789 | * mgmt_exec_nonemb_cmd()- Execute Non Embedded MBX Cmd |
| 790 | * @phba: Driver priv structure |
| 791 | * @nonemb_cmd: Address of the MBX command issued |
| 792 | * @resp_buf: Buffer to copy the MBX cmd response |
| 793 | * @resp_buf_len: respone lenght to be copied |
| 794 | * |
| 795 | **/ |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 796 | static int mgmt_exec_nonemb_cmd(struct beiscsi_hba *phba, |
| 797 | struct be_dma_mem *nonemb_cmd, void *resp_buf, |
| 798 | int resp_buf_len) |
| 799 | { |
| 800 | struct be_ctrl_info *ctrl = &phba->ctrl; |
| 801 | struct be_mcc_wrb *wrb = wrb_from_mccq(phba); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 802 | struct be_sge *sge; |
| 803 | unsigned int tag; |
| 804 | int rc = 0; |
| 805 | |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 806 | spin_lock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 807 | tag = alloc_mcc_tag(phba); |
| 808 | if (!tag) { |
| 809 | spin_unlock(&ctrl->mbox_lock); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 810 | rc = -ENOMEM; |
| 811 | goto free_cmd; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 812 | } |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 813 | memset(wrb, 0, sizeof(*wrb)); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 814 | wrb->tag0 |= tag; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 815 | sge = nonembedded_sgl(wrb); |
| 816 | |
| 817 | be_wrb_hdr_prepare(wrb, nonemb_cmd->size, false, 1); |
| 818 | sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma)); |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 819 | sge->pa_lo = cpu_to_le32(lower_32_bits(nonemb_cmd->dma)); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 820 | sge->len = cpu_to_le32(nonemb_cmd->size); |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 821 | |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 822 | be_mcc_notify(phba); |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 823 | spin_unlock(&ctrl->mbox_lock); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 824 | |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 825 | rc = beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd->va); |
| 826 | if (rc) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 827 | beiscsi_log(phba, KERN_ERR, |
| 828 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 829 | "BG_%d : mgmt_exec_nonemb_cmd Failed status\n"); |
| 830 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 831 | rc = -EIO; |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 832 | goto free_cmd; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 833 | } |
| 834 | |
| 835 | if (resp_buf) |
| 836 | memcpy(resp_buf, nonemb_cmd->va, resp_buf_len); |
| 837 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 838 | free_cmd: |
| 839 | pci_free_consistent(ctrl->pdev, nonemb_cmd->size, |
| 840 | nonemb_cmd->va, nonemb_cmd->dma); |
| 841 | return rc; |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 842 | } |
| 843 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 844 | static int mgmt_alloc_cmd_data(struct beiscsi_hba *phba, struct be_dma_mem *cmd, |
| 845 | int iscsi_cmd, int size) |
| 846 | { |
Mike Christie | b83d543 | 2012-05-23 20:40:54 -0500 | [diff] [blame] | 847 | cmd->va = pci_alloc_consistent(phba->ctrl.pdev, size, &cmd->dma); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 848 | if (!cmd->va) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 849 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 850 | "BG_%d : Failed to allocate memory for if info\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 851 | return -ENOMEM; |
| 852 | } |
Mike Christie | b83d543 | 2012-05-23 20:40:54 -0500 | [diff] [blame] | 853 | memset(cmd->va, 0, size); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 854 | cmd->size = size; |
| 855 | be_cmd_hdr_prepare(cmd->va, CMD_SUBSYSTEM_ISCSI, iscsi_cmd, size); |
| 856 | return 0; |
| 857 | } |
| 858 | |
| 859 | static int |
| 860 | mgmt_static_ip_modify(struct beiscsi_hba *phba, |
| 861 | struct be_cmd_get_if_info_resp *if_info, |
| 862 | struct iscsi_iface_param_info *ip_param, |
| 863 | struct iscsi_iface_param_info *subnet_param, |
| 864 | uint32_t ip_action) |
| 865 | { |
| 866 | struct be_cmd_set_ip_addr_req *req; |
| 867 | struct be_dma_mem nonemb_cmd; |
| 868 | uint32_t ip_type; |
| 869 | int rc; |
| 870 | |
| 871 | rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, |
| 872 | OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR, |
| 873 | sizeof(*req)); |
| 874 | if (rc) |
| 875 | return rc; |
| 876 | |
| 877 | ip_type = (ip_param->param == ISCSI_NET_PARAM_IPV6_ADDR) ? |
| 878 | BE2_IPV6 : BE2_IPV4 ; |
| 879 | |
| 880 | req = nonemb_cmd.va; |
| 881 | req->ip_params.record_entry_count = 1; |
| 882 | req->ip_params.ip_record.action = ip_action; |
| 883 | req->ip_params.ip_record.interface_hndl = |
| 884 | phba->interface_handle; |
| 885 | req->ip_params.ip_record.ip_addr.size_of_structure = |
| 886 | sizeof(struct be_ip_addr_subnet_format); |
| 887 | req->ip_params.ip_record.ip_addr.ip_type = ip_type; |
| 888 | |
| 889 | if (ip_action == IP_ACTION_ADD) { |
| 890 | memcpy(req->ip_params.ip_record.ip_addr.addr, ip_param->value, |
| 891 | ip_param->len); |
| 892 | |
| 893 | if (subnet_param) |
| 894 | memcpy(req->ip_params.ip_record.ip_addr.subnet_mask, |
| 895 | subnet_param->value, subnet_param->len); |
| 896 | } else { |
| 897 | memcpy(req->ip_params.ip_record.ip_addr.addr, |
| 898 | if_info->ip_addr.addr, ip_param->len); |
| 899 | |
| 900 | memcpy(req->ip_params.ip_record.ip_addr.subnet_mask, |
| 901 | if_info->ip_addr.subnet_mask, ip_param->len); |
| 902 | } |
| 903 | |
| 904 | rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0); |
| 905 | if (rc < 0) |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 906 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, |
| 907 | "BG_%d : Failed to Modify existing IP Address\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 908 | return rc; |
| 909 | } |
| 910 | |
| 911 | static int mgmt_modify_gateway(struct beiscsi_hba *phba, uint8_t *gt_addr, |
| 912 | uint32_t gtway_action, uint32_t param_len) |
| 913 | { |
| 914 | struct be_cmd_set_def_gateway_req *req; |
| 915 | struct be_dma_mem nonemb_cmd; |
| 916 | int rt_val; |
| 917 | |
| 918 | |
| 919 | rt_val = mgmt_alloc_cmd_data(phba, &nonemb_cmd, |
| 920 | OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY, |
| 921 | sizeof(*req)); |
| 922 | if (rt_val) |
| 923 | return rt_val; |
| 924 | |
| 925 | req = nonemb_cmd.va; |
| 926 | req->action = gtway_action; |
| 927 | req->ip_addr.ip_type = BE2_IPV4; |
| 928 | |
| 929 | memcpy(req->ip_addr.addr, gt_addr, param_len); |
| 930 | |
| 931 | return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0); |
| 932 | } |
| 933 | |
| 934 | int mgmt_set_ip(struct beiscsi_hba *phba, |
| 935 | struct iscsi_iface_param_info *ip_param, |
| 936 | struct iscsi_iface_param_info *subnet_param, |
| 937 | uint32_t boot_proto) |
| 938 | { |
| 939 | struct be_cmd_get_def_gateway_resp gtway_addr_set; |
| 940 | struct be_cmd_get_if_info_resp if_info; |
| 941 | struct be_cmd_set_dhcp_req *dhcpreq; |
| 942 | struct be_cmd_rel_dhcp_req *reldhcp; |
| 943 | struct be_dma_mem nonemb_cmd; |
| 944 | uint8_t *gtway_addr; |
| 945 | uint32_t ip_type; |
| 946 | int rc; |
| 947 | |
| 948 | if (mgmt_get_all_if_id(phba)) |
| 949 | return -EIO; |
| 950 | |
| 951 | memset(&if_info, 0, sizeof(if_info)); |
| 952 | ip_type = (ip_param->param == ISCSI_NET_PARAM_IPV6_ADDR) ? |
| 953 | BE2_IPV6 : BE2_IPV4 ; |
| 954 | |
| 955 | rc = mgmt_get_if_info(phba, ip_type, &if_info); |
| 956 | if (rc) |
| 957 | return rc; |
| 958 | |
| 959 | if (boot_proto == ISCSI_BOOTPROTO_DHCP) { |
| 960 | if (if_info.dhcp_state) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 961 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, |
| 962 | "BG_%d : DHCP Already Enabled\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 963 | return 0; |
| 964 | } |
| 965 | /* The ip_param->len is 1 in DHCP case. Setting |
| 966 | proper IP len as this it is used while |
| 967 | freeing the Static IP. |
| 968 | */ |
| 969 | ip_param->len = (ip_param->param == ISCSI_NET_PARAM_IPV6_ADDR) ? |
| 970 | IP_V6_LEN : IP_V4_LEN; |
| 971 | |
| 972 | } else { |
| 973 | if (if_info.dhcp_state) { |
| 974 | |
| 975 | memset(&if_info, 0, sizeof(if_info)); |
| 976 | rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, |
| 977 | OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR, |
| 978 | sizeof(*reldhcp)); |
| 979 | |
| 980 | if (rc) |
| 981 | return rc; |
| 982 | |
| 983 | reldhcp = nonemb_cmd.va; |
| 984 | reldhcp->interface_hndl = phba->interface_handle; |
| 985 | reldhcp->ip_type = ip_type; |
| 986 | |
| 987 | rc = mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0); |
| 988 | if (rc < 0) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 989 | beiscsi_log(phba, KERN_WARNING, |
| 990 | BEISCSI_LOG_CONFIG, |
| 991 | "BG_%d : Failed to Delete existing dhcp\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 992 | return rc; |
| 993 | } |
| 994 | } |
| 995 | } |
| 996 | |
| 997 | /* Delete the Static IP Set */ |
| 998 | if (if_info.ip_addr.addr[0]) { |
| 999 | rc = mgmt_static_ip_modify(phba, &if_info, ip_param, NULL, |
| 1000 | IP_ACTION_DEL); |
| 1001 | if (rc) |
| 1002 | return rc; |
| 1003 | } |
| 1004 | |
| 1005 | /* Delete the Gateway settings if mode change is to DHCP */ |
| 1006 | if (boot_proto == ISCSI_BOOTPROTO_DHCP) { |
| 1007 | memset(>way_addr_set, 0, sizeof(gtway_addr_set)); |
| 1008 | rc = mgmt_get_gateway(phba, BE2_IPV4, >way_addr_set); |
| 1009 | if (rc) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1010 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, |
| 1011 | "BG_%d : Failed to Get Gateway Addr\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 1012 | return rc; |
| 1013 | } |
| 1014 | |
| 1015 | if (gtway_addr_set.ip_addr.addr[0]) { |
| 1016 | gtway_addr = (uint8_t *)>way_addr_set.ip_addr.addr; |
| 1017 | rc = mgmt_modify_gateway(phba, gtway_addr, |
| 1018 | IP_ACTION_DEL, IP_V4_LEN); |
| 1019 | |
| 1020 | if (rc) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1021 | beiscsi_log(phba, KERN_WARNING, |
| 1022 | BEISCSI_LOG_CONFIG, |
| 1023 | "BG_%d : Failed to clear Gateway Addr Set\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 1024 | return rc; |
| 1025 | } |
| 1026 | } |
| 1027 | } |
| 1028 | |
| 1029 | /* Set Adapter to DHCP/Static Mode */ |
| 1030 | if (boot_proto == ISCSI_BOOTPROTO_DHCP) { |
| 1031 | rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, |
| 1032 | OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR, |
| 1033 | sizeof(*dhcpreq)); |
| 1034 | if (rc) |
| 1035 | return rc; |
| 1036 | |
| 1037 | dhcpreq = nonemb_cmd.va; |
| 1038 | dhcpreq->flags = BLOCKING; |
| 1039 | dhcpreq->retry_count = 1; |
| 1040 | dhcpreq->interface_hndl = phba->interface_handle; |
| 1041 | dhcpreq->ip_type = BE2_DHCP_V4; |
| 1042 | |
| 1043 | return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, NULL, 0); |
| 1044 | } else { |
| 1045 | return mgmt_static_ip_modify(phba, &if_info, ip_param, |
| 1046 | subnet_param, IP_ACTION_ADD); |
| 1047 | } |
| 1048 | |
| 1049 | return rc; |
| 1050 | } |
| 1051 | |
| 1052 | int mgmt_set_gateway(struct beiscsi_hba *phba, |
| 1053 | struct iscsi_iface_param_info *gateway_param) |
| 1054 | { |
| 1055 | struct be_cmd_get_def_gateway_resp gtway_addr_set; |
| 1056 | uint8_t *gtway_addr; |
| 1057 | int rt_val; |
| 1058 | |
| 1059 | memset(>way_addr_set, 0, sizeof(gtway_addr_set)); |
| 1060 | rt_val = mgmt_get_gateway(phba, BE2_IPV4, >way_addr_set); |
| 1061 | if (rt_val) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1062 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, |
| 1063 | "BG_%d : Failed to Get Gateway Addr\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 1064 | return rt_val; |
| 1065 | } |
| 1066 | |
| 1067 | if (gtway_addr_set.ip_addr.addr[0]) { |
| 1068 | gtway_addr = (uint8_t *)>way_addr_set.ip_addr.addr; |
| 1069 | rt_val = mgmt_modify_gateway(phba, gtway_addr, IP_ACTION_DEL, |
| 1070 | gateway_param->len); |
| 1071 | if (rt_val) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1072 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, |
| 1073 | "BG_%d : Failed to clear Gateway Addr Set\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 1074 | return rt_val; |
| 1075 | } |
| 1076 | } |
| 1077 | |
| 1078 | gtway_addr = (uint8_t *)&gateway_param->value; |
| 1079 | rt_val = mgmt_modify_gateway(phba, gtway_addr, IP_ACTION_ADD, |
| 1080 | gateway_param->len); |
| 1081 | |
| 1082 | if (rt_val) |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1083 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, |
| 1084 | "BG_%d : Failed to Set Gateway Addr\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 1085 | |
| 1086 | return rt_val; |
| 1087 | } |
| 1088 | |
| 1089 | int mgmt_get_gateway(struct beiscsi_hba *phba, int ip_type, |
| 1090 | struct be_cmd_get_def_gateway_resp *gateway) |
| 1091 | { |
| 1092 | struct be_cmd_get_def_gateway_req *req; |
| 1093 | struct be_dma_mem nonemb_cmd; |
| 1094 | int rc; |
| 1095 | |
| 1096 | rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, |
| 1097 | OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY, |
| 1098 | sizeof(*gateway)); |
| 1099 | if (rc) |
| 1100 | return rc; |
| 1101 | |
| 1102 | req = nonemb_cmd.va; |
| 1103 | req->ip_type = ip_type; |
| 1104 | |
| 1105 | return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, gateway, |
| 1106 | sizeof(*gateway)); |
| 1107 | } |
| 1108 | |
| 1109 | int mgmt_get_if_info(struct beiscsi_hba *phba, int ip_type, |
| 1110 | struct be_cmd_get_if_info_resp *if_info) |
| 1111 | { |
| 1112 | struct be_cmd_get_if_info_req *req; |
| 1113 | struct be_dma_mem nonemb_cmd; |
| 1114 | int rc; |
| 1115 | |
| 1116 | if (mgmt_get_all_if_id(phba)) |
| 1117 | return -EIO; |
| 1118 | |
| 1119 | rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, |
| 1120 | OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO, |
| 1121 | sizeof(*if_info)); |
| 1122 | if (rc) |
| 1123 | return rc; |
| 1124 | |
| 1125 | req = nonemb_cmd.va; |
| 1126 | req->interface_hndl = phba->interface_handle; |
| 1127 | req->ip_type = ip_type; |
| 1128 | |
| 1129 | return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, if_info, |
| 1130 | sizeof(*if_info)); |
| 1131 | } |
| 1132 | |
| 1133 | int mgmt_get_nic_conf(struct beiscsi_hba *phba, |
| 1134 | struct be_cmd_get_nic_conf_resp *nic) |
| 1135 | { |
| 1136 | struct be_dma_mem nonemb_cmd; |
| 1137 | int rc; |
| 1138 | |
| 1139 | rc = mgmt_alloc_cmd_data(phba, &nonemb_cmd, |
| 1140 | OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG, |
| 1141 | sizeof(*nic)); |
| 1142 | if (rc) |
| 1143 | return rc; |
| 1144 | |
| 1145 | return mgmt_exec_nonemb_cmd(phba, &nonemb_cmd, nic, sizeof(*nic)); |
| 1146 | } |
| 1147 | |
| 1148 | |
| 1149 | |
John Soni Jose | 2177199 | 2012-04-03 23:41:49 -0500 | [diff] [blame] | 1150 | unsigned int be_cmd_get_initname(struct beiscsi_hba *phba) |
| 1151 | { |
| 1152 | unsigned int tag = 0; |
| 1153 | struct be_mcc_wrb *wrb; |
| 1154 | struct be_cmd_hba_name *req; |
| 1155 | struct be_ctrl_info *ctrl = &phba->ctrl; |
| 1156 | |
| 1157 | spin_lock(&ctrl->mbox_lock); |
| 1158 | tag = alloc_mcc_tag(phba); |
| 1159 | if (!tag) { |
| 1160 | spin_unlock(&ctrl->mbox_lock); |
| 1161 | return tag; |
| 1162 | } |
| 1163 | |
| 1164 | wrb = wrb_from_mccq(phba); |
| 1165 | req = embedded_payload(wrb); |
| 1166 | wrb->tag0 |= tag; |
| 1167 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
| 1168 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI, |
| 1169 | OPCODE_ISCSI_INI_CFG_GET_HBA_NAME, |
| 1170 | sizeof(*req)); |
| 1171 | |
| 1172 | be_mcc_notify(phba); |
| 1173 | spin_unlock(&ctrl->mbox_lock); |
| 1174 | return tag; |
| 1175 | } |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 1176 | |
| 1177 | unsigned int be_cmd_get_port_speed(struct beiscsi_hba *phba) |
| 1178 | { |
| 1179 | unsigned int tag = 0; |
| 1180 | struct be_mcc_wrb *wrb; |
| 1181 | struct be_cmd_ntwk_link_status_req *req; |
| 1182 | struct be_ctrl_info *ctrl = &phba->ctrl; |
| 1183 | |
| 1184 | spin_lock(&ctrl->mbox_lock); |
| 1185 | tag = alloc_mcc_tag(phba); |
| 1186 | if (!tag) { |
| 1187 | spin_unlock(&ctrl->mbox_lock); |
| 1188 | return tag; |
| 1189 | } |
| 1190 | |
| 1191 | wrb = wrb_from_mccq(phba); |
| 1192 | req = embedded_payload(wrb); |
| 1193 | wrb->tag0 |= tag; |
| 1194 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
| 1195 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 1196 | OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, |
| 1197 | sizeof(*req)); |
| 1198 | |
| 1199 | be_mcc_notify(phba); |
| 1200 | spin_unlock(&ctrl->mbox_lock); |
| 1201 | return tag; |
| 1202 | } |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 1203 | |
| 1204 | /** |
| 1205 | * be_mgmt_get_boot_shandle()- Get the session handle |
| 1206 | * @phba: device priv structure instance |
| 1207 | * @s_handle: session handle returned for boot session. |
| 1208 | * |
| 1209 | * Get the boot target session handle. In case of |
| 1210 | * crashdump mode driver has to issue and MBX Cmd |
| 1211 | * for FW to login to boot target |
| 1212 | * |
| 1213 | * return |
| 1214 | * Success: 0 |
| 1215 | * Failure: Non-Zero value |
| 1216 | * |
| 1217 | **/ |
| 1218 | int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba, |
| 1219 | unsigned int *s_handle) |
| 1220 | { |
| 1221 | struct be_cmd_get_boot_target_resp *boot_resp; |
| 1222 | struct be_mcc_wrb *wrb; |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1223 | unsigned int tag; |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 1224 | uint8_t boot_retry = 3; |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1225 | int rc; |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 1226 | |
| 1227 | do { |
| 1228 | /* Get the Boot Target Session Handle and Count*/ |
| 1229 | tag = mgmt_get_boot_target(phba); |
| 1230 | if (!tag) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1231 | beiscsi_log(phba, KERN_ERR, |
| 1232 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_INIT, |
| 1233 | "BG_%d : Getting Boot Target Info Failed\n"); |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 1234 | return -EAGAIN; |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1235 | } |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 1236 | |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1237 | rc = beiscsi_mccq_compl(phba, tag, &wrb, NULL); |
| 1238 | if (rc) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1239 | beiscsi_log(phba, KERN_ERR, |
| 1240 | BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1241 | "BG_%d : MBX CMD get_boot_target Failed\n"); |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 1242 | return -EBUSY; |
| 1243 | } |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1244 | |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 1245 | boot_resp = embedded_payload(wrb); |
| 1246 | |
| 1247 | /* Check if the there are any Boot targets configured */ |
| 1248 | if (!boot_resp->boot_session_count) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1249 | beiscsi_log(phba, KERN_INFO, |
| 1250 | BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, |
| 1251 | "BG_%d ;No boot targets configured\n"); |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 1252 | return -ENXIO; |
| 1253 | } |
| 1254 | |
| 1255 | /* FW returns the session handle of the boot session */ |
| 1256 | if (boot_resp->boot_session_handle != INVALID_SESS_HANDLE) { |
| 1257 | *s_handle = boot_resp->boot_session_handle; |
| 1258 | return 0; |
| 1259 | } |
| 1260 | |
| 1261 | /* Issue MBX Cmd to FW to login to the boot target */ |
| 1262 | tag = mgmt_reopen_session(phba, BE_REOPEN_BOOT_SESSIONS, |
| 1263 | INVALID_SESS_HANDLE); |
| 1264 | if (!tag) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1265 | beiscsi_log(phba, KERN_ERR, |
| 1266 | BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, |
| 1267 | "BG_%d : mgmt_reopen_session Failed\n"); |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 1268 | return -EAGAIN; |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1269 | } |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 1270 | |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1271 | rc = beiscsi_mccq_compl(phba, tag, NULL, NULL); |
| 1272 | if (rc) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1273 | beiscsi_log(phba, KERN_ERR, |
| 1274 | BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1275 | "BG_%d : mgmt_reopen_session Failed"); |
| 1276 | return rc; |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 1277 | } |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 1278 | } while (--boot_retry); |
| 1279 | |
| 1280 | /* Couldn't log into the boot target */ |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1281 | beiscsi_log(phba, KERN_ERR, |
| 1282 | BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, |
| 1283 | "BG_%d : Login to Boot Target Failed\n"); |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 1284 | return -ENXIO; |
| 1285 | } |
John Soni Jose | 6f72238 | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 1286 | |
| 1287 | /** |
| 1288 | * mgmt_set_vlan()- Issue and wait for CMD completion |
| 1289 | * @phba: device private structure instance |
| 1290 | * @vlan_tag: VLAN tag |
| 1291 | * |
| 1292 | * Issue the MBX Cmd and wait for the completion of the |
| 1293 | * command. |
| 1294 | * |
| 1295 | * returns |
| 1296 | * Success: 0 |
| 1297 | * Failure: Non-Xero Value |
| 1298 | **/ |
| 1299 | int mgmt_set_vlan(struct beiscsi_hba *phba, |
| 1300 | uint16_t vlan_tag) |
| 1301 | { |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1302 | int rc; |
| 1303 | unsigned int tag; |
| 1304 | struct be_mcc_wrb *wrb = NULL; |
John Soni Jose | 6f72238 | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 1305 | |
| 1306 | tag = be_cmd_set_vlan(phba, vlan_tag); |
| 1307 | if (!tag) { |
| 1308 | beiscsi_log(phba, KERN_ERR, |
| 1309 | (BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX), |
| 1310 | "BG_%d : VLAN Setting Failed\n"); |
| 1311 | return -EBUSY; |
John Soni Jose | 6f72238 | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 1312 | } |
| 1313 | |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1314 | rc = beiscsi_mccq_compl(phba, tag, &wrb, NULL); |
| 1315 | if (rc) { |
| 1316 | beiscsi_log(phba, KERN_ERR, |
| 1317 | (BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX), |
| 1318 | "BS_%d : VLAN MBX Cmd Failed\n"); |
| 1319 | return rc; |
| 1320 | } |
| 1321 | return rc; |
John Soni Jose | 6f72238 | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 1322 | } |
John Soni Jose | 5cac759 | 2012-10-20 04:42:25 +0530 | [diff] [blame] | 1323 | |
| 1324 | /** |
| 1325 | * beiscsi_drvr_ver_disp()- Display the driver Name and Version |
| 1326 | * @dev: ptr to device not used. |
| 1327 | * @attr: device attribute, not used. |
| 1328 | * @buf: contains formatted text driver name and version |
| 1329 | * |
| 1330 | * return |
| 1331 | * size of the formatted string |
| 1332 | **/ |
| 1333 | ssize_t |
| 1334 | beiscsi_drvr_ver_disp(struct device *dev, struct device_attribute *attr, |
| 1335 | char *buf) |
| 1336 | { |
| 1337 | return snprintf(buf, PAGE_SIZE, BE_NAME "\n"); |
| 1338 | } |
John Soni Jose | acb9693 | 2012-10-20 04:44:35 +0530 | [diff] [blame] | 1339 | |
John Soni Jose | 26000db | 2012-10-20 04:45:06 +0530 | [diff] [blame] | 1340 | /** |
Jayamohan Kallickal | 22661e2 | 2013-04-05 20:38:28 -0700 | [diff] [blame] | 1341 | * beiscsi_fw_ver_disp()- Display Firmware Version |
| 1342 | * @dev: ptr to device not used. |
| 1343 | * @attr: device attribute, not used. |
| 1344 | * @buf: contains formatted text Firmware version |
| 1345 | * |
| 1346 | * return |
| 1347 | * size of the formatted string |
| 1348 | **/ |
| 1349 | ssize_t |
| 1350 | beiscsi_fw_ver_disp(struct device *dev, struct device_attribute *attr, |
| 1351 | char *buf) |
| 1352 | { |
| 1353 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1354 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
| 1355 | |
| 1356 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->fw_ver_str); |
| 1357 | } |
| 1358 | |
| 1359 | /** |
Jayamohan Kallickal | 6103c1f | 2013-09-28 15:35:52 -0700 | [diff] [blame] | 1360 | * beiscsi_active_session_disp()- Display Sessions Active |
Jayamohan Kallickal | 7ad4dfe | 2013-04-05 20:38:29 -0700 | [diff] [blame] | 1361 | * @dev: ptr to device not used. |
| 1362 | * @attr: device attribute, not used. |
| 1363 | * @buf: contains formatted text Session Count |
| 1364 | * |
| 1365 | * return |
| 1366 | * size of the formatted string |
| 1367 | **/ |
| 1368 | ssize_t |
Jayamohan Kallickal | 6103c1f | 2013-09-28 15:35:52 -0700 | [diff] [blame] | 1369 | beiscsi_active_session_disp(struct device *dev, struct device_attribute *attr, |
Jayamohan Kallickal | 7ad4dfe | 2013-04-05 20:38:29 -0700 | [diff] [blame] | 1370 | char *buf) |
| 1371 | { |
| 1372 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1373 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
Jayamohan Kallickal | 0a3db7c | 2013-09-28 15:35:49 -0700 | [diff] [blame] | 1374 | uint16_t avlbl_cids = 0, ulp_num, len = 0, total_cids = 0; |
Jayamohan Kallickal | 7ad4dfe | 2013-04-05 20:38:29 -0700 | [diff] [blame] | 1375 | |
Jayamohan Kallickal | 0a3db7c | 2013-09-28 15:35:49 -0700 | [diff] [blame] | 1376 | for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) { |
| 1377 | if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { |
| 1378 | avlbl_cids = BEISCSI_ULP_AVLBL_CID(phba, ulp_num); |
| 1379 | total_cids = BEISCSI_GET_CID_COUNT(phba, ulp_num); |
| 1380 | len += snprintf(buf+len, PAGE_SIZE - len, |
| 1381 | "ULP%d : %d\n", ulp_num, |
| 1382 | (total_cids - avlbl_cids)); |
| 1383 | } else |
| 1384 | len += snprintf(buf+len, PAGE_SIZE - len, |
| 1385 | "ULP%d : %d\n", ulp_num, 0); |
| 1386 | } |
| 1387 | |
| 1388 | return len; |
Jayamohan Kallickal | 7ad4dfe | 2013-04-05 20:38:29 -0700 | [diff] [blame] | 1389 | } |
| 1390 | |
| 1391 | /** |
Jayamohan Kallickal | 6103c1f | 2013-09-28 15:35:52 -0700 | [diff] [blame] | 1392 | * beiscsi_free_session_disp()- Display Avaliable Session |
| 1393 | * @dev: ptr to device not used. |
| 1394 | * @attr: device attribute, not used. |
| 1395 | * @buf: contains formatted text Session Count |
| 1396 | * |
| 1397 | * return |
| 1398 | * size of the formatted string |
| 1399 | **/ |
| 1400 | ssize_t |
| 1401 | beiscsi_free_session_disp(struct device *dev, struct device_attribute *attr, |
| 1402 | char *buf) |
| 1403 | { |
| 1404 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1405 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
| 1406 | uint16_t ulp_num, len = 0; |
| 1407 | |
| 1408 | for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) { |
| 1409 | if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) |
| 1410 | len += snprintf(buf+len, PAGE_SIZE - len, |
| 1411 | "ULP%d : %d\n", ulp_num, |
| 1412 | BEISCSI_ULP_AVLBL_CID(phba, ulp_num)); |
| 1413 | else |
| 1414 | len += snprintf(buf+len, PAGE_SIZE - len, |
| 1415 | "ULP%d : %d\n", ulp_num, 0); |
| 1416 | } |
| 1417 | |
| 1418 | return len; |
| 1419 | } |
| 1420 | |
| 1421 | /** |
John Soni Jose | 26000db | 2012-10-20 04:45:06 +0530 | [diff] [blame] | 1422 | * beiscsi_adap_family_disp()- Display adapter family. |
| 1423 | * @dev: ptr to device to get priv structure |
| 1424 | * @attr: device attribute, not used. |
| 1425 | * @buf: contains formatted text driver name and version |
| 1426 | * |
| 1427 | * return |
| 1428 | * size of the formatted string |
| 1429 | **/ |
| 1430 | ssize_t |
| 1431 | beiscsi_adap_family_disp(struct device *dev, struct device_attribute *attr, |
| 1432 | char *buf) |
| 1433 | { |
| 1434 | uint16_t dev_id = 0; |
| 1435 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1436 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
| 1437 | |
| 1438 | dev_id = phba->pcidev->device; |
| 1439 | switch (dev_id) { |
| 1440 | case BE_DEVICE_ID1: |
| 1441 | case OC_DEVICE_ID1: |
| 1442 | case OC_DEVICE_ID2: |
| 1443 | return snprintf(buf, PAGE_SIZE, "BE2 Adapter Family\n"); |
| 1444 | break; |
| 1445 | case BE_DEVICE_ID2: |
| 1446 | case OC_DEVICE_ID3: |
| 1447 | return snprintf(buf, PAGE_SIZE, "BE3-R Adapter Family\n"); |
| 1448 | break; |
| 1449 | case OC_SKH_ID1: |
| 1450 | return snprintf(buf, PAGE_SIZE, "Skyhawk-R Adapter Family\n"); |
| 1451 | break; |
| 1452 | default: |
| 1453 | return snprintf(buf, PAGE_SIZE, |
Masanari Iida | b23f7a0 | 2013-04-18 00:12:55 +0900 | [diff] [blame] | 1454 | "Unknown Adapter Family: 0x%x\n", dev_id); |
John Soni Jose | 26000db | 2012-10-20 04:45:06 +0530 | [diff] [blame] | 1455 | break; |
| 1456 | } |
| 1457 | } |
| 1458 | |
Jayamohan Kallickal | d3fea9a | 2013-09-28 15:35:53 -0700 | [diff] [blame] | 1459 | /** |
| 1460 | * beiscsi_phys_port()- Display Physical Port Identifier |
| 1461 | * @dev: ptr to device not used. |
| 1462 | * @attr: device attribute, not used. |
| 1463 | * @buf: contains formatted text port identifier |
| 1464 | * |
| 1465 | * return |
| 1466 | * size of the formatted string |
| 1467 | **/ |
| 1468 | ssize_t |
| 1469 | beiscsi_phys_port_disp(struct device *dev, struct device_attribute *attr, |
| 1470 | char *buf) |
| 1471 | { |
| 1472 | struct Scsi_Host *shost = class_to_shost(dev); |
| 1473 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
| 1474 | |
| 1475 | return snprintf(buf, PAGE_SIZE, "Port Identifier : %d\n", |
| 1476 | phba->fw_config.phys_port); |
| 1477 | } |
John Soni Jose | 26000db | 2012-10-20 04:45:06 +0530 | [diff] [blame] | 1478 | |
John Soni Jose | acb9693 | 2012-10-20 04:44:35 +0530 | [diff] [blame] | 1479 | void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params, |
| 1480 | struct wrb_handle *pwrb_handle, |
| 1481 | struct be_mem_descriptor *mem_descr) |
| 1482 | { |
| 1483 | struct iscsi_wrb *pwrb = pwrb_handle->pwrb; |
| 1484 | |
| 1485 | memset(pwrb, 0, sizeof(*pwrb)); |
| 1486 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, |
| 1487 | max_send_data_segment_length, pwrb, |
| 1488 | params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1489 | max_send_data_segment_length) / 32]); |
| 1490 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, type, pwrb, |
| 1491 | BE_TGT_CTX_UPDT_CMD); |
| 1492 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, |
| 1493 | first_burst_length, |
| 1494 | pwrb, |
| 1495 | params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1496 | first_burst_length) / 32]); |
| 1497 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, erl, pwrb, |
| 1498 | (params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1499 | erl) / 32] & OFFLD_PARAMS_ERL)); |
| 1500 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, dde, pwrb, |
| 1501 | (params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1502 | dde) / 32] & OFFLD_PARAMS_DDE) >> 2); |
| 1503 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, hde, pwrb, |
| 1504 | (params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1505 | hde) / 32] & OFFLD_PARAMS_HDE) >> 3); |
| 1506 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, ir2t, pwrb, |
| 1507 | (params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1508 | ir2t) / 32] & OFFLD_PARAMS_IR2T) >> 4); |
| 1509 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, imd, pwrb, |
| 1510 | (params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1511 | imd) / 32] & OFFLD_PARAMS_IMD) >> 5); |
| 1512 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, stat_sn, |
| 1513 | pwrb, |
| 1514 | (params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1515 | exp_statsn) / 32] + 1)); |
| 1516 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, wrb_idx, |
| 1517 | pwrb, pwrb_handle->wrb_index); |
| 1518 | |
| 1519 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, |
| 1520 | max_burst_length, pwrb, params->dw[offsetof |
| 1521 | (struct amap_beiscsi_offload_params, |
| 1522 | max_burst_length) / 32]); |
| 1523 | |
| 1524 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, ptr2nextwrb, |
| 1525 | pwrb, pwrb_handle->nxt_wrb_index); |
| 1526 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, |
| 1527 | session_state, pwrb, 0); |
| 1528 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, compltonack, |
| 1529 | pwrb, 1); |
| 1530 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, notpredblq, |
| 1531 | pwrb, 0); |
| 1532 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, mode, pwrb, |
| 1533 | 0); |
| 1534 | |
| 1535 | mem_descr += ISCSI_MEM_GLOBAL_HEADER; |
| 1536 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, |
| 1537 | pad_buffer_addr_hi, pwrb, |
| 1538 | mem_descr->mem_array[0].bus_address.u.a32.address_hi); |
| 1539 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, |
| 1540 | pad_buffer_addr_lo, pwrb, |
| 1541 | mem_descr->mem_array[0].bus_address.u.a32.address_lo); |
| 1542 | } |
| 1543 | |
| 1544 | void beiscsi_offload_cxn_v2(struct beiscsi_offload_params *params, |
| 1545 | struct wrb_handle *pwrb_handle) |
| 1546 | { |
| 1547 | struct iscsi_wrb *pwrb = pwrb_handle->pwrb; |
| 1548 | |
| 1549 | memset(pwrb, 0, sizeof(*pwrb)); |
| 1550 | |
John Soni Jose | acb9693 | 2012-10-20 04:44:35 +0530 | [diff] [blame] | 1551 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, |
| 1552 | max_burst_length, pwrb, params->dw[offsetof |
| 1553 | (struct amap_beiscsi_offload_params, |
| 1554 | max_burst_length) / 32]); |
| 1555 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, |
| 1556 | type, pwrb, |
| 1557 | BE_TGT_CTX_UPDT_CMD); |
| 1558 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, |
| 1559 | ptr2nextwrb, |
| 1560 | pwrb, pwrb_handle->nxt_wrb_index); |
| 1561 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, wrb_idx, |
| 1562 | pwrb, pwrb_handle->wrb_index); |
| 1563 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, |
| 1564 | max_send_data_segment_length, pwrb, |
| 1565 | params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1566 | max_send_data_segment_length) / 32]); |
| 1567 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, |
| 1568 | first_burst_length, pwrb, |
| 1569 | params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1570 | first_burst_length) / 32]); |
| 1571 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, |
Jayamohan Kallickal | 7331613 | 2013-09-28 15:35:41 -0700 | [diff] [blame] | 1572 | max_recv_dataseg_len, pwrb, |
| 1573 | params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1574 | max_recv_data_segment_length) / 32]); |
John Soni Jose | acb9693 | 2012-10-20 04:44:35 +0530 | [diff] [blame] | 1575 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, |
| 1576 | max_cxns, pwrb, BEISCSI_MAX_CXNS); |
| 1577 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, erl, pwrb, |
| 1578 | (params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1579 | erl) / 32] & OFFLD_PARAMS_ERL)); |
| 1580 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, dde, pwrb, |
| 1581 | (params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1582 | dde) / 32] & OFFLD_PARAMS_DDE) >> 2); |
| 1583 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, hde, pwrb, |
| 1584 | (params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1585 | hde) / 32] & OFFLD_PARAMS_HDE) >> 3); |
| 1586 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, |
| 1587 | ir2t, pwrb, |
| 1588 | (params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1589 | ir2t) / 32] & OFFLD_PARAMS_IR2T) >> 4); |
| 1590 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, imd, pwrb, |
| 1591 | (params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1592 | imd) / 32] & OFFLD_PARAMS_IMD) >> 5); |
| 1593 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, |
| 1594 | data_seq_inorder, |
| 1595 | pwrb, |
| 1596 | (params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1597 | data_seq_inorder) / 32] & |
| 1598 | OFFLD_PARAMS_DATA_SEQ_INORDER) >> 6); |
| 1599 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, |
| 1600 | pdu_seq_inorder, |
| 1601 | pwrb, |
| 1602 | (params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1603 | pdu_seq_inorder) / 32] & |
| 1604 | OFFLD_PARAMS_PDU_SEQ_INORDER) >> 7); |
| 1605 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, max_r2t, |
| 1606 | pwrb, |
| 1607 | (params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1608 | max_r2t) / 32] & |
| 1609 | OFFLD_PARAMS_MAX_R2T) >> 8); |
| 1610 | AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, stat_sn, |
| 1611 | pwrb, |
| 1612 | (params->dw[offsetof(struct amap_beiscsi_offload_params, |
| 1613 | exp_statsn) / 32] + 1)); |
| 1614 | } |