^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * This file is part of the Emulex Linux Device Driver for Enterprise iSCSI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Host Bus Adapters. Refer to the README file included with this package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * for driver version and adapter compatibility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (c) 2018 Broadcom. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This program is free software; you can redistribute it and/or modify it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * under the terms of version 2 of the GNU General Public License as published
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * This program is distributed in the hope that it will be useful. ALL EXPRESS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * See the GNU General Public License for more details, a copy of which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * can be found in the file COPYING included with this package.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * Contact Information:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * linux-drivers@broadcom.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/bsg-lib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <scsi/scsi_transport_iscsi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <scsi/scsi_bsg_iscsi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include "be_mgmt.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include "be_iscsi.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include "be_main.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct beiscsi_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct bsg_job *job,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct be_dma_mem *nonemb_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct be_mcc_wrb *wrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct be_sge *mcc_sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) unsigned int tag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct iscsi_bsg_request *bsg_req = job->request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct be_bsg_vendor_cmd *req = nonemb_cmd->va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) unsigned short region, sector_size, sector, offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) nonemb_cmd->size = job->request_payload.payload_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) memset(nonemb_cmd->va, 0, nonemb_cmd->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) region = bsg_req->rqst_data.h_vendor.vendor_cmd[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) sector_size = bsg_req->rqst_data.h_vendor.vendor_cmd[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) sector = bsg_req->rqst_data.h_vendor.vendor_cmd[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) offset = bsg_req->rqst_data.h_vendor.vendor_cmd[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) req->region = region;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) req->sector = sector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) req->offset = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) if (mutex_lock_interruptible(&ctrl->mbox_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) switch (bsg_req->rqst_data.h_vendor.vendor_cmd[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) case BEISCSI_WRITE_FLASH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) offset = sector * sector_size + offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) OPCODE_COMMON_WRITE_FLASH, sizeof(*req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) sg_copy_to_buffer(job->request_payload.sg_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) job->request_payload.sg_cnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) nonemb_cmd->va + offset, job->request_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) case BEISCSI_READ_FLASH:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) OPCODE_COMMON_READ_FLASH, sizeof(*req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) "BG_%d : Unsupported cmd = 0x%x\n\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) bsg_req->rqst_data.h_vendor.vendor_cmd[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) wrb = alloc_mcc_wrb(phba, &tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) if (!wrb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) mcc_sge = nonembedded_sgl(wrb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) be_wrb_hdr_prepare(wrb, nonemb_cmd->size, false,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) job->request_payload.sg_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) mcc_sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) mcc_sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) mcc_sge->len = cpu_to_le32(nonemb_cmd->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) be_mcc_notify(phba, tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) return tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * mgmt_open_connection()- Establish a TCP CXN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * @phba: driver priv structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * @dst_addr: Destination Address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * @beiscsi_ep: ptr to device endpoint struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * @nonemb_cmd: ptr to memory allocated for command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * Success: Tag number of the MBX Command issued
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * Failure: Error code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) int mgmt_open_connection(struct beiscsi_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) struct sockaddr *dst_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct beiscsi_endpoint *beiscsi_ep,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct be_dma_mem *nonemb_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct hwi_controller *phwi_ctrlr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) struct hwi_context_memory *phwi_context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) struct sockaddr_in *daddr_in = (struct sockaddr_in *)dst_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) struct sockaddr_in6 *daddr_in6 = (struct sockaddr_in6 *)dst_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) struct be_ctrl_info *ctrl = &phba->ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct be_mcc_wrb *wrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) struct tcp_connect_and_offload_in_v1 *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) unsigned short def_hdr_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) unsigned short def_data_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) struct phys_addr template_address = { 0, 0 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct phys_addr *ptemplate_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) unsigned int tag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) unsigned int i, ulp_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) unsigned short cid = beiscsi_ep->ep_cid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) struct be_sge *sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) if (dst_addr->sa_family != PF_INET && dst_addr->sa_family != PF_INET6) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) "BG_%d : unknown addr family %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) dst_addr->sa_family);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) phwi_ctrlr = phba->phwi_ctrlr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) phwi_context = phwi_ctrlr->phwi_ctxt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) ulp_num = phwi_ctrlr->wrb_context[BE_GET_CRI_FROM_CID(cid)].ulp_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) def_hdr_id = (unsigned short)HWI_GET_DEF_HDRQ_ID(phba, ulp_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) def_data_id = (unsigned short)HWI_GET_DEF_BUFQ_ID(phba, ulp_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) ptemplate_address = &template_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) ISCSI_GET_PDU_TEMPLATE_ADDRESS(phba, ptemplate_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (mutex_lock_interruptible(&ctrl->mbox_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) wrb = alloc_mcc_wrb(phba, &tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) if (!wrb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) sge = nonembedded_sgl(wrb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) req = nonemb_cmd->va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) memset(req, 0, sizeof(*req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) be_wrb_hdr_prepare(wrb, nonemb_cmd->size, false, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) nonemb_cmd->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) if (dst_addr->sa_family == PF_INET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) __be32 s_addr = daddr_in->sin_addr.s_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) req->ip_address.ip_type = BEISCSI_IP_TYPE_V4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) req->ip_address.addr[0] = s_addr & 0x000000ff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) req->ip_address.addr[1] = (s_addr & 0x0000ff00) >> 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) req->ip_address.addr[2] = (s_addr & 0x00ff0000) >> 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) req->ip_address.addr[3] = (s_addr & 0xff000000) >> 24;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) req->tcp_port = ntohs(daddr_in->sin_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) beiscsi_ep->dst_addr = daddr_in->sin_addr.s_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) beiscsi_ep->dst_tcpport = ntohs(daddr_in->sin_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) beiscsi_ep->ip_type = BEISCSI_IP_TYPE_V4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /* else its PF_INET6 family */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) req->ip_address.ip_type = BEISCSI_IP_TYPE_V6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) memcpy(&req->ip_address.addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) &daddr_in6->sin6_addr.in6_u.u6_addr8, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) req->tcp_port = ntohs(daddr_in6->sin6_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) beiscsi_ep->dst_tcpport = ntohs(daddr_in6->sin6_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) memcpy(&beiscsi_ep->dst6_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) &daddr_in6->sin6_addr.in6_u.u6_addr8, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) beiscsi_ep->ip_type = BEISCSI_IP_TYPE_V6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) req->cid = cid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) i = phba->nxt_cqid++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) if (phba->nxt_cqid == phba->num_cpus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) phba->nxt_cqid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) req->cq_id = phwi_context->be_cq[i].id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) "BG_%d : i=%d cq_id=%d\n", i, req->cq_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) req->defq_id = def_hdr_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) req->hdr_ring_id = def_hdr_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) req->data_ring_id = def_data_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) req->do_offload = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) req->dataout_template_pa.lo = ptemplate_address->lo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) req->dataout_template_pa.hi = ptemplate_address->hi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) sge->len = cpu_to_le32(nonemb_cmd->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) if (!is_chip_be2_be3r(phba)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) req->hdr.version = MBX_CMD_VER1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) req->tcp_window_size = 0x8000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) req->tcp_window_scale_count = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) be_mcc_notify(phba, tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) return tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * beiscsi_exec_nemb_cmd()- execute non-embedded MBX cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) * @phba: driver priv structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * @nonemb_cmd: DMA address of the MBX command to be issued
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) * @cbfn: callback func on MCC completion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) * @resp_buf: buffer to copy the MBX cmd response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) * @resp_buf_len: response length to be copied
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) static int beiscsi_exec_nemb_cmd(struct beiscsi_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) struct be_dma_mem *nonemb_cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) void (*cbfn)(struct beiscsi_hba *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) unsigned int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) void *resp_buf, u32 resp_buf_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) struct be_ctrl_info *ctrl = &phba->ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) struct be_mcc_wrb *wrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) struct be_sge *sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) unsigned int tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) mutex_lock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) wrb = alloc_mcc_wrb(phba, &tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) if (!wrb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) goto free_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) sge = nonembedded_sgl(wrb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) be_wrb_hdr_prepare(wrb, nonemb_cmd->size, false, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) sge->pa_lo = cpu_to_le32(lower_32_bits(nonemb_cmd->dma));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) sge->len = cpu_to_le32(nonemb_cmd->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) if (cbfn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) struct be_dma_mem *tag_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) set_bit(MCC_TAG_STATE_ASYNC, &ctrl->ptag_state[tag].tag_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) ctrl->ptag_state[tag].cbfn = cbfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) tag_mem = &phba->ctrl.ptag_state[tag].tag_mem_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) /* store DMA mem to be freed in callback */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) tag_mem->size = nonemb_cmd->size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) tag_mem->va = nonemb_cmd->va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) tag_mem->dma = nonemb_cmd->dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) be_mcc_notify(phba, tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) /* with cbfn set, its async cmd, don't wait */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) if (cbfn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) rc = beiscsi_mccq_compl_wait(phba, tag, NULL, nonemb_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) /* copy the response, if any */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) if (resp_buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) memcpy(resp_buf, nonemb_cmd->va, resp_buf_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) * This is special case of NTWK_GET_IF_INFO where the size of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) * response is not known. beiscsi_if_get_info checks the return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) * value to free DMA buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) if (rc == -EAGAIN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) * If FW is busy that is driver timed out, DMA buffer is saved with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) * the tag, only when the cmd completes this buffer is freed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) if (rc == -EBUSY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) free_cmd:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) dma_free_coherent(&ctrl->pdev->dev, nonemb_cmd->size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) nonemb_cmd->va, nonemb_cmd->dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) static int beiscsi_prep_nemb_cmd(struct beiscsi_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) struct be_dma_mem *cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) u8 subsystem, u8 opcode, u32 size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) cmd->va = dma_alloc_coherent(&phba->ctrl.pdev->dev, size, &cmd->dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) if (!cmd->va) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) "BG_%d : Failed to allocate memory for if info\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) cmd->size = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) be_cmd_hdr_prepare(cmd->va, subsystem, opcode, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) "BG_%d : subsystem %u cmd %u size %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) subsystem, opcode, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) static void __beiscsi_eq_delay_compl(struct beiscsi_hba *phba, unsigned int tag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) struct be_dma_mem *tag_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) /* status is ignored */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) __beiscsi_mcc_compl_status(phba, tag, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) tag_mem = &phba->ctrl.ptag_state[tag].tag_mem_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) if (tag_mem->size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) dma_free_coherent(&phba->pcidev->dev, tag_mem->size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) tag_mem->va, tag_mem->dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) tag_mem->size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) int beiscsi_modify_eq_delay(struct beiscsi_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) struct be_set_eqd *set_eqd, int num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) struct be_cmd_req_modify_eq_delay *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) struct be_dma_mem nonemb_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) int i, rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_COMMON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) OPCODE_COMMON_MODIFY_EQ_DELAY, sizeof(*req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) req = nonemb_cmd.va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) req->num_eq = cpu_to_le32(num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) for (i = 0; i < num; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) req->delay[i].eq_id = cpu_to_le32(set_eqd[i].eq_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) req->delay[i].phase = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) req->delay[i].delay_multiplier =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) cpu_to_le32(set_eqd[i].delay_multiplier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) return beiscsi_exec_nemb_cmd(phba, &nonemb_cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) __beiscsi_eq_delay_compl, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) * beiscsi_get_initiator_name - read initiator name from flash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) * @phba: device priv structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) * @name: buffer pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) * @cfg: fetch user configured
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) int beiscsi_get_initiator_name(struct beiscsi_hba *phba, char *name, bool cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) struct be_dma_mem nonemb_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) struct be_cmd_hba_name resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) struct be_cmd_hba_name *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_ISCSI_INI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) OPCODE_ISCSI_INI_CFG_GET_HBA_NAME, sizeof(resp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) req = nonemb_cmd.va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) if (cfg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) req->hdr.version = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) rc = beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) &resp, sizeof(resp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) beiscsi_log(phba, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) "BS_%d : Initiator Name MBX Failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) rc = sprintf(name, "%s\n", resp.initiator_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) unsigned int beiscsi_if_get_handle(struct beiscsi_hba *phba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) struct be_ctrl_info *ctrl = &phba->ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) struct be_mcc_wrb *wrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) struct be_cmd_get_all_if_id_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) struct be_cmd_get_all_if_id_req *pbe_allid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) unsigned int tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) int status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) if (mutex_lock_interruptible(&ctrl->mbox_lock))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) return -EINTR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) wrb = alloc_mcc_wrb(phba, &tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) if (!wrb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) req = embedded_payload(wrb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) sizeof(*req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) be_mcc_notify(phba, tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) status = beiscsi_mccq_compl_wait(phba, tag, &wrb, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) if (status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) "BG_%d : %s failed: %d\n", __func__, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) pbe_allid = embedded_payload(wrb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) /* we now support only one interface per function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) phba->interface_handle = pbe_allid->if_hndl_list[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) static inline bool beiscsi_if_zero_ip(u8 *ip, u32 ip_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) len = (ip_type < BEISCSI_IP_TYPE_V6) ? IP_V4_LEN : IP_V6_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) while (len && !ip[len - 1])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) len--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) return (len == 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) static int beiscsi_if_mod_gw(struct beiscsi_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) u32 action, u32 ip_type, u8 *gw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) struct be_cmd_set_def_gateway_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) struct be_dma_mem nonemb_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) int rt_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) rt_val = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_ISCSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) sizeof(*req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) if (rt_val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) return rt_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) req = nonemb_cmd.va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) req->action = action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) req->ip_addr.ip_type = ip_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) memcpy(req->ip_addr.addr, gw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) (ip_type < BEISCSI_IP_TYPE_V6) ? IP_V4_LEN : IP_V6_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) return beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) int beiscsi_if_set_gw(struct beiscsi_hba *phba, u32 ip_type, u8 *gw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) struct be_cmd_get_def_gateway_resp gw_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) int rt_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) memset(&gw_resp, 0, sizeof(gw_resp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) rt_val = beiscsi_if_get_gw(phba, ip_type, &gw_resp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) if (rt_val) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) "BG_%d : Failed to Get Gateway Addr\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) return rt_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) if (!beiscsi_if_zero_ip(gw_resp.ip_addr.addr, ip_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) rt_val = beiscsi_if_mod_gw(phba, IP_ACTION_DEL, ip_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) gw_resp.ip_addr.addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) if (rt_val) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) "BG_%d : Failed to clear Gateway Addr Set\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) return rt_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) rt_val = beiscsi_if_mod_gw(phba, IP_ACTION_ADD, ip_type, gw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) if (rt_val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) "BG_%d : Failed to Set Gateway Addr\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) return rt_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) int beiscsi_if_get_gw(struct beiscsi_hba *phba, u32 ip_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) struct be_cmd_get_def_gateway_resp *resp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) struct be_cmd_get_def_gateway_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) struct be_dma_mem nonemb_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_ISCSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) sizeof(*resp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) req = nonemb_cmd.va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) req->ip_type = ip_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) return beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) resp, sizeof(*resp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) beiscsi_if_clr_ip(struct beiscsi_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) struct be_cmd_get_if_info_resp *if_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) struct be_cmd_set_ip_addr_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) struct be_dma_mem nonemb_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_ISCSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) sizeof(*req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) req = nonemb_cmd.va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) req->ip_params.record_entry_count = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) req->ip_params.ip_record.action = IP_ACTION_DEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) req->ip_params.ip_record.interface_hndl =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) phba->interface_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) req->ip_params.ip_record.ip_addr.size_of_structure =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) sizeof(struct be_ip_addr_subnet_format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) req->ip_params.ip_record.ip_addr.ip_type = if_info->ip_addr.ip_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) memcpy(req->ip_params.ip_record.ip_addr.addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) if_info->ip_addr.addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) sizeof(if_info->ip_addr.addr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) memcpy(req->ip_params.ip_record.ip_addr.subnet_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) if_info->ip_addr.subnet_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) sizeof(if_info->ip_addr.subnet_mask));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) rc = beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) if (rc < 0 || req->ip_params.ip_record.status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) "BG_%d : failed to clear IP: rc %d status %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) rc, req->ip_params.ip_record.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) beiscsi_if_set_ip(struct beiscsi_hba *phba, u8 *ip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) u8 *subnet, u32 ip_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) struct be_cmd_set_ip_addr_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) struct be_dma_mem nonemb_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) uint32_t ip_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_ISCSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) sizeof(*req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) req = nonemb_cmd.va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) req->ip_params.record_entry_count = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) req->ip_params.ip_record.action = IP_ACTION_ADD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) req->ip_params.ip_record.interface_hndl =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) phba->interface_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) req->ip_params.ip_record.ip_addr.size_of_structure =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) sizeof(struct be_ip_addr_subnet_format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) req->ip_params.ip_record.ip_addr.ip_type = ip_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) ip_len = (ip_type < BEISCSI_IP_TYPE_V6) ? IP_V4_LEN : IP_V6_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) memcpy(req->ip_params.ip_record.ip_addr.addr, ip, ip_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) if (subnet)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) memcpy(req->ip_params.ip_record.ip_addr.subnet_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) subnet, ip_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) rc = beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) * In some cases, host needs to look into individual record status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) * even though FW reported success for that IOCTL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) if (rc < 0 || req->ip_params.ip_record.status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) __beiscsi_log(phba, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) "BG_%d : failed to set IP: rc %d status %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) rc, req->ip_params.ip_record.status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) if (req->ip_params.ip_record.status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) int beiscsi_if_en_static(struct beiscsi_hba *phba, u32 ip_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) u8 *ip, u8 *subnet)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) struct be_cmd_get_if_info_resp *if_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) struct be_cmd_rel_dhcp_req *reldhcp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) struct be_dma_mem nonemb_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) rc = beiscsi_if_get_info(phba, ip_type, &if_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) if (if_info->dhcp_state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) CMD_SUBSYSTEM_ISCSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) sizeof(*reldhcp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) reldhcp = nonemb_cmd.va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) reldhcp->interface_hndl = phba->interface_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) reldhcp->ip_type = ip_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) rc = beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) if (rc < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) "BG_%d : failed to release existing DHCP: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) /* first delete any IP set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) if (!beiscsi_if_zero_ip(if_info->ip_addr.addr, ip_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) rc = beiscsi_if_clr_ip(phba, if_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) /* if ip == NULL then this is called just to release DHCP IP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) if (ip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) rc = beiscsi_if_set_ip(phba, ip, subnet, ip_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) kfree(if_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) int beiscsi_if_en_dhcp(struct beiscsi_hba *phba, u32 ip_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) struct be_cmd_get_def_gateway_resp gw_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) struct be_cmd_get_if_info_resp *if_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) struct be_cmd_set_dhcp_req *dhcpreq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) struct be_dma_mem nonemb_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) u8 *gw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) rc = beiscsi_if_get_info(phba, ip_type, &if_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) if (if_info->dhcp_state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) "BG_%d : DHCP Already Enabled\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) /* first delete any IP set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) if (!beiscsi_if_zero_ip(if_info->ip_addr.addr, ip_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) rc = beiscsi_if_clr_ip(phba, if_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) /* delete gateway settings if mode change is to DHCP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) memset(&gw_resp, 0, sizeof(gw_resp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) /* use ip_type provided in if_info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) rc = beiscsi_if_get_gw(phba, if_info->ip_addr.ip_type, &gw_resp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) "BG_%d : Failed to Get Gateway Addr\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) gw = (u8 *)&gw_resp.ip_addr.addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) if (!beiscsi_if_zero_ip(gw, if_info->ip_addr.ip_type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) rc = beiscsi_if_mod_gw(phba, IP_ACTION_DEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) if_info->ip_addr.ip_type, gw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) "BG_%d : Failed to clear Gateway Addr Set\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_ISCSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) sizeof(*dhcpreq));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) dhcpreq = nonemb_cmd.va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) dhcpreq->flags = 1; /* 1 - blocking; 0 - non-blocking */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) dhcpreq->retry_count = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) dhcpreq->interface_hndl = phba->interface_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) dhcpreq->ip_type = ip_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) rc = beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) kfree(if_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) * beiscsi_if_set_vlan()- Issue and wait for CMD completion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) * @phba: device private structure instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) * @vlan_tag: VLAN tag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) * Issue the MBX Cmd and wait for the completion of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) * command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) * returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) * Success: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) * Failure: Non-Xero Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) int beiscsi_if_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) unsigned int tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) tag = be_cmd_set_vlan(phba, vlan_tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) if (!tag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) beiscsi_log(phba, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) (BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) "BG_%d : VLAN Setting Failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) rc = beiscsi_mccq_compl_wait(phba, tag, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) beiscsi_log(phba, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) (BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) "BS_%d : VLAN MBX Cmd Failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) int beiscsi_if_get_info(struct beiscsi_hba *phba, int ip_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) struct be_cmd_get_if_info_resp **if_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) struct be_cmd_get_if_info_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) struct be_dma_mem nonemb_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) uint32_t ioctl_size = sizeof(struct be_cmd_get_if_info_resp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) rc = beiscsi_if_get_handle(phba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) CMD_SUBSYSTEM_ISCSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) ioctl_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) req = nonemb_cmd.va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) req->interface_hndl = phba->interface_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) req->ip_type = ip_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) /* Allocate memory for if_info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) *if_info = kzalloc(ioctl_size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) if (!*if_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) beiscsi_log(phba, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) "BG_%d : Memory Allocation Failure\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) /* Free the DMA memory for the IOCTL issuing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) dma_free_coherent(&phba->ctrl.pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) nonemb_cmd.size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) nonemb_cmd.va,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) nonemb_cmd.dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) rc = beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL, *if_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) ioctl_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) /* Check if the error is because of Insufficent_Buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) if (rc == -EAGAIN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) /* Get the new memory size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) ioctl_size = ((struct be_cmd_resp_hdr *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) nonemb_cmd.va)->actual_resp_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) ioctl_size += sizeof(struct be_cmd_req_hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) /* Free the previous allocated DMA memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) nonemb_cmd.va,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) nonemb_cmd.dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) /* Free the virtual memory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) kfree(*if_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) } while (true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) int mgmt_get_nic_conf(struct beiscsi_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) struct be_cmd_get_nic_conf_resp *nic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) struct be_dma_mem nonemb_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) rc = beiscsi_prep_nemb_cmd(phba, &nonemb_cmd, CMD_SUBSYSTEM_ISCSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) sizeof(*nic));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) return beiscsi_exec_nemb_cmd(phba, &nonemb_cmd, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) nic, sizeof(*nic));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) static void beiscsi_boot_process_compl(struct beiscsi_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) unsigned int tag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) struct be_cmd_get_boot_target_resp *boot_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) struct be_cmd_resp_logout_fw_sess *logo_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) struct be_cmd_get_session_resp *sess_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) struct be_mcc_wrb *wrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) struct boot_struct *bs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) int boot_work, status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) if (!test_bit(BEISCSI_HBA_BOOT_WORK, &phba->state)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) __beiscsi_log(phba, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) "BG_%d : %s no boot work %lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) __func__, phba->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) if (phba->boot_struct.tag != tag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) __beiscsi_log(phba, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) "BG_%d : %s tag mismatch %d:%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) __func__, tag, phba->boot_struct.tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) bs = &phba->boot_struct;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) boot_work = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) switch (bs->action) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) case BEISCSI_BOOT_REOPEN_SESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) status = __beiscsi_mcc_compl_status(phba, tag, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) if (!status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) bs->action = BEISCSI_BOOT_GET_SHANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) bs->retry--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) case BEISCSI_BOOT_GET_SHANDLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) status = __beiscsi_mcc_compl_status(phba, tag, &wrb, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) if (!status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) boot_resp = embedded_payload(wrb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) bs->s_handle = boot_resp->boot_session_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) if (bs->s_handle == BE_BOOT_INVALID_SHANDLE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) bs->action = BEISCSI_BOOT_REOPEN_SESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) bs->retry--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) bs->action = BEISCSI_BOOT_GET_SINFO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) case BEISCSI_BOOT_GET_SINFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) status = __beiscsi_mcc_compl_status(phba, tag, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) &bs->nonemb_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) if (!status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) sess_resp = bs->nonemb_cmd.va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) memcpy(&bs->boot_sess, &sess_resp->session_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) sizeof(struct mgmt_session_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) bs->action = BEISCSI_BOOT_LOGOUT_SESS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) __beiscsi_log(phba, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) "BG_%d : get boot session info error : 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) boot_work = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) dma_free_coherent(&phba->ctrl.pdev->dev, bs->nonemb_cmd.size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) bs->nonemb_cmd.va, bs->nonemb_cmd.dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) bs->nonemb_cmd.va = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) case BEISCSI_BOOT_LOGOUT_SESS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) status = __beiscsi_mcc_compl_status(phba, tag, &wrb, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) if (!status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) logo_resp = embedded_payload(wrb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) if (logo_resp->session_status != BE_SESS_STATUS_CLOSE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) __beiscsi_log(phba, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) "BG_%d : FW boot session logout error : 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) logo_resp->session_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) /* continue to create boot_kset even if logout failed? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) bs->action = BEISCSI_BOOT_CREATE_KSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) /* clear the tag so no other completion matches this tag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) bs->tag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) if (!bs->retry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) boot_work = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) __beiscsi_log(phba, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) "BG_%d : failed to setup boot target: status %d action %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) status, bs->action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) if (!boot_work) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) /* wait for next event to start boot_work */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) clear_bit(BEISCSI_HBA_BOOT_WORK, &phba->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) schedule_work(&phba->boot_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) * beiscsi_boot_logout_sess()- Logout from boot FW session
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) * @phba: Device priv structure instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) * return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) * the TAG used for MBOX Command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) unsigned int beiscsi_boot_logout_sess(struct beiscsi_hba *phba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) struct be_ctrl_info *ctrl = &phba->ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) struct be_mcc_wrb *wrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) struct be_cmd_req_logout_fw_sess *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) unsigned int tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) mutex_lock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) wrb = alloc_mcc_wrb(phba, &tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) if (!wrb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) req = embedded_payload(wrb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) OPCODE_ISCSI_INI_SESSION_LOGOUT_TARGET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) sizeof(struct be_cmd_req_logout_fw_sess));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) /* Use the session handle copied into boot_sess */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) req->session_handle = phba->boot_struct.boot_sess.session_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) phba->boot_struct.tag = tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) set_bit(MCC_TAG_STATE_ASYNC, &ctrl->ptag_state[tag].tag_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) ctrl->ptag_state[tag].cbfn = beiscsi_boot_process_compl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) be_mcc_notify(phba, tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) return tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) * beiscsi_boot_reopen_sess()- Reopen boot session
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) * @phba: Device priv structure instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) * return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) * the TAG used for MBOX Command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) unsigned int beiscsi_boot_reopen_sess(struct beiscsi_hba *phba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) struct be_ctrl_info *ctrl = &phba->ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) struct be_mcc_wrb *wrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) struct be_cmd_reopen_session_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) unsigned int tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) mutex_lock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) wrb = alloc_mcc_wrb(phba, &tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) if (!wrb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) req = embedded_payload(wrb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) sizeof(struct be_cmd_reopen_session_resp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) req->reopen_type = BE_REOPEN_BOOT_SESSIONS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) req->session_handle = BE_BOOT_INVALID_SHANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) phba->boot_struct.tag = tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) set_bit(MCC_TAG_STATE_ASYNC, &ctrl->ptag_state[tag].tag_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) ctrl->ptag_state[tag].cbfn = beiscsi_boot_process_compl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) be_mcc_notify(phba, tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) return tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) * beiscsi_boot_get_sinfo()- Get boot session info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) * @phba: device priv structure instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) * Fetches the boot_struct.s_handle info from FW.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) * return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) * the TAG used for MBOX Command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) unsigned int beiscsi_boot_get_sinfo(struct beiscsi_hba *phba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) struct be_ctrl_info *ctrl = &phba->ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) struct be_cmd_get_session_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) struct be_dma_mem *nonemb_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) struct be_mcc_wrb *wrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) struct be_sge *sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) unsigned int tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) mutex_lock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) wrb = alloc_mcc_wrb(phba, &tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) if (!wrb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) nonemb_cmd = &phba->boot_struct.nonemb_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) nonemb_cmd->size = sizeof(struct be_cmd_get_session_resp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) nonemb_cmd->va = dma_alloc_coherent(&phba->ctrl.pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) nonemb_cmd->size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) &nonemb_cmd->dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) if (!nonemb_cmd->va) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) req = nonemb_cmd->va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) memset(req, 0, sizeof(*req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) sge = nonembedded_sgl(wrb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) OPCODE_ISCSI_INI_SESSION_GET_A_SESSION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) sizeof(struct be_cmd_get_session_resp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) req->session_handle = phba->boot_struct.s_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) sge->len = cpu_to_le32(nonemb_cmd->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) phba->boot_struct.tag = tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) set_bit(MCC_TAG_STATE_ASYNC, &ctrl->ptag_state[tag].tag_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) ctrl->ptag_state[tag].cbfn = beiscsi_boot_process_compl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) be_mcc_notify(phba, tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) return tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) unsigned int __beiscsi_boot_get_shandle(struct beiscsi_hba *phba, int async)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) struct be_ctrl_info *ctrl = &phba->ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) struct be_mcc_wrb *wrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) struct be_cmd_get_boot_target_req *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) unsigned int tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) mutex_lock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) wrb = alloc_mcc_wrb(phba, &tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) if (!wrb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) req = embedded_payload(wrb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) sizeof(struct be_cmd_get_boot_target_resp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) if (async) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) phba->boot_struct.tag = tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) set_bit(MCC_TAG_STATE_ASYNC, &ctrl->ptag_state[tag].tag_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) ctrl->ptag_state[tag].cbfn = beiscsi_boot_process_compl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) be_mcc_notify(phba, tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) return tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) * beiscsi_boot_get_shandle()- Get boot session handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) * @phba: device priv structure instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) * @s_handle: session handle returned for boot session.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) * return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) * Success: 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) * Failure: negative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) int beiscsi_boot_get_shandle(struct beiscsi_hba *phba, unsigned int *s_handle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) struct be_cmd_get_boot_target_resp *boot_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) struct be_mcc_wrb *wrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) unsigned int tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) *s_handle = BE_BOOT_INVALID_SHANDLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) /* get configured boot session count and handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) tag = __beiscsi_boot_get_shandle(phba, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) if (!tag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) beiscsi_log(phba, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) BEISCSI_LOG_CONFIG | BEISCSI_LOG_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) "BG_%d : Getting Boot Target Info Failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) rc = beiscsi_mccq_compl_wait(phba, tag, &wrb, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) beiscsi_log(phba, KERN_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) "BG_%d : MBX CMD get_boot_target Failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) boot_resp = embedded_payload(wrb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) /* check if there are any boot targets configured */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) if (!boot_resp->boot_session_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) __beiscsi_log(phba, KERN_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) "BG_%d : No boot targets configured\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) /* only if FW has logged in to the boot target, s_handle is valid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) *s_handle = boot_resp->boot_session_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) * beiscsi_drvr_ver_disp()- Display the driver Name and Version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) * @dev: ptr to device not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) * @attr: device attribute, not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) * @buf: contains formatted text driver name and version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) * return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) * size of the formatted string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) beiscsi_drvr_ver_disp(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) return snprintf(buf, PAGE_SIZE, BE_NAME "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) * beiscsi_fw_ver_disp()- Display Firmware Version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) * @dev: ptr to device not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) * @attr: device attribute, not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) * @buf: contains formatted text Firmware version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) * return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) * size of the formatted string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) beiscsi_fw_ver_disp(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) struct Scsi_Host *shost = class_to_shost(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) struct beiscsi_hba *phba = iscsi_host_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) return snprintf(buf, PAGE_SIZE, "%s\n", phba->fw_ver_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) * beiscsi_active_session_disp()- Display Sessions Active
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) * @dev: ptr to device not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) * @attr: device attribute, not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) * @buf: contains formatted text Session Count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) * return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) * size of the formatted string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) beiscsi_active_session_disp(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) struct Scsi_Host *shost = class_to_shost(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) struct beiscsi_hba *phba = iscsi_host_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) uint16_t avlbl_cids = 0, ulp_num, len = 0, total_cids = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) avlbl_cids = BEISCSI_ULP_AVLBL_CID(phba, ulp_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) total_cids = BEISCSI_GET_CID_COUNT(phba, ulp_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) len += scnprintf(buf+len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) "ULP%d : %d\n", ulp_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) (total_cids - avlbl_cids));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) len += scnprintf(buf+len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) "ULP%d : %d\n", ulp_num, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) * beiscsi_free_session_disp()- Display Avaliable Session
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) * @dev: ptr to device not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) * @attr: device attribute, not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) * @buf: contains formatted text Session Count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) * return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) * size of the formatted string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) beiscsi_free_session_disp(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) struct Scsi_Host *shost = class_to_shost(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) struct beiscsi_hba *phba = iscsi_host_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) uint16_t ulp_num, len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) for (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) len += scnprintf(buf+len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) "ULP%d : %d\n", ulp_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) BEISCSI_ULP_AVLBL_CID(phba, ulp_num));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) len += scnprintf(buf+len, PAGE_SIZE - len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) "ULP%d : %d\n", ulp_num, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) * beiscsi_adap_family_disp()- Display adapter family.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) * @dev: ptr to device to get priv structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) * @attr: device attribute, not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) * @buf: contains formatted text driver name and version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) * return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) * size of the formatted string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) beiscsi_adap_family_disp(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) uint16_t dev_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) struct Scsi_Host *shost = class_to_shost(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) struct beiscsi_hba *phba = iscsi_host_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) dev_id = phba->pcidev->device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) switch (dev_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) case BE_DEVICE_ID1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) case OC_DEVICE_ID1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) case OC_DEVICE_ID2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) return snprintf(buf, PAGE_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) "Obsolete/Unsupported BE2 Adapter Family\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) case BE_DEVICE_ID2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) case OC_DEVICE_ID3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) return snprintf(buf, PAGE_SIZE, "BE3-R Adapter Family\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) case OC_SKH_ID1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) return snprintf(buf, PAGE_SIZE, "Skyhawk-R Adapter Family\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) return snprintf(buf, PAGE_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) "Unknown Adapter Family: 0x%x\n", dev_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) * beiscsi_phys_port()- Display Physical Port Identifier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) * @dev: ptr to device not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) * @attr: device attribute, not used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) * @buf: contains formatted text port identifier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) * return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) * size of the formatted string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) ssize_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) beiscsi_phys_port_disp(struct device *dev, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) struct Scsi_Host *shost = class_to_shost(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) struct beiscsi_hba *phba = iscsi_host_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) return snprintf(buf, PAGE_SIZE, "Port Identifier : %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) phba->fw_config.phys_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) struct wrb_handle *pwrb_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) struct be_mem_descriptor *mem_descr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) struct hwi_wrb_context *pwrb_context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) struct iscsi_wrb *pwrb = pwrb_handle->pwrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) max_send_data_segment_length, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) max_send_data_segment_length) / 32]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, type, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) BE_TGT_CTX_UPDT_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) first_burst_length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) first_burst_length) / 32]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, erl, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) (params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) erl) / 32] & OFFLD_PARAMS_ERL));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, dde, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) (params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) dde) / 32] & OFFLD_PARAMS_DDE) >> 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, hde, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) (params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) hde) / 32] & OFFLD_PARAMS_HDE) >> 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, ir2t, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) (params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) ir2t) / 32] & OFFLD_PARAMS_IR2T) >> 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, imd, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) (params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) imd) / 32] & OFFLD_PARAMS_IMD) >> 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, stat_sn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) (params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) exp_statsn) / 32] + 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, wrb_idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) pwrb, pwrb_handle->wrb_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) max_burst_length, pwrb, params->dw[offsetof
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) (struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) max_burst_length) / 32]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, ptr2nextwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) pwrb, pwrb_handle->wrb_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) if (pwrb_context->plast_wrb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) ptr2nextwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) pwrb_context->plast_wrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) pwrb_handle->wrb_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) pwrb_context->plast_wrb = pwrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) session_state, pwrb, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, compltonack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) pwrb, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, notpredblq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) pwrb, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb, mode, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) mem_descr += ISCSI_MEM_GLOBAL_HEADER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) pad_buffer_addr_hi, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) mem_descr->mem_array[0].bus_address.u.a32.address_hi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) pad_buffer_addr_lo, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) mem_descr->mem_array[0].bus_address.u.a32.address_lo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) void beiscsi_offload_cxn_v2(struct beiscsi_offload_params *params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) struct wrb_handle *pwrb_handle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) struct hwi_wrb_context *pwrb_context)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) struct iscsi_wrb *pwrb = pwrb_handle->pwrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) max_burst_length, pwrb, params->dw[offsetof
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) (struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) max_burst_length) / 32]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) type, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) BE_TGT_CTX_UPDT_CMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) ptr2nextwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) pwrb, pwrb_handle->wrb_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) if (pwrb_context->plast_wrb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) ptr2nextwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) pwrb_context->plast_wrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) pwrb_handle->wrb_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) pwrb_context->plast_wrb = pwrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, wrb_idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) pwrb, pwrb_handle->wrb_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) max_send_data_segment_length, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) max_send_data_segment_length) / 32]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) first_burst_length, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) first_burst_length) / 32]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) max_recv_dataseg_len, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) max_recv_data_segment_length) / 32]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) max_cxns, pwrb, BEISCSI_MAX_CXNS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, erl, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) (params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) erl) / 32] & OFFLD_PARAMS_ERL));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, dde, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) (params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) dde) / 32] & OFFLD_PARAMS_DDE) >> 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, hde, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) (params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) hde) / 32] & OFFLD_PARAMS_HDE) >> 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) ir2t, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) (params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) ir2t) / 32] & OFFLD_PARAMS_IR2T) >> 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, imd, pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) (params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) imd) / 32] & OFFLD_PARAMS_IMD) >> 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) data_seq_inorder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) (params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) data_seq_inorder) / 32] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) OFFLD_PARAMS_DATA_SEQ_INORDER) >> 6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) pdu_seq_inorder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) (params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) pdu_seq_inorder) / 32] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) OFFLD_PARAMS_PDU_SEQ_INORDER) >> 7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, max_r2t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) (params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) max_r2t) / 32] &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) OFFLD_PARAMS_MAX_R2T) >> 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) AMAP_SET_BITS(struct amap_iscsi_target_context_update_wrb_v2, stat_sn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) pwrb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) (params->dw[offsetof(struct amap_beiscsi_offload_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) exp_statsn) / 32] + 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) unsigned int beiscsi_invalidate_cxn(struct beiscsi_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) struct beiscsi_endpoint *beiscsi_ep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) struct be_invalidate_connection_params_in *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) struct be_ctrl_info *ctrl = &phba->ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) struct be_mcc_wrb *wrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) unsigned int tag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) mutex_lock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) wrb = alloc_mcc_wrb(phba, &tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) if (!wrb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) req = embedded_payload(wrb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) be_wrb_hdr_prepare(wrb, sizeof(union be_invalidate_connection_params),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) true, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) sizeof(*req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) req->session_handle = beiscsi_ep->fw_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) req->cid = beiscsi_ep->ep_cid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) if (beiscsi_ep->conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) req->cleanup_type = BE_CLEANUP_TYPE_INVALIDATE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) req->cleanup_type = BE_CLEANUP_TYPE_ISSUE_TCP_RST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) * 0 - non-persistent targets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) * 1 - save session info on flash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) req->save_cfg = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) be_mcc_notify(phba, tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) return tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) unsigned int beiscsi_upload_cxn(struct beiscsi_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) struct beiscsi_endpoint *beiscsi_ep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) struct be_ctrl_info *ctrl = &phba->ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) struct be_mcc_wrb *wrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) struct be_tcp_upload_params_in *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) unsigned int tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) mutex_lock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) wrb = alloc_mcc_wrb(phba, &tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) if (!wrb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) req = embedded_payload(wrb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) be_wrb_hdr_prepare(wrb, sizeof(union be_tcp_upload_params), true, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) be_cmd_hdr_prepare(&req->hdr, CMD_COMMON_TCP_UPLOAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) OPCODE_COMMON_TCP_UPLOAD, sizeof(*req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) req->id = beiscsi_ep->ep_cid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) if (beiscsi_ep->conn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) req->upload_type = BE_UPLOAD_TYPE_GRACEFUL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) req->upload_type = BE_UPLOAD_TYPE_ABORT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) be_mcc_notify(phba, tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) return tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) int beiscsi_mgmt_invalidate_icds(struct beiscsi_hba *phba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) struct invldt_cmd_tbl *inv_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) unsigned int nents)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) struct be_ctrl_info *ctrl = &phba->ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) struct invldt_cmds_params_in *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) struct be_dma_mem nonemb_cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) struct be_mcc_wrb *wrb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) unsigned int i, tag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) struct be_sge *sge;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) if (!nents || nents > BE_INVLDT_CMD_TBL_SZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) nonemb_cmd.size = sizeof(union be_invldt_cmds_params);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) nonemb_cmd.va = dma_alloc_coherent(&phba->ctrl.pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) nonemb_cmd.size, &nonemb_cmd.dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) if (!nonemb_cmd.va) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) "BM_%d : invldt_cmds_params alloc failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) mutex_lock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) wrb = alloc_mcc_wrb(phba, &tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) if (!wrb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) nonemb_cmd.va, nonemb_cmd.dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) req = nonemb_cmd.va;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) be_wrb_hdr_prepare(wrb, nonemb_cmd.size, false, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) sizeof(*req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) req->ref_handle = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) req->cleanup_type = CMD_ISCSI_COMMAND_INVALIDATE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) for (i = 0; i < nents; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) req->table[i].icd = inv_tbl[i].icd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) req->table[i].cid = inv_tbl[i].cid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) req->icd_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) sge = nonembedded_sgl(wrb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd.dma));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) sge->pa_lo = cpu_to_le32(lower_32_bits(nonemb_cmd.dma));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) sge->len = cpu_to_le32(nonemb_cmd.size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) be_mcc_notify(phba, tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) mutex_unlock(&ctrl->mbox_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) rc = beiscsi_mccq_compl_wait(phba, tag, NULL, &nonemb_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) if (rc != -EBUSY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) nonemb_cmd.va, nonemb_cmd.dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) }