Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1 | /** |
Jitendra Bhivare | 60f36e0 | 2016-08-19 15:20:24 +0530 | [diff] [blame] | 2 | * Copyright (C) 2005 - 2016 Broadcom |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 3 | * All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License version 2 |
| 7 | * as published by the Free Software Foundation. The full GNU General |
| 8 | * Public License is included in this distribution in the file called COPYING. |
| 9 | * |
Jitendra Bhivare | 60f36e0 | 2016-08-19 15:20:24 +0530 | [diff] [blame] | 10 | * Written by: Jayamohan Kallickal (jayamohan.kallickal@broadcom.com) |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 11 | * |
| 12 | * Contact Information: |
Jitendra Bhivare | 60f36e0 | 2016-08-19 15:20:24 +0530 | [diff] [blame] | 13 | * linux-drivers@broadcom.com |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 14 | * |
Ketan Mukadam | c4f39bd | 2015-07-04 04:12:33 +0530 | [diff] [blame] | 15 | * Emulex |
Jayamohan Kallickal | 255fa9a | 2011-03-25 14:23:57 -0700 | [diff] [blame] | 16 | * 3333 Susan Street |
| 17 | * Costa Mesa, CA 92626 |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | #include <scsi/libiscsi.h> |
| 21 | #include <scsi/scsi_transport_iscsi.h> |
| 22 | #include <scsi/scsi_transport.h> |
| 23 | #include <scsi/scsi_cmnd.h> |
| 24 | #include <scsi/scsi_device.h> |
| 25 | #include <scsi/scsi_host.h> |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 26 | #include <scsi/scsi_netlink.h> |
| 27 | #include <net/netlink.h> |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 28 | #include <scsi/scsi.h> |
| 29 | |
| 30 | #include "be_iscsi.h" |
| 31 | |
| 32 | extern struct iscsi_transport beiscsi_iscsi_transport; |
| 33 | |
| 34 | /** |
| 35 | * beiscsi_session_create - creates a new iscsi session |
| 36 | * @cmds_max: max commands supported |
| 37 | * @qdepth: max queue depth supported |
| 38 | * @initial_cmdsn: initial iscsi CMDSN |
| 39 | */ |
| 40 | struct iscsi_cls_session *beiscsi_session_create(struct iscsi_endpoint *ep, |
| 41 | u16 cmds_max, |
| 42 | u16 qdepth, |
| 43 | u32 initial_cmdsn) |
| 44 | { |
| 45 | struct Scsi_Host *shost; |
| 46 | struct beiscsi_endpoint *beiscsi_ep; |
| 47 | struct iscsi_cls_session *cls_session; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 48 | struct beiscsi_hba *phba; |
Jayamohan Kallickal | b8b9e1b8 | 2009-09-22 08:21:22 +0530 | [diff] [blame] | 49 | struct iscsi_session *sess; |
| 50 | struct beiscsi_session *beiscsi_sess; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 51 | struct beiscsi_io_task *io_task; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 52 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 53 | |
| 54 | if (!ep) { |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 55 | pr_err("beiscsi_session_create: invalid ep\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 56 | return NULL; |
| 57 | } |
| 58 | beiscsi_ep = ep->dd_data; |
| 59 | phba = beiscsi_ep->phba; |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 60 | |
Jitendra Bhivare | d1d5ca8 | 2016-08-19 15:20:18 +0530 | [diff] [blame] | 61 | if (!beiscsi_hba_is_online(phba)) { |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 62 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 63 | "BS_%d : HBA in error 0x%lx\n", phba->state); |
| 64 | return NULL; |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 65 | } |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 66 | |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 67 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 68 | "BS_%d : In beiscsi_session_create\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 69 | if (cmds_max > beiscsi_ep->phba->params.wrbs_per_cxn) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 70 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 71 | "BS_%d : Cannot handle %d cmds." |
| 72 | "Max cmds per session supported is %d. Using %d." |
| 73 | "\n", cmds_max, |
| 74 | beiscsi_ep->phba->params.wrbs_per_cxn, |
| 75 | beiscsi_ep->phba->params.wrbs_per_cxn); |
| 76 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 77 | cmds_max = beiscsi_ep->phba->params.wrbs_per_cxn; |
| 78 | } |
| 79 | |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 80 | shost = phba->shost; |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 81 | cls_session = iscsi_session_setup(&beiscsi_iscsi_transport, |
| 82 | shost, cmds_max, |
| 83 | sizeof(*beiscsi_sess), |
| 84 | sizeof(*io_task), |
| 85 | initial_cmdsn, ISCSI_MAX_TARGET); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 86 | if (!cls_session) |
| 87 | return NULL; |
| 88 | sess = cls_session->dd_data; |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 89 | beiscsi_sess = sess->dd_data; |
| 90 | beiscsi_sess->bhs_pool = pci_pool_create("beiscsi_bhs_pool", |
| 91 | phba->pcidev, |
| 92 | sizeof(struct be_cmd_bhs), |
| 93 | 64, 0); |
| 94 | if (!beiscsi_sess->bhs_pool) |
| 95 | goto destroy_sess; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 96 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 97 | return cls_session; |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 98 | destroy_sess: |
| 99 | iscsi_session_teardown(cls_session); |
| 100 | return NULL; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | /** |
| 104 | * beiscsi_session_destroy - destroys iscsi session |
| 105 | * @cls_session: pointer to iscsi cls session |
| 106 | * |
| 107 | * Destroys iSCSI session instance and releases |
| 108 | * resources allocated for it. |
| 109 | */ |
| 110 | void beiscsi_session_destroy(struct iscsi_cls_session *cls_session) |
| 111 | { |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 112 | struct iscsi_session *sess = cls_session->dd_data; |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 113 | struct beiscsi_session *beiscsi_sess = sess->dd_data; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 114 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 115 | printk(KERN_INFO "In beiscsi_session_destroy\n"); |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 116 | pci_pool_destroy(beiscsi_sess->bhs_pool); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 117 | iscsi_session_teardown(cls_session); |
| 118 | } |
| 119 | |
| 120 | /** |
Jitendra Bhivare | 480195c | 2016-08-19 15:20:15 +0530 | [diff] [blame] | 121 | * beiscsi_session_fail(): Closing session with appropriate error |
| 122 | * @cls_session: ptr to session |
| 123 | **/ |
| 124 | void beiscsi_session_fail(struct iscsi_cls_session *cls_session) |
| 125 | { |
| 126 | iscsi_session_failure(cls_session->dd_data, ISCSI_ERR_CONN_FAILED); |
| 127 | } |
| 128 | |
| 129 | |
| 130 | /** |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 131 | * beiscsi_conn_create - create an instance of iscsi connection |
| 132 | * @cls_session: ptr to iscsi_cls_session |
| 133 | * @cid: iscsi cid |
| 134 | */ |
| 135 | struct iscsi_cls_conn * |
| 136 | beiscsi_conn_create(struct iscsi_cls_session *cls_session, u32 cid) |
| 137 | { |
| 138 | struct beiscsi_hba *phba; |
| 139 | struct Scsi_Host *shost; |
| 140 | struct iscsi_cls_conn *cls_conn; |
| 141 | struct beiscsi_conn *beiscsi_conn; |
| 142 | struct iscsi_conn *conn; |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 143 | struct iscsi_session *sess; |
| 144 | struct beiscsi_session *beiscsi_sess; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 145 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 146 | shost = iscsi_session_to_shost(cls_session); |
| 147 | phba = iscsi_host_priv(shost); |
| 148 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 149 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 150 | "BS_%d : In beiscsi_conn_create ,cid" |
| 151 | "from iscsi layer=%d\n", cid); |
| 152 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 153 | cls_conn = iscsi_conn_setup(cls_session, sizeof(*beiscsi_conn), cid); |
| 154 | if (!cls_conn) |
| 155 | return NULL; |
| 156 | |
| 157 | conn = cls_conn->dd_data; |
| 158 | beiscsi_conn = conn->dd_data; |
| 159 | beiscsi_conn->ep = NULL; |
| 160 | beiscsi_conn->phba = phba; |
| 161 | beiscsi_conn->conn = conn; |
Jayamohan Kallickal | 2afc95b | 2009-09-22 08:22:26 +0530 | [diff] [blame] | 162 | sess = cls_session->dd_data; |
| 163 | beiscsi_sess = sess->dd_data; |
| 164 | beiscsi_conn->beiscsi_sess = beiscsi_sess; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 165 | return cls_conn; |
| 166 | } |
| 167 | |
| 168 | /** |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 169 | * beiscsi_conn_bind - Binds iscsi session/connection with TCP connection |
| 170 | * @cls_session: pointer to iscsi cls session |
| 171 | * @cls_conn: pointer to iscsi cls conn |
| 172 | * @transport_fd: EP handle(64 bit) |
| 173 | * |
| 174 | * This function binds the TCP Conn with iSCSI Connection and Session. |
| 175 | */ |
| 176 | int beiscsi_conn_bind(struct iscsi_cls_session *cls_session, |
| 177 | struct iscsi_cls_conn *cls_conn, |
| 178 | u64 transport_fd, int is_leading) |
| 179 | { |
| 180 | struct iscsi_conn *conn = cls_conn->dd_data; |
| 181 | struct beiscsi_conn *beiscsi_conn = conn->dd_data; |
Mike Christie | 3093b04 | 2011-07-25 13:48:46 -0500 | [diff] [blame] | 182 | struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); |
| 183 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
Jayamohan Kallickal | 1e4be6f | 2013-09-28 15:35:50 -0700 | [diff] [blame] | 184 | struct hwi_controller *phwi_ctrlr = phba->phwi_ctrlr; |
| 185 | struct hwi_wrb_context *pwrb_context; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 186 | struct beiscsi_endpoint *beiscsi_ep; |
| 187 | struct iscsi_endpoint *ep; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 188 | uint16_t cri_index; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 189 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 190 | ep = iscsi_lookup_endpoint(transport_fd); |
| 191 | if (!ep) |
| 192 | return -EINVAL; |
| 193 | |
| 194 | beiscsi_ep = ep->dd_data; |
| 195 | |
| 196 | if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) |
| 197 | return -EINVAL; |
| 198 | |
| 199 | if (beiscsi_ep->phba != phba) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 200 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 201 | "BS_%d : beiscsi_ep->hba=%p not equal to phba=%p\n", |
| 202 | beiscsi_ep->phba, phba); |
| 203 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 204 | return -EEXIST; |
| 205 | } |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 206 | cri_index = BE_GET_CRI_FROM_CID(beiscsi_ep->ep_cid); |
| 207 | if (phba->conn_table[cri_index]) { |
| 208 | if (beiscsi_conn != phba->conn_table[cri_index] || |
| 209 | beiscsi_ep != phba->conn_table[cri_index]->ep) { |
| 210 | __beiscsi_log(phba, KERN_ERR, |
| 211 | "BS_%d : conn_table not empty at %u: cid %u conn %p:%p\n", |
| 212 | cri_index, |
| 213 | beiscsi_ep->ep_cid, |
| 214 | beiscsi_conn, |
| 215 | phba->conn_table[cri_index]); |
| 216 | return -EINVAL; |
| 217 | } |
| 218 | } |
Jayamohan Kallickal | 1e4be6f | 2013-09-28 15:35:50 -0700 | [diff] [blame] | 219 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 220 | beiscsi_conn->beiscsi_conn_cid = beiscsi_ep->ep_cid; |
| 221 | beiscsi_conn->ep = beiscsi_ep; |
| 222 | beiscsi_ep->conn = beiscsi_conn; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 223 | /** |
| 224 | * Each connection is associated with a WRBQ kept in wrb_context. |
| 225 | * Store doorbell offset for transmit path. |
| 226 | */ |
| 227 | pwrb_context = &phwi_ctrlr->wrb_context[cri_index]; |
Jayamohan Kallickal | 1e4be6f | 2013-09-28 15:35:50 -0700 | [diff] [blame] | 228 | beiscsi_conn->doorbell_offset = pwrb_context->doorbell_offset; |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 229 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 230 | "BS_%d : cid %d phba->conn_table[%u]=%p\n", |
| 231 | beiscsi_ep->ep_cid, cri_index, beiscsi_conn); |
| 232 | phba->conn_table[cri_index] = beiscsi_conn; |
| 233 | return 0; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 234 | } |
| 235 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 236 | static int beiscsi_iface_create_ipv4(struct beiscsi_hba *phba) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 237 | { |
| 238 | if (phba->ipv4_iface) |
| 239 | return 0; |
| 240 | |
| 241 | phba->ipv4_iface = iscsi_create_iface(phba->shost, |
| 242 | &beiscsi_iscsi_transport, |
| 243 | ISCSI_IFACE_TYPE_IPV4, |
| 244 | 0, 0); |
| 245 | if (!phba->ipv4_iface) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 246 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 247 | "BS_%d : Could not " |
| 248 | "create default IPv4 address.\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 249 | return -ENODEV; |
| 250 | } |
| 251 | |
| 252 | return 0; |
| 253 | } |
| 254 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 255 | static int beiscsi_iface_create_ipv6(struct beiscsi_hba *phba) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 256 | { |
| 257 | if (phba->ipv6_iface) |
| 258 | return 0; |
| 259 | |
| 260 | phba->ipv6_iface = iscsi_create_iface(phba->shost, |
| 261 | &beiscsi_iscsi_transport, |
| 262 | ISCSI_IFACE_TYPE_IPV6, |
| 263 | 0, 0); |
| 264 | if (!phba->ipv6_iface) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 265 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 266 | "BS_%d : Could not " |
| 267 | "create default IPv6 address.\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 268 | return -ENODEV; |
| 269 | } |
| 270 | |
| 271 | return 0; |
| 272 | } |
| 273 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 274 | void beiscsi_iface_create_default(struct beiscsi_hba *phba) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 275 | { |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 276 | struct be_cmd_get_if_info_resp *if_info; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 277 | |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 278 | if (!beiscsi_if_get_info(phba, BEISCSI_IP_TYPE_V4, &if_info)) { |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 279 | beiscsi_iface_create_ipv4(phba); |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 280 | kfree(if_info); |
| 281 | } |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 282 | |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 283 | if (!beiscsi_if_get_info(phba, BEISCSI_IP_TYPE_V6, &if_info)) { |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 284 | beiscsi_iface_create_ipv6(phba); |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 285 | kfree(if_info); |
| 286 | } |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 287 | } |
| 288 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 289 | void beiscsi_iface_destroy_default(struct beiscsi_hba *phba) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 290 | { |
Jitendra Bhivare | f7dd017 | 2016-08-19 15:20:01 +0530 | [diff] [blame] | 291 | if (phba->ipv6_iface) { |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 292 | iscsi_destroy_iface(phba->ipv6_iface); |
Jitendra Bhivare | f7dd017 | 2016-08-19 15:20:01 +0530 | [diff] [blame] | 293 | phba->ipv6_iface = NULL; |
| 294 | } |
| 295 | if (phba->ipv4_iface) { |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 296 | iscsi_destroy_iface(phba->ipv4_iface); |
Jitendra Bhivare | f7dd017 | 2016-08-19 15:20:01 +0530 | [diff] [blame] | 297 | phba->ipv4_iface = NULL; |
| 298 | } |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 299 | } |
| 300 | |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 301 | /** |
| 302 | * beiscsi_set_vlan_tag()- Set the VLAN TAG |
| 303 | * @shost: Scsi Host for the driver instance |
| 304 | * @iface_param: Interface paramters |
| 305 | * |
| 306 | * Set the VLAN TAG for the adapter or disable |
| 307 | * the VLAN config |
| 308 | * |
| 309 | * returns |
| 310 | * Success: 0 |
| 311 | * Failure: Non-Zero Value |
| 312 | **/ |
| 313 | static int |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 314 | beiscsi_iface_config_vlan(struct Scsi_Host *shost, |
| 315 | struct iscsi_iface_param_info *iface_param) |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 316 | { |
| 317 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
Jitendra Bhivare | c5bf888 | 2016-08-19 15:20:05 +0530 | [diff] [blame] | 318 | int ret = -EPERM; |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 319 | |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 320 | switch (iface_param->param) { |
| 321 | case ISCSI_NET_PARAM_VLAN_ENABLED: |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 322 | ret = 0; |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 323 | if (iface_param->value[0] != ISCSI_VLAN_ENABLE) |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 324 | ret = beiscsi_if_set_vlan(phba, BEISCSI_VLAN_DISABLE); |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 325 | break; |
| 326 | case ISCSI_NET_PARAM_VLAN_TAG: |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 327 | ret = beiscsi_if_set_vlan(phba, |
| 328 | *((uint16_t *)iface_param->value)); |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 329 | break; |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 330 | } |
| 331 | return ret; |
| 332 | } |
| 333 | |
| 334 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 335 | static int |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 336 | beiscsi_iface_config_ipv4(struct Scsi_Host *shost, |
| 337 | struct iscsi_iface_param_info *info, |
| 338 | void *data, uint32_t dt_len) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 339 | { |
| 340 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 341 | u8 *ip = NULL, *subnet = NULL, *gw; |
| 342 | struct nlattr *nla; |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 343 | int ret = -EPERM; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 344 | |
| 345 | /* Check the param */ |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 346 | switch (info->param) { |
Jitendra Bhivare | f7dd017 | 2016-08-19 15:20:01 +0530 | [diff] [blame] | 347 | case ISCSI_NET_PARAM_IFACE_ENABLE: |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 348 | if (info->value[0] == ISCSI_IFACE_ENABLE) |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 349 | ret = beiscsi_iface_create_ipv4(phba); |
Jitendra Bhivare | f7dd017 | 2016-08-19 15:20:01 +0530 | [diff] [blame] | 350 | else { |
| 351 | iscsi_destroy_iface(phba->ipv4_iface); |
| 352 | phba->ipv4_iface = NULL; |
| 353 | } |
| 354 | break; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 355 | case ISCSI_NET_PARAM_IPV4_GW: |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 356 | gw = info->value; |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 357 | ret = beiscsi_if_set_gw(phba, BEISCSI_IP_TYPE_V4, gw); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 358 | break; |
| 359 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 360 | if (info->value[0] == ISCSI_BOOTPROTO_DHCP) |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 361 | ret = beiscsi_if_en_dhcp(phba, BEISCSI_IP_TYPE_V4); |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 362 | else if (info->value[0] == ISCSI_BOOTPROTO_STATIC) |
| 363 | /* release DHCP IP address */ |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 364 | ret = beiscsi_if_en_static(phba, BEISCSI_IP_TYPE_V4, |
| 365 | NULL, NULL); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 366 | else |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 367 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 368 | "BS_%d : Invalid BOOTPROTO: %d\n", |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 369 | info->value[0]); |
| 370 | break; |
| 371 | case ISCSI_NET_PARAM_IPV4_ADDR: |
| 372 | ip = info->value; |
| 373 | nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_SUBNET); |
| 374 | if (nla) { |
| 375 | info = nla_data(nla); |
| 376 | subnet = info->value; |
| 377 | } |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 378 | ret = beiscsi_if_en_static(phba, BEISCSI_IP_TYPE_V4, |
| 379 | ip, subnet); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 380 | break; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 381 | case ISCSI_NET_PARAM_IPV4_SUBNET: |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 382 | /* |
| 383 | * OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR ioctl needs IP |
| 384 | * and subnet both. Find IP to be applied for this subnet. |
| 385 | */ |
| 386 | subnet = info->value; |
| 387 | nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_ADDR); |
| 388 | if (nla) { |
| 389 | info = nla_data(nla); |
| 390 | ip = info->value; |
| 391 | } |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 392 | ret = beiscsi_if_en_static(phba, BEISCSI_IP_TYPE_V4, |
| 393 | ip, subnet); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 394 | break; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 395 | } |
| 396 | |
| 397 | return ret; |
| 398 | } |
| 399 | |
| 400 | static int |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 401 | beiscsi_iface_config_ipv6(struct Scsi_Host *shost, |
| 402 | struct iscsi_iface_param_info *iface_param, |
| 403 | void *data, uint32_t dt_len) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 404 | { |
| 405 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 406 | int ret = -EPERM; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 407 | |
| 408 | switch (iface_param->param) { |
| 409 | case ISCSI_NET_PARAM_IFACE_ENABLE: |
| 410 | if (iface_param->value[0] == ISCSI_IFACE_ENABLE) |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 411 | ret = beiscsi_iface_create_ipv6(phba); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 412 | else { |
| 413 | iscsi_destroy_iface(phba->ipv6_iface); |
Jitendra Bhivare | f7dd017 | 2016-08-19 15:20:01 +0530 | [diff] [blame] | 414 | phba->ipv6_iface = NULL; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 415 | } |
| 416 | break; |
| 417 | case ISCSI_NET_PARAM_IPV6_ADDR: |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 418 | ret = beiscsi_if_en_static(phba, BEISCSI_IP_TYPE_V6, |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 419 | iface_param->value, NULL); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 420 | break; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | return ret; |
| 424 | } |
| 425 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 426 | int beiscsi_iface_set_param(struct Scsi_Host *shost, |
| 427 | void *data, uint32_t dt_len) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 428 | { |
| 429 | struct iscsi_iface_param_info *iface_param = NULL; |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 430 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 431 | struct nlattr *attrib; |
| 432 | uint32_t rm_len = dt_len; |
Jitendra Bhivare | c5bf888 | 2016-08-19 15:20:05 +0530 | [diff] [blame] | 433 | int ret; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 434 | |
Jitendra Bhivare | d1d5ca8 | 2016-08-19 15:20:18 +0530 | [diff] [blame] | 435 | if (!beiscsi_hba_is_online(phba)) { |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 436 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 437 | "BS_%d : HBA in error 0x%lx\n", phba->state); |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 438 | return -EBUSY; |
| 439 | } |
| 440 | |
Jitendra Bhivare | c5bf888 | 2016-08-19 15:20:05 +0530 | [diff] [blame] | 441 | /* update interface_handle */ |
| 442 | ret = beiscsi_if_get_handle(phba); |
| 443 | if (ret) { |
| 444 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 445 | "BS_%d : Getting Interface Handle Failed\n"); |
| 446 | return ret; |
| 447 | } |
| 448 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 449 | nla_for_each_attr(attrib, data, dt_len, rm_len) { |
| 450 | iface_param = nla_data(attrib); |
| 451 | |
| 452 | if (iface_param->param_type != ISCSI_NET_PARAM) |
| 453 | continue; |
| 454 | |
| 455 | /* |
| 456 | * BE2ISCSI only supports 1 interface |
| 457 | */ |
| 458 | if (iface_param->iface_num) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 459 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 460 | "BS_%d : Invalid iface_num %d." |
| 461 | "Only iface_num 0 is supported.\n", |
| 462 | iface_param->iface_num); |
| 463 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 464 | return -EINVAL; |
| 465 | } |
| 466 | |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 467 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 468 | "BS_%d : %s.0 set param %d", |
| 469 | (iface_param->iface_type == ISCSI_IFACE_TYPE_IPV4) ? |
| 470 | "ipv4" : "ipv6", iface_param->param); |
| 471 | |
| 472 | ret = -EPERM; |
| 473 | switch (iface_param->param) { |
| 474 | case ISCSI_NET_PARAM_VLAN_ENABLED: |
| 475 | case ISCSI_NET_PARAM_VLAN_TAG: |
| 476 | ret = beiscsi_iface_config_vlan(shost, iface_param); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 477 | break; |
| 478 | default: |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 479 | switch (iface_param->iface_type) { |
| 480 | case ISCSI_IFACE_TYPE_IPV4: |
| 481 | ret = beiscsi_iface_config_ipv4(shost, |
| 482 | iface_param, |
| 483 | data, dt_len); |
| 484 | break; |
| 485 | case ISCSI_IFACE_TYPE_IPV6: |
| 486 | ret = beiscsi_iface_config_ipv6(shost, |
| 487 | iface_param, |
| 488 | data, dt_len); |
| 489 | break; |
| 490 | } |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 491 | } |
| 492 | |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 493 | if (ret == -EPERM) { |
| 494 | __beiscsi_log(phba, KERN_ERR, |
| 495 | "BS_%d : %s.0 set param %d not permitted", |
| 496 | (iface_param->iface_type == |
| 497 | ISCSI_IFACE_TYPE_IPV4) ? "ipv4" : "ipv6", |
| 498 | iface_param->param); |
| 499 | ret = 0; |
| 500 | } |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 501 | if (ret) |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 502 | break; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | return ret; |
| 506 | } |
| 507 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 508 | static int __beiscsi_iface_get_param(struct beiscsi_hba *phba, |
| 509 | struct iscsi_iface *iface, |
| 510 | int param, char *buf) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 511 | { |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 512 | struct be_cmd_get_if_info_resp *if_info; |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 513 | int len, ip_type = BEISCSI_IP_TYPE_V4; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 514 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 515 | if (iface->iface_type == ISCSI_IFACE_TYPE_IPV6) |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 516 | ip_type = BEISCSI_IP_TYPE_V6; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 517 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 518 | len = beiscsi_if_get_info(phba, ip_type, &if_info); |
Geyslan G. Bem | 0e7c60c | 2013-11-18 16:42:57 -0300 | [diff] [blame] | 519 | if (len) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 520 | return len; |
| 521 | |
| 522 | switch (param) { |
| 523 | case ISCSI_NET_PARAM_IPV4_ADDR: |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 524 | len = sprintf(buf, "%pI4\n", if_info->ip_addr.addr); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 525 | break; |
| 526 | case ISCSI_NET_PARAM_IPV6_ADDR: |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 527 | len = sprintf(buf, "%pI6\n", if_info->ip_addr.addr); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 528 | break; |
| 529 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 530 | if (!if_info->dhcp_state) |
John Soni Jose | 8359c79 | 2012-10-20 04:43:03 +0530 | [diff] [blame] | 531 | len = sprintf(buf, "static\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 532 | else |
John Soni Jose | 8359c79 | 2012-10-20 04:43:03 +0530 | [diff] [blame] | 533 | len = sprintf(buf, "dhcp\n"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 534 | break; |
| 535 | case ISCSI_NET_PARAM_IPV4_SUBNET: |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 536 | len = sprintf(buf, "%pI4\n", if_info->ip_addr.subnet_mask); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 537 | break; |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 538 | case ISCSI_NET_PARAM_VLAN_ENABLED: |
| 539 | len = sprintf(buf, "%s\n", |
Jitendra Bhivare | ea89604 | 2016-08-19 15:19:58 +0530 | [diff] [blame] | 540 | (if_info->vlan_priority == BEISCSI_VLAN_DISABLE) ? |
| 541 | "disable" : "enable"); |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 542 | break; |
| 543 | case ISCSI_NET_PARAM_VLAN_ID: |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 544 | if (if_info->vlan_priority == BEISCSI_VLAN_DISABLE) |
Geyslan G. Bem | 0e7c60c | 2013-11-18 16:42:57 -0300 | [diff] [blame] | 545 | len = -EINVAL; |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 546 | else |
| 547 | len = sprintf(buf, "%d\n", |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 548 | (if_info->vlan_priority & |
| 549 | ISCSI_MAX_VLAN_ID)); |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 550 | break; |
| 551 | case ISCSI_NET_PARAM_VLAN_PRIORITY: |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 552 | if (if_info->vlan_priority == BEISCSI_VLAN_DISABLE) |
Geyslan G. Bem | 0e7c60c | 2013-11-18 16:42:57 -0300 | [diff] [blame] | 553 | len = -EINVAL; |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 554 | else |
| 555 | len = sprintf(buf, "%d\n", |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 556 | ((if_info->vlan_priority >> 13) & |
| 557 | ISCSI_MAX_VLAN_PRIORITY)); |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 558 | break; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 559 | default: |
| 560 | WARN_ON(1); |
| 561 | } |
| 562 | |
Jayamohan Kallickal | 1f536d4 | 2013-09-28 15:35:56 -0700 | [diff] [blame] | 563 | kfree(if_info); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 564 | return len; |
| 565 | } |
| 566 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 567 | int beiscsi_iface_get_param(struct iscsi_iface *iface, |
| 568 | enum iscsi_param_type param_type, |
| 569 | int param, char *buf) |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 570 | { |
| 571 | struct Scsi_Host *shost = iscsi_iface_to_shost(iface); |
| 572 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
| 573 | struct be_cmd_get_def_gateway_resp gateway; |
Jitendra Bhivare | c5bf888 | 2016-08-19 15:20:05 +0530 | [diff] [blame] | 574 | int len = -EPERM; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 575 | |
Jitendra Bhivare | d8383b3 | 2016-08-19 15:20:07 +0530 | [diff] [blame] | 576 | if (param_type != ISCSI_NET_PARAM) |
| 577 | return 0; |
Jitendra Bhivare | d1d5ca8 | 2016-08-19 15:20:18 +0530 | [diff] [blame] | 578 | if (!beiscsi_hba_is_online(phba)) { |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 579 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 580 | "BS_%d : HBA in error 0x%lx\n", phba->state); |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 581 | return -EBUSY; |
| 582 | } |
| 583 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 584 | switch (param) { |
| 585 | case ISCSI_NET_PARAM_IPV4_ADDR: |
| 586 | case ISCSI_NET_PARAM_IPV4_SUBNET: |
| 587 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: |
| 588 | case ISCSI_NET_PARAM_IPV6_ADDR: |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 589 | case ISCSI_NET_PARAM_VLAN_ENABLED: |
| 590 | case ISCSI_NET_PARAM_VLAN_ID: |
| 591 | case ISCSI_NET_PARAM_VLAN_PRIORITY: |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 592 | len = __beiscsi_iface_get_param(phba, iface, param, buf); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 593 | break; |
| 594 | case ISCSI_NET_PARAM_IFACE_ENABLE: |
Jitendra Bhivare | f7dd017 | 2016-08-19 15:20:01 +0530 | [diff] [blame] | 595 | if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4) |
| 596 | len = sprintf(buf, "%s\n", |
| 597 | phba->ipv4_iface ? "enable" : "disable"); |
| 598 | else if (iface->iface_type == ISCSI_IFACE_TYPE_IPV6) |
| 599 | len = sprintf(buf, "%s\n", |
| 600 | phba->ipv6_iface ? "enable" : "disable"); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 601 | break; |
| 602 | case ISCSI_NET_PARAM_IPV4_GW: |
| 603 | memset(&gateway, 0, sizeof(gateway)); |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 604 | len = beiscsi_if_get_gw(phba, BEISCSI_IP_TYPE_V4, &gateway); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 605 | if (!len) |
| 606 | len = sprintf(buf, "%pI4\n", &gateway.ip_addr.addr); |
| 607 | break; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | return len; |
| 611 | } |
| 612 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 613 | /** |
Mike Christie | c7f7fd5 | 2011-02-16 15:04:41 -0600 | [diff] [blame] | 614 | * beiscsi_ep_get_param - get the iscsi parameter |
| 615 | * @ep: pointer to iscsi ep |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 616 | * @param: parameter type identifier |
| 617 | * @buf: buffer pointer |
| 618 | * |
| 619 | * returns iscsi parameter |
| 620 | */ |
Mike Christie | c7f7fd5 | 2011-02-16 15:04:41 -0600 | [diff] [blame] | 621 | int beiscsi_ep_get_param(struct iscsi_endpoint *ep, |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 622 | enum iscsi_param param, char *buf) |
| 623 | { |
Mike Christie | c7f7fd5 | 2011-02-16 15:04:41 -0600 | [diff] [blame] | 624 | struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; |
Jitendra Bhivare | c5bf888 | 2016-08-19 15:20:05 +0530 | [diff] [blame] | 625 | int len; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 626 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 627 | beiscsi_log(beiscsi_ep->phba, KERN_INFO, |
| 628 | BEISCSI_LOG_CONFIG, |
| 629 | "BS_%d : In beiscsi_ep_get_param," |
| 630 | " param= %d\n", param); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 631 | |
| 632 | switch (param) { |
| 633 | case ISCSI_PARAM_CONN_PORT: |
| 634 | len = sprintf(buf, "%hu\n", beiscsi_ep->dst_tcpport); |
| 635 | break; |
| 636 | case ISCSI_PARAM_CONN_ADDRESS: |
Jitendra Bhivare | 290aa37 | 2016-08-19 15:20:08 +0530 | [diff] [blame] | 637 | if (beiscsi_ep->ip_type == BEISCSI_IP_TYPE_V4) |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 638 | len = sprintf(buf, "%pI4\n", &beiscsi_ep->dst_addr); |
| 639 | else |
| 640 | len = sprintf(buf, "%pI6\n", &beiscsi_ep->dst6_addr); |
| 641 | break; |
| 642 | default: |
Jitendra Bhivare | c5bf888 | 2016-08-19 15:20:05 +0530 | [diff] [blame] | 643 | len = -EPERM; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 644 | } |
| 645 | return len; |
| 646 | } |
| 647 | |
| 648 | int beiscsi_set_param(struct iscsi_cls_conn *cls_conn, |
| 649 | enum iscsi_param param, char *buf, int buflen) |
| 650 | { |
| 651 | struct iscsi_conn *conn = cls_conn->dd_data; |
| 652 | struct iscsi_session *session = conn->session; |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 653 | struct beiscsi_hba *phba = NULL; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 654 | int ret; |
| 655 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 656 | phba = ((struct beiscsi_conn *)conn->dd_data)->phba; |
| 657 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 658 | "BS_%d : In beiscsi_conn_set_param," |
| 659 | " param= %d\n", param); |
| 660 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 661 | ret = iscsi_set_param(cls_conn, param, buf, buflen); |
| 662 | if (ret) |
| 663 | return ret; |
| 664 | /* |
| 665 | * If userspace tried to set the value to higher than we can |
| 666 | * support override here. |
| 667 | */ |
| 668 | switch (param) { |
| 669 | case ISCSI_PARAM_FIRST_BURST: |
| 670 | if (session->first_burst > 8192) |
| 671 | session->first_burst = 8192; |
| 672 | break; |
| 673 | case ISCSI_PARAM_MAX_RECV_DLENGTH: |
| 674 | if (conn->max_recv_dlength > 65536) |
| 675 | conn->max_recv_dlength = 65536; |
| 676 | break; |
| 677 | case ISCSI_PARAM_MAX_BURST: |
Jayamohan Kallickal | 230dceb | 2010-01-23 05:36:10 +0530 | [diff] [blame] | 678 | if (session->max_burst > 262144) |
| 679 | session->max_burst = 262144; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 680 | break; |
Jayamohan Kallickal | 42f43c4 | 2010-07-22 04:26:45 +0530 | [diff] [blame] | 681 | case ISCSI_PARAM_MAX_XMIT_DLENGTH: |
Jayamohan Kallickal | 7331613 | 2013-09-28 15:35:41 -0700 | [diff] [blame] | 682 | if (conn->max_xmit_dlength > 65536) |
Jayamohan Kallickal | 42f43c4 | 2010-07-22 04:26:45 +0530 | [diff] [blame] | 683 | conn->max_xmit_dlength = 65536; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 684 | default: |
| 685 | return 0; |
| 686 | } |
| 687 | |
| 688 | return 0; |
| 689 | } |
| 690 | |
| 691 | /** |
John Soni Jose | 2177199 | 2012-04-03 23:41:49 -0500 | [diff] [blame] | 692 | * beiscsi_get_initname - Read Initiator Name from flash |
| 693 | * @buf: buffer bointer |
| 694 | * @phba: The device priv structure instance |
| 695 | * |
| 696 | * returns number of bytes |
| 697 | */ |
| 698 | static int beiscsi_get_initname(char *buf, struct beiscsi_hba *phba) |
| 699 | { |
| 700 | int rc; |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 701 | unsigned int tag; |
John Soni Jose | 2177199 | 2012-04-03 23:41:49 -0500 | [diff] [blame] | 702 | struct be_mcc_wrb *wrb; |
| 703 | struct be_cmd_hba_name *resp; |
John Soni Jose | 2177199 | 2012-04-03 23:41:49 -0500 | [diff] [blame] | 704 | |
| 705 | tag = be_cmd_get_initname(phba); |
| 706 | if (!tag) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 707 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 708 | "BS_%d : Getting Initiator Name Failed\n"); |
| 709 | |
John Soni Jose | 2177199 | 2012-04-03 23:41:49 -0500 | [diff] [blame] | 710 | return -EBUSY; |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 711 | } |
John Soni Jose | 2177199 | 2012-04-03 23:41:49 -0500 | [diff] [blame] | 712 | |
Jitendra Bhivare | 8884033 | 2016-02-04 15:49:12 +0530 | [diff] [blame] | 713 | rc = beiscsi_mccq_compl_wait(phba, tag, &wrb, NULL); |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 714 | if (rc) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 715 | beiscsi_log(phba, KERN_ERR, |
| 716 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 717 | "BS_%d : Initiator Name MBX Failed\n"); |
| 718 | return rc; |
John Soni Jose | 2177199 | 2012-04-03 23:41:49 -0500 | [diff] [blame] | 719 | } |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 720 | |
John Soni Jose | 2177199 | 2012-04-03 23:41:49 -0500 | [diff] [blame] | 721 | resp = embedded_payload(wrb); |
| 722 | rc = sprintf(buf, "%s\n", resp->initiator_name); |
| 723 | return rc; |
| 724 | } |
| 725 | |
| 726 | /** |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 727 | * beiscsi_get_port_state - Get the Port State |
| 728 | * @shost : pointer to scsi_host structure |
| 729 | * |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 730 | */ |
| 731 | static void beiscsi_get_port_state(struct Scsi_Host *shost) |
| 732 | { |
| 733 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
| 734 | struct iscsi_cls_host *ihost = shost->shost_data; |
| 735 | |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 736 | ihost->port_state = test_bit(BEISCSI_HBA_LINK_UP, &phba->state) ? |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 737 | ISCSI_PORT_STATE_UP : ISCSI_PORT_STATE_DOWN; |
| 738 | } |
| 739 | |
| 740 | /** |
| 741 | * beiscsi_get_port_speed - Get the Port Speed from Adapter |
| 742 | * @shost : pointer to scsi_host structure |
| 743 | * |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 744 | */ |
Jitendra Bhivare | 048084c | 2016-01-20 14:10:58 +0530 | [diff] [blame] | 745 | static void beiscsi_get_port_speed(struct Scsi_Host *shost) |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 746 | { |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 747 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
| 748 | struct iscsi_cls_host *ihost = shost->shost_data; |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 749 | |
Jitendra Bhivare | 048084c | 2016-01-20 14:10:58 +0530 | [diff] [blame] | 750 | switch (phba->port_speed) { |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 751 | case BE2ISCSI_LINK_SPEED_10MBPS: |
| 752 | ihost->port_speed = ISCSI_PORT_SPEED_10MBPS; |
| 753 | break; |
| 754 | case BE2ISCSI_LINK_SPEED_100MBPS: |
Jayamohan Kallickal | 3e39317 | 2014-01-29 02:16:40 -0500 | [diff] [blame] | 755 | ihost->port_speed = ISCSI_PORT_SPEED_100MBPS; |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 756 | break; |
| 757 | case BE2ISCSI_LINK_SPEED_1GBPS: |
| 758 | ihost->port_speed = ISCSI_PORT_SPEED_1GBPS; |
| 759 | break; |
| 760 | case BE2ISCSI_LINK_SPEED_10GBPS: |
| 761 | ihost->port_speed = ISCSI_PORT_SPEED_10GBPS; |
| 762 | break; |
Jitendra Bhivare | 048084c | 2016-01-20 14:10:58 +0530 | [diff] [blame] | 763 | case BE2ISCSI_LINK_SPEED_25GBPS: |
| 764 | ihost->port_speed = ISCSI_PORT_SPEED_25GBPS; |
| 765 | break; |
| 766 | case BE2ISCSI_LINK_SPEED_40GBPS: |
| 767 | ihost->port_speed = ISCSI_PORT_SPEED_40GBPS; |
| 768 | break; |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 769 | default: |
| 770 | ihost->port_speed = ISCSI_PORT_SPEED_UNKNOWN; |
| 771 | } |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | /** |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 775 | * beiscsi_get_host_param - get the iscsi parameter |
| 776 | * @shost: pointer to scsi_host structure |
| 777 | * @param: parameter type identifier |
| 778 | * @buf: buffer pointer |
| 779 | * |
| 780 | * returns host parameter |
| 781 | */ |
| 782 | int beiscsi_get_host_param(struct Scsi_Host *shost, |
| 783 | enum iscsi_host_param param, char *buf) |
| 784 | { |
Mike Christie | 3093b04 | 2011-07-25 13:48:46 -0500 | [diff] [blame] | 785 | struct beiscsi_hba *phba = iscsi_host_priv(shost); |
Jayamohan Kallickal | b15d05b | 2010-08-12 23:36:06 +0530 | [diff] [blame] | 786 | int status = 0; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 787 | |
Jitendra Bhivare | d1d5ca8 | 2016-08-19 15:20:18 +0530 | [diff] [blame] | 788 | if (!beiscsi_hba_is_online(phba)) { |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 789 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 790 | "BS_%d : HBA in error 0x%lx\n", phba->state); |
| 791 | return -EBUSY; |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 792 | } |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 793 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 794 | "BS_%d : In beiscsi_get_host_param, param = %d\n", param); |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 795 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 796 | switch (param) { |
| 797 | case ISCSI_HOST_PARAM_HWADDRESS: |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 798 | status = beiscsi_get_macaddr(buf, phba); |
| 799 | if (status < 0) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 800 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 801 | "BS_%d : beiscsi_get_macaddr Failed\n"); |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 802 | return status; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 803 | } |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 804 | break; |
John Soni Jose | 2177199 | 2012-04-03 23:41:49 -0500 | [diff] [blame] | 805 | case ISCSI_HOST_PARAM_INITIATOR_NAME: |
| 806 | status = beiscsi_get_initname(buf, phba); |
| 807 | if (status < 0) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 808 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 809 | "BS_%d : Retreiving Initiator Name Failed\n"); |
John Soni Jose | 2177199 | 2012-04-03 23:41:49 -0500 | [diff] [blame] | 810 | return status; |
| 811 | } |
| 812 | break; |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 813 | case ISCSI_HOST_PARAM_PORT_STATE: |
| 814 | beiscsi_get_port_state(shost); |
| 815 | status = sprintf(buf, "%s\n", iscsi_get_port_state_name(shost)); |
| 816 | break; |
| 817 | case ISCSI_HOST_PARAM_PORT_SPEED: |
Jitendra Bhivare | 048084c | 2016-01-20 14:10:58 +0530 | [diff] [blame] | 818 | beiscsi_get_port_speed(shost); |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 819 | status = sprintf(buf, "%s\n", iscsi_get_port_speed_name(shost)); |
| 820 | break; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 821 | default: |
| 822 | return iscsi_host_get_param(shost, param, buf); |
| 823 | } |
Jayamohan Kallickal | b15d05b | 2010-08-12 23:36:06 +0530 | [diff] [blame] | 824 | return status; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 825 | } |
| 826 | |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 827 | int beiscsi_get_macaddr(char *buf, struct beiscsi_hba *phba) |
| 828 | { |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 829 | struct be_cmd_get_nic_conf_resp resp; |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 830 | int rc; |
| 831 | |
Jayamohan Kallickal | 6c83185 | 2013-09-28 15:35:40 -0700 | [diff] [blame] | 832 | if (phba->mac_addr_set) |
John Soni Jose | df5d0e6 | 2012-08-20 23:00:31 +0530 | [diff] [blame] | 833 | return sysfs_format_mac(buf, phba->mac_address, ETH_ALEN); |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 834 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 835 | memset(&resp, 0, sizeof(resp)); |
| 836 | rc = mgmt_get_nic_conf(phba, &resp); |
| 837 | if (rc) |
| 838 | return rc; |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 839 | |
Jayamohan Kallickal | 6c83185 | 2013-09-28 15:35:40 -0700 | [diff] [blame] | 840 | phba->mac_addr_set = true; |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 841 | memcpy(phba->mac_address, resp.mac_address, ETH_ALEN); |
| 842 | return sysfs_format_mac(buf, phba->mac_address, ETH_ALEN); |
Jayamohan Kallickal | c7acc5b | 2010-07-22 04:29:18 +0530 | [diff] [blame] | 843 | } |
| 844 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 845 | /** |
| 846 | * beiscsi_conn_get_stats - get the iscsi stats |
| 847 | * @cls_conn: pointer to iscsi cls conn |
| 848 | * @stats: pointer to iscsi_stats structure |
| 849 | * |
| 850 | * returns iscsi stats |
| 851 | */ |
| 852 | void beiscsi_conn_get_stats(struct iscsi_cls_conn *cls_conn, |
| 853 | struct iscsi_stats *stats) |
| 854 | { |
| 855 | struct iscsi_conn *conn = cls_conn->dd_data; |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 856 | struct beiscsi_hba *phba = NULL; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 857 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 858 | phba = ((struct beiscsi_conn *)conn->dd_data)->phba; |
| 859 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 860 | "BS_%d : In beiscsi_conn_get_stats\n"); |
| 861 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 862 | stats->txdata_octets = conn->txdata_octets; |
| 863 | stats->rxdata_octets = conn->rxdata_octets; |
| 864 | stats->dataout_pdus = conn->dataout_pdus_cnt; |
| 865 | stats->scsirsp_pdus = conn->scsirsp_pdus_cnt; |
| 866 | stats->scsicmd_pdus = conn->scsicmd_pdus_cnt; |
| 867 | stats->datain_pdus = conn->datain_pdus_cnt; |
| 868 | stats->tmfrsp_pdus = conn->tmfrsp_pdus_cnt; |
| 869 | stats->tmfcmd_pdus = conn->tmfcmd_pdus_cnt; |
| 870 | stats->r2t_pdus = conn->r2t_pdus_cnt; |
| 871 | stats->digest_err = 0; |
| 872 | stats->timeout_err = 0; |
Mike Christie | 915aafd | 2014-07-01 11:24:38 -0500 | [diff] [blame] | 873 | stats->custom_length = 1; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 874 | strcpy(stats->custom[0].desc, "eh_abort_cnt"); |
| 875 | stats->custom[0].value = conn->eh_abort_cnt; |
| 876 | } |
| 877 | |
| 878 | /** |
| 879 | * beiscsi_set_params_for_offld - get the parameters for offload |
| 880 | * @beiscsi_conn: pointer to beiscsi_conn |
| 881 | * @params: pointer to offload_params structure |
| 882 | */ |
| 883 | static void beiscsi_set_params_for_offld(struct beiscsi_conn *beiscsi_conn, |
| 884 | struct beiscsi_offload_params *params) |
| 885 | { |
| 886 | struct iscsi_conn *conn = beiscsi_conn->conn; |
| 887 | struct iscsi_session *session = conn->session; |
| 888 | |
| 889 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, max_burst_length, |
| 890 | params, session->max_burst); |
| 891 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, |
| 892 | max_send_data_segment_length, params, |
| 893 | conn->max_xmit_dlength); |
| 894 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, first_burst_length, |
| 895 | params, session->first_burst); |
| 896 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, erl, params, |
| 897 | session->erl); |
| 898 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, dde, params, |
| 899 | conn->datadgst_en); |
| 900 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, hde, params, |
| 901 | conn->hdrdgst_en); |
| 902 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, ir2t, params, |
| 903 | session->initial_r2t_en); |
| 904 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, imd, params, |
| 905 | session->imm_data_en); |
John Soni Jose | acb9693 | 2012-10-20 04:44:35 +0530 | [diff] [blame] | 906 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, |
| 907 | data_seq_inorder, params, |
| 908 | session->dataseq_inorder_en); |
| 909 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, |
| 910 | pdu_seq_inorder, params, |
| 911 | session->pdu_inorder_en); |
| 912 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, max_r2t, params, |
| 913 | session->max_r2t); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 914 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, exp_statsn, params, |
| 915 | (conn->exp_statsn - 1)); |
Jayamohan Kallickal | 7331613 | 2013-09-28 15:35:41 -0700 | [diff] [blame] | 916 | AMAP_SET_BITS(struct amap_beiscsi_offload_params, |
| 917 | max_recv_data_segment_length, params, |
| 918 | conn->max_recv_dlength); |
| 919 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 920 | } |
| 921 | |
| 922 | /** |
| 923 | * beiscsi_conn_start - offload of session to chip |
| 924 | * @cls_conn: pointer to beiscsi_conn |
| 925 | */ |
| 926 | int beiscsi_conn_start(struct iscsi_cls_conn *cls_conn) |
| 927 | { |
| 928 | struct iscsi_conn *conn = cls_conn->dd_data; |
| 929 | struct beiscsi_conn *beiscsi_conn = conn->dd_data; |
| 930 | struct beiscsi_endpoint *beiscsi_ep; |
| 931 | struct beiscsi_offload_params params; |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 932 | struct beiscsi_hba *phba; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 933 | |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 934 | phba = ((struct beiscsi_conn *)conn->dd_data)->phba; |
| 935 | |
Jitendra Bhivare | d1d5ca8 | 2016-08-19 15:20:18 +0530 | [diff] [blame] | 936 | if (!beiscsi_hba_is_online(phba)) { |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 937 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 938 | "BS_%d : HBA in error 0x%lx\n", phba->state); |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 939 | return -EBUSY; |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 940 | } |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 941 | beiscsi_log(beiscsi_conn->phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 942 | "BS_%d : In beiscsi_conn_start\n"); |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 943 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 944 | memset(¶ms, 0, sizeof(struct beiscsi_offload_params)); |
| 945 | beiscsi_ep = beiscsi_conn->ep; |
| 946 | if (!beiscsi_ep) |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 947 | beiscsi_log(beiscsi_conn->phba, KERN_ERR, |
| 948 | BEISCSI_LOG_CONFIG, |
| 949 | "BS_%d : In beiscsi_conn_start , no beiscsi_ep\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 950 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 951 | beiscsi_conn->login_in_progress = 0; |
| 952 | beiscsi_set_params_for_offld(beiscsi_conn, ¶ms); |
| 953 | beiscsi_offload_connection(beiscsi_conn, ¶ms); |
| 954 | iscsi_conn_start(cls_conn); |
| 955 | return 0; |
| 956 | } |
| 957 | |
| 958 | /** |
| 959 | * beiscsi_get_cid - Allocate a cid |
| 960 | * @phba: The phba instance |
| 961 | */ |
| 962 | static int beiscsi_get_cid(struct beiscsi_hba *phba) |
| 963 | { |
Jayamohan Kallickal | 0a3db7c | 2013-09-28 15:35:49 -0700 | [diff] [blame] | 964 | uint16_t cid_avlbl_ulp0, cid_avlbl_ulp1; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 965 | unsigned short cid, cid_from_ulp; |
| 966 | struct ulp_cid_info *cid_info; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 967 | |
Jayamohan Kallickal | 0a3db7c | 2013-09-28 15:35:49 -0700 | [diff] [blame] | 968 | /* Find the ULP which has more CID available */ |
| 969 | cid_avlbl_ulp0 = (phba->cid_array_info[BEISCSI_ULP0]) ? |
| 970 | BEISCSI_ULP0_AVLBL_CID(phba) : 0; |
| 971 | cid_avlbl_ulp1 = (phba->cid_array_info[BEISCSI_ULP1]) ? |
| 972 | BEISCSI_ULP1_AVLBL_CID(phba) : 0; |
| 973 | cid_from_ulp = (cid_avlbl_ulp0 > cid_avlbl_ulp1) ? |
| 974 | BEISCSI_ULP0 : BEISCSI_ULP1; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 975 | /** |
| 976 | * If iSCSI protocol is loaded only on ULP 0, and when cid_avlbl_ulp |
| 977 | * is ZERO for both, ULP 1 is returned. |
| 978 | * Check if ULP is loaded before getting new CID. |
| 979 | */ |
| 980 | if (!test_bit(cid_from_ulp, (void *)&phba->fw_config.ulp_supported)) |
| 981 | return BE_INVALID_CID; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 982 | |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 983 | cid_info = phba->cid_array_info[cid_from_ulp]; |
| 984 | cid = cid_info->cid_array[cid_info->cid_alloc]; |
| 985 | if (!cid_info->avlbl_cids || cid == BE_INVALID_CID) { |
| 986 | __beiscsi_log(phba, KERN_ERR, |
| 987 | "BS_%d : failed to get cid: available %u:%u\n", |
| 988 | cid_info->avlbl_cids, cid_info->cid_free); |
| 989 | return BE_INVALID_CID; |
Jayamohan Kallickal | 0a3db7c | 2013-09-28 15:35:49 -0700 | [diff] [blame] | 990 | } |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 991 | /* empty the slot */ |
| 992 | cid_info->cid_array[cid_info->cid_alloc++] = BE_INVALID_CID; |
| 993 | if (cid_info->cid_alloc == BEISCSI_GET_CID_COUNT(phba, cid_from_ulp)) |
| 994 | cid_info->cid_alloc = 0; |
| 995 | cid_info->avlbl_cids--; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 996 | return cid; |
| 997 | } |
| 998 | |
| 999 | /** |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1000 | * beiscsi_put_cid - Free the cid |
| 1001 | * @phba: The phba for which the cid is being freed |
| 1002 | * @cid: The cid to free |
| 1003 | */ |
| 1004 | static void beiscsi_put_cid(struct beiscsi_hba *phba, unsigned short cid) |
| 1005 | { |
Jayamohan Kallickal | 0a3db7c | 2013-09-28 15:35:49 -0700 | [diff] [blame] | 1006 | uint16_t cri_index = BE_GET_CRI_FROM_CID(cid); |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1007 | struct hwi_wrb_context *pwrb_context; |
| 1008 | struct hwi_controller *phwi_ctrlr; |
| 1009 | struct ulp_cid_info *cid_info; |
| 1010 | uint16_t cid_post_ulp; |
Jayamohan Kallickal | 0a3db7c | 2013-09-28 15:35:49 -0700 | [diff] [blame] | 1011 | |
| 1012 | phwi_ctrlr = phba->phwi_ctrlr; |
| 1013 | pwrb_context = &phwi_ctrlr->wrb_context[cri_index]; |
| 1014 | cid_post_ulp = pwrb_context->ulp_num; |
| 1015 | |
| 1016 | cid_info = phba->cid_array_info[cid_post_ulp]; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1017 | /* fill only in empty slot */ |
| 1018 | if (cid_info->cid_array[cid_info->cid_free] != BE_INVALID_CID) { |
| 1019 | __beiscsi_log(phba, KERN_ERR, |
| 1020 | "BS_%d : failed to put cid %u: available %u:%u\n", |
| 1021 | cid, cid_info->avlbl_cids, cid_info->cid_free); |
| 1022 | return; |
| 1023 | } |
Jayamohan Kallickal | 0a3db7c | 2013-09-28 15:35:49 -0700 | [diff] [blame] | 1024 | cid_info->cid_array[cid_info->cid_free++] = cid; |
| 1025 | if (cid_info->cid_free == BEISCSI_GET_CID_COUNT(phba, cid_post_ulp)) |
| 1026 | cid_info->cid_free = 0; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1027 | cid_info->avlbl_cids++; |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1028 | } |
| 1029 | |
| 1030 | /** |
| 1031 | * beiscsi_free_ep - free endpoint |
| 1032 | * @ep: pointer to iscsi endpoint structure |
| 1033 | */ |
| 1034 | static void beiscsi_free_ep(struct beiscsi_endpoint *beiscsi_ep) |
| 1035 | { |
| 1036 | struct beiscsi_hba *phba = beiscsi_ep->phba; |
Jayamohan Kallickal | 43f388b | 2013-04-05 20:38:25 -0700 | [diff] [blame] | 1037 | struct beiscsi_conn *beiscsi_conn; |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1038 | |
| 1039 | beiscsi_put_cid(phba, beiscsi_ep->ep_cid); |
| 1040 | beiscsi_ep->phba = NULL; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1041 | /* clear this to track freeing in beiscsi_ep_disconnect */ |
| 1042 | phba->ep_array[BE_GET_CRI_FROM_CID(beiscsi_ep->ep_cid)] = NULL; |
Jayamohan Kallickal | 43f388b | 2013-04-05 20:38:25 -0700 | [diff] [blame] | 1043 | |
| 1044 | /** |
| 1045 | * Check if any connection resource allocated by driver |
| 1046 | * is to be freed.This case occurs when target redirection |
| 1047 | * or connection retry is done. |
| 1048 | **/ |
| 1049 | if (!beiscsi_ep->conn) |
| 1050 | return; |
| 1051 | |
| 1052 | beiscsi_conn = beiscsi_ep->conn; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1053 | /** |
| 1054 | * Break ep->conn link here so that completions after |
| 1055 | * this are ignored. |
| 1056 | */ |
| 1057 | beiscsi_ep->conn = NULL; |
Jayamohan Kallickal | 43f388b | 2013-04-05 20:38:25 -0700 | [diff] [blame] | 1058 | if (beiscsi_conn->login_in_progress) { |
Jayamohan Kallickal | 4a4a11b | 2013-04-05 20:38:31 -0700 | [diff] [blame] | 1059 | beiscsi_free_mgmt_task_handles(beiscsi_conn, |
| 1060 | beiscsi_conn->task); |
Jayamohan Kallickal | 43f388b | 2013-04-05 20:38:25 -0700 | [diff] [blame] | 1061 | beiscsi_conn->login_in_progress = 0; |
| 1062 | } |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1063 | } |
| 1064 | |
| 1065 | /** |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1066 | * beiscsi_open_conn - Ask FW to open a TCP connection |
| 1067 | * @ep: endpoint to be used |
| 1068 | * @src_addr: The source IP address |
| 1069 | * @dst_addr: The Destination IP address |
| 1070 | * |
| 1071 | * Asks the FW to open a TCP connection |
| 1072 | */ |
| 1073 | static int beiscsi_open_conn(struct iscsi_endpoint *ep, |
| 1074 | struct sockaddr *src_addr, |
| 1075 | struct sockaddr *dst_addr, int non_blocking) |
| 1076 | { |
| 1077 | struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; |
| 1078 | struct beiscsi_hba *phba = beiscsi_ep->phba; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1079 | struct tcp_connect_and_offload_out *ptcpcnct_out; |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 1080 | struct be_dma_mem nonemb_cmd; |
Jayamohan Kallickal | b3c202d | 2014-05-05 21:41:27 -0400 | [diff] [blame] | 1081 | unsigned int tag, req_memsize; |
Jayamohan Kallickal | d3ad2bb | 2010-07-22 04:16:38 +0530 | [diff] [blame] | 1082 | int ret = -ENOMEM; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1083 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1084 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 1085 | "BS_%d : In beiscsi_open_conn\n"); |
| 1086 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1087 | beiscsi_ep->ep_cid = beiscsi_get_cid(phba); |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1088 | if (beiscsi_ep->ep_cid == BE_INVALID_CID) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1089 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 1090 | "BS_%d : No free cid available\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1091 | return ret; |
| 1092 | } |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1093 | |
| 1094 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 1095 | "BS_%d : In beiscsi_open_conn, ep_cid=%d\n", |
| 1096 | beiscsi_ep->ep_cid); |
| 1097 | |
Jayamohan Kallickal | a7909b3 | 2013-04-05 20:38:32 -0700 | [diff] [blame] | 1098 | phba->ep_array[BE_GET_CRI_FROM_CID |
| 1099 | (beiscsi_ep->ep_cid)] = ep; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1100 | |
| 1101 | beiscsi_ep->cid_vld = 0; |
Jayamohan Kallickal | b3c202d | 2014-05-05 21:41:27 -0400 | [diff] [blame] | 1102 | |
| 1103 | if (is_chip_be2_be3r(phba)) |
| 1104 | req_memsize = sizeof(struct tcp_connect_and_offload_in); |
| 1105 | else |
| 1106 | req_memsize = sizeof(struct tcp_connect_and_offload_in_v1); |
| 1107 | |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 1108 | nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, |
Jayamohan Kallickal | b3c202d | 2014-05-05 21:41:27 -0400 | [diff] [blame] | 1109 | req_memsize, |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 1110 | &nonemb_cmd.dma); |
| 1111 | if (nonemb_cmd.va == NULL) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1112 | |
| 1113 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 1114 | "BS_%d : Failed to allocate memory for" |
| 1115 | " mgmt_open_connection\n"); |
| 1116 | |
Jayamohan Kallickal | a7909b3 | 2013-04-05 20:38:32 -0700 | [diff] [blame] | 1117 | beiscsi_free_ep(beiscsi_ep); |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 1118 | return -ENOMEM; |
| 1119 | } |
Jayamohan Kallickal | b3c202d | 2014-05-05 21:41:27 -0400 | [diff] [blame] | 1120 | nonemb_cmd.size = req_memsize; |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 1121 | memset(nonemb_cmd.va, 0, nonemb_cmd.size); |
| 1122 | tag = mgmt_open_connection(phba, dst_addr, beiscsi_ep, &nonemb_cmd); |
Jitendra Bhivare | fa1261c | 2016-12-13 15:56:01 +0530 | [diff] [blame] | 1123 | if (!tag) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1124 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 1125 | "BS_%d : mgmt_open_connection Failed for cid=%d\n", |
| 1126 | beiscsi_ep->ep_cid); |
| 1127 | |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 1128 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, |
| 1129 | nonemb_cmd.va, nonemb_cmd.dma); |
Jayamohan Kallickal | a7909b3 | 2013-04-05 20:38:32 -0700 | [diff] [blame] | 1130 | beiscsi_free_ep(beiscsi_ep); |
Jayamohan Kallickal | 1f92638 | 2010-07-22 04:22:27 +0530 | [diff] [blame] | 1131 | return -EAGAIN; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1132 | } |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1133 | |
Jitendra Bhivare | 8884033 | 2016-02-04 15:49:12 +0530 | [diff] [blame] | 1134 | ret = beiscsi_mccq_compl_wait(phba, tag, NULL, &nonemb_cmd); |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1135 | if (ret) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1136 | beiscsi_log(phba, KERN_ERR, |
| 1137 | BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1138 | "BS_%d : mgmt_open_connection Failed"); |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1139 | |
Jayamohan Kallickal | 1957aa7 | 2014-01-29 02:16:39 -0500 | [diff] [blame] | 1140 | if (ret != -EBUSY) |
| 1141 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, |
| 1142 | nonemb_cmd.va, nonemb_cmd.dma); |
| 1143 | |
Jayamohan Kallickal | a7909b3 | 2013-04-05 20:38:32 -0700 | [diff] [blame] | 1144 | beiscsi_free_ep(beiscsi_ep); |
Jayamohan Kallickal | 1957aa7 | 2014-01-29 02:16:39 -0500 | [diff] [blame] | 1145 | return ret; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1146 | } |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1147 | |
Jayamohan Kallickal | 1e234bb | 2013-04-05 20:38:23 -0700 | [diff] [blame] | 1148 | ptcpcnct_out = (struct tcp_connect_and_offload_out *)nonemb_cmd.va; |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1149 | beiscsi_ep = ep->dd_data; |
| 1150 | beiscsi_ep->fw_handle = ptcpcnct_out->connection_handle; |
| 1151 | beiscsi_ep->cid_vld = 1; |
| 1152 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 1153 | "BS_%d : mgmt_open_connection Success\n"); |
| 1154 | |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 1155 | pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, |
| 1156 | nonemb_cmd.va, nonemb_cmd.dma); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1157 | return 0; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1158 | } |
| 1159 | |
| 1160 | /** |
| 1161 | * beiscsi_ep_connect - Ask chip to create TCP Conn |
| 1162 | * @scsi_host: Pointer to scsi_host structure |
| 1163 | * @dst_addr: The IP address of Target |
| 1164 | * @non_blocking: blocking or non-blocking call |
| 1165 | * |
| 1166 | * This routines first asks chip to create a connection and then allocates an EP |
| 1167 | */ |
| 1168 | struct iscsi_endpoint * |
| 1169 | beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr, |
| 1170 | int non_blocking) |
| 1171 | { |
| 1172 | struct beiscsi_hba *phba; |
| 1173 | struct beiscsi_endpoint *beiscsi_ep; |
| 1174 | struct iscsi_endpoint *ep; |
| 1175 | int ret; |
| 1176 | |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 1177 | if (!shost) { |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1178 | ret = -ENXIO; |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 1179 | pr_err("beiscsi_ep_connect shost is NULL\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1180 | return ERR_PTR(ret); |
| 1181 | } |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 1182 | |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 1183 | phba = iscsi_host_priv(shost); |
Jitendra Bhivare | d1d5ca8 | 2016-08-19 15:20:18 +0530 | [diff] [blame] | 1184 | if (!beiscsi_hba_is_online(phba)) { |
Jayamohan Kallickal | cf6e3c6 | 2013-04-05 20:38:33 -0700 | [diff] [blame] | 1185 | ret = -EIO; |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 1186 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 1187 | "BS_%d : HBA in error 0x%lx\n", phba->state); |
Jayamohan Kallickal | cf6e3c6 | 2013-04-05 20:38:33 -0700 | [diff] [blame] | 1188 | return ERR_PTR(ret); |
| 1189 | } |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 1190 | if (!test_bit(BEISCSI_HBA_LINK_UP, &phba->state)) { |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 1191 | ret = -EBUSY; |
John Soni Jose | 8359c79 | 2012-10-20 04:43:03 +0530 | [diff] [blame] | 1192 | beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, |
| 1193 | "BS_%d : The Adapter Port state is Down!!!\n"); |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 1194 | return ERR_PTR(ret); |
| 1195 | } |
| 1196 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1197 | ep = iscsi_create_endpoint(sizeof(struct beiscsi_endpoint)); |
| 1198 | if (!ep) { |
| 1199 | ret = -ENOMEM; |
| 1200 | return ERR_PTR(ret); |
| 1201 | } |
| 1202 | |
| 1203 | beiscsi_ep = ep->dd_data; |
| 1204 | beiscsi_ep->phba = phba; |
Jayamohan Kallickal | c2462288 | 2010-01-05 05:05:34 +0530 | [diff] [blame] | 1205 | beiscsi_ep->openiscsi_ep = ep; |
Jayamohan Kallickal | f5ed7bd | 2010-07-22 04:18:01 +0530 | [diff] [blame] | 1206 | ret = beiscsi_open_conn(ep, NULL, dst_addr, non_blocking); |
| 1207 | if (ret) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1208 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
| 1209 | "BS_%d : Failed in beiscsi_open_conn\n"); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1210 | goto free_ep; |
| 1211 | } |
| 1212 | |
| 1213 | return ep; |
| 1214 | |
| 1215 | free_ep: |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1216 | iscsi_destroy_endpoint(ep); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1217 | return ERR_PTR(ret); |
| 1218 | } |
| 1219 | |
| 1220 | /** |
| 1221 | * beiscsi_ep_poll - Poll to see if connection is established |
| 1222 | * @ep: endpoint to be used |
| 1223 | * @timeout_ms: timeout specified in millisecs |
| 1224 | * |
| 1225 | * Poll to see if TCP connection established |
| 1226 | */ |
| 1227 | int beiscsi_ep_poll(struct iscsi_endpoint *ep, int timeout_ms) |
| 1228 | { |
| 1229 | struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; |
| 1230 | |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1231 | beiscsi_log(beiscsi_ep->phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 1232 | "BS_%d : In beiscsi_ep_poll\n"); |
| 1233 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1234 | if (beiscsi_ep->cid_vld == 1) |
| 1235 | return 1; |
| 1236 | else |
| 1237 | return 0; |
| 1238 | } |
| 1239 | |
| 1240 | /** |
Jayamohan Kallickal | b7ab35b | 2014-08-08 01:00:01 -0400 | [diff] [blame] | 1241 | * beiscsi_flush_cq()- Flush the CQ created. |
| 1242 | * @phba: ptr device priv structure. |
| 1243 | * |
| 1244 | * Before the connection resource are freed flush |
| 1245 | * all the CQ enteries |
| 1246 | **/ |
| 1247 | static void beiscsi_flush_cq(struct beiscsi_hba *phba) |
| 1248 | { |
| 1249 | uint16_t i; |
| 1250 | struct be_eq_obj *pbe_eq; |
| 1251 | struct hwi_controller *phwi_ctrlr; |
| 1252 | struct hwi_context_memory *phwi_context; |
| 1253 | |
| 1254 | phwi_ctrlr = phba->phwi_ctrlr; |
| 1255 | phwi_context = phwi_ctrlr->phwi_ctxt; |
| 1256 | |
| 1257 | for (i = 0; i < phba->num_cpus; i++) { |
| 1258 | pbe_eq = &phwi_context->be_eq[i]; |
Christoph Hellwig | 511cbce | 2015-11-10 14:56:14 +0100 | [diff] [blame] | 1259 | irq_poll_disable(&pbe_eq->iopoll); |
Jitendra Bhivare | 1094cf6 | 2016-01-20 14:10:56 +0530 | [diff] [blame] | 1260 | beiscsi_process_cq(pbe_eq, BE2_MAX_NUM_CQ_PROC); |
Christoph Hellwig | 511cbce | 2015-11-10 14:56:14 +0100 | [diff] [blame] | 1261 | irq_poll_enable(&pbe_eq->iopoll); |
Jayamohan Kallickal | b7ab35b | 2014-08-08 01:00:01 -0400 | [diff] [blame] | 1262 | } |
| 1263 | } |
| 1264 | |
| 1265 | /** |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1266 | * beiscsi_close_conn - Upload the connection |
| 1267 | * @ep: The iscsi endpoint |
| 1268 | * @flag: The type of connection closure |
| 1269 | */ |
Jayamohan Kallickal | c2462288 | 2010-01-05 05:05:34 +0530 | [diff] [blame] | 1270 | static int beiscsi_close_conn(struct beiscsi_endpoint *beiscsi_ep, int flag) |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1271 | { |
| 1272 | int ret = 0; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1273 | unsigned int tag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1274 | struct beiscsi_hba *phba = beiscsi_ep->phba; |
| 1275 | |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1276 | tag = mgmt_upload_connection(phba, beiscsi_ep->ep_cid, flag); |
| 1277 | if (!tag) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1278 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 1279 | "BS_%d : upload failed for cid 0x%x\n", |
| 1280 | beiscsi_ep->ep_cid); |
| 1281 | |
Jayamohan Kallickal | d3ad2bb | 2010-07-22 04:16:38 +0530 | [diff] [blame] | 1282 | ret = -EAGAIN; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1283 | } |
John Soni Jose | e175def | 2012-10-20 04:45:40 +0530 | [diff] [blame] | 1284 | |
Jitendra Bhivare | 8884033 | 2016-02-04 15:49:12 +0530 | [diff] [blame] | 1285 | ret = beiscsi_mccq_compl_wait(phba, tag, NULL, NULL); |
Jayamohan Kallickal | b7ab35b | 2014-08-08 01:00:01 -0400 | [diff] [blame] | 1286 | |
| 1287 | /* Flush the CQ entries */ |
| 1288 | beiscsi_flush_cq(phba); |
| 1289 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1290 | return ret; |
| 1291 | } |
| 1292 | |
| 1293 | /** |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1294 | * beiscsi_ep_disconnect - Tears down the TCP connection |
| 1295 | * @ep: endpoint to be used |
| 1296 | * |
| 1297 | * Tears down the TCP connection |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1298 | */ |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1299 | void beiscsi_ep_disconnect(struct iscsi_endpoint *ep) |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1300 | { |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1301 | struct beiscsi_conn *beiscsi_conn; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1302 | struct beiscsi_endpoint *beiscsi_ep; |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1303 | struct beiscsi_hba *phba; |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1304 | unsigned int tag; |
John Soni Jose | 0a513dd | 2012-08-20 23:00:55 +0530 | [diff] [blame] | 1305 | uint8_t mgmt_invalidate_flag, tcp_upload_flag; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1306 | unsigned short savecfg_flag = CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH; |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1307 | uint16_t cri_index; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1308 | |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1309 | beiscsi_ep = ep->dd_data; |
| 1310 | phba = beiscsi_ep->phba; |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1311 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1312 | "BS_%d : In beiscsi_ep_disconnect for ep_cid = %u\n", |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1313 | beiscsi_ep->ep_cid); |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1314 | |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1315 | cri_index = BE_GET_CRI_FROM_CID(beiscsi_ep->ep_cid); |
| 1316 | if (!phba->ep_array[cri_index]) { |
| 1317 | __beiscsi_log(phba, KERN_ERR, |
| 1318 | "BS_%d : ep_array at %u cid %u empty\n", |
| 1319 | cri_index, |
| 1320 | beiscsi_ep->ep_cid); |
| 1321 | return; |
| 1322 | } |
| 1323 | |
John Soni Jose | 0a513dd | 2012-08-20 23:00:55 +0530 | [diff] [blame] | 1324 | if (beiscsi_ep->conn) { |
| 1325 | beiscsi_conn = beiscsi_ep->conn; |
| 1326 | iscsi_suspend_queue(beiscsi_conn->conn); |
| 1327 | mgmt_invalidate_flag = ~BEISCSI_NO_RST_ISSUE; |
| 1328 | tcp_upload_flag = CONNECTION_UPLOAD_GRACEFUL; |
| 1329 | } else { |
| 1330 | mgmt_invalidate_flag = BEISCSI_NO_RST_ISSUE; |
| 1331 | tcp_upload_flag = CONNECTION_UPLOAD_ABORT; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1332 | } |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1333 | |
Jitendra Bhivare | d1d5ca8 | 2016-08-19 15:20:18 +0530 | [diff] [blame] | 1334 | if (!beiscsi_hba_is_online(phba)) { |
Jitendra Bhivare | 9122e99 | 2016-08-19 15:20:11 +0530 | [diff] [blame] | 1335 | beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, |
| 1336 | "BS_%d : HBA in error 0x%lx\n", phba->state); |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 1337 | goto free_ep; |
| 1338 | } |
| 1339 | |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1340 | tag = mgmt_invalidate_connection(phba, beiscsi_ep, |
John Soni Jose | 0a513dd | 2012-08-20 23:00:55 +0530 | [diff] [blame] | 1341 | beiscsi_ep->ep_cid, |
| 1342 | mgmt_invalidate_flag, |
| 1343 | savecfg_flag); |
Jayamohan Kallickal | 756d29c | 2010-01-05 05:10:46 +0530 | [diff] [blame] | 1344 | if (!tag) { |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1345 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, |
John Soni Jose | 0a513dd | 2012-08-20 23:00:55 +0530 | [diff] [blame] | 1346 | "BS_%d : mgmt_invalidate_connection Failed for cid=%d\n", |
John Soni Jose | 99bc5d5 | 2012-08-20 23:00:18 +0530 | [diff] [blame] | 1347 | beiscsi_ep->ep_cid); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1348 | } |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1349 | |
Jitendra Bhivare | 8884033 | 2016-02-04 15:49:12 +0530 | [diff] [blame] | 1350 | beiscsi_mccq_compl_wait(phba, tag, NULL, NULL); |
John Soni Jose | 0a513dd | 2012-08-20 23:00:55 +0530 | [diff] [blame] | 1351 | beiscsi_close_conn(beiscsi_ep, tcp_upload_flag); |
Jayamohan Kallickal | 3567f36 | 2013-09-28 15:35:58 -0700 | [diff] [blame] | 1352 | free_ep: |
Jayamohan Kallickal | 9343be7 | 2014-01-29 02:16:43 -0500 | [diff] [blame] | 1353 | msleep(BEISCSI_LOGOUT_SYNC_DELAY); |
Jayamohan Kallickal | c2462288 | 2010-01-05 05:05:34 +0530 | [diff] [blame] | 1354 | beiscsi_free_ep(beiscsi_ep); |
Jitendra Bhivare | 413f365 | 2016-12-13 15:56:03 +0530 | [diff] [blame] | 1355 | if (!phba->conn_table[cri_index]) |
| 1356 | __beiscsi_log(phba, KERN_ERR, |
| 1357 | "BS_%d : conn_table empty at %u: cid %u\n", |
| 1358 | cri_index, |
| 1359 | beiscsi_ep->ep_cid); |
| 1360 | phba->conn_table[cri_index] = NULL; |
Mike Christie | fa95d20 | 2010-06-09 03:30:08 -0500 | [diff] [blame] | 1361 | iscsi_destroy_endpoint(beiscsi_ep->openiscsi_ep); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1362 | } |
Mike Christie | 3128c6c | 2011-07-25 13:48:42 -0500 | [diff] [blame] | 1363 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 1364 | umode_t beiscsi_attr_is_visible(int param_type, int param) |
Mike Christie | 3128c6c | 2011-07-25 13:48:42 -0500 | [diff] [blame] | 1365 | { |
| 1366 | switch (param_type) { |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 1367 | case ISCSI_NET_PARAM: |
| 1368 | switch (param) { |
| 1369 | case ISCSI_NET_PARAM_IFACE_ENABLE: |
| 1370 | case ISCSI_NET_PARAM_IPV4_ADDR: |
| 1371 | case ISCSI_NET_PARAM_IPV4_SUBNET: |
| 1372 | case ISCSI_NET_PARAM_IPV4_BOOTPROTO: |
| 1373 | case ISCSI_NET_PARAM_IPV4_GW: |
| 1374 | case ISCSI_NET_PARAM_IPV6_ADDR: |
John Soni Jose | 6f72238e | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 1375 | case ISCSI_NET_PARAM_VLAN_ID: |
| 1376 | case ISCSI_NET_PARAM_VLAN_PRIORITY: |
| 1377 | case ISCSI_NET_PARAM_VLAN_ENABLED: |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 1378 | return S_IRUGO; |
| 1379 | default: |
| 1380 | return 0; |
| 1381 | } |
Mike Christie | f27fb2e | 2011-07-25 13:48:45 -0500 | [diff] [blame] | 1382 | case ISCSI_HOST_PARAM: |
| 1383 | switch (param) { |
| 1384 | case ISCSI_HOST_PARAM_HWADDRESS: |
John Soni Jose | c62eef0 | 2012-04-03 23:41:52 -0500 | [diff] [blame] | 1385 | case ISCSI_HOST_PARAM_INITIATOR_NAME: |
| 1386 | case ISCSI_HOST_PARAM_PORT_STATE: |
| 1387 | case ISCSI_HOST_PARAM_PORT_SPEED: |
Mike Christie | f27fb2e | 2011-07-25 13:48:45 -0500 | [diff] [blame] | 1388 | return S_IRUGO; |
| 1389 | default: |
| 1390 | return 0; |
| 1391 | } |
Mike Christie | 3128c6c | 2011-07-25 13:48:42 -0500 | [diff] [blame] | 1392 | case ISCSI_PARAM: |
| 1393 | switch (param) { |
| 1394 | case ISCSI_PARAM_MAX_RECV_DLENGTH: |
| 1395 | case ISCSI_PARAM_MAX_XMIT_DLENGTH: |
| 1396 | case ISCSI_PARAM_HDRDGST_EN: |
| 1397 | case ISCSI_PARAM_DATADGST_EN: |
| 1398 | case ISCSI_PARAM_CONN_ADDRESS: |
| 1399 | case ISCSI_PARAM_CONN_PORT: |
| 1400 | case ISCSI_PARAM_EXP_STATSN: |
| 1401 | case ISCSI_PARAM_PERSISTENT_ADDRESS: |
| 1402 | case ISCSI_PARAM_PERSISTENT_PORT: |
| 1403 | case ISCSI_PARAM_PING_TMO: |
| 1404 | case ISCSI_PARAM_RECV_TMO: |
Mike Christie | 1d063c1 | 2011-07-25 13:48:43 -0500 | [diff] [blame] | 1405 | case ISCSI_PARAM_INITIAL_R2T_EN: |
| 1406 | case ISCSI_PARAM_MAX_R2T: |
| 1407 | case ISCSI_PARAM_IMM_DATA_EN: |
| 1408 | case ISCSI_PARAM_FIRST_BURST: |
| 1409 | case ISCSI_PARAM_MAX_BURST: |
| 1410 | case ISCSI_PARAM_PDU_INORDER_EN: |
| 1411 | case ISCSI_PARAM_DATASEQ_INORDER_EN: |
| 1412 | case ISCSI_PARAM_ERL: |
| 1413 | case ISCSI_PARAM_TARGET_NAME: |
| 1414 | case ISCSI_PARAM_TPGT: |
| 1415 | case ISCSI_PARAM_USERNAME: |
| 1416 | case ISCSI_PARAM_PASSWORD: |
| 1417 | case ISCSI_PARAM_USERNAME_IN: |
| 1418 | case ISCSI_PARAM_PASSWORD_IN: |
| 1419 | case ISCSI_PARAM_FAST_ABORT: |
| 1420 | case ISCSI_PARAM_ABORT_TMO: |
| 1421 | case ISCSI_PARAM_LU_RESET_TMO: |
| 1422 | case ISCSI_PARAM_IFACE_NAME: |
| 1423 | case ISCSI_PARAM_INITIATOR_NAME: |
Mike Christie | 3128c6c | 2011-07-25 13:48:42 -0500 | [diff] [blame] | 1424 | return S_IRUGO; |
| 1425 | default: |
| 1426 | return 0; |
| 1427 | } |
| 1428 | } |
| 1429 | |
| 1430 | return 0; |
| 1431 | } |