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