Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1 | /** |
Jayamohan Kallickal | d2eeb1a | 2010-01-23 05:35:15 +0530 | [diff] [blame] | 2 | * Copyright (C) 2005 - 2010 ServerEngines |
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 | * |
| 10 | * Written by: Jayamohan Kallickal (jayamohank@serverengines.com) |
| 11 | * |
| 12 | * Contact Information: |
| 13 | * linux-drivers@serverengines.com |
| 14 | * |
| 15 | * ServerEngines |
| 16 | * 209 N. Fair Oaks Ave |
| 17 | * Sunnyvale, CA 94085 |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #include "be_mgmt.h" |
| 22 | #include "be_iscsi.h" |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame^] | 23 | #include <scsi/scsi_transport_iscsi.h> |
| 24 | |
| 25 | unsigned int beiscsi_get_boot_target(struct beiscsi_hba *phba) |
| 26 | { |
| 27 | struct be_ctrl_info *ctrl = &phba->ctrl; |
| 28 | struct be_mcc_wrb *wrb; |
| 29 | struct be_cmd_req_get_mac_addr *req; |
| 30 | unsigned int tag = 0; |
| 31 | |
| 32 | SE_DEBUG(DBG_LVL_8, "In bescsi_get_boot_target\n"); |
| 33 | spin_lock(&ctrl->mbox_lock); |
| 34 | tag = alloc_mcc_tag(phba); |
| 35 | if (!tag) { |
| 36 | spin_unlock(&ctrl->mbox_lock); |
| 37 | return tag; |
| 38 | } |
| 39 | |
| 40 | wrb = wrb_from_mccq(phba); |
| 41 | req = embedded_payload(wrb); |
| 42 | wrb->tag0 |= tag; |
| 43 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
| 44 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI, |
| 45 | OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET, |
| 46 | sizeof(*req)); |
| 47 | |
| 48 | be_mcc_notify(phba); |
| 49 | spin_unlock(&ctrl->mbox_lock); |
| 50 | return tag; |
| 51 | } |
| 52 | |
| 53 | unsigned int beiscsi_get_session_info(struct beiscsi_hba *phba, |
| 54 | u32 boot_session_handle, |
| 55 | struct be_dma_mem *nonemb_cmd) |
| 56 | { |
| 57 | struct be_ctrl_info *ctrl = &phba->ctrl; |
| 58 | struct be_mcc_wrb *wrb; |
| 59 | unsigned int tag = 0; |
| 60 | struct be_cmd_req_get_session *req; |
| 61 | struct be_cmd_resp_get_session *resp; |
| 62 | struct be_sge *sge; |
| 63 | |
| 64 | SE_DEBUG(DBG_LVL_8, "In beiscsi_get_session_info\n"); |
| 65 | spin_lock(&ctrl->mbox_lock); |
| 66 | tag = alloc_mcc_tag(phba); |
| 67 | if (!tag) { |
| 68 | spin_unlock(&ctrl->mbox_lock); |
| 69 | return tag; |
| 70 | } |
| 71 | |
| 72 | nonemb_cmd->size = sizeof(*resp); |
| 73 | req = nonemb_cmd->va; |
| 74 | memset(req, 0, sizeof(*req)); |
| 75 | wrb = wrb_from_mccq(phba); |
| 76 | sge = nonembedded_sgl(wrb); |
| 77 | wrb->tag0 |= tag; |
| 78 | |
| 79 | |
| 80 | wrb->tag0 |= tag; |
| 81 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1); |
| 82 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI, |
| 83 | OPCODE_ISCSI_INI_SESSION_GET_A_SESSION, |
| 84 | sizeof(*resp)); |
| 85 | req->session_handle = boot_session_handle; |
| 86 | sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma)); |
| 87 | sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); |
| 88 | sge->len = cpu_to_le32(nonemb_cmd->size); |
| 89 | |
| 90 | be_mcc_notify(phba); |
| 91 | spin_unlock(&ctrl->mbox_lock); |
| 92 | return tag; |
| 93 | } |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 94 | |
Jayamohan Kallickal | 03a1231 | 2010-07-22 04:17:16 +0530 | [diff] [blame] | 95 | int mgmt_get_fw_config(struct be_ctrl_info *ctrl, |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 96 | struct beiscsi_hba *phba) |
| 97 | { |
| 98 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); |
| 99 | struct be_fw_cfg *req = embedded_payload(wrb); |
| 100 | int status = 0; |
| 101 | |
| 102 | spin_lock(&ctrl->mbox_lock); |
| 103 | memset(wrb, 0, sizeof(*wrb)); |
| 104 | |
| 105 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
| 106 | |
| 107 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 108 | OPCODE_COMMON_QUERY_FIRMWARE_CONFIG, sizeof(*req)); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 109 | status = be_mbox_notify(ctrl); |
| 110 | if (!status) { |
| 111 | struct be_fw_cfg *pfw_cfg; |
| 112 | pfw_cfg = req; |
| 113 | phba->fw_config.phys_port = pfw_cfg->phys_port; |
| 114 | phba->fw_config.iscsi_icd_start = |
| 115 | pfw_cfg->ulp[0].icd_base; |
| 116 | phba->fw_config.iscsi_icd_count = |
| 117 | pfw_cfg->ulp[0].icd_count; |
| 118 | phba->fw_config.iscsi_cid_start = |
| 119 | pfw_cfg->ulp[0].sq_base; |
| 120 | phba->fw_config.iscsi_cid_count = |
| 121 | pfw_cfg->ulp[0].sq_count; |
Jayamohan Kallickal | 7da5087 | 2010-01-05 05:04:12 +0530 | [diff] [blame] | 122 | if (phba->fw_config.iscsi_cid_count > (BE2_MAX_SESSIONS / 2)) { |
Jayamohan Kallickal | a3babda | 2010-01-07 01:51:44 +0530 | [diff] [blame] | 123 | SE_DEBUG(DBG_LVL_8, |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 124 | "FW reported MAX CXNS as %d\t" |
Jayamohan Kallickal | a3babda | 2010-01-07 01:51:44 +0530 | [diff] [blame] | 125 | "Max Supported = %d.\n", |
| 126 | phba->fw_config.iscsi_cid_count, |
| 127 | BE2_MAX_SESSIONS); |
| 128 | phba->fw_config.iscsi_cid_count = BE2_MAX_SESSIONS / 2; |
Jayamohan Kallickal | 7da5087 | 2010-01-05 05:04:12 +0530 | [diff] [blame] | 129 | } |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 130 | } else { |
| 131 | shost_printk(KERN_WARNING, phba->shost, |
Jayamohan Kallickal | 457ff3b | 2010-07-22 04:16:00 +0530 | [diff] [blame] | 132 | "Failed in mgmt_get_fw_config\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | spin_unlock(&ctrl->mbox_lock); |
| 136 | return status; |
| 137 | } |
| 138 | |
Jayamohan Kallickal | 03a1231 | 2010-07-22 04:17:16 +0530 | [diff] [blame] | 139 | int mgmt_check_supported_fw(struct be_ctrl_info *ctrl, |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 140 | struct beiscsi_hba *phba) |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 141 | { |
| 142 | struct be_dma_mem nonemb_cmd; |
| 143 | struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); |
| 144 | struct be_mgmt_controller_attributes *req; |
| 145 | struct be_sge *sge = nonembedded_sgl(wrb); |
| 146 | int status = 0; |
| 147 | |
| 148 | nonemb_cmd.va = pci_alloc_consistent(ctrl->pdev, |
| 149 | sizeof(struct be_mgmt_controller_attributes), |
| 150 | &nonemb_cmd.dma); |
| 151 | if (nonemb_cmd.va == NULL) { |
| 152 | SE_DEBUG(DBG_LVL_1, |
| 153 | "Failed to allocate memory for mgmt_check_supported_fw" |
| 154 | "\n"); |
Jayamohan Kallickal | d3ad2bb | 2010-07-22 04:16:38 +0530 | [diff] [blame] | 155 | return -ENOMEM; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 156 | } |
| 157 | nonemb_cmd.size = sizeof(struct be_mgmt_controller_attributes); |
| 158 | req = nonemb_cmd.va; |
Jayamohan Kallickal | f98c96b | 2010-02-11 05:11:15 +0530 | [diff] [blame] | 159 | memset(req, 0, sizeof(*req)); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 160 | spin_lock(&ctrl->mbox_lock); |
| 161 | memset(wrb, 0, sizeof(*wrb)); |
| 162 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1); |
| 163 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
| 164 | OPCODE_COMMON_GET_CNTL_ATTRIBUTES, sizeof(*req)); |
| 165 | sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd.dma)); |
| 166 | sge->pa_lo = cpu_to_le32(nonemb_cmd.dma & 0xFFFFFFFF); |
| 167 | sge->len = cpu_to_le32(nonemb_cmd.size); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 168 | status = be_mbox_notify(ctrl); |
| 169 | if (!status) { |
| 170 | struct be_mgmt_controller_attributes_resp *resp = nonemb_cmd.va; |
| 171 | SE_DEBUG(DBG_LVL_8, "Firmware version of CMD: %s\n", |
| 172 | resp->params.hba_attribs.flashrom_version_string); |
| 173 | SE_DEBUG(DBG_LVL_8, "Firmware version is : %s\n", |
| 174 | resp->params.hba_attribs.firmware_version_string); |
| 175 | SE_DEBUG(DBG_LVL_8, |
| 176 | "Developer Build, not performing version check...\n"); |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 177 | phba->fw_config.iscsi_features = |
| 178 | resp->params.hba_attribs.iscsi_features; |
| 179 | SE_DEBUG(DBG_LVL_8, " phba->fw_config.iscsi_features = %d\n", |
| 180 | phba->fw_config.iscsi_features); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 181 | } else |
| 182 | SE_DEBUG(DBG_LVL_1, " Failed in mgmt_check_supported_fw\n"); |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 183 | spin_unlock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 184 | if (nonemb_cmd.va) |
| 185 | pci_free_consistent(ctrl->pdev, nonemb_cmd.size, |
| 186 | nonemb_cmd.va, nonemb_cmd.dma); |
| 187 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 188 | return status; |
| 189 | } |
| 190 | |
Jayamohan Kallickal | 03a1231 | 2010-07-22 04:17:16 +0530 | [diff] [blame] | 191 | int mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short chute) |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 192 | { |
| 193 | struct be_ctrl_info *ctrl = &phba->ctrl; |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 194 | struct be_mcc_wrb *wrb = wrb_from_mccq(phba); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 195 | struct iscsi_cleanup_req *req = embedded_payload(wrb); |
| 196 | int status = 0; |
| 197 | |
| 198 | spin_lock(&ctrl->mbox_lock); |
| 199 | memset(wrb, 0, sizeof(*wrb)); |
| 200 | |
| 201 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
| 202 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, |
| 203 | OPCODE_COMMON_ISCSI_CLEANUP, sizeof(*req)); |
| 204 | |
| 205 | req->chute = chute; |
| 206 | req->hdr_ring_id = 0; |
| 207 | req->data_ring_id = 0; |
| 208 | |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 209 | status = be_mcc_notify_wait(phba); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 210 | if (status) |
| 211 | shost_printk(KERN_WARNING, phba->shost, |
| 212 | " mgmt_epfw_cleanup , FAILED\n"); |
| 213 | spin_unlock(&ctrl->mbox_lock); |
| 214 | return status; |
| 215 | } |
| 216 | |
Jayamohan Kallickal | 03a1231 | 2010-07-22 04:17:16 +0530 | [diff] [blame] | 217 | unsigned int mgmt_invalidate_icds(struct beiscsi_hba *phba, |
Jayamohan Kallickal | 4183122 | 2010-02-20 08:02:39 +0530 | [diff] [blame] | 218 | struct invalidate_command_table *inv_tbl, |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 219 | unsigned int num_invalidate, unsigned int cid, |
| 220 | struct be_dma_mem *nonemb_cmd) |
| 221 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 222 | { |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 223 | struct be_ctrl_info *ctrl = &phba->ctrl; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 224 | struct be_mcc_wrb *wrb; |
| 225 | struct be_sge *sge; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 226 | struct invalidate_commands_params_in *req; |
Jayamohan Kallickal | 4183122 | 2010-02-20 08:02:39 +0530 | [diff] [blame] | 227 | unsigned int i, tag = 0; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 228 | |
| 229 | spin_lock(&ctrl->mbox_lock); |
| 230 | tag = alloc_mcc_tag(phba); |
| 231 | if (!tag) { |
| 232 | spin_unlock(&ctrl->mbox_lock); |
| 233 | return tag; |
| 234 | } |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 235 | |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 236 | req = nonemb_cmd->va; |
Jayamohan Kallickal | f98c96b | 2010-02-11 05:11:15 +0530 | [diff] [blame] | 237 | memset(req, 0, sizeof(*req)); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 238 | wrb = wrb_from_mccq(phba); |
| 239 | sge = nonembedded_sgl(wrb); |
| 240 | wrb->tag0 |= tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 241 | |
| 242 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1); |
| 243 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, |
| 244 | OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS, |
| 245 | sizeof(*req)); |
| 246 | req->ref_handle = 0; |
| 247 | req->cleanup_type = CMD_ISCSI_COMMAND_INVALIDATE; |
Jayamohan Kallickal | 4183122 | 2010-02-20 08:02:39 +0530 | [diff] [blame] | 248 | for (i = 0; i < num_invalidate; i++) { |
| 249 | req->table[i].icd = inv_tbl->icd; |
| 250 | req->table[i].cid = inv_tbl->cid; |
| 251 | req->icd_count++; |
| 252 | inv_tbl++; |
| 253 | } |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 254 | sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma)); |
| 255 | sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); |
| 256 | sge->len = cpu_to_le32(nonemb_cmd->size); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 257 | |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 258 | be_mcc_notify(phba); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 259 | spin_unlock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 260 | return tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 261 | } |
| 262 | |
Jayamohan Kallickal | 03a1231 | 2010-07-22 04:17:16 +0530 | [diff] [blame] | 263 | unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba, |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 264 | struct beiscsi_endpoint *beiscsi_ep, |
| 265 | unsigned short cid, |
| 266 | unsigned short issue_reset, |
| 267 | unsigned short savecfg_flag) |
| 268 | { |
| 269 | struct be_ctrl_info *ctrl = &phba->ctrl; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 270 | struct be_mcc_wrb *wrb; |
| 271 | struct iscsi_invalidate_connection_params_in *req; |
| 272 | unsigned int tag = 0; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 273 | |
| 274 | spin_lock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 275 | tag = alloc_mcc_tag(phba); |
| 276 | if (!tag) { |
| 277 | spin_unlock(&ctrl->mbox_lock); |
| 278 | return tag; |
| 279 | } |
| 280 | wrb = wrb_from_mccq(phba); |
| 281 | wrb->tag0 |= tag; |
| 282 | req = embedded_payload(wrb); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 283 | |
| 284 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
| 285 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI, |
| 286 | OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION, |
| 287 | sizeof(*req)); |
| 288 | req->session_handle = beiscsi_ep->fw_handle; |
| 289 | req->cid = cid; |
| 290 | if (issue_reset) |
| 291 | req->cleanup_type = CMD_ISCSI_CONNECTION_ISSUE_TCP_RST; |
| 292 | else |
| 293 | req->cleanup_type = CMD_ISCSI_CONNECTION_INVALIDATE; |
| 294 | req->save_cfg = savecfg_flag; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 295 | be_mcc_notify(phba); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 296 | spin_unlock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 297 | return tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 298 | } |
| 299 | |
Jayamohan Kallickal | 03a1231 | 2010-07-22 04:17:16 +0530 | [diff] [blame] | 300 | unsigned int mgmt_upload_connection(struct beiscsi_hba *phba, |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 301 | unsigned short cid, unsigned int upload_flag) |
| 302 | { |
| 303 | struct be_ctrl_info *ctrl = &phba->ctrl; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 304 | struct be_mcc_wrb *wrb; |
| 305 | struct tcp_upload_params_in *req; |
| 306 | unsigned int tag = 0; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 307 | |
| 308 | spin_lock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 309 | tag = alloc_mcc_tag(phba); |
| 310 | if (!tag) { |
| 311 | spin_unlock(&ctrl->mbox_lock); |
| 312 | return tag; |
| 313 | } |
| 314 | wrb = wrb_from_mccq(phba); |
| 315 | req = embedded_payload(wrb); |
| 316 | wrb->tag0 |= tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 317 | |
| 318 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
| 319 | be_cmd_hdr_prepare(&req->hdr, CMD_COMMON_TCP_UPLOAD, |
| 320 | OPCODE_COMMON_TCP_UPLOAD, sizeof(*req)); |
| 321 | req->id = (unsigned short)cid; |
| 322 | req->upload_type = (unsigned char)upload_flag; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 323 | be_mcc_notify(phba); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 324 | spin_unlock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 325 | return tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | int mgmt_open_connection(struct beiscsi_hba *phba, |
| 329 | struct sockaddr *dst_addr, |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 330 | struct beiscsi_endpoint *beiscsi_ep, |
| 331 | struct be_dma_mem *nonemb_cmd) |
| 332 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 333 | { |
| 334 | struct hwi_controller *phwi_ctrlr; |
| 335 | struct hwi_context_memory *phwi_context; |
| 336 | struct sockaddr_in *daddr_in = (struct sockaddr_in *)dst_addr; |
| 337 | struct sockaddr_in6 *daddr_in6 = (struct sockaddr_in6 *)dst_addr; |
| 338 | struct be_ctrl_info *ctrl = &phba->ctrl; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 339 | struct be_mcc_wrb *wrb; |
| 340 | struct tcp_connect_and_offload_in *req; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 341 | unsigned short def_hdr_id; |
| 342 | unsigned short def_data_id; |
| 343 | struct phys_addr template_address = { 0, 0 }; |
| 344 | struct phys_addr *ptemplate_address; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 345 | unsigned int tag = 0; |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 346 | unsigned int i; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 347 | unsigned short cid = beiscsi_ep->ep_cid; |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 348 | struct be_sge *sge; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 349 | |
| 350 | phwi_ctrlr = phba->phwi_ctrlr; |
| 351 | phwi_context = phwi_ctrlr->phwi_ctxt; |
| 352 | def_hdr_id = (unsigned short)HWI_GET_DEF_HDRQ_ID(phba); |
| 353 | def_data_id = (unsigned short)HWI_GET_DEF_BUFQ_ID(phba); |
| 354 | |
| 355 | ptemplate_address = &template_address; |
| 356 | ISCSI_GET_PDU_TEMPLATE_ADDRESS(phba, ptemplate_address); |
| 357 | spin_lock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 358 | tag = alloc_mcc_tag(phba); |
| 359 | if (!tag) { |
| 360 | spin_unlock(&ctrl->mbox_lock); |
| 361 | return tag; |
| 362 | } |
| 363 | wrb = wrb_from_mccq(phba); |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 364 | memset(wrb, 0, sizeof(*wrb)); |
| 365 | sge = nonembedded_sgl(wrb); |
| 366 | |
| 367 | req = nonemb_cmd->va; |
| 368 | memset(req, 0, sizeof(*req)); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 369 | wrb->tag0 |= tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 370 | |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 371 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 1); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 372 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, |
| 373 | OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD, |
| 374 | sizeof(*req)); |
| 375 | if (dst_addr->sa_family == PF_INET) { |
| 376 | __be32 s_addr = daddr_in->sin_addr.s_addr; |
| 377 | req->ip_address.ip_type = BE2_IPV4; |
| 378 | req->ip_address.ip_address[0] = s_addr & 0x000000ff; |
| 379 | req->ip_address.ip_address[1] = (s_addr & 0x0000ff00) >> 8; |
| 380 | req->ip_address.ip_address[2] = (s_addr & 0x00ff0000) >> 16; |
| 381 | req->ip_address.ip_address[3] = (s_addr & 0xff000000) >> 24; |
| 382 | req->tcp_port = ntohs(daddr_in->sin_port); |
| 383 | beiscsi_ep->dst_addr = daddr_in->sin_addr.s_addr; |
| 384 | beiscsi_ep->dst_tcpport = ntohs(daddr_in->sin_port); |
| 385 | beiscsi_ep->ip_type = BE2_IPV4; |
| 386 | } else if (dst_addr->sa_family == PF_INET6) { |
| 387 | req->ip_address.ip_type = BE2_IPV6; |
| 388 | memcpy(&req->ip_address.ip_address, |
| 389 | &daddr_in6->sin6_addr.in6_u.u6_addr8, 16); |
| 390 | req->tcp_port = ntohs(daddr_in6->sin6_port); |
| 391 | beiscsi_ep->dst_tcpport = ntohs(daddr_in6->sin6_port); |
| 392 | memcpy(&beiscsi_ep->dst6_addr, |
| 393 | &daddr_in6->sin6_addr.in6_u.u6_addr8, 16); |
| 394 | beiscsi_ep->ip_type = BE2_IPV6; |
| 395 | } else{ |
| 396 | shost_printk(KERN_ERR, phba->shost, "unknown addr family %d\n", |
| 397 | dst_addr->sa_family); |
| 398 | spin_unlock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 5db3f33 | 2010-07-22 04:24:22 +0530 | [diff] [blame] | 399 | free_mcc_tag(&phba->ctrl, tag); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 400 | return -EINVAL; |
| 401 | |
| 402 | } |
| 403 | req->cid = cid; |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 404 | i = phba->nxt_cqid++; |
| 405 | if (phba->nxt_cqid == phba->num_cpus) |
| 406 | phba->nxt_cqid = 0; |
| 407 | req->cq_id = phwi_context->be_cq[i].id; |
Jayamohan Kallickal | 457ff3b | 2010-07-22 04:16:00 +0530 | [diff] [blame] | 408 | SE_DEBUG(DBG_LVL_8, "i=%d cq_id=%d\n", i, req->cq_id); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 409 | req->defq_id = def_hdr_id; |
| 410 | req->hdr_ring_id = def_hdr_id; |
| 411 | req->data_ring_id = def_data_id; |
| 412 | req->do_offload = 1; |
| 413 | req->dataout_template_pa.lo = ptemplate_address->lo; |
| 414 | req->dataout_template_pa.hi = ptemplate_address->hi; |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 415 | sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma)); |
| 416 | sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); |
| 417 | sge->len = cpu_to_le32(nonemb_cmd->size); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 418 | be_mcc_notify(phba); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 419 | spin_unlock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 420 | return tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 421 | } |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 422 | |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 423 | unsigned int be_cmd_get_mac_addr(struct beiscsi_hba *phba) |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 424 | { |
| 425 | struct be_ctrl_info *ctrl = &phba->ctrl; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 426 | struct be_mcc_wrb *wrb; |
| 427 | struct be_cmd_req_get_mac_addr *req; |
| 428 | unsigned int tag = 0; |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 429 | |
| 430 | SE_DEBUG(DBG_LVL_8, "In be_cmd_get_mac_addr\n"); |
| 431 | spin_lock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 432 | tag = alloc_mcc_tag(phba); |
| 433 | if (!tag) { |
| 434 | spin_unlock(&ctrl->mbox_lock); |
| 435 | return tag; |
| 436 | } |
| 437 | |
| 438 | wrb = wrb_from_mccq(phba); |
| 439 | req = embedded_payload(wrb); |
| 440 | wrb->tag0 |= tag; |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 441 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
| 442 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, |
| 443 | OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG, |
| 444 | sizeof(*req)); |
| 445 | |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 446 | be_mcc_notify(phba); |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 447 | spin_unlock(&ctrl->mbox_lock); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 448 | return tag; |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 449 | } |
| 450 | |