16733b39aSJayamohan Kallickal /** 2533c165fSJayamohan Kallickal * Copyright (C) 2005 - 2013 Emulex 36733b39aSJayamohan Kallickal * All rights reserved. 46733b39aSJayamohan Kallickal * 56733b39aSJayamohan Kallickal * This program is free software; you can redistribute it and/or 66733b39aSJayamohan Kallickal * modify it under the terms of the GNU General Public License version 2 76733b39aSJayamohan Kallickal * as published by the Free Software Foundation. The full GNU General 86733b39aSJayamohan Kallickal * Public License is included in this distribution in the file called COPYING. 96733b39aSJayamohan Kallickal * 10255fa9a3SJayamohan Kallickal * Written by: Jayamohan Kallickal (jayamohan.kallickal@emulex.com) 116733b39aSJayamohan Kallickal * 126733b39aSJayamohan Kallickal * Contact Information: 13255fa9a3SJayamohan Kallickal * linux-drivers@emulex.com 146733b39aSJayamohan Kallickal * 15255fa9a3SJayamohan Kallickal * Emulex 16255fa9a3SJayamohan Kallickal * 3333 Susan Street 17255fa9a3SJayamohan Kallickal * Costa Mesa, CA 92626 186733b39aSJayamohan Kallickal */ 196733b39aSJayamohan Kallickal 206733b39aSJayamohan Kallickal #include <scsi/libiscsi.h> 216733b39aSJayamohan Kallickal #include <scsi/scsi_transport_iscsi.h> 226733b39aSJayamohan Kallickal #include <scsi/scsi_transport.h> 236733b39aSJayamohan Kallickal #include <scsi/scsi_cmnd.h> 246733b39aSJayamohan Kallickal #include <scsi/scsi_device.h> 256733b39aSJayamohan Kallickal #include <scsi/scsi_host.h> 260e43895eSMike Christie #include <scsi/scsi_netlink.h> 270e43895eSMike Christie #include <net/netlink.h> 286733b39aSJayamohan Kallickal #include <scsi/scsi.h> 296733b39aSJayamohan Kallickal 306733b39aSJayamohan Kallickal #include "be_iscsi.h" 316733b39aSJayamohan Kallickal 326733b39aSJayamohan Kallickal extern struct iscsi_transport beiscsi_iscsi_transport; 336733b39aSJayamohan Kallickal 346733b39aSJayamohan Kallickal /** 356733b39aSJayamohan Kallickal * beiscsi_session_create - creates a new iscsi session 366733b39aSJayamohan Kallickal * @cmds_max: max commands supported 376733b39aSJayamohan Kallickal * @qdepth: max queue depth supported 386733b39aSJayamohan Kallickal * @initial_cmdsn: initial iscsi CMDSN 396733b39aSJayamohan Kallickal */ 406733b39aSJayamohan Kallickal struct iscsi_cls_session *beiscsi_session_create(struct iscsi_endpoint *ep, 416733b39aSJayamohan Kallickal u16 cmds_max, 426733b39aSJayamohan Kallickal u16 qdepth, 436733b39aSJayamohan Kallickal u32 initial_cmdsn) 446733b39aSJayamohan Kallickal { 456733b39aSJayamohan Kallickal struct Scsi_Host *shost; 466733b39aSJayamohan Kallickal struct beiscsi_endpoint *beiscsi_ep; 476733b39aSJayamohan Kallickal struct iscsi_cls_session *cls_session; 486733b39aSJayamohan Kallickal struct beiscsi_hba *phba; 49b8b9e1b8SJayamohan Kallickal struct iscsi_session *sess; 50b8b9e1b8SJayamohan Kallickal struct beiscsi_session *beiscsi_sess; 516733b39aSJayamohan Kallickal struct beiscsi_io_task *io_task; 526733b39aSJayamohan Kallickal 536733b39aSJayamohan Kallickal 546733b39aSJayamohan Kallickal if (!ep) { 5599bc5d55SJohn Soni Jose printk(KERN_ERR 5699bc5d55SJohn Soni Jose "beiscsi_session_create: invalid ep\n"); 576733b39aSJayamohan Kallickal return NULL; 586733b39aSJayamohan Kallickal } 596733b39aSJayamohan Kallickal beiscsi_ep = ep->dd_data; 606733b39aSJayamohan Kallickal phba = beiscsi_ep->phba; 616733b39aSJayamohan Kallickal shost = phba->shost; 6299bc5d55SJohn Soni Jose 6399bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, 6499bc5d55SJohn Soni Jose "BS_%d : In beiscsi_session_create\n"); 6599bc5d55SJohn Soni Jose 666733b39aSJayamohan Kallickal if (cmds_max > beiscsi_ep->phba->params.wrbs_per_cxn) { 6799bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 6899bc5d55SJohn Soni Jose "BS_%d : Cannot handle %d cmds." 696733b39aSJayamohan Kallickal "Max cmds per session supported is %d. Using %d." 706733b39aSJayamohan Kallickal "\n", cmds_max, 716733b39aSJayamohan Kallickal beiscsi_ep->phba->params.wrbs_per_cxn, 726733b39aSJayamohan Kallickal beiscsi_ep->phba->params.wrbs_per_cxn); 7399bc5d55SJohn Soni Jose 746733b39aSJayamohan Kallickal cmds_max = beiscsi_ep->phba->params.wrbs_per_cxn; 756733b39aSJayamohan Kallickal } 766733b39aSJayamohan Kallickal 776733b39aSJayamohan Kallickal cls_session = iscsi_session_setup(&beiscsi_iscsi_transport, 786733b39aSJayamohan Kallickal shost, cmds_max, 79b8b9e1b8SJayamohan Kallickal sizeof(*beiscsi_sess), 80b8b9e1b8SJayamohan Kallickal sizeof(*io_task), 816733b39aSJayamohan Kallickal initial_cmdsn, ISCSI_MAX_TARGET); 826733b39aSJayamohan Kallickal if (!cls_session) 836733b39aSJayamohan Kallickal return NULL; 846733b39aSJayamohan Kallickal sess = cls_session->dd_data; 852afc95bfSJayamohan Kallickal beiscsi_sess = sess->dd_data; 862afc95bfSJayamohan Kallickal beiscsi_sess->bhs_pool = pci_pool_create("beiscsi_bhs_pool", 872afc95bfSJayamohan Kallickal phba->pcidev, 882afc95bfSJayamohan Kallickal sizeof(struct be_cmd_bhs), 892afc95bfSJayamohan Kallickal 64, 0); 902afc95bfSJayamohan Kallickal if (!beiscsi_sess->bhs_pool) 912afc95bfSJayamohan Kallickal goto destroy_sess; 926733b39aSJayamohan Kallickal 936733b39aSJayamohan Kallickal return cls_session; 942afc95bfSJayamohan Kallickal destroy_sess: 952afc95bfSJayamohan Kallickal iscsi_session_teardown(cls_session); 962afc95bfSJayamohan Kallickal return NULL; 976733b39aSJayamohan Kallickal } 986733b39aSJayamohan Kallickal 996733b39aSJayamohan Kallickal /** 1006733b39aSJayamohan Kallickal * beiscsi_session_destroy - destroys iscsi session 1016733b39aSJayamohan Kallickal * @cls_session: pointer to iscsi cls session 1026733b39aSJayamohan Kallickal * 1036733b39aSJayamohan Kallickal * Destroys iSCSI session instance and releases 1046733b39aSJayamohan Kallickal * resources allocated for it. 1056733b39aSJayamohan Kallickal */ 1066733b39aSJayamohan Kallickal void beiscsi_session_destroy(struct iscsi_cls_session *cls_session) 1076733b39aSJayamohan Kallickal { 1086733b39aSJayamohan Kallickal struct iscsi_session *sess = cls_session->dd_data; 1092afc95bfSJayamohan Kallickal struct beiscsi_session *beiscsi_sess = sess->dd_data; 1106733b39aSJayamohan Kallickal 11199bc5d55SJohn Soni Jose printk(KERN_INFO "In beiscsi_session_destroy\n"); 1122afc95bfSJayamohan Kallickal pci_pool_destroy(beiscsi_sess->bhs_pool); 1136733b39aSJayamohan Kallickal iscsi_session_teardown(cls_session); 1146733b39aSJayamohan Kallickal } 1156733b39aSJayamohan Kallickal 1166733b39aSJayamohan Kallickal /** 1176733b39aSJayamohan Kallickal * beiscsi_conn_create - create an instance of iscsi connection 1186733b39aSJayamohan Kallickal * @cls_session: ptr to iscsi_cls_session 1196733b39aSJayamohan Kallickal * @cid: iscsi cid 1206733b39aSJayamohan Kallickal */ 1216733b39aSJayamohan Kallickal struct iscsi_cls_conn * 1226733b39aSJayamohan Kallickal beiscsi_conn_create(struct iscsi_cls_session *cls_session, u32 cid) 1236733b39aSJayamohan Kallickal { 1246733b39aSJayamohan Kallickal struct beiscsi_hba *phba; 1256733b39aSJayamohan Kallickal struct Scsi_Host *shost; 1266733b39aSJayamohan Kallickal struct iscsi_cls_conn *cls_conn; 1276733b39aSJayamohan Kallickal struct beiscsi_conn *beiscsi_conn; 1286733b39aSJayamohan Kallickal struct iscsi_conn *conn; 1292afc95bfSJayamohan Kallickal struct iscsi_session *sess; 1302afc95bfSJayamohan Kallickal struct beiscsi_session *beiscsi_sess; 1316733b39aSJayamohan Kallickal 1326733b39aSJayamohan Kallickal shost = iscsi_session_to_shost(cls_session); 1336733b39aSJayamohan Kallickal phba = iscsi_host_priv(shost); 1346733b39aSJayamohan Kallickal 13599bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, 13699bc5d55SJohn Soni Jose "BS_%d : In beiscsi_conn_create ,cid" 13799bc5d55SJohn Soni Jose "from iscsi layer=%d\n", cid); 13899bc5d55SJohn Soni Jose 1396733b39aSJayamohan Kallickal cls_conn = iscsi_conn_setup(cls_session, sizeof(*beiscsi_conn), cid); 1406733b39aSJayamohan Kallickal if (!cls_conn) 1416733b39aSJayamohan Kallickal return NULL; 1426733b39aSJayamohan Kallickal 1436733b39aSJayamohan Kallickal conn = cls_conn->dd_data; 1446733b39aSJayamohan Kallickal beiscsi_conn = conn->dd_data; 1456733b39aSJayamohan Kallickal beiscsi_conn->ep = NULL; 1466733b39aSJayamohan Kallickal beiscsi_conn->phba = phba; 1476733b39aSJayamohan Kallickal beiscsi_conn->conn = conn; 1482afc95bfSJayamohan Kallickal sess = cls_session->dd_data; 1492afc95bfSJayamohan Kallickal beiscsi_sess = sess->dd_data; 1502afc95bfSJayamohan Kallickal beiscsi_conn->beiscsi_sess = beiscsi_sess; 1516733b39aSJayamohan Kallickal return cls_conn; 1526733b39aSJayamohan Kallickal } 1536733b39aSJayamohan Kallickal 1546733b39aSJayamohan Kallickal /** 1556733b39aSJayamohan Kallickal * beiscsi_bindconn_cid - Bind the beiscsi_conn with phba connection table 1566733b39aSJayamohan Kallickal * @beiscsi_conn: The pointer to beiscsi_conn structure 1576733b39aSJayamohan Kallickal * @phba: The phba instance 1586733b39aSJayamohan Kallickal * @cid: The cid to free 1596733b39aSJayamohan Kallickal */ 1606733b39aSJayamohan Kallickal static int beiscsi_bindconn_cid(struct beiscsi_hba *phba, 1616733b39aSJayamohan Kallickal struct beiscsi_conn *beiscsi_conn, 1626733b39aSJayamohan Kallickal unsigned int cid) 1636733b39aSJayamohan Kallickal { 164a7909b39SJayamohan Kallickal uint16_t cri_index = BE_GET_CRI_FROM_CID(cid); 165a7909b39SJayamohan Kallickal 166a7909b39SJayamohan Kallickal if (phba->conn_table[cri_index]) { 16799bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 16899bc5d55SJohn Soni Jose "BS_%d : Connection table already occupied. Detected clash\n"); 16999bc5d55SJohn Soni Jose 1706733b39aSJayamohan Kallickal return -EINVAL; 1716733b39aSJayamohan Kallickal } else { 17299bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, 17399bc5d55SJohn Soni Jose "BS_%d : phba->conn_table[%d]=%p(beiscsi_conn)\n", 174a7909b39SJayamohan Kallickal cri_index, beiscsi_conn); 17599bc5d55SJohn Soni Jose 176a7909b39SJayamohan Kallickal phba->conn_table[cri_index] = beiscsi_conn; 1776733b39aSJayamohan Kallickal } 1786733b39aSJayamohan Kallickal return 0; 1796733b39aSJayamohan Kallickal } 1806733b39aSJayamohan Kallickal 1816733b39aSJayamohan Kallickal /** 1826733b39aSJayamohan Kallickal * beiscsi_conn_bind - Binds iscsi session/connection with TCP connection 1836733b39aSJayamohan Kallickal * @cls_session: pointer to iscsi cls session 1846733b39aSJayamohan Kallickal * @cls_conn: pointer to iscsi cls conn 1856733b39aSJayamohan Kallickal * @transport_fd: EP handle(64 bit) 1866733b39aSJayamohan Kallickal * 1876733b39aSJayamohan Kallickal * This function binds the TCP Conn with iSCSI Connection and Session. 1886733b39aSJayamohan Kallickal */ 1896733b39aSJayamohan Kallickal int beiscsi_conn_bind(struct iscsi_cls_session *cls_session, 1906733b39aSJayamohan Kallickal struct iscsi_cls_conn *cls_conn, 1916733b39aSJayamohan Kallickal u64 transport_fd, int is_leading) 1926733b39aSJayamohan Kallickal { 1936733b39aSJayamohan Kallickal struct iscsi_conn *conn = cls_conn->dd_data; 1946733b39aSJayamohan Kallickal struct beiscsi_conn *beiscsi_conn = conn->dd_data; 1953093b048SMike Christie struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); 1963093b048SMike Christie struct beiscsi_hba *phba = iscsi_host_priv(shost); 197*1e4be6ffSJayamohan Kallickal struct hwi_controller *phwi_ctrlr = phba->phwi_ctrlr; 198*1e4be6ffSJayamohan Kallickal struct hwi_wrb_context *pwrb_context; 1996733b39aSJayamohan Kallickal struct beiscsi_endpoint *beiscsi_ep; 2006733b39aSJayamohan Kallickal struct iscsi_endpoint *ep; 2016733b39aSJayamohan Kallickal 2026733b39aSJayamohan Kallickal ep = iscsi_lookup_endpoint(transport_fd); 2036733b39aSJayamohan Kallickal if (!ep) 2046733b39aSJayamohan Kallickal return -EINVAL; 2056733b39aSJayamohan Kallickal 2066733b39aSJayamohan Kallickal beiscsi_ep = ep->dd_data; 2076733b39aSJayamohan Kallickal 2086733b39aSJayamohan Kallickal if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) 2096733b39aSJayamohan Kallickal return -EINVAL; 2106733b39aSJayamohan Kallickal 2116733b39aSJayamohan Kallickal if (beiscsi_ep->phba != phba) { 21299bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 21399bc5d55SJohn Soni Jose "BS_%d : beiscsi_ep->hba=%p not equal to phba=%p\n", 2146733b39aSJayamohan Kallickal beiscsi_ep->phba, phba); 21599bc5d55SJohn Soni Jose 2166733b39aSJayamohan Kallickal return -EEXIST; 2176733b39aSJayamohan Kallickal } 2186733b39aSJayamohan Kallickal 219*1e4be6ffSJayamohan Kallickal pwrb_context = &phwi_ctrlr->wrb_context[BE_GET_CRI_FROM_CID( 220*1e4be6ffSJayamohan Kallickal beiscsi_ep->ep_cid)]; 221*1e4be6ffSJayamohan Kallickal 2226733b39aSJayamohan Kallickal beiscsi_conn->beiscsi_conn_cid = beiscsi_ep->ep_cid; 2236733b39aSJayamohan Kallickal beiscsi_conn->ep = beiscsi_ep; 2246733b39aSJayamohan Kallickal beiscsi_ep->conn = beiscsi_conn; 225*1e4be6ffSJayamohan Kallickal beiscsi_conn->doorbell_offset = pwrb_context->doorbell_offset; 22699bc5d55SJohn Soni Jose 22799bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, 22899bc5d55SJohn Soni Jose "BS_%d : beiscsi_conn=%p conn=%p ep_cid=%d\n", 2296733b39aSJayamohan Kallickal beiscsi_conn, conn, beiscsi_ep->ep_cid); 23099bc5d55SJohn Soni Jose 2316733b39aSJayamohan Kallickal return beiscsi_bindconn_cid(phba, beiscsi_conn, beiscsi_ep->ep_cid); 2326733b39aSJayamohan Kallickal } 2336733b39aSJayamohan Kallickal 2340e43895eSMike Christie static int beiscsi_create_ipv4_iface(struct beiscsi_hba *phba) 2350e43895eSMike Christie { 2360e43895eSMike Christie if (phba->ipv4_iface) 2370e43895eSMike Christie return 0; 2380e43895eSMike Christie 2390e43895eSMike Christie phba->ipv4_iface = iscsi_create_iface(phba->shost, 2400e43895eSMike Christie &beiscsi_iscsi_transport, 2410e43895eSMike Christie ISCSI_IFACE_TYPE_IPV4, 2420e43895eSMike Christie 0, 0); 2430e43895eSMike Christie if (!phba->ipv4_iface) { 24499bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 24599bc5d55SJohn Soni Jose "BS_%d : Could not " 2460e43895eSMike Christie "create default IPv4 address.\n"); 2470e43895eSMike Christie return -ENODEV; 2480e43895eSMike Christie } 2490e43895eSMike Christie 2500e43895eSMike Christie return 0; 2510e43895eSMike Christie } 2520e43895eSMike Christie 2530e43895eSMike Christie static int beiscsi_create_ipv6_iface(struct beiscsi_hba *phba) 2540e43895eSMike Christie { 2550e43895eSMike Christie if (phba->ipv6_iface) 2560e43895eSMike Christie return 0; 2570e43895eSMike Christie 2580e43895eSMike Christie phba->ipv6_iface = iscsi_create_iface(phba->shost, 2590e43895eSMike Christie &beiscsi_iscsi_transport, 2600e43895eSMike Christie ISCSI_IFACE_TYPE_IPV6, 2610e43895eSMike Christie 0, 0); 2620e43895eSMike Christie if (!phba->ipv6_iface) { 26399bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 26499bc5d55SJohn Soni Jose "BS_%d : Could not " 2650e43895eSMike Christie "create default IPv6 address.\n"); 2660e43895eSMike Christie return -ENODEV; 2670e43895eSMike Christie } 2680e43895eSMike Christie 2690e43895eSMike Christie return 0; 2700e43895eSMike Christie } 2710e43895eSMike Christie 2720e43895eSMike Christie void beiscsi_create_def_ifaces(struct beiscsi_hba *phba) 2730e43895eSMike Christie { 2740e43895eSMike Christie struct be_cmd_get_if_info_resp if_info; 2750e43895eSMike Christie 2760e43895eSMike Christie if (!mgmt_get_if_info(phba, BE2_IPV4, &if_info)) 2770e43895eSMike Christie beiscsi_create_ipv4_iface(phba); 2780e43895eSMike Christie 2790e43895eSMike Christie if (!mgmt_get_if_info(phba, BE2_IPV6, &if_info)) 2800e43895eSMike Christie beiscsi_create_ipv6_iface(phba); 2810e43895eSMike Christie } 2820e43895eSMike Christie 2830e43895eSMike Christie void beiscsi_destroy_def_ifaces(struct beiscsi_hba *phba) 2840e43895eSMike Christie { 2850e43895eSMike Christie if (phba->ipv6_iface) 2860e43895eSMike Christie iscsi_destroy_iface(phba->ipv6_iface); 2870e43895eSMike Christie if (phba->ipv4_iface) 2880e43895eSMike Christie iscsi_destroy_iface(phba->ipv4_iface); 2890e43895eSMike Christie } 2900e43895eSMike Christie 2910e43895eSMike Christie static int 2920e43895eSMike Christie beiscsi_set_static_ip(struct Scsi_Host *shost, 2930e43895eSMike Christie struct iscsi_iface_param_info *iface_param, 2940e43895eSMike Christie void *data, uint32_t dt_len) 2950e43895eSMike Christie { 2960e43895eSMike Christie struct beiscsi_hba *phba = iscsi_host_priv(shost); 2970e43895eSMike Christie struct iscsi_iface_param_info *iface_ip = NULL; 2980e43895eSMike Christie struct iscsi_iface_param_info *iface_subnet = NULL; 2990e43895eSMike Christie struct nlattr *nla; 3000e43895eSMike Christie int ret; 3010e43895eSMike Christie 3020e43895eSMike Christie 3030e43895eSMike Christie switch (iface_param->param) { 3040e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_BOOTPROTO: 3050e43895eSMike Christie nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_ADDR); 3060e43895eSMike Christie if (nla) 3070e43895eSMike Christie iface_ip = nla_data(nla); 3080e43895eSMike Christie 3090e43895eSMike Christie nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_SUBNET); 3100e43895eSMike Christie if (nla) 3110e43895eSMike Christie iface_subnet = nla_data(nla); 3120e43895eSMike Christie break; 3130e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_ADDR: 3140e43895eSMike Christie iface_ip = iface_param; 3150e43895eSMike Christie nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_SUBNET); 3160e43895eSMike Christie if (nla) 3170e43895eSMike Christie iface_subnet = nla_data(nla); 3180e43895eSMike Christie break; 3190e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_SUBNET: 3200e43895eSMike Christie iface_subnet = iface_param; 3210e43895eSMike Christie nla = nla_find(data, dt_len, ISCSI_NET_PARAM_IPV4_ADDR); 3220e43895eSMike Christie if (nla) 3230e43895eSMike Christie iface_ip = nla_data(nla); 3240e43895eSMike Christie break; 3250e43895eSMike Christie default: 32699bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 32799bc5d55SJohn Soni Jose "BS_%d : Unsupported param %d\n", 3280e43895eSMike Christie iface_param->param); 3290e43895eSMike Christie } 3300e43895eSMike Christie 3310e43895eSMike Christie if (!iface_ip || !iface_subnet) { 33299bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 33399bc5d55SJohn Soni Jose "BS_%d : IP and Subnet Mask required\n"); 3340e43895eSMike Christie return -EINVAL; 3350e43895eSMike Christie } 3360e43895eSMike Christie 3370e43895eSMike Christie ret = mgmt_set_ip(phba, iface_ip, iface_subnet, 3380e43895eSMike Christie ISCSI_BOOTPROTO_STATIC); 3390e43895eSMike Christie 3400e43895eSMike Christie return ret; 3410e43895eSMike Christie } 3420e43895eSMike Christie 3436f72238eSJohn Soni Jose /** 3446f72238eSJohn Soni Jose * beiscsi_set_vlan_tag()- Set the VLAN TAG 3456f72238eSJohn Soni Jose * @shost: Scsi Host for the driver instance 3466f72238eSJohn Soni Jose * @iface_param: Interface paramters 3476f72238eSJohn Soni Jose * 3486f72238eSJohn Soni Jose * Set the VLAN TAG for the adapter or disable 3496f72238eSJohn Soni Jose * the VLAN config 3506f72238eSJohn Soni Jose * 3516f72238eSJohn Soni Jose * returns 3526f72238eSJohn Soni Jose * Success: 0 3536f72238eSJohn Soni Jose * Failure: Non-Zero Value 3546f72238eSJohn Soni Jose **/ 3556f72238eSJohn Soni Jose static int 3566f72238eSJohn Soni Jose beiscsi_set_vlan_tag(struct Scsi_Host *shost, 3576f72238eSJohn Soni Jose struct iscsi_iface_param_info *iface_param) 3586f72238eSJohn Soni Jose { 3596f72238eSJohn Soni Jose struct beiscsi_hba *phba = iscsi_host_priv(shost); 3606f72238eSJohn Soni Jose int ret = 0; 3616f72238eSJohn Soni Jose 3626f72238eSJohn Soni Jose /* Get the Interface Handle */ 3636f72238eSJohn Soni Jose if (mgmt_get_all_if_id(phba)) { 3646f72238eSJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 3656f72238eSJohn Soni Jose "BS_%d : Getting Interface Handle Failed\n"); 3666f72238eSJohn Soni Jose return -EIO; 3676f72238eSJohn Soni Jose } 3686f72238eSJohn Soni Jose 3696f72238eSJohn Soni Jose switch (iface_param->param) { 3706f72238eSJohn Soni Jose case ISCSI_NET_PARAM_VLAN_ENABLED: 3716f72238eSJohn Soni Jose if (iface_param->value[0] != ISCSI_VLAN_ENABLE) 3726f72238eSJohn Soni Jose ret = mgmt_set_vlan(phba, BEISCSI_VLAN_DISABLE); 3736f72238eSJohn Soni Jose break; 3746f72238eSJohn Soni Jose case ISCSI_NET_PARAM_VLAN_TAG: 3756f72238eSJohn Soni Jose ret = mgmt_set_vlan(phba, 3766f72238eSJohn Soni Jose *((uint16_t *)iface_param->value)); 3776f72238eSJohn Soni Jose break; 3786f72238eSJohn Soni Jose default: 3796f72238eSJohn Soni Jose beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, 380b23f7a09SMasanari Iida "BS_%d : Unknown Param Type : %d\n", 3816f72238eSJohn Soni Jose iface_param->param); 3826f72238eSJohn Soni Jose return -ENOSYS; 3836f72238eSJohn Soni Jose } 3846f72238eSJohn Soni Jose return ret; 3856f72238eSJohn Soni Jose } 3866f72238eSJohn Soni Jose 3876f72238eSJohn Soni Jose 3880e43895eSMike Christie static int 3890e43895eSMike Christie beiscsi_set_ipv4(struct Scsi_Host *shost, 3900e43895eSMike Christie struct iscsi_iface_param_info *iface_param, 3910e43895eSMike Christie void *data, uint32_t dt_len) 3920e43895eSMike Christie { 3930e43895eSMike Christie struct beiscsi_hba *phba = iscsi_host_priv(shost); 3940e43895eSMike Christie int ret = 0; 3950e43895eSMike Christie 3960e43895eSMike Christie /* Check the param */ 3970e43895eSMike Christie switch (iface_param->param) { 3980e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_GW: 3990e43895eSMike Christie ret = mgmt_set_gateway(phba, iface_param); 4000e43895eSMike Christie break; 4010e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_BOOTPROTO: 4020e43895eSMike Christie if (iface_param->value[0] == ISCSI_BOOTPROTO_DHCP) 4030e43895eSMike Christie ret = mgmt_set_ip(phba, iface_param, 4040e43895eSMike Christie NULL, ISCSI_BOOTPROTO_DHCP); 4050e43895eSMike Christie else if (iface_param->value[0] == ISCSI_BOOTPROTO_STATIC) 4060e43895eSMike Christie ret = beiscsi_set_static_ip(shost, iface_param, 4070e43895eSMike Christie data, dt_len); 4080e43895eSMike Christie else 40999bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 41099bc5d55SJohn Soni Jose "BS_%d : Invalid BOOTPROTO: %d\n", 4110e43895eSMike Christie iface_param->value[0]); 4120e43895eSMike Christie break; 4130e43895eSMike Christie case ISCSI_NET_PARAM_IFACE_ENABLE: 4140e43895eSMike Christie if (iface_param->value[0] == ISCSI_IFACE_ENABLE) 4150e43895eSMike Christie ret = beiscsi_create_ipv4_iface(phba); 4160e43895eSMike Christie else 4170e43895eSMike Christie iscsi_destroy_iface(phba->ipv4_iface); 4180e43895eSMike Christie break; 4190e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_SUBNET: 4200e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_ADDR: 4210e43895eSMike Christie ret = beiscsi_set_static_ip(shost, iface_param, 4220e43895eSMike Christie data, dt_len); 4230e43895eSMike Christie break; 4246f72238eSJohn Soni Jose case ISCSI_NET_PARAM_VLAN_ENABLED: 4256f72238eSJohn Soni Jose case ISCSI_NET_PARAM_VLAN_TAG: 4266f72238eSJohn Soni Jose ret = beiscsi_set_vlan_tag(shost, iface_param); 4276f72238eSJohn Soni Jose break; 4280e43895eSMike Christie default: 42999bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 43099bc5d55SJohn Soni Jose "BS_%d : Param %d not supported\n", 4310e43895eSMike Christie iface_param->param); 4320e43895eSMike Christie } 4330e43895eSMike Christie 4340e43895eSMike Christie return ret; 4350e43895eSMike Christie } 4360e43895eSMike Christie 4370e43895eSMike Christie static int 4380e43895eSMike Christie beiscsi_set_ipv6(struct Scsi_Host *shost, 4390e43895eSMike Christie struct iscsi_iface_param_info *iface_param, 4400e43895eSMike Christie void *data, uint32_t dt_len) 4410e43895eSMike Christie { 4420e43895eSMike Christie struct beiscsi_hba *phba = iscsi_host_priv(shost); 4430e43895eSMike Christie int ret = 0; 4440e43895eSMike Christie 4450e43895eSMike Christie switch (iface_param->param) { 4460e43895eSMike Christie case ISCSI_NET_PARAM_IFACE_ENABLE: 4470e43895eSMike Christie if (iface_param->value[0] == ISCSI_IFACE_ENABLE) 4480e43895eSMike Christie ret = beiscsi_create_ipv6_iface(phba); 4490e43895eSMike Christie else { 4500e43895eSMike Christie iscsi_destroy_iface(phba->ipv6_iface); 4510e43895eSMike Christie ret = 0; 4520e43895eSMike Christie } 4530e43895eSMike Christie break; 4540e43895eSMike Christie case ISCSI_NET_PARAM_IPV6_ADDR: 4550e43895eSMike Christie ret = mgmt_set_ip(phba, iface_param, NULL, 4560e43895eSMike Christie ISCSI_BOOTPROTO_STATIC); 4570e43895eSMike Christie break; 4580e43895eSMike Christie default: 45999bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 46099bc5d55SJohn Soni Jose "BS_%d : Param %d not supported\n", 4610e43895eSMike Christie iface_param->param); 4620e43895eSMike Christie } 4630e43895eSMike Christie 4640e43895eSMike Christie return ret; 4650e43895eSMike Christie } 4660e43895eSMike Christie 4670e43895eSMike Christie int be2iscsi_iface_set_param(struct Scsi_Host *shost, 4680e43895eSMike Christie void *data, uint32_t dt_len) 4690e43895eSMike Christie { 4700e43895eSMike Christie struct iscsi_iface_param_info *iface_param = NULL; 47199bc5d55SJohn Soni Jose struct beiscsi_hba *phba = iscsi_host_priv(shost); 4720e43895eSMike Christie struct nlattr *attrib; 4730e43895eSMike Christie uint32_t rm_len = dt_len; 4740e43895eSMike Christie int ret = 0 ; 4750e43895eSMike Christie 4760e43895eSMike Christie nla_for_each_attr(attrib, data, dt_len, rm_len) { 4770e43895eSMike Christie iface_param = nla_data(attrib); 4780e43895eSMike Christie 4790e43895eSMike Christie if (iface_param->param_type != ISCSI_NET_PARAM) 4800e43895eSMike Christie continue; 4810e43895eSMike Christie 4820e43895eSMike Christie /* 4830e43895eSMike Christie * BE2ISCSI only supports 1 interface 4840e43895eSMike Christie */ 4850e43895eSMike Christie if (iface_param->iface_num) { 48699bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 48799bc5d55SJohn Soni Jose "BS_%d : Invalid iface_num %d." 4880e43895eSMike Christie "Only iface_num 0 is supported.\n", 4890e43895eSMike Christie iface_param->iface_num); 49099bc5d55SJohn Soni Jose 4910e43895eSMike Christie return -EINVAL; 4920e43895eSMike Christie } 4930e43895eSMike Christie 4940e43895eSMike Christie switch (iface_param->iface_type) { 4950e43895eSMike Christie case ISCSI_IFACE_TYPE_IPV4: 4960e43895eSMike Christie ret = beiscsi_set_ipv4(shost, iface_param, 4970e43895eSMike Christie data, dt_len); 4980e43895eSMike Christie break; 4990e43895eSMike Christie case ISCSI_IFACE_TYPE_IPV6: 5000e43895eSMike Christie ret = beiscsi_set_ipv6(shost, iface_param, 5010e43895eSMike Christie data, dt_len); 5020e43895eSMike Christie break; 5030e43895eSMike Christie default: 50499bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 50599bc5d55SJohn Soni Jose "BS_%d : Invalid iface type :%d passed\n", 5060e43895eSMike Christie iface_param->iface_type); 5070e43895eSMike Christie break; 5080e43895eSMike Christie } 5090e43895eSMike Christie 5100e43895eSMike Christie if (ret) 5110e43895eSMike Christie return ret; 5120e43895eSMike Christie } 5130e43895eSMike Christie 5140e43895eSMike Christie return ret; 5150e43895eSMike Christie } 5160e43895eSMike Christie 5170e43895eSMike Christie static int be2iscsi_get_if_param(struct beiscsi_hba *phba, 5180e43895eSMike Christie struct iscsi_iface *iface, int param, 5190e43895eSMike Christie char *buf) 5200e43895eSMike Christie { 5210e43895eSMike Christie struct be_cmd_get_if_info_resp if_info; 5220e43895eSMike Christie int len, ip_type = BE2_IPV4; 5230e43895eSMike Christie 5240e43895eSMike Christie memset(&if_info, 0, sizeof(if_info)); 5250e43895eSMike Christie 5260e43895eSMike Christie if (iface->iface_type == ISCSI_IFACE_TYPE_IPV6) 5270e43895eSMike Christie ip_type = BE2_IPV6; 5280e43895eSMike Christie 5290e43895eSMike Christie len = mgmt_get_if_info(phba, ip_type, &if_info); 5300e43895eSMike Christie if (len) 5310e43895eSMike Christie return len; 5320e43895eSMike Christie 5330e43895eSMike Christie switch (param) { 5340e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_ADDR: 5350e43895eSMike Christie len = sprintf(buf, "%pI4\n", &if_info.ip_addr.addr); 5360e43895eSMike Christie break; 5370e43895eSMike Christie case ISCSI_NET_PARAM_IPV6_ADDR: 5380e43895eSMike Christie len = sprintf(buf, "%pI6\n", &if_info.ip_addr.addr); 5390e43895eSMike Christie break; 5400e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_BOOTPROTO: 5410e43895eSMike Christie if (!if_info.dhcp_state) 5428359c79bSJohn Soni Jose len = sprintf(buf, "static\n"); 5430e43895eSMike Christie else 5448359c79bSJohn Soni Jose len = sprintf(buf, "dhcp\n"); 5450e43895eSMike Christie break; 5460e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_SUBNET: 5470e43895eSMike Christie len = sprintf(buf, "%pI4\n", &if_info.ip_addr.subnet_mask); 5480e43895eSMike Christie break; 5496f72238eSJohn Soni Jose case ISCSI_NET_PARAM_VLAN_ENABLED: 5506f72238eSJohn Soni Jose len = sprintf(buf, "%s\n", 5516f72238eSJohn Soni Jose (if_info.vlan_priority == BEISCSI_VLAN_DISABLE) 5528359c79bSJohn Soni Jose ? "Disabled\n" : "Enabled\n"); 5536f72238eSJohn Soni Jose break; 5546f72238eSJohn Soni Jose case ISCSI_NET_PARAM_VLAN_ID: 5556f72238eSJohn Soni Jose if (if_info.vlan_priority == BEISCSI_VLAN_DISABLE) 5566f72238eSJohn Soni Jose return -EINVAL; 5576f72238eSJohn Soni Jose else 5586f72238eSJohn Soni Jose len = sprintf(buf, "%d\n", 5596f72238eSJohn Soni Jose (if_info.vlan_priority & 5606f72238eSJohn Soni Jose ISCSI_MAX_VLAN_ID)); 5616f72238eSJohn Soni Jose break; 5626f72238eSJohn Soni Jose case ISCSI_NET_PARAM_VLAN_PRIORITY: 5636f72238eSJohn Soni Jose if (if_info.vlan_priority == BEISCSI_VLAN_DISABLE) 5646f72238eSJohn Soni Jose return -EINVAL; 5656f72238eSJohn Soni Jose else 5666f72238eSJohn Soni Jose len = sprintf(buf, "%d\n", 5676f72238eSJohn Soni Jose ((if_info.vlan_priority >> 13) & 5686f72238eSJohn Soni Jose ISCSI_MAX_VLAN_PRIORITY)); 5696f72238eSJohn Soni Jose break; 5700e43895eSMike Christie default: 5710e43895eSMike Christie WARN_ON(1); 5720e43895eSMike Christie } 5730e43895eSMike Christie 5740e43895eSMike Christie return len; 5750e43895eSMike Christie } 5760e43895eSMike Christie 5770e43895eSMike Christie int be2iscsi_iface_get_param(struct iscsi_iface *iface, 5780e43895eSMike Christie enum iscsi_param_type param_type, 5790e43895eSMike Christie int param, char *buf) 5800e43895eSMike Christie { 5810e43895eSMike Christie struct Scsi_Host *shost = iscsi_iface_to_shost(iface); 5820e43895eSMike Christie struct beiscsi_hba *phba = iscsi_host_priv(shost); 5830e43895eSMike Christie struct be_cmd_get_def_gateway_resp gateway; 5840e43895eSMike Christie int len = -ENOSYS; 5850e43895eSMike Christie 5860e43895eSMike Christie switch (param) { 5870e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_ADDR: 5880e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_SUBNET: 5890e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_BOOTPROTO: 5900e43895eSMike Christie case ISCSI_NET_PARAM_IPV6_ADDR: 5916f72238eSJohn Soni Jose case ISCSI_NET_PARAM_VLAN_ENABLED: 5926f72238eSJohn Soni Jose case ISCSI_NET_PARAM_VLAN_ID: 5936f72238eSJohn Soni Jose case ISCSI_NET_PARAM_VLAN_PRIORITY: 5940e43895eSMike Christie len = be2iscsi_get_if_param(phba, iface, param, buf); 5950e43895eSMike Christie break; 5960e43895eSMike Christie case ISCSI_NET_PARAM_IFACE_ENABLE: 5978359c79bSJohn Soni Jose len = sprintf(buf, "enabled\n"); 5980e43895eSMike Christie break; 5990e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_GW: 6000e43895eSMike Christie memset(&gateway, 0, sizeof(gateway)); 6010e43895eSMike Christie len = mgmt_get_gateway(phba, BE2_IPV4, &gateway); 6020e43895eSMike Christie if (!len) 6030e43895eSMike Christie len = sprintf(buf, "%pI4\n", &gateway.ip_addr.addr); 6040e43895eSMike Christie break; 6050e43895eSMike Christie default: 6060e43895eSMike Christie len = -ENOSYS; 6070e43895eSMike Christie } 6080e43895eSMike Christie 6090e43895eSMike Christie return len; 6100e43895eSMike Christie } 6110e43895eSMike Christie 6126733b39aSJayamohan Kallickal /** 613c7f7fd5bSMike Christie * beiscsi_ep_get_param - get the iscsi parameter 614c7f7fd5bSMike Christie * @ep: pointer to iscsi ep 6156733b39aSJayamohan Kallickal * @param: parameter type identifier 6166733b39aSJayamohan Kallickal * @buf: buffer pointer 6176733b39aSJayamohan Kallickal * 6186733b39aSJayamohan Kallickal * returns iscsi parameter 6196733b39aSJayamohan Kallickal */ 620c7f7fd5bSMike Christie int beiscsi_ep_get_param(struct iscsi_endpoint *ep, 6216733b39aSJayamohan Kallickal enum iscsi_param param, char *buf) 6226733b39aSJayamohan Kallickal { 623c7f7fd5bSMike Christie struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; 6246733b39aSJayamohan Kallickal int len = 0; 6256733b39aSJayamohan Kallickal 62699bc5d55SJohn Soni Jose beiscsi_log(beiscsi_ep->phba, KERN_INFO, 62799bc5d55SJohn Soni Jose BEISCSI_LOG_CONFIG, 62899bc5d55SJohn Soni Jose "BS_%d : In beiscsi_ep_get_param," 62999bc5d55SJohn Soni Jose " param= %d\n", param); 6306733b39aSJayamohan Kallickal 6316733b39aSJayamohan Kallickal switch (param) { 6326733b39aSJayamohan Kallickal case ISCSI_PARAM_CONN_PORT: 6336733b39aSJayamohan Kallickal len = sprintf(buf, "%hu\n", beiscsi_ep->dst_tcpport); 6346733b39aSJayamohan Kallickal break; 6356733b39aSJayamohan Kallickal case ISCSI_PARAM_CONN_ADDRESS: 6366733b39aSJayamohan Kallickal if (beiscsi_ep->ip_type == BE2_IPV4) 6376733b39aSJayamohan Kallickal len = sprintf(buf, "%pI4\n", &beiscsi_ep->dst_addr); 6386733b39aSJayamohan Kallickal else 6396733b39aSJayamohan Kallickal len = sprintf(buf, "%pI6\n", &beiscsi_ep->dst6_addr); 6406733b39aSJayamohan Kallickal break; 6416733b39aSJayamohan Kallickal default: 642c7f7fd5bSMike Christie return -ENOSYS; 6436733b39aSJayamohan Kallickal } 6446733b39aSJayamohan Kallickal return len; 6456733b39aSJayamohan Kallickal } 6466733b39aSJayamohan Kallickal 6476733b39aSJayamohan Kallickal int beiscsi_set_param(struct iscsi_cls_conn *cls_conn, 6486733b39aSJayamohan Kallickal enum iscsi_param param, char *buf, int buflen) 6496733b39aSJayamohan Kallickal { 6506733b39aSJayamohan Kallickal struct iscsi_conn *conn = cls_conn->dd_data; 6516733b39aSJayamohan Kallickal struct iscsi_session *session = conn->session; 65299bc5d55SJohn Soni Jose struct beiscsi_hba *phba = NULL; 6536733b39aSJayamohan Kallickal int ret; 6546733b39aSJayamohan Kallickal 65599bc5d55SJohn Soni Jose phba = ((struct beiscsi_conn *)conn->dd_data)->phba; 65699bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, 65799bc5d55SJohn Soni Jose "BS_%d : In beiscsi_conn_set_param," 65899bc5d55SJohn Soni Jose " param= %d\n", param); 65999bc5d55SJohn Soni Jose 6606733b39aSJayamohan Kallickal ret = iscsi_set_param(cls_conn, param, buf, buflen); 6616733b39aSJayamohan Kallickal if (ret) 6626733b39aSJayamohan Kallickal return ret; 6636733b39aSJayamohan Kallickal /* 6646733b39aSJayamohan Kallickal * If userspace tried to set the value to higher than we can 6656733b39aSJayamohan Kallickal * support override here. 6666733b39aSJayamohan Kallickal */ 6676733b39aSJayamohan Kallickal switch (param) { 6686733b39aSJayamohan Kallickal case ISCSI_PARAM_FIRST_BURST: 6696733b39aSJayamohan Kallickal if (session->first_burst > 8192) 6706733b39aSJayamohan Kallickal session->first_burst = 8192; 6716733b39aSJayamohan Kallickal break; 6726733b39aSJayamohan Kallickal case ISCSI_PARAM_MAX_RECV_DLENGTH: 6736733b39aSJayamohan Kallickal if (conn->max_recv_dlength > 65536) 6746733b39aSJayamohan Kallickal conn->max_recv_dlength = 65536; 6756733b39aSJayamohan Kallickal break; 6766733b39aSJayamohan Kallickal case ISCSI_PARAM_MAX_BURST: 677230dceb4SJayamohan Kallickal if (session->max_burst > 262144) 678230dceb4SJayamohan Kallickal session->max_burst = 262144; 6796733b39aSJayamohan Kallickal break; 68042f43c41SJayamohan Kallickal case ISCSI_PARAM_MAX_XMIT_DLENGTH: 6817331613eSJayamohan Kallickal if (conn->max_xmit_dlength > 65536) 68242f43c41SJayamohan Kallickal conn->max_xmit_dlength = 65536; 6836733b39aSJayamohan Kallickal default: 6846733b39aSJayamohan Kallickal return 0; 6856733b39aSJayamohan Kallickal } 6866733b39aSJayamohan Kallickal 6876733b39aSJayamohan Kallickal return 0; 6886733b39aSJayamohan Kallickal } 6896733b39aSJayamohan Kallickal 6906733b39aSJayamohan Kallickal /** 6912177199dSJohn Soni Jose * beiscsi_get_initname - Read Initiator Name from flash 6922177199dSJohn Soni Jose * @buf: buffer bointer 6932177199dSJohn Soni Jose * @phba: The device priv structure instance 6942177199dSJohn Soni Jose * 6952177199dSJohn Soni Jose * returns number of bytes 6962177199dSJohn Soni Jose */ 6972177199dSJohn Soni Jose static int beiscsi_get_initname(char *buf, struct beiscsi_hba *phba) 6982177199dSJohn Soni Jose { 6992177199dSJohn Soni Jose int rc; 700e175defeSJohn Soni Jose unsigned int tag; 7012177199dSJohn Soni Jose struct be_mcc_wrb *wrb; 7022177199dSJohn Soni Jose struct be_cmd_hba_name *resp; 7032177199dSJohn Soni Jose 7042177199dSJohn Soni Jose tag = be_cmd_get_initname(phba); 7052177199dSJohn Soni Jose if (!tag) { 70699bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 70799bc5d55SJohn Soni Jose "BS_%d : Getting Initiator Name Failed\n"); 70899bc5d55SJohn Soni Jose 7092177199dSJohn Soni Jose return -EBUSY; 710e175defeSJohn Soni Jose } 7112177199dSJohn Soni Jose 712e175defeSJohn Soni Jose rc = beiscsi_mccq_compl(phba, tag, &wrb, NULL); 713e175defeSJohn Soni Jose if (rc) { 71499bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, 71599bc5d55SJohn Soni Jose BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, 716e175defeSJohn Soni Jose "BS_%d : Initiator Name MBX Failed\n"); 717e175defeSJohn Soni Jose return rc; 7182177199dSJohn Soni Jose } 719e175defeSJohn Soni Jose 7202177199dSJohn Soni Jose resp = embedded_payload(wrb); 7212177199dSJohn Soni Jose rc = sprintf(buf, "%s\n", resp->initiator_name); 7222177199dSJohn Soni Jose return rc; 7232177199dSJohn Soni Jose } 7242177199dSJohn Soni Jose 7252177199dSJohn Soni Jose /** 726c62eef0dSJohn Soni Jose * beiscsi_get_port_state - Get the Port State 727c62eef0dSJohn Soni Jose * @shost : pointer to scsi_host structure 728c62eef0dSJohn Soni Jose * 729c62eef0dSJohn Soni Jose */ 730c62eef0dSJohn Soni Jose static void beiscsi_get_port_state(struct Scsi_Host *shost) 731c62eef0dSJohn Soni Jose { 732c62eef0dSJohn Soni Jose struct beiscsi_hba *phba = iscsi_host_priv(shost); 733c62eef0dSJohn Soni Jose struct iscsi_cls_host *ihost = shost->shost_data; 734c62eef0dSJohn Soni Jose 735c62eef0dSJohn Soni Jose ihost->port_state = (phba->state == BE_ADAPTER_UP) ? 736c62eef0dSJohn Soni Jose ISCSI_PORT_STATE_UP : ISCSI_PORT_STATE_DOWN; 737c62eef0dSJohn Soni Jose } 738c62eef0dSJohn Soni Jose 739c62eef0dSJohn Soni Jose /** 740c62eef0dSJohn Soni Jose * beiscsi_get_port_speed - Get the Port Speed from Adapter 741c62eef0dSJohn Soni Jose * @shost : pointer to scsi_host structure 742c62eef0dSJohn Soni Jose * 743c62eef0dSJohn Soni Jose * returns Success/Failure 744c62eef0dSJohn Soni Jose */ 745c62eef0dSJohn Soni Jose static int beiscsi_get_port_speed(struct Scsi_Host *shost) 746c62eef0dSJohn Soni Jose { 747e175defeSJohn Soni Jose int rc; 748e175defeSJohn Soni Jose unsigned int tag; 749c62eef0dSJohn Soni Jose struct be_mcc_wrb *wrb; 750c62eef0dSJohn Soni Jose struct be_cmd_ntwk_link_status_resp *resp; 751c62eef0dSJohn Soni Jose struct beiscsi_hba *phba = iscsi_host_priv(shost); 752c62eef0dSJohn Soni Jose struct iscsi_cls_host *ihost = shost->shost_data; 753c62eef0dSJohn Soni Jose 754c62eef0dSJohn Soni Jose tag = be_cmd_get_port_speed(phba); 755c62eef0dSJohn Soni Jose if (!tag) { 75699bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 75799bc5d55SJohn Soni Jose "BS_%d : Getting Port Speed Failed\n"); 75899bc5d55SJohn Soni Jose 759c62eef0dSJohn Soni Jose return -EBUSY; 760e175defeSJohn Soni Jose } 761e175defeSJohn Soni Jose rc = beiscsi_mccq_compl(phba, tag, &wrb, NULL); 762e175defeSJohn Soni Jose if (rc) { 76399bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, 76499bc5d55SJohn Soni Jose BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, 765e175defeSJohn Soni Jose "BS_%d : Port Speed MBX Failed\n"); 766e175defeSJohn Soni Jose return rc; 767c62eef0dSJohn Soni Jose } 768c62eef0dSJohn Soni Jose resp = embedded_payload(wrb); 769c62eef0dSJohn Soni Jose 770c62eef0dSJohn Soni Jose switch (resp->mac_speed) { 771c62eef0dSJohn Soni Jose case BE2ISCSI_LINK_SPEED_10MBPS: 772c62eef0dSJohn Soni Jose ihost->port_speed = ISCSI_PORT_SPEED_10MBPS; 773c62eef0dSJohn Soni Jose break; 774c62eef0dSJohn Soni Jose case BE2ISCSI_LINK_SPEED_100MBPS: 775c62eef0dSJohn Soni Jose ihost->port_speed = BE2ISCSI_LINK_SPEED_100MBPS; 776c62eef0dSJohn Soni Jose break; 777c62eef0dSJohn Soni Jose case BE2ISCSI_LINK_SPEED_1GBPS: 778c62eef0dSJohn Soni Jose ihost->port_speed = ISCSI_PORT_SPEED_1GBPS; 779c62eef0dSJohn Soni Jose break; 780c62eef0dSJohn Soni Jose case BE2ISCSI_LINK_SPEED_10GBPS: 781c62eef0dSJohn Soni Jose ihost->port_speed = ISCSI_PORT_SPEED_10GBPS; 782c62eef0dSJohn Soni Jose break; 783c62eef0dSJohn Soni Jose default: 784c62eef0dSJohn Soni Jose ihost->port_speed = ISCSI_PORT_SPEED_UNKNOWN; 785c62eef0dSJohn Soni Jose } 786c62eef0dSJohn Soni Jose return 0; 787c62eef0dSJohn Soni Jose } 788c62eef0dSJohn Soni Jose 789c62eef0dSJohn Soni Jose /** 7906733b39aSJayamohan Kallickal * beiscsi_get_host_param - get the iscsi parameter 7916733b39aSJayamohan Kallickal * @shost: pointer to scsi_host structure 7926733b39aSJayamohan Kallickal * @param: parameter type identifier 7936733b39aSJayamohan Kallickal * @buf: buffer pointer 7946733b39aSJayamohan Kallickal * 7956733b39aSJayamohan Kallickal * returns host parameter 7966733b39aSJayamohan Kallickal */ 7976733b39aSJayamohan Kallickal int beiscsi_get_host_param(struct Scsi_Host *shost, 7986733b39aSJayamohan Kallickal enum iscsi_host_param param, char *buf) 7996733b39aSJayamohan Kallickal { 8003093b048SMike Christie struct beiscsi_hba *phba = iscsi_host_priv(shost); 801b15d05b0SJayamohan Kallickal int status = 0; 8026733b39aSJayamohan Kallickal 80399bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, 80499bc5d55SJohn Soni Jose "BS_%d : In beiscsi_get_host_param," 80599bc5d55SJohn Soni Jose " param= %d\n", param); 80699bc5d55SJohn Soni Jose 8076733b39aSJayamohan Kallickal switch (param) { 8086733b39aSJayamohan Kallickal case ISCSI_HOST_PARAM_HWADDRESS: 809c7acc5b8SJayamohan Kallickal status = beiscsi_get_macaddr(buf, phba); 810c7acc5b8SJayamohan Kallickal if (status < 0) { 81199bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 81299bc5d55SJohn Soni Jose "BS_%d : beiscsi_get_macaddr Failed\n"); 813c7acc5b8SJayamohan Kallickal return status; 814c7acc5b8SJayamohan Kallickal } 815c7acc5b8SJayamohan Kallickal break; 8162177199dSJohn Soni Jose case ISCSI_HOST_PARAM_INITIATOR_NAME: 8172177199dSJohn Soni Jose status = beiscsi_get_initname(buf, phba); 8182177199dSJohn Soni Jose if (status < 0) { 81999bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 82099bc5d55SJohn Soni Jose "BS_%d : Retreiving Initiator Name Failed\n"); 8212177199dSJohn Soni Jose return status; 8222177199dSJohn Soni Jose } 8232177199dSJohn Soni Jose break; 824c62eef0dSJohn Soni Jose case ISCSI_HOST_PARAM_PORT_STATE: 825c62eef0dSJohn Soni Jose beiscsi_get_port_state(shost); 826c62eef0dSJohn Soni Jose status = sprintf(buf, "%s\n", iscsi_get_port_state_name(shost)); 827c62eef0dSJohn Soni Jose break; 828c62eef0dSJohn Soni Jose case ISCSI_HOST_PARAM_PORT_SPEED: 829c62eef0dSJohn Soni Jose status = beiscsi_get_port_speed(shost); 830c62eef0dSJohn Soni Jose if (status) { 83199bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 83299bc5d55SJohn Soni Jose "BS_%d : Retreiving Port Speed Failed\n"); 833c62eef0dSJohn Soni Jose return status; 834c62eef0dSJohn Soni Jose } 835c62eef0dSJohn Soni Jose status = sprintf(buf, "%s\n", iscsi_get_port_speed_name(shost)); 836c62eef0dSJohn Soni Jose break; 837c7acc5b8SJayamohan Kallickal default: 838c7acc5b8SJayamohan Kallickal return iscsi_host_get_param(shost, param, buf); 839c7acc5b8SJayamohan Kallickal } 840b15d05b0SJayamohan Kallickal return status; 841c7acc5b8SJayamohan Kallickal } 842c7acc5b8SJayamohan Kallickal 843c7acc5b8SJayamohan Kallickal int beiscsi_get_macaddr(char *buf, struct beiscsi_hba *phba) 844c7acc5b8SJayamohan Kallickal { 8450e43895eSMike Christie struct be_cmd_get_nic_conf_resp resp; 846c7acc5b8SJayamohan Kallickal int rc; 847c7acc5b8SJayamohan Kallickal 8486c83185aSJayamohan Kallickal if (phba->mac_addr_set) 849df5d0e6eSJohn Soni Jose return sysfs_format_mac(buf, phba->mac_address, ETH_ALEN); 850c7acc5b8SJayamohan Kallickal 8510e43895eSMike Christie memset(&resp, 0, sizeof(resp)); 8520e43895eSMike Christie rc = mgmt_get_nic_conf(phba, &resp); 8530e43895eSMike Christie if (rc) 854c7acc5b8SJayamohan Kallickal return rc; 855c7acc5b8SJayamohan Kallickal 8566c83185aSJayamohan Kallickal phba->mac_addr_set = true; 8570e43895eSMike Christie memcpy(phba->mac_address, resp.mac_address, ETH_ALEN); 8580e43895eSMike Christie return sysfs_format_mac(buf, phba->mac_address, ETH_ALEN); 8590e43895eSMike Christie } 8606733b39aSJayamohan Kallickal 8616733b39aSJayamohan Kallickal /** 8626733b39aSJayamohan Kallickal * beiscsi_conn_get_stats - get the iscsi stats 8636733b39aSJayamohan Kallickal * @cls_conn: pointer to iscsi cls conn 8646733b39aSJayamohan Kallickal * @stats: pointer to iscsi_stats structure 8656733b39aSJayamohan Kallickal * 8666733b39aSJayamohan Kallickal * returns iscsi stats 8676733b39aSJayamohan Kallickal */ 8686733b39aSJayamohan Kallickal void beiscsi_conn_get_stats(struct iscsi_cls_conn *cls_conn, 8696733b39aSJayamohan Kallickal struct iscsi_stats *stats) 8706733b39aSJayamohan Kallickal { 8716733b39aSJayamohan Kallickal struct iscsi_conn *conn = cls_conn->dd_data; 87299bc5d55SJohn Soni Jose struct beiscsi_hba *phba = NULL; 8736733b39aSJayamohan Kallickal 87499bc5d55SJohn Soni Jose phba = ((struct beiscsi_conn *)conn->dd_data)->phba; 87599bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, 87699bc5d55SJohn Soni Jose "BS_%d : In beiscsi_conn_get_stats\n"); 87799bc5d55SJohn Soni Jose 8786733b39aSJayamohan Kallickal stats->txdata_octets = conn->txdata_octets; 8796733b39aSJayamohan Kallickal stats->rxdata_octets = conn->rxdata_octets; 8806733b39aSJayamohan Kallickal stats->dataout_pdus = conn->dataout_pdus_cnt; 8816733b39aSJayamohan Kallickal stats->scsirsp_pdus = conn->scsirsp_pdus_cnt; 8826733b39aSJayamohan Kallickal stats->scsicmd_pdus = conn->scsicmd_pdus_cnt; 8836733b39aSJayamohan Kallickal stats->datain_pdus = conn->datain_pdus_cnt; 8846733b39aSJayamohan Kallickal stats->tmfrsp_pdus = conn->tmfrsp_pdus_cnt; 8856733b39aSJayamohan Kallickal stats->tmfcmd_pdus = conn->tmfcmd_pdus_cnt; 8866733b39aSJayamohan Kallickal stats->r2t_pdus = conn->r2t_pdus_cnt; 8876733b39aSJayamohan Kallickal stats->digest_err = 0; 8886733b39aSJayamohan Kallickal stats->timeout_err = 0; 8896733b39aSJayamohan Kallickal stats->custom_length = 0; 8906733b39aSJayamohan Kallickal strcpy(stats->custom[0].desc, "eh_abort_cnt"); 8916733b39aSJayamohan Kallickal stats->custom[0].value = conn->eh_abort_cnt; 8926733b39aSJayamohan Kallickal } 8936733b39aSJayamohan Kallickal 8946733b39aSJayamohan Kallickal /** 8956733b39aSJayamohan Kallickal * beiscsi_set_params_for_offld - get the parameters for offload 8966733b39aSJayamohan Kallickal * @beiscsi_conn: pointer to beiscsi_conn 8976733b39aSJayamohan Kallickal * @params: pointer to offload_params structure 8986733b39aSJayamohan Kallickal */ 8996733b39aSJayamohan Kallickal static void beiscsi_set_params_for_offld(struct beiscsi_conn *beiscsi_conn, 9006733b39aSJayamohan Kallickal struct beiscsi_offload_params *params) 9016733b39aSJayamohan Kallickal { 9026733b39aSJayamohan Kallickal struct iscsi_conn *conn = beiscsi_conn->conn; 9036733b39aSJayamohan Kallickal struct iscsi_session *session = conn->session; 9046733b39aSJayamohan Kallickal 9056733b39aSJayamohan Kallickal AMAP_SET_BITS(struct amap_beiscsi_offload_params, max_burst_length, 9066733b39aSJayamohan Kallickal params, session->max_burst); 9076733b39aSJayamohan Kallickal AMAP_SET_BITS(struct amap_beiscsi_offload_params, 9086733b39aSJayamohan Kallickal max_send_data_segment_length, params, 9096733b39aSJayamohan Kallickal conn->max_xmit_dlength); 9106733b39aSJayamohan Kallickal AMAP_SET_BITS(struct amap_beiscsi_offload_params, first_burst_length, 9116733b39aSJayamohan Kallickal params, session->first_burst); 9126733b39aSJayamohan Kallickal AMAP_SET_BITS(struct amap_beiscsi_offload_params, erl, params, 9136733b39aSJayamohan Kallickal session->erl); 9146733b39aSJayamohan Kallickal AMAP_SET_BITS(struct amap_beiscsi_offload_params, dde, params, 9156733b39aSJayamohan Kallickal conn->datadgst_en); 9166733b39aSJayamohan Kallickal AMAP_SET_BITS(struct amap_beiscsi_offload_params, hde, params, 9176733b39aSJayamohan Kallickal conn->hdrdgst_en); 9186733b39aSJayamohan Kallickal AMAP_SET_BITS(struct amap_beiscsi_offload_params, ir2t, params, 9196733b39aSJayamohan Kallickal session->initial_r2t_en); 9206733b39aSJayamohan Kallickal AMAP_SET_BITS(struct amap_beiscsi_offload_params, imd, params, 9216733b39aSJayamohan Kallickal session->imm_data_en); 922acb9693cSJohn Soni Jose AMAP_SET_BITS(struct amap_beiscsi_offload_params, 923acb9693cSJohn Soni Jose data_seq_inorder, params, 924acb9693cSJohn Soni Jose session->dataseq_inorder_en); 925acb9693cSJohn Soni Jose AMAP_SET_BITS(struct amap_beiscsi_offload_params, 926acb9693cSJohn Soni Jose pdu_seq_inorder, params, 927acb9693cSJohn Soni Jose session->pdu_inorder_en); 928acb9693cSJohn Soni Jose AMAP_SET_BITS(struct amap_beiscsi_offload_params, max_r2t, params, 929acb9693cSJohn Soni Jose session->max_r2t); 9306733b39aSJayamohan Kallickal AMAP_SET_BITS(struct amap_beiscsi_offload_params, exp_statsn, params, 9316733b39aSJayamohan Kallickal (conn->exp_statsn - 1)); 9327331613eSJayamohan Kallickal AMAP_SET_BITS(struct amap_beiscsi_offload_params, 9337331613eSJayamohan Kallickal max_recv_data_segment_length, params, 9347331613eSJayamohan Kallickal conn->max_recv_dlength); 9357331613eSJayamohan Kallickal 9366733b39aSJayamohan Kallickal } 9376733b39aSJayamohan Kallickal 9386733b39aSJayamohan Kallickal /** 9396733b39aSJayamohan Kallickal * beiscsi_conn_start - offload of session to chip 9406733b39aSJayamohan Kallickal * @cls_conn: pointer to beiscsi_conn 9416733b39aSJayamohan Kallickal */ 9426733b39aSJayamohan Kallickal int beiscsi_conn_start(struct iscsi_cls_conn *cls_conn) 9436733b39aSJayamohan Kallickal { 9446733b39aSJayamohan Kallickal struct iscsi_conn *conn = cls_conn->dd_data; 9456733b39aSJayamohan Kallickal struct beiscsi_conn *beiscsi_conn = conn->dd_data; 9466733b39aSJayamohan Kallickal struct beiscsi_endpoint *beiscsi_ep; 9476733b39aSJayamohan Kallickal struct beiscsi_offload_params params; 9486733b39aSJayamohan Kallickal 94999bc5d55SJohn Soni Jose beiscsi_log(beiscsi_conn->phba, KERN_INFO, 95099bc5d55SJohn Soni Jose BEISCSI_LOG_CONFIG, 95199bc5d55SJohn Soni Jose "BS_%d : In beiscsi_conn_start\n"); 95299bc5d55SJohn Soni Jose 9536733b39aSJayamohan Kallickal memset(¶ms, 0, sizeof(struct beiscsi_offload_params)); 9546733b39aSJayamohan Kallickal beiscsi_ep = beiscsi_conn->ep; 9556733b39aSJayamohan Kallickal if (!beiscsi_ep) 95699bc5d55SJohn Soni Jose beiscsi_log(beiscsi_conn->phba, KERN_ERR, 95799bc5d55SJohn Soni Jose BEISCSI_LOG_CONFIG, 95899bc5d55SJohn Soni Jose "BS_%d : In beiscsi_conn_start , no beiscsi_ep\n"); 9596733b39aSJayamohan Kallickal 9606733b39aSJayamohan Kallickal beiscsi_conn->login_in_progress = 0; 9616733b39aSJayamohan Kallickal beiscsi_set_params_for_offld(beiscsi_conn, ¶ms); 9626733b39aSJayamohan Kallickal beiscsi_offload_connection(beiscsi_conn, ¶ms); 9636733b39aSJayamohan Kallickal iscsi_conn_start(cls_conn); 9646733b39aSJayamohan Kallickal return 0; 9656733b39aSJayamohan Kallickal } 9666733b39aSJayamohan Kallickal 9676733b39aSJayamohan Kallickal /** 9686733b39aSJayamohan Kallickal * beiscsi_get_cid - Allocate a cid 9696733b39aSJayamohan Kallickal * @phba: The phba instance 9706733b39aSJayamohan Kallickal */ 9716733b39aSJayamohan Kallickal static int beiscsi_get_cid(struct beiscsi_hba *phba) 9726733b39aSJayamohan Kallickal { 9730a3db7c0SJayamohan Kallickal unsigned short cid = 0xFFFF, cid_from_ulp; 9740a3db7c0SJayamohan Kallickal struct ulp_cid_info *cid_info = NULL; 9750a3db7c0SJayamohan Kallickal uint16_t cid_avlbl_ulp0, cid_avlbl_ulp1; 9766733b39aSJayamohan Kallickal 9770a3db7c0SJayamohan Kallickal /* Find the ULP which has more CID available */ 9780a3db7c0SJayamohan Kallickal cid_avlbl_ulp0 = (phba->cid_array_info[BEISCSI_ULP0]) ? 9790a3db7c0SJayamohan Kallickal BEISCSI_ULP0_AVLBL_CID(phba) : 0; 9800a3db7c0SJayamohan Kallickal cid_avlbl_ulp1 = (phba->cid_array_info[BEISCSI_ULP1]) ? 9810a3db7c0SJayamohan Kallickal BEISCSI_ULP1_AVLBL_CID(phba) : 0; 9820a3db7c0SJayamohan Kallickal cid_from_ulp = (cid_avlbl_ulp0 > cid_avlbl_ulp1) ? 9830a3db7c0SJayamohan Kallickal BEISCSI_ULP0 : BEISCSI_ULP1; 9840a3db7c0SJayamohan Kallickal 9850a3db7c0SJayamohan Kallickal if (test_bit(cid_from_ulp, (void *)&phba->fw_config.ulp_supported)) { 9860a3db7c0SJayamohan Kallickal cid_info = phba->cid_array_info[cid_from_ulp]; 9870a3db7c0SJayamohan Kallickal if (!cid_info->avlbl_cids) 9886733b39aSJayamohan Kallickal return cid; 9896733b39aSJayamohan Kallickal 9900a3db7c0SJayamohan Kallickal cid = cid_info->cid_array[cid_info->cid_alloc++]; 9910a3db7c0SJayamohan Kallickal 9920a3db7c0SJayamohan Kallickal if (cid_info->cid_alloc == BEISCSI_GET_CID_COUNT( 9930a3db7c0SJayamohan Kallickal phba, cid_from_ulp)) 9940a3db7c0SJayamohan Kallickal cid_info->cid_alloc = 0; 9950a3db7c0SJayamohan Kallickal 9960a3db7c0SJayamohan Kallickal cid_info->avlbl_cids--; 9970a3db7c0SJayamohan Kallickal } 9986733b39aSJayamohan Kallickal return cid; 9996733b39aSJayamohan Kallickal } 10006733b39aSJayamohan Kallickal 10016733b39aSJayamohan Kallickal /** 1002fa95d206SMike Christie * beiscsi_put_cid - Free the cid 1003fa95d206SMike Christie * @phba: The phba for which the cid is being freed 1004fa95d206SMike Christie * @cid: The cid to free 1005fa95d206SMike Christie */ 1006fa95d206SMike Christie static void beiscsi_put_cid(struct beiscsi_hba *phba, unsigned short cid) 1007fa95d206SMike Christie { 10080a3db7c0SJayamohan Kallickal uint16_t cid_post_ulp; 10090a3db7c0SJayamohan Kallickal struct hwi_controller *phwi_ctrlr; 10100a3db7c0SJayamohan Kallickal struct hwi_wrb_context *pwrb_context; 10110a3db7c0SJayamohan Kallickal struct ulp_cid_info *cid_info = NULL; 10120a3db7c0SJayamohan Kallickal uint16_t cri_index = BE_GET_CRI_FROM_CID(cid); 10130a3db7c0SJayamohan Kallickal 10140a3db7c0SJayamohan Kallickal phwi_ctrlr = phba->phwi_ctrlr; 10150a3db7c0SJayamohan Kallickal pwrb_context = &phwi_ctrlr->wrb_context[cri_index]; 10160a3db7c0SJayamohan Kallickal cid_post_ulp = pwrb_context->ulp_num; 10170a3db7c0SJayamohan Kallickal 10180a3db7c0SJayamohan Kallickal cid_info = phba->cid_array_info[cid_post_ulp]; 10190a3db7c0SJayamohan Kallickal cid_info->avlbl_cids++; 10200a3db7c0SJayamohan Kallickal 10210a3db7c0SJayamohan Kallickal cid_info->cid_array[cid_info->cid_free++] = cid; 10220a3db7c0SJayamohan Kallickal if (cid_info->cid_free == BEISCSI_GET_CID_COUNT(phba, cid_post_ulp)) 10230a3db7c0SJayamohan Kallickal cid_info->cid_free = 0; 1024fa95d206SMike Christie } 1025fa95d206SMike Christie 1026fa95d206SMike Christie /** 1027fa95d206SMike Christie * beiscsi_free_ep - free endpoint 1028fa95d206SMike Christie * @ep: pointer to iscsi endpoint structure 1029fa95d206SMike Christie */ 1030fa95d206SMike Christie static void beiscsi_free_ep(struct beiscsi_endpoint *beiscsi_ep) 1031fa95d206SMike Christie { 1032fa95d206SMike Christie struct beiscsi_hba *phba = beiscsi_ep->phba; 103343f388b0SJayamohan Kallickal struct beiscsi_conn *beiscsi_conn; 1034fa95d206SMike Christie 1035fa95d206SMike Christie beiscsi_put_cid(phba, beiscsi_ep->ep_cid); 1036fa95d206SMike Christie beiscsi_ep->phba = NULL; 1037a7909b39SJayamohan Kallickal phba->ep_array[BE_GET_CRI_FROM_CID 1038a7909b39SJayamohan Kallickal (beiscsi_ep->ep_cid)] = NULL; 103943f388b0SJayamohan Kallickal 104043f388b0SJayamohan Kallickal /** 104143f388b0SJayamohan Kallickal * Check if any connection resource allocated by driver 104243f388b0SJayamohan Kallickal * is to be freed.This case occurs when target redirection 104343f388b0SJayamohan Kallickal * or connection retry is done. 104443f388b0SJayamohan Kallickal **/ 104543f388b0SJayamohan Kallickal if (!beiscsi_ep->conn) 104643f388b0SJayamohan Kallickal return; 104743f388b0SJayamohan Kallickal 104843f388b0SJayamohan Kallickal beiscsi_conn = beiscsi_ep->conn; 104943f388b0SJayamohan Kallickal if (beiscsi_conn->login_in_progress) { 10504a4a11b9SJayamohan Kallickal beiscsi_free_mgmt_task_handles(beiscsi_conn, 10514a4a11b9SJayamohan Kallickal beiscsi_conn->task); 105243f388b0SJayamohan Kallickal beiscsi_conn->login_in_progress = 0; 105343f388b0SJayamohan Kallickal } 1054fa95d206SMike Christie } 1055fa95d206SMike Christie 1056fa95d206SMike Christie /** 10576733b39aSJayamohan Kallickal * beiscsi_open_conn - Ask FW to open a TCP connection 10586733b39aSJayamohan Kallickal * @ep: endpoint to be used 10596733b39aSJayamohan Kallickal * @src_addr: The source IP address 10606733b39aSJayamohan Kallickal * @dst_addr: The Destination IP address 10616733b39aSJayamohan Kallickal * 10626733b39aSJayamohan Kallickal * Asks the FW to open a TCP connection 10636733b39aSJayamohan Kallickal */ 10646733b39aSJayamohan Kallickal static int beiscsi_open_conn(struct iscsi_endpoint *ep, 10656733b39aSJayamohan Kallickal struct sockaddr *src_addr, 10666733b39aSJayamohan Kallickal struct sockaddr *dst_addr, int non_blocking) 10676733b39aSJayamohan Kallickal { 10686733b39aSJayamohan Kallickal struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; 10696733b39aSJayamohan Kallickal struct beiscsi_hba *phba = beiscsi_ep->phba; 1070756d29c8SJayamohan Kallickal struct tcp_connect_and_offload_out *ptcpcnct_out; 10713cbb7a74SJayamohan Kallickal struct be_dma_mem nonemb_cmd; 1072e175defeSJohn Soni Jose unsigned int tag; 1073d3ad2bb3SJayamohan Kallickal int ret = -ENOMEM; 10746733b39aSJayamohan Kallickal 107599bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, 107699bc5d55SJohn Soni Jose "BS_%d : In beiscsi_open_conn\n"); 107799bc5d55SJohn Soni Jose 10786733b39aSJayamohan Kallickal beiscsi_ep->ep_cid = beiscsi_get_cid(phba); 10796733b39aSJayamohan Kallickal if (beiscsi_ep->ep_cid == 0xFFFF) { 108099bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 108199bc5d55SJohn Soni Jose "BS_%d : No free cid available\n"); 10826733b39aSJayamohan Kallickal return ret; 10836733b39aSJayamohan Kallickal } 108499bc5d55SJohn Soni Jose 108599bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, 108699bc5d55SJohn Soni Jose "BS_%d : In beiscsi_open_conn, ep_cid=%d\n", 10876733b39aSJayamohan Kallickal beiscsi_ep->ep_cid); 108899bc5d55SJohn Soni Jose 1089a7909b39SJayamohan Kallickal phba->ep_array[BE_GET_CRI_FROM_CID 1090a7909b39SJayamohan Kallickal (beiscsi_ep->ep_cid)] = ep; 10916733b39aSJayamohan Kallickal 10926733b39aSJayamohan Kallickal beiscsi_ep->cid_vld = 0; 10933cbb7a74SJayamohan Kallickal nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, 10943cbb7a74SJayamohan Kallickal sizeof(struct tcp_connect_and_offload_in), 10953cbb7a74SJayamohan Kallickal &nonemb_cmd.dma); 10963cbb7a74SJayamohan Kallickal if (nonemb_cmd.va == NULL) { 109799bc5d55SJohn Soni Jose 109899bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 109999bc5d55SJohn Soni Jose "BS_%d : Failed to allocate memory for" 110099bc5d55SJohn Soni Jose " mgmt_open_connection\n"); 110199bc5d55SJohn Soni Jose 1102a7909b39SJayamohan Kallickal beiscsi_free_ep(beiscsi_ep); 11033cbb7a74SJayamohan Kallickal return -ENOMEM; 11043cbb7a74SJayamohan Kallickal } 11053cbb7a74SJayamohan Kallickal nonemb_cmd.size = sizeof(struct tcp_connect_and_offload_in); 11063cbb7a74SJayamohan Kallickal memset(nonemb_cmd.va, 0, nonemb_cmd.size); 11073cbb7a74SJayamohan Kallickal tag = mgmt_open_connection(phba, dst_addr, beiscsi_ep, &nonemb_cmd); 11081e234bbbSJayamohan Kallickal if (tag <= 0) { 110999bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 111099bc5d55SJohn Soni Jose "BS_%d : mgmt_open_connection Failed for cid=%d\n", 1111756d29c8SJayamohan Kallickal beiscsi_ep->ep_cid); 111299bc5d55SJohn Soni Jose 11133cbb7a74SJayamohan Kallickal pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, 11143cbb7a74SJayamohan Kallickal nonemb_cmd.va, nonemb_cmd.dma); 1115a7909b39SJayamohan Kallickal beiscsi_free_ep(beiscsi_ep); 11161f92638fSJayamohan Kallickal return -EAGAIN; 1117756d29c8SJayamohan Kallickal } 1118e175defeSJohn Soni Jose 11191e234bbbSJayamohan Kallickal ret = beiscsi_mccq_compl(phba, tag, NULL, nonemb_cmd.va); 1120e175defeSJohn Soni Jose if (ret) { 112199bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, 112299bc5d55SJohn Soni Jose BEISCSI_LOG_CONFIG | BEISCSI_LOG_MBOX, 1123e175defeSJohn Soni Jose "BS_%d : mgmt_open_connection Failed"); 112499bc5d55SJohn Soni Jose 11253cbb7a74SJayamohan Kallickal pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, 11263cbb7a74SJayamohan Kallickal nonemb_cmd.va, nonemb_cmd.dma); 1127a7909b39SJayamohan Kallickal beiscsi_free_ep(beiscsi_ep); 1128a7909b39SJayamohan Kallickal return -EBUSY; 1129e175defeSJohn Soni Jose } 1130756d29c8SJayamohan Kallickal 11311e234bbbSJayamohan Kallickal ptcpcnct_out = (struct tcp_connect_and_offload_out *)nonemb_cmd.va; 1132756d29c8SJayamohan Kallickal beiscsi_ep = ep->dd_data; 1133756d29c8SJayamohan Kallickal beiscsi_ep->fw_handle = ptcpcnct_out->connection_handle; 1134756d29c8SJayamohan Kallickal beiscsi_ep->cid_vld = 1; 113599bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, 113699bc5d55SJohn Soni Jose "BS_%d : mgmt_open_connection Success\n"); 1137e175defeSJohn Soni Jose 11383cbb7a74SJayamohan Kallickal pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size, 11393cbb7a74SJayamohan Kallickal nonemb_cmd.va, nonemb_cmd.dma); 1140756d29c8SJayamohan Kallickal return 0; 11416733b39aSJayamohan Kallickal } 11426733b39aSJayamohan Kallickal 11436733b39aSJayamohan Kallickal /** 11446733b39aSJayamohan Kallickal * beiscsi_ep_connect - Ask chip to create TCP Conn 11456733b39aSJayamohan Kallickal * @scsi_host: Pointer to scsi_host structure 11466733b39aSJayamohan Kallickal * @dst_addr: The IP address of Target 11476733b39aSJayamohan Kallickal * @non_blocking: blocking or non-blocking call 11486733b39aSJayamohan Kallickal * 11496733b39aSJayamohan Kallickal * This routines first asks chip to create a connection and then allocates an EP 11506733b39aSJayamohan Kallickal */ 11516733b39aSJayamohan Kallickal struct iscsi_endpoint * 11526733b39aSJayamohan Kallickal beiscsi_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr, 11536733b39aSJayamohan Kallickal int non_blocking) 11546733b39aSJayamohan Kallickal { 11556733b39aSJayamohan Kallickal struct beiscsi_hba *phba; 11566733b39aSJayamohan Kallickal struct beiscsi_endpoint *beiscsi_ep; 11576733b39aSJayamohan Kallickal struct iscsi_endpoint *ep; 11586733b39aSJayamohan Kallickal int ret; 11596733b39aSJayamohan Kallickal 11606733b39aSJayamohan Kallickal if (shost) 11616733b39aSJayamohan Kallickal phba = iscsi_host_priv(shost); 11626733b39aSJayamohan Kallickal else { 11636733b39aSJayamohan Kallickal ret = -ENXIO; 116499bc5d55SJohn Soni Jose printk(KERN_ERR 116599bc5d55SJohn Soni Jose "beiscsi_ep_connect shost is NULL\n"); 11666733b39aSJayamohan Kallickal return ERR_PTR(ret); 11676733b39aSJayamohan Kallickal } 1168bfead3b2SJayamohan Kallickal 1169cf6e3c64SJayamohan Kallickal if (beiscsi_error(phba)) { 1170cf6e3c64SJayamohan Kallickal ret = -EIO; 1171cf6e3c64SJayamohan Kallickal beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, 1172cf6e3c64SJayamohan Kallickal "BS_%d : The FW state Not Stable!!!\n"); 1173cf6e3c64SJayamohan Kallickal return ERR_PTR(ret); 1174cf6e3c64SJayamohan Kallickal } 1175cf6e3c64SJayamohan Kallickal 11765dc1c416SJayamohan Kallickal if (phba->state != BE_ADAPTER_UP) { 1177bfead3b2SJayamohan Kallickal ret = -EBUSY; 11788359c79bSJohn Soni Jose beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, 11798359c79bSJohn Soni Jose "BS_%d : The Adapter Port state is Down!!!\n"); 1180bfead3b2SJayamohan Kallickal return ERR_PTR(ret); 1181bfead3b2SJayamohan Kallickal } 1182bfead3b2SJayamohan Kallickal 11836733b39aSJayamohan Kallickal ep = iscsi_create_endpoint(sizeof(struct beiscsi_endpoint)); 11846733b39aSJayamohan Kallickal if (!ep) { 11856733b39aSJayamohan Kallickal ret = -ENOMEM; 11866733b39aSJayamohan Kallickal return ERR_PTR(ret); 11876733b39aSJayamohan Kallickal } 11886733b39aSJayamohan Kallickal 11896733b39aSJayamohan Kallickal beiscsi_ep = ep->dd_data; 11906733b39aSJayamohan Kallickal beiscsi_ep->phba = phba; 1191c2462288SJayamohan Kallickal beiscsi_ep->openiscsi_ep = ep; 1192f5ed7bd4SJayamohan Kallickal ret = beiscsi_open_conn(ep, NULL, dst_addr, non_blocking); 1193f5ed7bd4SJayamohan Kallickal if (ret) { 119499bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 119599bc5d55SJohn Soni Jose "BS_%d : Failed in beiscsi_open_conn\n"); 11966733b39aSJayamohan Kallickal goto free_ep; 11976733b39aSJayamohan Kallickal } 11986733b39aSJayamohan Kallickal 11996733b39aSJayamohan Kallickal return ep; 12006733b39aSJayamohan Kallickal 12016733b39aSJayamohan Kallickal free_ep: 1202fa95d206SMike Christie iscsi_destroy_endpoint(ep); 12036733b39aSJayamohan Kallickal return ERR_PTR(ret); 12046733b39aSJayamohan Kallickal } 12056733b39aSJayamohan Kallickal 12066733b39aSJayamohan Kallickal /** 12076733b39aSJayamohan Kallickal * beiscsi_ep_poll - Poll to see if connection is established 12086733b39aSJayamohan Kallickal * @ep: endpoint to be used 12096733b39aSJayamohan Kallickal * @timeout_ms: timeout specified in millisecs 12106733b39aSJayamohan Kallickal * 12116733b39aSJayamohan Kallickal * Poll to see if TCP connection established 12126733b39aSJayamohan Kallickal */ 12136733b39aSJayamohan Kallickal int beiscsi_ep_poll(struct iscsi_endpoint *ep, int timeout_ms) 12146733b39aSJayamohan Kallickal { 12156733b39aSJayamohan Kallickal struct beiscsi_endpoint *beiscsi_ep = ep->dd_data; 12166733b39aSJayamohan Kallickal 121799bc5d55SJohn Soni Jose beiscsi_log(beiscsi_ep->phba, KERN_INFO, BEISCSI_LOG_CONFIG, 121899bc5d55SJohn Soni Jose "BS_%d : In beiscsi_ep_poll\n"); 121999bc5d55SJohn Soni Jose 12206733b39aSJayamohan Kallickal if (beiscsi_ep->cid_vld == 1) 12216733b39aSJayamohan Kallickal return 1; 12226733b39aSJayamohan Kallickal else 12236733b39aSJayamohan Kallickal return 0; 12246733b39aSJayamohan Kallickal } 12256733b39aSJayamohan Kallickal 12266733b39aSJayamohan Kallickal /** 12276733b39aSJayamohan Kallickal * beiscsi_close_conn - Upload the connection 12286733b39aSJayamohan Kallickal * @ep: The iscsi endpoint 12296733b39aSJayamohan Kallickal * @flag: The type of connection closure 12306733b39aSJayamohan Kallickal */ 1231c2462288SJayamohan Kallickal static int beiscsi_close_conn(struct beiscsi_endpoint *beiscsi_ep, int flag) 12326733b39aSJayamohan Kallickal { 12336733b39aSJayamohan Kallickal int ret = 0; 1234756d29c8SJayamohan Kallickal unsigned int tag; 12356733b39aSJayamohan Kallickal struct beiscsi_hba *phba = beiscsi_ep->phba; 12366733b39aSJayamohan Kallickal 1237756d29c8SJayamohan Kallickal tag = mgmt_upload_connection(phba, beiscsi_ep->ep_cid, flag); 1238756d29c8SJayamohan Kallickal if (!tag) { 123999bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, 124099bc5d55SJohn Soni Jose "BS_%d : upload failed for cid 0x%x\n", 12416733b39aSJayamohan Kallickal beiscsi_ep->ep_cid); 124299bc5d55SJohn Soni Jose 1243d3ad2bb3SJayamohan Kallickal ret = -EAGAIN; 12446733b39aSJayamohan Kallickal } 1245e175defeSJohn Soni Jose 1246e175defeSJohn Soni Jose ret = beiscsi_mccq_compl(phba, tag, NULL, NULL); 12476733b39aSJayamohan Kallickal return ret; 12486733b39aSJayamohan Kallickal } 12496733b39aSJayamohan Kallickal 12506733b39aSJayamohan Kallickal /** 12516733b39aSJayamohan Kallickal * beiscsi_unbind_conn_to_cid - Unbind the beiscsi_conn from phba conn table 12526733b39aSJayamohan Kallickal * @phba: The phba instance 12536733b39aSJayamohan Kallickal * @cid: The cid to free 12546733b39aSJayamohan Kallickal */ 12556733b39aSJayamohan Kallickal static int beiscsi_unbind_conn_to_cid(struct beiscsi_hba *phba, 12566733b39aSJayamohan Kallickal unsigned int cid) 12576733b39aSJayamohan Kallickal { 1258a7909b39SJayamohan Kallickal uint16_t cri_index = BE_GET_CRI_FROM_CID(cid); 1259a7909b39SJayamohan Kallickal 1260a7909b39SJayamohan Kallickal if (phba->conn_table[cri_index]) 1261a7909b39SJayamohan Kallickal phba->conn_table[cri_index] = NULL; 12626733b39aSJayamohan Kallickal else { 126399bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, 126499bc5d55SJohn Soni Jose "BS_%d : Connection table Not occupied.\n"); 12656733b39aSJayamohan Kallickal return -EINVAL; 12666733b39aSJayamohan Kallickal } 12676733b39aSJayamohan Kallickal return 0; 12686733b39aSJayamohan Kallickal } 12696733b39aSJayamohan Kallickal 12706733b39aSJayamohan Kallickal /** 1271fa95d206SMike Christie * beiscsi_ep_disconnect - Tears down the TCP connection 1272fa95d206SMike Christie * @ep: endpoint to be used 1273fa95d206SMike Christie * 1274fa95d206SMike Christie * Tears down the TCP connection 12756733b39aSJayamohan Kallickal */ 1276fa95d206SMike Christie void beiscsi_ep_disconnect(struct iscsi_endpoint *ep) 12776733b39aSJayamohan Kallickal { 1278fa95d206SMike Christie struct beiscsi_conn *beiscsi_conn; 12796733b39aSJayamohan Kallickal struct beiscsi_endpoint *beiscsi_ep; 1280fa95d206SMike Christie struct beiscsi_hba *phba; 1281756d29c8SJayamohan Kallickal unsigned int tag; 12820a513dd8SJohn Soni Jose uint8_t mgmt_invalidate_flag, tcp_upload_flag; 12836733b39aSJayamohan Kallickal unsigned short savecfg_flag = CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH; 12846733b39aSJayamohan Kallickal 1285fa95d206SMike Christie beiscsi_ep = ep->dd_data; 1286fa95d206SMike Christie phba = beiscsi_ep->phba; 128799bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, 128899bc5d55SJohn Soni Jose "BS_%d : In beiscsi_ep_disconnect for ep_cid = %d\n", 1289fa95d206SMike Christie beiscsi_ep->ep_cid); 1290fa95d206SMike Christie 12910a513dd8SJohn Soni Jose if (beiscsi_ep->conn) { 1292fa95d206SMike Christie beiscsi_conn = beiscsi_ep->conn; 1293fa95d206SMike Christie iscsi_suspend_queue(beiscsi_conn->conn); 12940a513dd8SJohn Soni Jose mgmt_invalidate_flag = ~BEISCSI_NO_RST_ISSUE; 12950a513dd8SJohn Soni Jose tcp_upload_flag = CONNECTION_UPLOAD_GRACEFUL; 12960a513dd8SJohn Soni Jose } else { 12970a513dd8SJohn Soni Jose mgmt_invalidate_flag = BEISCSI_NO_RST_ISSUE; 12980a513dd8SJohn Soni Jose tcp_upload_flag = CONNECTION_UPLOAD_ABORT; 12990a513dd8SJohn Soni Jose } 1300fa95d206SMike Christie 1301756d29c8SJayamohan Kallickal tag = mgmt_invalidate_connection(phba, beiscsi_ep, 13020a513dd8SJohn Soni Jose beiscsi_ep->ep_cid, 13030a513dd8SJohn Soni Jose mgmt_invalidate_flag, 13046733b39aSJayamohan Kallickal savecfg_flag); 1305756d29c8SJayamohan Kallickal if (!tag) { 130699bc5d55SJohn Soni Jose beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 13070a513dd8SJohn Soni Jose "BS_%d : mgmt_invalidate_connection Failed for cid=%d\n", 13086733b39aSJayamohan Kallickal beiscsi_ep->ep_cid); 13096733b39aSJayamohan Kallickal } 1310fa95d206SMike Christie 1311e175defeSJohn Soni Jose beiscsi_mccq_compl(phba, tag, NULL, NULL); 13120a513dd8SJohn Soni Jose beiscsi_close_conn(beiscsi_ep, tcp_upload_flag); 1313c2462288SJayamohan Kallickal beiscsi_free_ep(beiscsi_ep); 13146733b39aSJayamohan Kallickal beiscsi_unbind_conn_to_cid(phba, beiscsi_ep->ep_cid); 1315fa95d206SMike Christie iscsi_destroy_endpoint(beiscsi_ep->openiscsi_ep); 13166733b39aSJayamohan Kallickal } 13173128c6c7SMike Christie 1318587a1f16SAl Viro umode_t be2iscsi_attr_is_visible(int param_type, int param) 13193128c6c7SMike Christie { 13203128c6c7SMike Christie switch (param_type) { 13210e43895eSMike Christie case ISCSI_NET_PARAM: 13220e43895eSMike Christie switch (param) { 13230e43895eSMike Christie case ISCSI_NET_PARAM_IFACE_ENABLE: 13240e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_ADDR: 13250e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_SUBNET: 13260e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_BOOTPROTO: 13270e43895eSMike Christie case ISCSI_NET_PARAM_IPV4_GW: 13280e43895eSMike Christie case ISCSI_NET_PARAM_IPV6_ADDR: 13296f72238eSJohn Soni Jose case ISCSI_NET_PARAM_VLAN_ID: 13306f72238eSJohn Soni Jose case ISCSI_NET_PARAM_VLAN_PRIORITY: 13316f72238eSJohn Soni Jose case ISCSI_NET_PARAM_VLAN_ENABLED: 13320e43895eSMike Christie return S_IRUGO; 13330e43895eSMike Christie default: 13340e43895eSMike Christie return 0; 13350e43895eSMike Christie } 1336f27fb2efSMike Christie case ISCSI_HOST_PARAM: 1337f27fb2efSMike Christie switch (param) { 1338f27fb2efSMike Christie case ISCSI_HOST_PARAM_HWADDRESS: 1339c62eef0dSJohn Soni Jose case ISCSI_HOST_PARAM_INITIATOR_NAME: 1340c62eef0dSJohn Soni Jose case ISCSI_HOST_PARAM_PORT_STATE: 1341c62eef0dSJohn Soni Jose case ISCSI_HOST_PARAM_PORT_SPEED: 1342f27fb2efSMike Christie return S_IRUGO; 1343f27fb2efSMike Christie default: 1344f27fb2efSMike Christie return 0; 1345f27fb2efSMike Christie } 13463128c6c7SMike Christie case ISCSI_PARAM: 13473128c6c7SMike Christie switch (param) { 13483128c6c7SMike Christie case ISCSI_PARAM_MAX_RECV_DLENGTH: 13493128c6c7SMike Christie case ISCSI_PARAM_MAX_XMIT_DLENGTH: 13503128c6c7SMike Christie case ISCSI_PARAM_HDRDGST_EN: 13513128c6c7SMike Christie case ISCSI_PARAM_DATADGST_EN: 13523128c6c7SMike Christie case ISCSI_PARAM_CONN_ADDRESS: 13533128c6c7SMike Christie case ISCSI_PARAM_CONN_PORT: 13543128c6c7SMike Christie case ISCSI_PARAM_EXP_STATSN: 13553128c6c7SMike Christie case ISCSI_PARAM_PERSISTENT_ADDRESS: 13563128c6c7SMike Christie case ISCSI_PARAM_PERSISTENT_PORT: 13573128c6c7SMike Christie case ISCSI_PARAM_PING_TMO: 13583128c6c7SMike Christie case ISCSI_PARAM_RECV_TMO: 13591d063c17SMike Christie case ISCSI_PARAM_INITIAL_R2T_EN: 13601d063c17SMike Christie case ISCSI_PARAM_MAX_R2T: 13611d063c17SMike Christie case ISCSI_PARAM_IMM_DATA_EN: 13621d063c17SMike Christie case ISCSI_PARAM_FIRST_BURST: 13631d063c17SMike Christie case ISCSI_PARAM_MAX_BURST: 13641d063c17SMike Christie case ISCSI_PARAM_PDU_INORDER_EN: 13651d063c17SMike Christie case ISCSI_PARAM_DATASEQ_INORDER_EN: 13661d063c17SMike Christie case ISCSI_PARAM_ERL: 13671d063c17SMike Christie case ISCSI_PARAM_TARGET_NAME: 13681d063c17SMike Christie case ISCSI_PARAM_TPGT: 13691d063c17SMike Christie case ISCSI_PARAM_USERNAME: 13701d063c17SMike Christie case ISCSI_PARAM_PASSWORD: 13711d063c17SMike Christie case ISCSI_PARAM_USERNAME_IN: 13721d063c17SMike Christie case ISCSI_PARAM_PASSWORD_IN: 13731d063c17SMike Christie case ISCSI_PARAM_FAST_ABORT: 13741d063c17SMike Christie case ISCSI_PARAM_ABORT_TMO: 13751d063c17SMike Christie case ISCSI_PARAM_LU_RESET_TMO: 13761d063c17SMike Christie case ISCSI_PARAM_IFACE_NAME: 13771d063c17SMike Christie case ISCSI_PARAM_INITIATOR_NAME: 13783128c6c7SMike Christie return S_IRUGO; 13793128c6c7SMike Christie default: 13803128c6c7SMike Christie return 0; 13813128c6c7SMike Christie } 13823128c6c7SMike Christie } 13833128c6c7SMike Christie 13843128c6c7SMike Christie return 0; 13853128c6c7SMike Christie } 1386