···1122+1 Release Date : Sun May 14 22:49:52 PDT 2006 - Sumant Patro <Sumant.Patro@lsil.com>33+2 Current Version : 00.00.03.0144+3 Older Version : 00.00.02.0455+66+i. Added support for ZCR controller.77+88+ New device id 0x413 added.99+1010+ii. Bug fix : Disable controller interrupt before firing INIT cmd to FW.1111+1212+ Interrupt is enabled after required initialization is over.1313+ This is done to ensure that driver is ready to handle interrupts when1414+ it is generated by the controller.1515+1616+ -Sumant Patro <Sumant.Patro@lsil.com>1717+2181 Release Date : Wed Feb 03 14:31:44 PST 2006 - Sumant Patro <Sumant.Patro@lsil.com>3192 Current Version : 00.00.02.044203 Older Version : 00.00.02.04
+17-121
drivers/infiniband/ulp/iser/iscsi_iser.c
···437437}438438439439static int440440-iscsi_iser_conn_set_param(struct iscsi_cls_conn *cls_conn,441441- enum iscsi_param param, uint32_t value)440440+iscsi_iser_set_param(struct iscsi_cls_conn *cls_conn,441441+ enum iscsi_param param, char *buf, int buflen)442442{443443- struct iscsi_conn *conn = cls_conn->dd_data;444444- struct iscsi_session *session = conn->session;445445-446446- spin_lock_bh(&session->lock);447447- if (conn->c_stage != ISCSI_CONN_INITIAL_STAGE &&448448- conn->stop_stage != STOP_CONN_RECOVER) {449449- printk(KERN_ERR "iscsi_iser: can not change parameter [%d]\n",450450- param);451451- spin_unlock_bh(&session->lock);452452- return 0;453453- }454454- spin_unlock_bh(&session->lock);443443+ int value;455444456445 switch (param) {457446 case ISCSI_PARAM_MAX_RECV_DLENGTH:458447 /* TBD */459448 break;460460- case ISCSI_PARAM_MAX_XMIT_DLENGTH:461461- conn->max_xmit_dlength = value;462462- break;463449 case ISCSI_PARAM_HDRDGST_EN:450450+ sscanf(buf, "%d", &value);464451 if (value) {465452 printk(KERN_ERR "DataDigest wasn't negotiated to None");466453 return -EPROTO;467454 }468455 break;469456 case ISCSI_PARAM_DATADGST_EN:457457+ sscanf(buf, "%d", &value);470458 if (value) {471459 printk(KERN_ERR "DataDigest wasn't negotiated to None");472460 return -EPROTO;473461 }474462 break;475475- case ISCSI_PARAM_INITIAL_R2T_EN:476476- session->initial_r2t_en = value;477477- break;478478- case ISCSI_PARAM_IMM_DATA_EN:479479- session->imm_data_en = value;480480- break;481481- case ISCSI_PARAM_FIRST_BURST:482482- session->first_burst = value;483483- break;484484- case ISCSI_PARAM_MAX_BURST:485485- session->max_burst = value;486486- break;487487- case ISCSI_PARAM_PDU_INORDER_EN:488488- session->pdu_inorder_en = value;489489- break;490490- case ISCSI_PARAM_DATASEQ_INORDER_EN:491491- session->dataseq_inorder_en = value;492492- break;493493- case ISCSI_PARAM_ERL:494494- session->erl = value;495495- break;496463 case ISCSI_PARAM_IFMARKER_EN:464464+ sscanf(buf, "%d", &value);497465 if (value) {498466 printk(KERN_ERR "IFMarker wasn't negotiated to No");499467 return -EPROTO;500468 }501469 break;502470 case ISCSI_PARAM_OFMARKER_EN:471471+ sscanf(buf, "%d", &value);503472 if (value) {504473 printk(KERN_ERR "OFMarker wasn't negotiated to No");505474 return -EPROTO;506475 }507476 break;508477 default:509509- break;478478+ return iscsi_set_param(cls_conn, param, buf, buflen);510479 }511480512481 return 0;513482}514514-515515-static int516516-iscsi_iser_session_get_param(struct iscsi_cls_session *cls_session,517517- enum iscsi_param param, uint32_t *value)518518-{519519- struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);520520- struct iscsi_session *session = iscsi_hostdata(shost->hostdata);521521-522522- switch (param) {523523- case ISCSI_PARAM_INITIAL_R2T_EN:524524- *value = session->initial_r2t_en;525525- break;526526- case ISCSI_PARAM_MAX_R2T:527527- *value = session->max_r2t;528528- break;529529- case ISCSI_PARAM_IMM_DATA_EN:530530- *value = session->imm_data_en;531531- break;532532- case ISCSI_PARAM_FIRST_BURST:533533- *value = session->first_burst;534534- break;535535- case ISCSI_PARAM_MAX_BURST:536536- *value = session->max_burst;537537- break;538538- case ISCSI_PARAM_PDU_INORDER_EN:539539- *value = session->pdu_inorder_en;540540- break;541541- case ISCSI_PARAM_DATASEQ_INORDER_EN:542542- *value = session->dataseq_inorder_en;543543- break;544544- case ISCSI_PARAM_ERL:545545- *value = session->erl;546546- break;547547- case ISCSI_PARAM_IFMARKER_EN:548548- *value = 0;549549- break;550550- case ISCSI_PARAM_OFMARKER_EN:551551- *value = 0;552552- break;553553- default:554554- return ISCSI_ERR_PARAM_NOT_FOUND;555555- }556556-557557- return 0;558558-}559559-560560-static int561561-iscsi_iser_conn_get_param(struct iscsi_cls_conn *cls_conn,562562- enum iscsi_param param, uint32_t *value)563563-{564564- struct iscsi_conn *conn = cls_conn->dd_data;565565-566566- switch(param) {567567- case ISCSI_PARAM_MAX_RECV_DLENGTH:568568- *value = conn->max_recv_dlength;569569- break;570570- case ISCSI_PARAM_MAX_XMIT_DLENGTH:571571- *value = conn->max_xmit_dlength;572572- break;573573- case ISCSI_PARAM_HDRDGST_EN:574574- *value = 0;575575- break;576576- case ISCSI_PARAM_DATADGST_EN:577577- *value = 0;578578- break;579579- /*case ISCSI_PARAM_TARGET_RECV_DLENGTH:580580- *value = conn->target_recv_dlength;581581- break;582582- case ISCSI_PARAM_INITIATOR_RECV_DLENGTH:583583- *value = conn->initiator_recv_dlength;584584- break;*/585585- default:586586- return ISCSI_ERR_PARAM_NOT_FOUND;587587- }588588-589589- return 0;590590-}591591-592483593484static void594485iscsi_iser_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *stats)···592701 ISCSI_FIRST_BURST |593702 ISCSI_MAX_BURST |594703 ISCSI_PDU_INORDER_EN |595595- ISCSI_DATASEQ_INORDER_EN,704704+ ISCSI_DATASEQ_INORDER_EN |705705+ ISCSI_EXP_STATSN |706706+ ISCSI_PERSISTENT_PORT |707707+ ISCSI_PERSISTENT_ADDRESS |708708+ ISCSI_TARGET_NAME |709709+ ISCSI_TPGT,596710 .host_template = &iscsi_iser_sht,597711 .conndata_size = sizeof(struct iscsi_conn),598712 .max_lun = ISCSI_ISER_MAX_LUN,···609713 .create_conn = iscsi_iser_conn_create,610714 .bind_conn = iscsi_iser_conn_bind,611715 .destroy_conn = iscsi_iser_conn_destroy,612612- .set_param = iscsi_iser_conn_set_param,613613- .get_conn_param = iscsi_iser_conn_get_param,614614- .get_session_param = iscsi_iser_session_get_param,716716+ .set_param = iscsi_iser_set_param,717717+ .get_conn_param = iscsi_conn_get_param,718718+ .get_session_param = iscsi_session_get_param,615719 .start_conn = iscsi_iser_conn_start,616720 .stop_conn = iscsi_conn_stop,617721 /* these are called as part of conn recovery */
+5
drivers/message/fusion/Makefile
···3333# For mptfc:3434#CFLAGS_mptfc.o += -DMPT_DEBUG_FC35353636+# For mptsas:3737+#CFLAGS_mptsas.o += -DMPT_DEBUG_SAS3838+#CFLAGS_mptsas.o += -DMPT_DEBUG_SAS_WIDE3939+4040+3641#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-} LSI_LOGIC37423843obj-$(CONFIG_FUSION_SPI) += mptbase.o mptscsih.o mptspi.o
-89
drivers/message/fusion/lsi/fc_log.h
···11-/*22- * Copyright (c) 2000-2001 LSI Logic Corporation. All rights reserved.33- *44- * NAME: fc_log.h55- * SUMMARY: MPI IocLogInfo definitions for the SYMFC9xx chips66- * DESCRIPTION: Contains the enumerated list of values that may be returned77- * in the IOCLogInfo field of a MPI Default Reply Message.88- *99- * CREATION DATE: 6/02/20001010- * ID: $Id: fc_log.h,v 4.6 2001/07/26 14:41:33 sschremm Exp $1111- */1212-1313-1414-/*1515- * MpiIocLogInfo_t enum1616- *1717- * These 32 bit values are used in the IOCLogInfo field of the MPI reply1818- * messages.1919- * The value is 0xabcccccc where2020- * a = The type of log info as per the MPI spec. Since these codes are2121- * all for Fibre Channel this value will always be 2.2222- * b = Specifies a subclass of the firmware where2323- * 0 = FCP Initiator2424- * 1 = FCP Target2525- * 2 = LAN2626- * 3 = MPI Message Layer2727- * 4 = FC Link2828- * 5 = Context Manager2929- * 6 = Invalid Field Offset3030- * 7 = State Change Info3131- * all others are reserved for future use3232- * c = A specific value within the subclass.3333- *3434- * NOTE: Any new values should be added to the end of each subclass so that the3535- * codes remain consistent across firmware releases.3636- */3737-typedef enum _MpiIocLogInfoFc3838-{3939- MPI_IOCLOGINFO_FC_INIT_BASE = 0x20000000,4040- MPI_IOCLOGINFO_FC_INIT_ERROR_OUT_OF_ORDER_FRAME = 0x20000001, /* received an out of order frame - unsupported */4141- MPI_IOCLOGINFO_FC_INIT_ERROR_BAD_START_OF_FRAME = 0x20000002, /* Bad Rx Frame, bad start of frame primative */4242- MPI_IOCLOGINFO_FC_INIT_ERROR_BAD_END_OF_FRAME = 0x20000003, /* Bad Rx Frame, bad end of frame primative */4343- MPI_IOCLOGINFO_FC_INIT_ERROR_OVER_RUN = 0x20000004, /* Bad Rx Frame, overrun */4444- MPI_IOCLOGINFO_FC_INIT_ERROR_RX_OTHER = 0x20000005, /* Other errors caught by IOC which require retries */4545- MPI_IOCLOGINFO_FC_INIT_ERROR_SUBPROC_DEAD = 0x20000006, /* Main processor could not initialize sub-processor */4646- MPI_IOCLOGINFO_FC_INIT_ERROR_RX_OVERRUN = 0x20000007, /* Scatter Gather overrun */4747- MPI_IOCLOGINFO_FC_INIT_ERROR_RX_BAD_STATUS = 0x20000008, /* Receiver detected context mismatch via invalid header */4848- MPI_IOCLOGINFO_FC_INIT_ERROR_RX_UNEXPECTED_FRAME= 0x20000009, /* CtxMgr detected unsupported frame type */4949- MPI_IOCLOGINFO_FC_INIT_ERROR_LINK_FAILURE = 0x2000000A, /* Link failure occurred */5050- MPI_IOCLOGINFO_FC_INIT_ERROR_TX_TIMEOUT = 0x2000000B, /* Transmitter timeout error */5151-5252- MPI_IOCLOGINFO_FC_TARGET_BASE = 0x21000000,5353- MPI_IOCLOGINFO_FC_TARGET_NO_PDISC = 0x21000001, /* not sent because we are waiting for a PDISC from the initiator */5454- MPI_IOCLOGINFO_FC_TARGET_NO_LOGIN = 0x21000002, /* not sent because we are not logged in to the remote node */5555- MPI_IOCLOGINFO_FC_TARGET_DOAR_KILLED_BY_LIP = 0x21000003, /* Data Out, Auto Response, not sent due to a LIP */5656- MPI_IOCLOGINFO_FC_TARGET_DIAR_KILLED_BY_LIP = 0x21000004, /* Data In, Auto Response, not sent due to a LIP */5757- MPI_IOCLOGINFO_FC_TARGET_DIAR_MISSING_DATA = 0x21000005, /* Data In, Auto Response, missing data frames */5858- MPI_IOCLOGINFO_FC_TARGET_DONR_KILLED_BY_LIP = 0x21000006, /* Data Out, No Response, not sent due to a LIP */5959- MPI_IOCLOGINFO_FC_TARGET_WRSP_KILLED_BY_LIP = 0x21000007, /* Auto-response after a write not sent due to a LIP */6060- MPI_IOCLOGINFO_FC_TARGET_DINR_KILLED_BY_LIP = 0x21000008, /* Data In, No Response, not completed due to a LIP */6161- MPI_IOCLOGINFO_FC_TARGET_DINR_MISSING_DATA = 0x21000009, /* Data In, No Response, missing data frames */6262- MPI_IOCLOGINFO_FC_TARGET_MRSP_KILLED_BY_LIP = 0x2100000a, /* Manual Response not sent due to a LIP */6363- MPI_IOCLOGINFO_FC_TARGET_NO_CLASS_3 = 0x2100000b, /* not sent because remote node does not support Class 3 */6464- MPI_IOCLOGINFO_FC_TARGET_LOGIN_NOT_VALID = 0x2100000c, /* not sent because login to remote node not validated */6565- MPI_IOCLOGINFO_FC_TARGET_FROM_OUTBOUND = 0x2100000e, /* cleared from the outbound queue after a logout */6666- MPI_IOCLOGINFO_FC_TARGET_WAITING_FOR_DATA_IN = 0x2100000f, /* cleared waiting for data after a logout */6767-6868- MPI_IOCLOGINFO_FC_LAN_BASE = 0x22000000,6969- MPI_IOCLOGINFO_FC_LAN_TRANS_SGL_MISSING = 0x22000001, /* Transaction Context Sgl Missing */7070- MPI_IOCLOGINFO_FC_LAN_TRANS_WRONG_PLACE = 0x22000002, /* Transaction Context found before an EOB */7171- MPI_IOCLOGINFO_FC_LAN_TRANS_RES_BITS_SET = 0x22000003, /* Transaction Context value has reserved bits set */7272- MPI_IOCLOGINFO_FC_LAN_WRONG_SGL_FLAG = 0x22000004, /* Invalid SGL Flags */7373-7474- MPI_IOCLOGINFO_FC_MSG_BASE = 0x23000000,7575-7676- MPI_IOCLOGINFO_FC_LINK_BASE = 0x24000000,7777- MPI_IOCLOGINFO_FC_LINK_LOOP_INIT_TIMEOUT = 0x24000001, /* Loop initialization timed out */7878- MPI_IOCLOGINFO_FC_LINK_ALREADY_INITIALIZED = 0x24000002, /* Another system controller already initialized the loop */7979- MPI_IOCLOGINFO_FC_LINK_LINK_NOT_ESTABLISHED = 0x24000003, /* Not synchronized to signal or still negotiating (possible cable problem) */8080- MPI_IOCLOGINFO_FC_LINK_CRC_ERROR = 0x24000004, /* CRC check detected error on received frame */8181-8282- MPI_IOCLOGINFO_FC_CTX_BASE = 0x25000000,8383-8484- MPI_IOCLOGINFO_FC_INVALID_FIELD_BYTE_OFFSET = 0x26000000, /* The lower 24 bits give the byte offset of the field in the request message that is invalid */8585- MPI_IOCLOGINFO_FC_INVALID_FIELD_MAX_OFFSET = 0x26ffffff,8686-8787- MPI_IOCLOGINFO_FC_STATE_CHANGE = 0x27000000 /* The lower 24 bits give additional information concerning state change */8888-8989-} MpiIocLogInfoFc_t;
+3-2
drivers/message/fusion/lsi/mpi.h
···66 * Title: MPI Message independent structures and definitions77 * Creation Date: July 27, 200088 *99- * mpi.h Version: 01.05.1099+ * mpi.h Version: 01.05.111010 *1111 * Version History1212 * ---------------···7676 * Added EEDP IOCStatus codes.7777 * 08-03-05 01.05.09 Bumped MPI_HEADER_VERSION_UNIT.7878 * 08-30-05 01.05.10 Added 2 new IOCStatus codes for Target.7979+ * 03-27-06 01.05.11 Bumped MPI_HEADER_VERSION_UNIT.7980 * --------------------------------------------------------------------------8081 */8182···107106/* Note: The major versions of 0xe0 through 0xff are reserved */108107109108/* versioning for this MPI header set */110110-#define MPI_HEADER_VERSION_UNIT (0x0C)109109+#define MPI_HEADER_VERSION_UNIT (0x0D)111110#define MPI_HEADER_VERSION_DEV (0x00)112111#define MPI_HEADER_VERSION_UNIT_MASK (0xFF00)113112#define MPI_HEADER_VERSION_UNIT_SHIFT (8)
···66 Copyright (c) 2000-2005 LSI Logic Corporation.7788 ---------------------------------------99- Header Set Release Version: 01.05.121010- Header Set Release Date: 08-30-0599+ Header Set Release Version: 01.05.131010+ Header Set Release Date: 03-27-061111 ---------------------------------------12121313 Filename Current version Prior version1414 ---------- --------------- -------------1515- mpi.h 01.05.10 01.05.091616- mpi_ioc.h 01.05.10 01.05.091717- mpi_cnfg.h 01.05.11 01.05.101818- mpi_init.h 01.05.06 01.05.061919- mpi_targ.h 01.05.05 01.05.051515+ mpi.h 01.05.11 01.05.101616+ mpi_ioc.h 01.05.11 01.05.101717+ mpi_cnfg.h 01.05.12 01.05.111818+ mpi_init.h 01.05.07 01.05.061919+ mpi_targ.h 01.05.06 01.05.052020 mpi_fc.h 01.05.01 01.05.012121 mpi_lan.h 01.05.01 01.05.012222 mpi_raid.h 01.05.02 01.05.022323 mpi_tool.h 01.05.03 01.05.032424 mpi_inb.h 01.05.01 01.05.012525- mpi_sas.h 01.05.02 01.05.012626- mpi_type.h 01.05.02 01.05.012727- mpi_history.txt 01.05.12 01.05.112525+ mpi_sas.h 01.05.03 01.05.022626+ mpi_type.h 01.05.02 01.05.022727+ mpi_history.txt 01.05.13 01.05.12282829293030 * Date Version Description···9393 * Added EEDP IOCStatus codes.9494 * 08-03-05 01.05.09 Bumped MPI_HEADER_VERSION_UNIT.9595 * 08-30-05 01.05.10 Added 2 new IOCStatus codes for Target.9696+ * 03-27-06 01.05.11 Bumped MPI_HEADER_VERSION_UNIT.9697 * --------------------------------------------------------------------------97989899mpi_ioc.h···171170 * Added new ReasonCode value for SAS Device Status Change172171 * event.173172 * Added new family code for FC949E.173173+ * 03-27-06 01.05.11 Added MPI_IOCFACTS_CAPABILITY_TLR.174174+ * Added additional Reason Codes and more event data fields175175+ * to EVENT_DATA_SAS_DEVICE_STATUS_CHANGE.176176+ * Added EVENT_DATA_SAS_BROADCAST_PRIMITIVE structure and177177+ * new event.178178+ * Added MPI_EVENT_SAS_SMP_ERROR and event data structure.179179+ * Added MPI_EVENT_SAS_INIT_DEVICE_STATUS_CHANGE and event180180+ * data structure.181181+ * Added MPI_EVENT_SAS_INIT_TABLE_OVERFLOW and event182182+ * data structure.183183+ * Added MPI_EXT_IMAGE_TYPE_INITIALIZATION.174184 * --------------------------------------------------------------------------175185176186mpi_cnfg.h···437425 * Added postpone SATA Init bit to SAS IO Unit Page 1438426 * ControlFlags.439427 * Changed LogEntry format for Log Page 0.428428+ * 03-27-06 01.05.12 Added two new Flags defines for Manufacturing Page 4.429429+ * Added Manufacturing Page 7.430430+ * Added MPI_IOCPAGE2_CAP_FLAGS_RAID_64_BIT_ADDRESSING.431431+ * Added IOC Page 6.432432+ * Added PrevBootDeviceForm field to CONFIG_PAGE_BIOS_2.433433+ * Added MaxLBAHigh field to RAID Volume Page 0.434434+ * Added Nvdata version fields to SAS IO Unit Page 0.435435+ * Added AdditionalControlFlags, MaxTargetPortConnectTime,436436+ * ReportDeviceMissingDelay, and IODeviceMissingDelay437437+ * fields to SAS IO Unit Page 1.440438 * --------------------------------------------------------------------------441439442440mpi_init.h···489467 * Added four new defines for SEP SlotStatus.490468 * 08-03-05 01.05.06 Fixed some MPI_SCSIIO32_MSGFLGS_ defines to make them491469 * unique in the first 32 characters.470470+ * 03-27-06 01.05.07 Added Task Management type of Clear ACA.492471 * --------------------------------------------------------------------------493472494473mpi_targ.h···534511 * 02-22-05 01.05.03 Changed a comment.535512 * 03-11-05 01.05.04 Removed TargetAssistExtended Request.536513 * 06-24-05 01.05.05 Added TargetAssistExtended structures and defines.514514+ * 03-27-06 01.05.06 Added a comment.537515 * --------------------------------------------------------------------------538516539517mpi_fc.h···634610 * 08-30-05 01.05.02 Added DeviceInfo bit for SEP.635611 * Added PrimFlags and Primitive field to SAS IO Unit636612 * Control request, and added a new operation code.613613+ * 03-27-06 01.05.03 Added Force Full Discovery, Transmit Port Select Signal,614614+ * and Remove Device operations to SAS IO Unit Control.615615+ * Added DevHandle field to SAS IO Unit Control request and616616+ * reply.637617 * --------------------------------------------------------------------------638618639619mpi_type.h···653625654626mpi_history.txt Parts list history655627656656-Filename 01.05.12 01.05.11 01.05.10 01.05.09657657----------- -------- -------- -------- --------658658-mpi.h 01.05.10 01.05.09 01.05.08 01.05.07659659-mpi_ioc.h 01.05.10 01.05.09 01.05.09 01.05.08660660-mpi_cnfg.h 01.05.11 01.05.10 01.05.09 01.05.08661661-mpi_init.h 01.05.06 01.05.06 01.05.05 01.05.04662662-mpi_targ.h 01.05.05 01.05.05 01.05.05 01.05.04663663-mpi_fc.h 01.05.01 01.05.01 01.05.01 01.05.01664664-mpi_lan.h 01.05.01 01.05.01 01.05.01 01.05.01665665-mpi_raid.h 01.05.02 01.05.02 01.05.02 01.05.02666666-mpi_tool.h 01.05.03 01.05.03 01.05.03 01.05.03667667-mpi_inb.h 01.05.01 01.05.01 01.05.01 01.05.01668668-mpi_sas.h 01.05.02 01.05.01 01.05.01 01.05.01669669-mpi_type.h 01.05.02 01.05.01 01.05.01 01.05.01628628+Filename 01.05.13 01.05.12 01.05.11 01.05.10 01.05.09629629+---------- -------- -------- -------- -------- --------630630+mpi.h 01.05.11 01.05.10 01.05.09 01.05.08 01.05.07631631+mpi_ioc.h 01.05.11 01.05.10 01.05.09 01.05.09 01.05.08632632+mpi_cnfg.h 01.05.12 01.05.11 01.05.10 01.05.09 01.05.08633633+mpi_init.h 01.05.07 01.05.06 01.05.06 01.05.05 01.05.04634634+mpi_targ.h 01.05.06 01.05.05 01.05.05 01.05.05 01.05.04635635+mpi_fc.h 01.05.01 01.05.01 01.05.01 01.05.01 01.05.01636636+mpi_lan.h 01.05.01 01.05.01 01.05.01 01.05.01 01.05.01637637+mpi_raid.h 01.05.02 01.05.02 01.05.02 01.05.02 01.05.02638638+mpi_tool.h 01.05.03 01.05.03 01.05.03 01.05.03 01.05.03639639+mpi_inb.h 01.05.01 01.05.01 01.05.01 01.05.01 01.05.01640640+mpi_sas.h 01.05.03 01.05.02 01.05.01 01.05.01 01.05.01641641+mpi_type.h 01.05.02 01.05.02 01.05.01 01.05.01 01.05.01670642671643Filename 01.05.08 01.05.07 01.05.06 01.05.05 01.05.04 01.05.03672644---------- -------- -------- -------- -------- -------- --------
+3-1
drivers/message/fusion/lsi/mpi_init.h
···66 * Title: MPI initiator mode messages and structures77 * Creation Date: June 8, 200088 *99- * mpi_init.h Version: 01.05.0699+ * mpi_init.h Version: 01.05.071010 *1111 * Version History1212 * ---------------···5252 * Added four new defines for SEP SlotStatus.5353 * 08-03-05 01.05.06 Fixed some MPI_SCSIIO32_MSGFLGS_ defines to make them5454 * unique in the first 32 characters.5555+ * 03-27-06 01.05.07 Added Task Management type of Clear ACA.5556 * --------------------------------------------------------------------------5657 */5758···428427#define MPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET (0x05)429428#define MPI_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET (0x06)430429#define MPI_SCSITASKMGMT_TASKTYPE_QUERY_TASK (0x07)430430+#define MPI_SCSITASKMGMT_TASKTYPE_CLEAR_ACA (0x08)431431432432/* MsgFlags bits */433433#define MPI_SCSITASKMGMT_MSGFLAGS_TARGET_RESET_OPTION (0x00)
+123-31
drivers/message/fusion/lsi/mpi_ioc.h
···66 * Title: MPI IOC, Port, Event, FW Download, and FW Upload messages77 * Creation Date: August 11, 200088 *99- * mpi_ioc.h Version: 01.05.1099+ * mpi_ioc.h Version: 01.05.111010 *1111 * Version History1212 * ---------------···8787 * Added new ReasonCode value for SAS Device Status Change8888 * event.8989 * Added new family code for FC949E.9090+ * 03-27-06 01.05.11 Added MPI_IOCFACTS_CAPABILITY_TLR.9191+ * Added additional Reason Codes and more event data fields9292+ * to EVENT_DATA_SAS_DEVICE_STATUS_CHANGE.9393+ * Added EVENT_DATA_SAS_BROADCAST_PRIMITIVE structure and9494+ * new event.9595+ * Added MPI_EVENT_SAS_SMP_ERROR and event data structure.9696+ * Added MPI_EVENT_SAS_INIT_DEVICE_STATUS_CHANGE and event9797+ * data structure.9898+ * Added MPI_EVENT_SAS_INIT_TABLE_OVERFLOW and event9999+ * data structure.100100+ * Added MPI_EXT_IMAGE_TYPE_INITIALIZATION.90101 * --------------------------------------------------------------------------91102 */92103···283272#define MPI_IOCFACTS_CAPABILITY_MULTICAST (0x00000100)284273#define MPI_IOCFACTS_CAPABILITY_SCSIIO32 (0x00000200)285274#define MPI_IOCFACTS_CAPABILITY_NO_SCSIIO16 (0x00000400)275275+#define MPI_IOCFACTS_CAPABILITY_TLR (0x00000800)286276287277288278/*****************************************************************************···460448461449/* Event */462450463463-#define MPI_EVENT_NONE (0x00000000)464464-#define MPI_EVENT_LOG_DATA (0x00000001)465465-#define MPI_EVENT_STATE_CHANGE (0x00000002)466466-#define MPI_EVENT_UNIT_ATTENTION (0x00000003)467467-#define MPI_EVENT_IOC_BUS_RESET (0x00000004)468468-#define MPI_EVENT_EXT_BUS_RESET (0x00000005)469469-#define MPI_EVENT_RESCAN (0x00000006)470470-#define MPI_EVENT_LINK_STATUS_CHANGE (0x00000007)471471-#define MPI_EVENT_LOOP_STATE_CHANGE (0x00000008)472472-#define MPI_EVENT_LOGOUT (0x00000009)473473-#define MPI_EVENT_EVENT_CHANGE (0x0000000A)474474-#define MPI_EVENT_INTEGRATED_RAID (0x0000000B)475475-#define MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE (0x0000000C)476476-#define MPI_EVENT_ON_BUS_TIMER_EXPIRED (0x0000000D)477477-#define MPI_EVENT_QUEUE_FULL (0x0000000E)478478-#define MPI_EVENT_SAS_DEVICE_STATUS_CHANGE (0x0000000F)479479-#define MPI_EVENT_SAS_SES (0x00000010)480480-#define MPI_EVENT_PERSISTENT_TABLE_FULL (0x00000011)481481-#define MPI_EVENT_SAS_PHY_LINK_STATUS (0x00000012)482482-#define MPI_EVENT_SAS_DISCOVERY_ERROR (0x00000013)483483-#define MPI_EVENT_IR_RESYNC_UPDATE (0x00000014)484484-#define MPI_EVENT_IR2 (0x00000015)485485-#define MPI_EVENT_SAS_DISCOVERY (0x00000016)486486-#define MPI_EVENT_LOG_ENTRY_ADDED (0x00000021)451451+#define MPI_EVENT_NONE (0x00000000)452452+#define MPI_EVENT_LOG_DATA (0x00000001)453453+#define MPI_EVENT_STATE_CHANGE (0x00000002)454454+#define MPI_EVENT_UNIT_ATTENTION (0x00000003)455455+#define MPI_EVENT_IOC_BUS_RESET (0x00000004)456456+#define MPI_EVENT_EXT_BUS_RESET (0x00000005)457457+#define MPI_EVENT_RESCAN (0x00000006)458458+#define MPI_EVENT_LINK_STATUS_CHANGE (0x00000007)459459+#define MPI_EVENT_LOOP_STATE_CHANGE (0x00000008)460460+#define MPI_EVENT_LOGOUT (0x00000009)461461+#define MPI_EVENT_EVENT_CHANGE (0x0000000A)462462+#define MPI_EVENT_INTEGRATED_RAID (0x0000000B)463463+#define MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE (0x0000000C)464464+#define MPI_EVENT_ON_BUS_TIMER_EXPIRED (0x0000000D)465465+#define MPI_EVENT_QUEUE_FULL (0x0000000E)466466+#define MPI_EVENT_SAS_DEVICE_STATUS_CHANGE (0x0000000F)467467+#define MPI_EVENT_SAS_SES (0x00000010)468468+#define MPI_EVENT_PERSISTENT_TABLE_FULL (0x00000011)469469+#define MPI_EVENT_SAS_PHY_LINK_STATUS (0x00000012)470470+#define MPI_EVENT_SAS_DISCOVERY_ERROR (0x00000013)471471+#define MPI_EVENT_IR_RESYNC_UPDATE (0x00000014)472472+#define MPI_EVENT_IR2 (0x00000015)473473+#define MPI_EVENT_SAS_DISCOVERY (0x00000016)474474+#define MPI_EVENT_SAS_BROADCAST_PRIMITIVE (0x00000017)475475+#define MPI_EVENT_SAS_INIT_DEVICE_STATUS_CHANGE (0x00000018)476476+#define MPI_EVENT_SAS_INIT_TABLE_OVERFLOW (0x00000019)477477+#define MPI_EVENT_SAS_SMP_ERROR (0x0000001A)478478+#define MPI_EVENT_LOG_ENTRY_ADDED (0x00000021)487479488480/* AckRequired field values */489481···574558 U8 PhyNum; /* 0Eh */575559 U8 Reserved1; /* 0Fh */576560 U64 SASAddress; /* 10h */561561+ U8 LUN[8]; /* 18h */562562+ U16 TaskTag; /* 20h */563563+ U16 Reserved2; /* 22h */577564} EVENT_DATA_SAS_DEVICE_STATUS_CHANGE,578565 MPI_POINTER PTR_EVENT_DATA_SAS_DEVICE_STATUS_CHANGE,579566 MpiEventDataSasDeviceStatusChange_t,580567 MPI_POINTER pMpiEventDataSasDeviceStatusChange_t;581568582569/* MPI SAS Device Status Change Event data ReasonCode values */583583-#define MPI_EVENT_SAS_DEV_STAT_RC_ADDED (0x03)584584-#define MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING (0x04)585585-#define MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA (0x05)586586-#define MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED (0x06)587587-#define MPI_EVENT_SAS_DEV_STAT_RC_UNSUPPORTED (0x07)588588-#define MPI_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET (0x08)570570+#define MPI_EVENT_SAS_DEV_STAT_RC_ADDED (0x03)571571+#define MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING (0x04)572572+#define MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA (0x05)573573+#define MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED (0x06)574574+#define MPI_EVENT_SAS_DEV_STAT_RC_UNSUPPORTED (0x07)575575+#define MPI_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET (0x08)576576+#define MPI_EVENT_SAS_DEV_STAT_RC_TASK_ABORT_INTERNAL (0x09)577577+#define MPI_EVENT_SAS_DEV_STAT_RC_ABORT_TASK_SET_INTERNAL (0x0A)578578+#define MPI_EVENT_SAS_DEV_STAT_RC_CLEAR_TASK_SET_INTERNAL (0x0B)579579+#define MPI_EVENT_SAS_DEV_STAT_RC_QUERY_TASK_INTERNAL (0x0C)589580590581591582/* SCSI Event data for Queue Full event */···765742} EVENT_DATA_SAS_SES, MPI_POINTER PTR_EVENT_DATA_SAS_SES,766743 MpiEventDataSasSes_t, MPI_POINTER pMpiEventDataSasSes_t;767744745745+/* SAS Broadcast Primitive Event data */746746+747747+typedef struct _EVENT_DATA_SAS_BROADCAST_PRIMITIVE748748+{749749+ U8 PhyNum; /* 00h */750750+ U8 Port; /* 01h */751751+ U8 PortWidth; /* 02h */752752+ U8 Primitive; /* 04h */753753+} EVENT_DATA_SAS_BROADCAST_PRIMITIVE,754754+ MPI_POINTER PTR_EVENT_DATA_SAS_BROADCAST_PRIMITIVE,755755+ MpiEventDataSasBroadcastPrimitive_t,756756+ MPI_POINTER pMpiEventDataSasBroadcastPrimitive_t;757757+758758+#define MPI_EVENT_PRIMITIVE_CHANGE (0x01)759759+#define MPI_EVENT_PRIMITIVE_EXPANDER (0x03)760760+#define MPI_EVENT_PRIMITIVE_RESERVED2 (0x04)761761+#define MPI_EVENT_PRIMITIVE_RESERVED3 (0x05)762762+#define MPI_EVENT_PRIMITIVE_RESERVED4 (0x06)763763+#define MPI_EVENT_PRIMITIVE_CHANGE0_RESERVED (0x07)764764+#define MPI_EVENT_PRIMITIVE_CHANGE1_RESERVED (0x08)765765+768766/* SAS Phy Link Status Event data */769767770768typedef struct _EVENT_DATA_SAS_PHY_LINK_STATUS···847803#define MPI_EVENT_DSCVRY_ERR_DS_TABLE_TO_TABLE (0x00000400)848804#define MPI_EVENT_DSCVRY_ERR_DS_MULTPL_PATHS (0x00000800)849805#define MPI_EVENT_DSCVRY_ERR_DS_MAX_SATA_TARGETS (0x00001000)806806+807807+/* SAS SMP Error Event data */808808+809809+typedef struct _EVENT_DATA_SAS_SMP_ERROR810810+{811811+ U8 Status; /* 00h */812812+ U8 Port; /* 01h */813813+ U8 SMPFunctionResult; /* 02h */814814+ U8 Reserved1; /* 03h */815815+ U64 SASAddress; /* 04h */816816+} EVENT_DATA_SAS_SMP_ERROR, MPI_POINTER PTR_EVENT_DATA_SAS_SMP_ERROR,817817+ MpiEventDataSasSmpError_t, MPI_POINTER pMpiEventDataSasSmpError_t;818818+819819+/* defines for the Status field of the SAS SMP Error event */820820+#define MPI_EVENT_SAS_SMP_FUNCTION_RESULT_VALID (0x00)821821+#define MPI_EVENT_SAS_SMP_CRC_ERROR (0x01)822822+#define MPI_EVENT_SAS_SMP_TIMEOUT (0x02)823823+#define MPI_EVENT_SAS_SMP_NO_DESTINATION (0x03)824824+#define MPI_EVENT_SAS_SMP_BAD_DESTINATION (0x04)825825+826826+/* SAS Initiator Device Status Change Event data */827827+828828+typedef struct _EVENT_DATA_SAS_INIT_DEV_STATUS_CHANGE829829+{830830+ U8 ReasonCode; /* 00h */831831+ U8 Port; /* 01h */832832+ U16 DevHandle; /* 02h */833833+ U64 SASAddress; /* 04h */834834+} EVENT_DATA_SAS_INIT_DEV_STATUS_CHANGE,835835+ MPI_POINTER PTR_EVENT_DATA_SAS_INIT_DEV_STATUS_CHANGE,836836+ MpiEventDataSasInitDevStatusChange_t,837837+ MPI_POINTER pMpiEventDataSasInitDevStatusChange_t;838838+839839+/* defines for the ReasonCode field of the SAS Initiator Device Status Change event */840840+#define MPI_EVENT_SAS_INIT_RC_ADDED (0x01)841841+842842+/* SAS Initiator Device Table Overflow Event data */843843+844844+typedef struct _EVENT_DATA_SAS_INIT_TABLE_OVERFLOW845845+{846846+ U8 MaxInit; /* 00h */847847+ U8 CurrentInit; /* 01h */848848+ U16 Reserved1; /* 02h */849849+} EVENT_DATA_SAS_INIT_TABLE_OVERFLOW,850850+ MPI_POINTER PTR_EVENT_DATA_SAS_INIT_TABLE_OVERFLOW,851851+ MpiEventDataSasInitTableOverflow_t,852852+ MPI_POINTER pMpiEventDataSasInitTableOverflow_t;850853851854852855/*****************************************************************************···11041013#define MPI_EXT_IMAGE_TYPE_FW (0x01)11051014#define MPI_EXT_IMAGE_TYPE_NVDATA (0x03)11061015#define MPI_EXT_IMAGE_TYPE_BOOTLOADER (0x04)10161016+#define MPI_EXT_IMAGE_TYPE_INITIALIZATION (0x05)1107101711081018#endif
+79-3
drivers/message/fusion/lsi/mpi_log_sas.h
···1313#ifndef IOPI_IOCLOGINFO_H_INCLUDED1414#define IOPI_IOCLOGINFO_H_INCLUDED15151616+#define SAS_LOGINFO_NEXUS_LOSS 0x311700001717+#define SAS_LOGINFO_MASK 0xFFFF000016181719/****************************************************************************/1820/* IOC LOGINFO defines, 0x00000000 - 0x0FFFFFFF */···5351#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_DNM (0x00030500) /* Device Not Mapped */5452#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_PERSIST (0x00030600) /* Persistent Page not found */5553#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_DEFAULT (0x00030700) /* Default Page not found */5454+5555+#define IOP_LOGINFO_CODE_DIAG_MSG_ERROR (0x00040000) /* Error handling diag msg - or'd with diag status */5656+5657#define IOP_LOGINFO_CODE_TASK_TERMINATED (0x00050000)57585859#define IOP_LOGINFO_CODE_ENCL_MGMT_READ_ACTION_ERR0R (0x00060001) /* Read Action not supported for SEP msg */···108103#define PL_LOGINFO_CODE_IO_EXECUTED (0x00140000)109104#define PL_LOGINFO_CODE_PERS_RESV_OUT_NOT_AFFIL_OWNER (0x00150000)110105#define PL_LOGINFO_CODE_OPEN_TXDMA_ABORT (0x00160000)106106+#define PL_LOGINFO_CODE_IO_DEVICE_MISSING_DELAY_RETRY (0x00170000)111107#define PL_LOGINFO_SUB_CODE_OPEN_FAILURE (0x00000100)112108#define PL_LOGINFO_SUB_CODE_OPEN_FAILURE_NO_DEST_TIMEOUT (0x00000101)113109#define PL_LOGINFO_SUB_CODE_OPEN_FAILURE_ORR_TIMEOUT (0x0000011A) /* Open Reject (Retry) Timeout */···171165/****************************************************************************/172166/* IR LOGINFO_CODE defines, valid if IOC_LOGINFO_ORIGINATOR = IR */173167/****************************************************************************/174174-#define IR_LOGINFO_CODE_UNUSED1 (0x00010000)175175-#define IR_LOGINFO_CODE_UNUSED2 (0x00020000)168168+#define IR_LOGINFO_RAID_ACTION_ERROR (0x00010000)169169+#define IR_LOGINFO_CODE_UNUSED2 (0x00020000)170170+171171+/* Amount of information passed down for Create Volume is too large */172172+#define IR_LOGINFO_VOLUME_CREATE_INVALID_LENGTH (0x00010001)173173+/* Creation of duplicate volume attempted (Bus/Target ID checked) */174174+#define IR_LOGINFO_VOLUME_CREATE_DUPLICATE (0x00010002)175175+/* Creation failed due to maximum number of supported volumes exceeded */176176+#define IR_LOGINFO_VOLUME_CREATE_NO_SLOTS (0x00010003)177177+/* Creation failed due to DMA error in trying to read from host */178178+#define IR_LOGINFO_VOLUME_CREATE_DMA_ERROR (0x00010004)179179+/* Creation failed due to invalid volume type passed down */180180+#define IR_LOGINFO_VOLUME_CREATE_INVALID_VOLUME_TYPE (0x00010005)181181+/* Creation failed due to error reading MFG Page 4 */182182+#define IR_LOGINFO_VOLUME_MFG_PAGE4_ERROR (0x00010006)183183+/* Creation failed when trying to create internal structures */184184+#define IR_LOGINFO_VOLUME_INTERNAL_CONFIG_STRUCTURE_ERROR (0x00010007)185185+186186+/* Activation failed due to trying to activate an already active volume */187187+#define IR_LOGINFO_VOLUME_ACTIVATING_AN_ACTIVE_VOLUME (0x00010010)188188+/* Activation failed due to trying to active unsupported volume type */189189+#define IR_LOGINFO_VOLUME_ACTIVATING_INVALID_VOLUME_TYPE (0x00010011)190190+/* Activation failed due to trying to active too many volumes */191191+#define IR_LOGINFO_VOLUME_ACTIVATING_TOO_MANY_VOLUMES (0x00010012)192192+/* Activation failed due to Volume ID in use already */193193+#define IR_LOGINFO_VOLUME_ACTIVATING_VOLUME_ID_IN_USE (0x00010013)194194+/* Activation failed call to activateVolume returned failure */195195+#define IR_LOGINFO_VOLUME_ACTIVATE_VOLUME_FAILED (0x00010014)196196+/* Activation failed trying to import the volume */197197+#define IR_LOGINFO_VOLUME_ACTIVATING_IMPORT_VOLUME_FAILED (0x00010015)198198+199199+/* Phys Disk failed, too many phys disks */200200+#define IR_LOGINFO_PHYSDISK_CREATE_TOO_MANY_DISKS (0x00010020)201201+/* Amount of information passed down for Create Pnysdisk is too large */202202+#define IR_LOGINFO_PHYSDISK_CREATE_INVALID_LENGTH (0x00010021)203203+/* Creation failed due to DMA error in trying to read from host */204204+#define IR_LOGINFO_PHYSDISK_CREATE_DMA_ERROR (0x00010022)205205+/* Creation failed due to invalid Bus TargetID passed down */206206+#define IR_LOGINFO_PHYSDISK_CREATE_BUS_TID_INVALID (0x00010023)207207+/* Creation failed due to error in creating RAID Phys Disk Config Page */208208+#define IR_LOGINFO_PHYSDISK_CREATE_CONFIG_PAGE_ERROR (0x00010024)209209+210210+211211+/* Compatibility Error : IR Disabled */212212+#define IR_LOGINFO_COMPAT_ERROR_RAID_DISABLED (0x00010030)213213+/* Compatibility Error : Inquiry Comand failed */214214+#define IR_LOGINFO_COMPAT_ERROR_INQUIRY_FAILED (0x00010031)215215+/* Compatibility Error : Device not direct access device */216216+#define IR_LOGINFO_COMPAT_ERROR_NOT_DIRECT_ACCESS (0x00010032)217217+/* Compatibility Error : Removable device found */218218+#define IR_LOGINFO_COMPAT_ERROR_REMOVABLE_FOUND (0x00010033)219219+/* Compatibility Error : Device SCSI Version not 2 or higher */220220+#define IR_LOGINFO_COMPAT_ERROR_NEED_SCSI_2_OR_HIGHER (0x00010034)221221+/* Compatibility Error : SATA device, 48 BIT LBA not supported */222222+#define IR_LOGINFO_COMPAT_ERROR_SATA_48BIT_LBA_NOT_SUPPORTED (0x00010035)223223+/* Compatibility Error : Device does not have 512 byte block sizes */224224+#define IR_LOGINFO_COMPAT_ERROR_DEVICE_NOT_512_BYTE_BLOCK (0x00010036)225225+/* Compatibility Error : Volume Type check failed */226226+#define IR_LOGINFO_COMPAT_ERROR_VOLUME_TYPE_CHECK_FAILED (0x00010037)227227+/* Compatibility Error : Volume Type is unsupported by FW */228228+#define IR_LOGINFO_COMPAT_ERROR_UNSUPPORTED_VOLUME_TYPE (0x00010038)229229+/* Compatibility Error : Disk drive too small for use in volume */230230+#define IR_LOGINFO_COMPAT_ERROR_DISK_TOO_SMALL (0x00010039)231231+/* Compatibility Error : Phys disk for Create Volume not found */232232+#define IR_LOGINFO_COMPAT_ERROR_PHYS_DISK_NOT_FOUND (0x0001003A)233233+/* Compatibility Error : membership count error, too many or too few disks for volume type */234234+#define IR_LOGINFO_COMPAT_ERROR_MEMBERSHIP_COUNT (0x0001003B)235235+/* Compatibility Error : Disk stripe sizes must be 64KB */236236+#define IR_LOGINFO_COMPAT_ERROR_NON_64K_STRIPE_SIZE (0x0001003C)237237+/* Compatibility Error : IME size limited to < 2TB */238238+#define IR_LOGINFO_COMPAT_ERROR_IME_VOL_NOT_CURRENTLY_SUPPORTED (0x0001003D)239239+176240177241/****************************************************************************/178178-/* Defines for convienence */242242+/* Defines for convenience */179243/****************************************************************************/180244#define IOC_LOGINFO_PREFIX_IOP ((MPI_IOCLOGINFO_TYPE_SAS << MPI_IOCLOGINFO_TYPE_SHIFT) | IOC_LOGINFO_ORIGINATOR_IOP)181245#define IOC_LOGINFO_PREFIX_PL ((MPI_IOCLOGINFO_TYPE_SAS << MPI_IOCLOGINFO_TYPE_SHIFT) | IOC_LOGINFO_ORIGINATOR_PL)
+10-3
drivers/message/fusion/lsi/mpi_sas.h
···66 * Title: MPI Serial Attached SCSI structures and definitions77 * Creation Date: August 19, 200488 *99- * mpi_sas.h Version: 01.05.0299+ * mpi_sas.h Version: 01.05.031010 *1111 * Version History1212 * ---------------···1717 * 08-30-05 01.05.02 Added DeviceInfo bit for SEP.1818 * Added PrimFlags and Primitive field to SAS IO Unit1919 * Control request, and added a new operation code.2020+ * 03-27-06 01.05.03 Added Force Full Discovery, Transmit Port Select Signal,2121+ * and Remove Device operations to SAS IO Unit Control.2222+ * Added DevHandle field to SAS IO Unit Control request and2323+ * reply.2024 * --------------------------------------------------------------------------2125 */2226···213209 U8 Reserved1; /* 01h */214210 U8 ChainOffset; /* 02h */215211 U8 Function; /* 03h */216216- U16 Reserved2; /* 04h */212212+ U16 DevHandle; /* 04h */217213 U8 Reserved3; /* 06h */218214 U8 MsgFlags; /* 07h */219215 U32 MsgContext; /* 08h */···235231#define MPI_SAS_OP_PHY_CLEAR_ERROR_LOG (0x08)236232#define MPI_SAS_OP_MAP_CURRENT (0x09)237233#define MPI_SAS_OP_SEND_PRIMITIVE (0x0A)234234+#define MPI_SAS_OP_FORCE_FULL_DISCOVERY (0x0B)235235+#define MPI_SAS_OP_TRANSMIT_PORT_SELECT_SIGNAL (0x0C)236236+#define MPI_SAS_OP_TRANSMIT_REMOVE_DEVICE (0x0D)238237239238/* values for the PrimFlags field */240239#define MPI_SAS_PRIMFLAGS_SINGLE (0x08)···252245 U8 Reserved1; /* 01h */253246 U8 MsgLength; /* 02h */254247 U8 Function; /* 03h */255255- U16 Reserved2; /* 04h */248248+ U16 DevHandle; /* 04h */256249 U8 Reserved3; /* 06h */257250 U8 MsgFlags; /* 07h */258251 U32 MsgContext; /* 08h */
···173173STATIC int NCR_700_host_reset(struct scsi_cmnd * SCpnt);174174STATIC void NCR_700_chip_setup(struct Scsi_Host *host);175175STATIC void NCR_700_chip_reset(struct Scsi_Host *host);176176+STATIC int NCR_700_slave_alloc(struct scsi_device *SDpnt);176177STATIC int NCR_700_slave_configure(struct scsi_device *SDpnt);177178STATIC void NCR_700_slave_destroy(struct scsi_device *SDpnt);178179static int NCR_700_change_queue_depth(struct scsi_device *SDpnt, int depth);···182181STATIC struct device_attribute *NCR_700_dev_attrs[];183182184183STATIC struct scsi_transport_template *NCR_700_transport_template = NULL;185185-186186-struct NCR_700_sense {187187- unsigned char cmnd[MAX_COMMAND_SIZE];188188-};189184190185static char *NCR_700_phase[] = {191186 "",···330333 tpnt->use_clustering = ENABLE_CLUSTERING;331334 tpnt->slave_configure = NCR_700_slave_configure;332335 tpnt->slave_destroy = NCR_700_slave_destroy;336336+ tpnt->slave_alloc = NCR_700_slave_alloc;333337 tpnt->change_queue_depth = NCR_700_change_queue_depth;334338 tpnt->change_queue_type = NCR_700_change_queue_type;335339···609611 struct NCR_700_command_slot *slot = 610612 (struct NCR_700_command_slot *)SCp->host_scribble;611613612612- NCR_700_unmap(hostdata, SCp, slot);614614+ dma_unmap_single(hostdata->dev, slot->pCmd,615615+ sizeof(SCp->cmnd), DMA_TO_DEVICE);613616 if (slot->flags == NCR_700_FLAG_AUTOSENSE) {614614- struct NCR_700_sense *sense = SCp->device->hostdata;617617+ char *cmnd = NCR_700_get_sense_cmnd(SCp->device);615618#ifdef NCR_700_DEBUG616619 printk(" ORIGINAL CMD %p RETURNED %d, new return is %d sense is\n",617620 SCp, SCp->cmnd[7], result);···623624 /* restore the old result if the request sense was624625 * successful */625626 if(result == 0)626626- result = sense->cmnd[7];627627+ result = cmnd[7];627628 } else628628- dma_unmap_single(hostdata->dev, slot->pCmd,629629- sizeof(SCp->cmnd), DMA_TO_DEVICE);629629+ NCR_700_unmap(hostdata, SCp, slot);630630631631 free_slot(slot, hostdata);632632#ifdef NCR_700_DEBUG···967969 status_byte(hostdata->status[0]) == COMMAND_TERMINATED) {968970 struct NCR_700_command_slot *slot =969971 (struct NCR_700_command_slot *)SCp->host_scribble;970970- if(SCp->cmnd[0] == REQUEST_SENSE) {972972+ if(slot->flags == NCR_700_FLAG_AUTOSENSE) {971973 /* OOPS: bad device, returning another972974 * contingent allegiance condition */973975 scmd_printk(KERN_ERR, SCp,974976 "broken device is looping in contingent allegiance: ignoring\n");975977 NCR_700_scsi_done(hostdata, SCp, hostdata->status[0]);976978 } else {977977- struct NCR_700_sense *sense = SCp->device->hostdata;979979+ char *cmnd =980980+ NCR_700_get_sense_cmnd(SCp->device);978981#ifdef NCR_DEBUG979982 scsi_print_command(SCp);980983 printk(" cmd %p has status %d, requesting sense\n",···993994 sizeof(SCp->cmnd),994995 DMA_TO_DEVICE);995996996996- sense->cmnd[0] = REQUEST_SENSE;997997- sense->cmnd[1] = (SCp->device->lun & 0x7) << 5;998998- sense->cmnd[2] = 0;999999- sense->cmnd[3] = 0;10001000- sense->cmnd[4] = sizeof(SCp->sense_buffer);10011001- sense->cmnd[5] = 0;997997+ cmnd[0] = REQUEST_SENSE;998998+ cmnd[1] = (SCp->device->lun & 0x7) << 5;999999+ cmnd[2] = 0;10001000+ cmnd[3] = 0;10011001+ cmnd[4] = sizeof(SCp->sense_buffer);10021002+ cmnd[5] = 0;10021003 /* Here's a quiet hack: the10031004 * REQUEST_SENSE command is six bytes,10041005 * so store a flag indicating that10051006 * this was an internal sense request10061007 * and the original status at the end10071008 * of the command */10081008- sense->cmnd[6] = NCR_700_INTERNAL_SENSE_MAGIC;10091009- sense->cmnd[7] = hostdata->status[0];10101010- slot->pCmd = dma_map_single(hostdata->dev, sense->cmnd, sizeof(sense->cmnd), DMA_TO_DEVICE);10091009+ cmnd[6] = NCR_700_INTERNAL_SENSE_MAGIC;10101010+ cmnd[7] = hostdata->status[0];10111011+ slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE);10111012 slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);10121013 slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | sizeof(SCp->sense_buffer));10131014 slot->SG[0].pAddr = bS_to_host(slot->dma_handle);···1529153015301531 /* clear all the negotiated parameters */15311532 __shost_for_each_device(SDp, host)15321532- SDp->hostdata = NULL;15331533+ NCR_700_clear_flag(SDp, ~0);1533153415341535 /* clear all the slots and their pending commands */15351536 for(i = 0; i < NCR_700_COMMAND_SLOTS_PER_HOST; i++) {···20342035 spi_flags(STp) |= NCR_700_DEV_PRINT_SYNC_NEGOTIATION;20352036}2036203720382038+STATIC int20392039+NCR_700_slave_alloc(struct scsi_device *SDp)20402040+{20412041+ SDp->hostdata = kzalloc(sizeof(struct NCR_700_Device_Parameters),20422042+ GFP_KERNEL);2037204320442044+ if (!SDp->hostdata)20452045+ return -ENOMEM;20462046+20472047+ return 0;20482048+}2038204920392050STATIC int20402051NCR_700_slave_configure(struct scsi_device *SDp)20412052{20422053 struct NCR_700_Host_Parameters *hostdata = 20432054 (struct NCR_700_Host_Parameters *)SDp->host->hostdata[0];20442044-20452045- SDp->hostdata = kmalloc(GFP_KERNEL, sizeof(struct NCR_700_sense));20462046-20472047- if (!SDp->hostdata)20482048- return -ENOMEM;2049205520502056 /* to do here: allocate memory; build a queue_full list */20512057 if(SDp->tagged_supported) {
+23-11
drivers/scsi/53c700.h
···1212#include <asm/io.h>13131414#include <scsi/scsi_device.h>1515-1515+#include <scsi/scsi_cmnd.h>16161717/* Turn on for general debugging---too verbose for normal use */1818#undef NCR_700_DEBUG···7676 #define SCRIPT_RETURN 0x900800007777};78787979-/* We use device->hostdata to store negotiated parameters. This is8080- * supposed to be a pointer to a device private area, but we cannot8181- * really use it as such since it will never be freed, so just use the8282- * 32 bits to cram the information. The SYNC negotiation sequence looks8383- * like:7979+struct NCR_700_Device_Parameters {8080+ /* space for creating a request sense command. Really, except8181+ * for the annoying SCSI-2 requirement for LUN information in8282+ * cmnd[1], this could be in static storage */8383+ unsigned char cmnd[MAX_COMMAND_SIZE];8484+ __u8 depth;8585+};8686+8787+8888+/* The SYNC negotiation sequence looks like:8489 * 8590 * If DEV_NEGOTIATED_SYNC not set, tack and SDTR message on to the8691 * initial identify for the device and set DEV_BEGIN_SYNC_NEGOTATION···10398#define NCR_700_DEV_BEGIN_SYNC_NEGOTIATION (1<<17)10499#define NCR_700_DEV_PRINT_SYNC_NEGOTIATION (1<<19)105100101101+static inline char *NCR_700_get_sense_cmnd(struct scsi_device *SDp)102102+{103103+ struct NCR_700_Device_Parameters *hostdata = SDp->hostdata;104104+105105+ return hostdata->cmnd;106106+}107107+106108static inline void107109NCR_700_set_depth(struct scsi_device *SDp, __u8 depth)108110{109109- long l = (long)SDp->hostdata;111111+ struct NCR_700_Device_Parameters *hostdata = SDp->hostdata;110112111111- l &= 0xffff00ff;112112- l |= 0xff00 & (depth << 8);113113- SDp->hostdata = (void *)l;113113+ hostdata->depth = depth;114114}115115static inline __u8116116NCR_700_get_depth(struct scsi_device *SDp)117117{118118- return ((((unsigned long)SDp->hostdata) & 0xff00)>>8);118118+ struct NCR_700_Device_Parameters *hostdata = SDp->hostdata;119119+120120+ return hostdata->depth;119121}120122static inline int121123NCR_700_is_flag_set(struct scsi_device *SDp, __u32 flag)
+1-25
drivers/scsi/aacraid/comminit.c
···9292 init->AdapterFibsPhysicalAddress = cpu_to_le32((u32)phys);9393 init->AdapterFibsSize = cpu_to_le32(fibsize);9494 init->AdapterFibAlign = cpu_to_le32(sizeof(struct hw_fib));9595- /* 9696- * number of 4k pages of host physical memory. The aacraid fw needs9797- * this number to be less than 4gb worth of pages. num_physpages is in9898- * system page units. New firmware doesn't have any issues with the9999- * mapping system, but older Firmware did, and had *troubles* dealing100100- * with the math overloading past 32 bits, thus we must limit this101101- * field.102102- *103103- * This assumes the memory is mapped zero->n, which isnt104104- * always true on real computers. It also has some slight problems105105- * with the GART on x86-64. I've btw never tried DMA from PCI space106106- * on this platform but don't be surprised if its problematic.107107- * [AK: something is very very wrong when a driver tests this symbol.108108- * Someone should figure out what the comment writer really meant here and fix109109- * the code. Or just remove that bad code. ]110110- */111111-#ifndef CONFIG_IOMMU112112- if ((num_physpages << (PAGE_SHIFT - 12)) <= AAC_MAX_HOSTPHYSMEMPAGES) {113113- init->HostPhysMemPages = 114114- cpu_to_le32(num_physpages << (PAGE_SHIFT-12));115115- } else 116116-#endif 117117- {118118- init->HostPhysMemPages = cpu_to_le32(AAC_MAX_HOSTPHYSMEMPAGES);119119- }9595+ init->HostPhysMemPages = cpu_to_le32(AAC_MAX_HOSTPHYSMEMPAGES);1209612197 init->InitFlags = 0;12298 if (dev->new_comm_interface) {
···535535 struct ibmvscsi_host_data *hostdata)536536{537537 u64 *crq_as_u64 = (u64 *) &evt_struct->crq;538538+ int request_status;538539 int rc;539540540541 /* If we have exhausted our request limit, just fail this request.···543542 * (such as task management requests) that the mid layer may think we544543 * can handle more requests (can_queue) when we actually can't545544 */546546- if ((evt_struct->crq.format == VIOSRP_SRP_FORMAT) &&547547- (atomic_dec_if_positive(&hostdata->request_limit) < 0))548548- goto send_error;545545+ if (evt_struct->crq.format == VIOSRP_SRP_FORMAT) {546546+ request_status =547547+ atomic_dec_if_positive(&hostdata->request_limit);548548+ /* If request limit was -1 when we started, it is now even549549+ * less than that550550+ */551551+ if (request_status < -1)552552+ goto send_error;553553+ /* Otherwise, if we have run out of requests */554554+ else if (request_status < 0)555555+ goto send_busy;556556+ }549557550558 /* Copy the IU into the transfer area */551559 *evt_struct->xfer_iu = evt_struct->iu;···577567578568 return 0;579569580580- send_error:570570+ send_busy:581571 unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev);582572583573 free_event_struct(&hostdata->pool, evt_struct);584574 return SCSI_MLQUEUE_HOST_BUSY;575575+576576+ send_error:577577+ unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev);578578+579579+ if (evt_struct->cmnd != NULL) {580580+ evt_struct->cmnd->result = DID_ERROR << 16;581581+ evt_struct->cmnd_done(evt_struct->cmnd);582582+ } else if (evt_struct->done)583583+ evt_struct->done(evt_struct);584584+585585+ free_event_struct(&hostdata->pool, evt_struct);586586+ return 0;585587}586588587589/**···12061184 return;12071185 case 0xFF: /* Hypervisor telling us the connection is closed */12081186 scsi_block_requests(hostdata->host);11871187+ atomic_set(&hostdata->request_limit, 0);12091188 if (crq->format == 0x06) {12101189 /* We need to re-setup the interpartition connection */12111190 printk(KERN_INFO12121191 "ibmvscsi: Re-enabling adapter!\n");12131213- atomic_set(&hostdata->request_limit, -1);12141192 purge_requests(hostdata, DID_REQUEUE);12151215- if (ibmvscsi_reenable_crq_queue(&hostdata->queue,12161216- hostdata) == 0)12171217- if (ibmvscsi_send_crq(hostdata,12181218- 0xC001000000000000LL, 0))11931193+ if ((ibmvscsi_reenable_crq_queue(&hostdata->queue,11941194+ hostdata) == 0) ||11951195+ (ibmvscsi_send_crq(hostdata,11961196+ 0xC001000000000000LL, 0))) {11971197+ atomic_set(&hostdata->request_limit,11981198+ -1);12191199 printk(KERN_ERR12201220- "ibmvscsi: transmit error after"12001200+ "ibmvscsi: error after"12211201 " enable\n");12021202+ }12221203 } else {12231204 printk(KERN_INFO12241205 "ibmvscsi: Virtual adapter failed rc %d!\n",12251206 crq->format);1226120712271227- atomic_set(&hostdata->request_limit, -1);12281208 purge_requests(hostdata, DID_ERROR);12291229- ibmvscsi_reset_crq_queue(&hostdata->queue, hostdata);12091209+ if ((ibmvscsi_reset_crq_queue(&hostdata->queue,12101210+ hostdata)) ||12111211+ (ibmvscsi_send_crq(hostdata,12121212+ 0xC001000000000000LL, 0))) {12131213+ atomic_set(&hostdata->request_limit,12141214+ -1);12151215+ printk(KERN_ERR12161216+ "ibmvscsi: error after reset\n");12171217+ }12301218 }12311219 scsi_unblock_requests(hostdata->host);12321220 return;···14991467 struct Scsi_Host *host;15001468 struct device *dev = &vdev->dev;15011469 unsigned long wait_switch = 0;14701470+ int rc;1502147115031472 vdev->dev.driver_data = NULL;15041473···15171484 atomic_set(&hostdata->request_limit, -1);15181485 hostdata->host->max_sectors = 32 * 8; /* default max I/O 32 pages */1519148615201520- if (ibmvscsi_init_crq_queue(&hostdata->queue, hostdata,15211521- max_requests) != 0) {14871487+ rc = ibmvscsi_init_crq_queue(&hostdata->queue, hostdata, max_requests);14881488+ if (rc != 0 && rc != H_RESOURCE) {15221489 printk(KERN_ERR "ibmvscsi: couldn't initialize crq\n");15231490 goto init_crq_failed;15241491 }···15381505 * to fail if the other end is not acive. In that case we don't15391506 * want to scan15401507 */15411541- if (ibmvscsi_send_crq(hostdata, 0xC001000000000000LL, 0) == 0) {15081508+ if (ibmvscsi_send_crq(hostdata, 0xC001000000000000LL, 0) == 015091509+ || rc == H_RESOURCE) {15421510 /*15431511 * Wait around max init_timeout secs for the adapter to finish15441512 * initializing. When we are done initializing, we will have a
+3-2
drivers/scsi/ibmvscsi/rpa_vscsi.c
···208208 int max_requests)209209{210210 int rc;211211+ int retrc;211212 struct vio_dev *vdev = to_vio_dev(hostdata->dev);212213213214 queue->msgs = (struct viosrp_crq *)get_zeroed_page(GFP_KERNEL);···227226 gather_partition_info();228227 set_adapter_info(hostdata);229228230230- rc = plpar_hcall_norets(H_REG_CRQ,229229+ retrc = rc = plpar_hcall_norets(H_REG_CRQ,231230 vdev->unit_address,232231 queue->msg_token, PAGE_SIZE);233232 if (rc == H_RESOURCE)···264263 tasklet_init(&hostdata->srp_task, (void *)ibmvscsi_task,265264 (unsigned long)hostdata);266265267267- return 0;266266+ return retrc;268267269268 req_irq_failed:270269 do {
···4141#define LPFC_ABORT_WAIT 2424243434444-static inline void4545-lpfc_block_requests(struct lpfc_hba * phba)4646-{4747- down(&phba->hba_can_block);4848- scsi_block_requests(phba->host);4949-}5050-5151-static inline void5252-lpfc_unblock_requests(struct lpfc_hba * phba)5353-{5454- scsi_unblock_requests(phba->host);5555- up(&phba->hba_can_block);5656-}5757-5844/*5945 * This routine allocates a scsi buffer, which contains all the necessary6046 * information needed to initiate a SCSI I/O. The non-DMAable buffer region···845859 unsigned int loop_count = 0;846860 int ret = SUCCESS;847861848848- lpfc_block_requests(phba);849862 spin_lock_irq(shost->host_lock);850863851864 lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble;···930945 cmnd->device->lun, cmnd->serial_number);931946932947 spin_unlock_irq(shost->host_lock);933933- lpfc_unblock_requests(phba);934948935949 return ret;936950}···947963 int ret = FAILED;948964 int cnt, loopcnt;949965950950- lpfc_block_requests(phba);951966 spin_lock_irq(shost->host_lock);952967 /*953968 * If target is not in a MAPPED state, delay the reset until···1048106510491066out:10501067 spin_unlock_irq(shost->host_lock);10511051- lpfc_unblock_requests(phba);10521068 return ret;10531069}10541070···10621080 int cnt, loopcnt;10631081 struct lpfc_scsi_buf * lpfc_cmd;1064108210651065- lpfc_block_requests(phba);10661083 spin_lock_irq(shost->host_lock);1067108410681085 lpfc_cmd = lpfc_get_scsi_buf(phba);···11441163 phba->brd_no, ret);11451164out:11461165 spin_unlock_irq(shost->host_lock);11471147- lpfc_unblock_requests(phba);11481166 return ret;11491167}11501168
+24-8
drivers/scsi/megaraid/megaraid_sas.c
···1010 * 2 of the License, or (at your option) any later version.1111 *1212 * FILE : megaraid_sas.c1313- * Version : v00.00.02.041313+ * Version : v00.00.03.011414 *1515 * Authors:1616 * Sreenivas Bagalkote <Sreenivas.Bagalkote@lsil.com>···55555656 {5757 PCI_VENDOR_ID_LSI_LOGIC,5858- PCI_DEVICE_ID_LSI_SAS1064R, // xscale IOP5858+ PCI_DEVICE_ID_LSI_SAS1064R, /* xscale IOP */5959 PCI_ANY_ID,6060 PCI_ANY_ID,6161 },6262 {6363 PCI_VENDOR_ID_LSI_LOGIC,6464- PCI_DEVICE_ID_LSI_SAS1078R, // ppc IOP6464+ PCI_DEVICE_ID_LSI_SAS1078R, /* ppc IOP */6565 PCI_ANY_ID,6666 PCI_ANY_ID,6767 },6868 {6969+ PCI_VENDOR_ID_LSI_LOGIC,7070+ PCI_DEVICE_ID_LSI_VERDE_ZCR, /* xscale IOP, vega */7171+ PCI_ANY_ID,7272+ PCI_ANY_ID,7373+ },7474+ {6975 PCI_VENDOR_ID_DELL,7070- PCI_DEVICE_ID_DELL_PERC5, // xscale IOP7676+ PCI_DEVICE_ID_DELL_PERC5, /* xscale IOP */7177 PCI_ANY_ID,7278 PCI_ANY_ID,7379 },···295289 * @regs: MFI register set296290 */297291static inline void298298-megasas_disable_intr(struct megasas_register_set __iomem * regs)292292+megasas_disable_intr(struct megasas_instance *instance)299293{300294 u32 mask = 0x1f; 295295+ struct megasas_register_set __iomem *regs = instance->reg_set;296296+297297+ if(instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1078R)298298+ mask = 0xffffffff;299299+301300 writel(mask, ®s->outbound_intr_mask);302301303302 /* Dummy readl to force pci flush */···12711260 /*12721261 * Bring it to READY state; assuming max wait 2 secs12731262 */12741274- megasas_disable_intr(instance->reg_set);12631263+ megasas_disable_intr(instance);12751264 writel(MFI_INIT_READY, &instance->reg_set->inbound_doorbell);1276126512771266 max_wait = 10;···17681757 init_frame->data_xfer_len = sizeof(struct megasas_init_queue_info);1769175817701759 /*17601760+ * disable the intr before firing the init frame to FW17611761+ */17621762+ megasas_disable_intr(instance);17631763+17641764+ /*17711765 * Issue the init frame in polled mode17721766 */17731767 if (megasas_issue_polled(instance, cmd)) {···22502234 megasas_mgmt_info.max_index--;2251223522522236 pci_set_drvdata(pdev, NULL);22532253- megasas_disable_intr(instance->reg_set);22372237+ megasas_disable_intr(instance);22542238 free_irq(instance->pdev->irq, instance);2255223922562240 megasas_release_mfi(instance);···2380236423812365 pci_set_drvdata(instance->pdev, NULL);2382236623832383- megasas_disable_intr(instance->reg_set);23672367+ megasas_disable_intr(instance);2384236823852369 free_irq(instance->pdev->irq, instance);23862370
···3737/*3838* Macros use for debugging the driver.3939*/4040-#undef ENTER_TRACE4141-#if defined(ENTER_TRACE)4242-#define ENTER(x) do { printk("qla2100 : Entering %s()\n", x); } while (0)4343-#define LEAVE(x) do { printk("qla2100 : Leaving %s()\n", x); } while (0)4444-#define ENTER_INTR(x) do { printk("qla2100 : Entering %s()\n", x); } while (0)4545-#define LEAVE_INTR(x) do { printk("qla2100 : Leaving %s()\n", x); } while (0)4646-#else4747-#define ENTER(x) do {} while (0)4848-#define LEAVE(x) do {} while (0)4949-#define ENTER_INTR(x) do {} while (0)5050-#define LEAVE_INTR(x) do {} while (0)5151-#endif52405353-#if DEBUG_QLA21005454-#define DEBUG(x) do {x;} while (0);5555-#else5656-#define DEBUG(x) do {} while (0);5757-#endif4141+#define DEBUG(x) do { if (extended_error_logging) { x; } } while (0)58425943#if defined(QL_DEBUG_LEVEL_1)6060-#define DEBUG1(x) do {x;} while (0);4444+#define DEBUG1(x) do {x;} while (0)6145#else6262-#define DEBUG1(x) do {} while (0);4646+#define DEBUG1(x) do {} while (0)6347#endif64486565-#if defined(QL_DEBUG_LEVEL_2)6666-#define DEBUG2(x) do {x;} while (0);6767-#define DEBUG2_3(x) do {x;} while (0);6868-#define DEBUG2_3_11(x) do {x;} while (0);6969-#define DEBUG2_9_10(x) do {x;} while (0);7070-#define DEBUG2_11(x) do {x;} while (0);7171-#define DEBUG2_13(x) do {x;} while (0);7272-#else7373-#define DEBUG2(x) do {} while (0);7474-#endif4949+#define DEBUG2(x) do { if (extended_error_logging) { x; } } while (0)5050+#define DEBUG2_3(x) do { if (extended_error_logging) { x; } } while (0)5151+#define DEBUG2_3_11(x) do { if (extended_error_logging) { x; } } while (0)5252+#define DEBUG2_9_10(x) do { if (extended_error_logging) { x; } } while (0)5353+#define DEBUG2_11(x) do { if (extended_error_logging) { x; } } while (0)5454+#define DEBUG2_13(x) do { if (extended_error_logging) { x; } } while (0)75557656#if defined(QL_DEBUG_LEVEL_3)7777-#define DEBUG3(x) do {x;} while (0);7878-#define DEBUG2_3(x) do {x;} while (0);7979-#define DEBUG2_3_11(x) do {x;} while (0);8080-#define DEBUG3_11(x) do {x;} while (0);5757+#define DEBUG3(x) do {x;} while (0)5858+#define DEBUG3_11(x) do {x;} while (0)8159#else8282-#define DEBUG3(x) do {} while (0);8383- #if !defined(QL_DEBUG_LEVEL_2)8484- #define DEBUG2_3(x) do {} while (0);8585- #endif6060+#define DEBUG3(x) do {} while (0)8661#endif87628863#if defined(QL_DEBUG_LEVEL_4)8989-#define DEBUG4(x) do {x;} while (0);6464+#define DEBUG4(x) do {x;} while (0)9065#else9191-#define DEBUG4(x) do {} while (0);6666+#define DEBUG4(x) do {} while (0)9267#endif93689469#if defined(QL_DEBUG_LEVEL_5)9595-#define DEBUG5(x) do {x;} while (0);7070+#define DEBUG5(x) do {x;} while (0)9671#else9797-#define DEBUG5(x) do {} while (0);7272+#define DEBUG5(x) do {} while (0)9873#endif997410075#if defined(QL_DEBUG_LEVEL_7)101101-#define DEBUG7(x) do {x;} while (0);7676+#define DEBUG7(x) do {x;} while (0)10277#else103103-#define DEBUG7(x) do {} while (0);7878+#define DEBUG7(x) do {} while (0)10479#endif1058010681#if defined(QL_DEBUG_LEVEL_9)107107-#define DEBUG9(x) do {x;} while (0);108108-#define DEBUG9_10(x) do {x;} while (0);109109-#define DEBUG2_9_10(x) do {x;} while (0);8282+#define DEBUG9(x) do {x;} while (0)8383+#define DEBUG9_10(x) do {x;} while (0)11084#else111111-#define DEBUG9(x) do {} while (0);8585+#define DEBUG9(x) do {} while (0)11286#endif1138711488#if defined(QL_DEBUG_LEVEL_10)115115-#define DEBUG10(x) do {x;} while (0);116116-#define DEBUG2_9_10(x) do {x;} while (0);117117-#define DEBUG9_10(x) do {x;} while (0);8989+#define DEBUG10(x) do {x;} while (0)9090+#define DEBUG9_10(x) do {x;} while (0)11891#else119119-#define DEBUG10(x) do {} while (0);120120- #if !defined(DEBUG2_9_10)121121- #define DEBUG2_9_10(x) do {} while (0);122122- #endif9292+#define DEBUG10(x) do {} while (0)12393 #if !defined(DEBUG9_10)124124- #define DEBUG9_10(x) do {} while (0);9494+ #define DEBUG9_10(x) do {} while (0)12595 #endif12696#endif1279712898#if defined(QL_DEBUG_LEVEL_11)129129-#define DEBUG11(x) do{x;} while(0);130130-#if !defined(DEBUG2_11)131131-#define DEBUG2_11(x) do{x;} while(0);132132-#endif133133-#if !defined(DEBUG2_3_11)134134-#define DEBUG2_3_11(x) do{x;} while(0);135135-#endif9999+#define DEBUG11(x) do{x;} while(0)136100#if !defined(DEBUG3_11)137137-#define DEBUG3_11(x) do{x;} while(0);101101+#define DEBUG3_11(x) do{x;} while(0)138102#endif139103#else140140-#define DEBUG11(x) do{} while(0);141141- #if !defined(QL_DEBUG_LEVEL_2)142142- #define DEBUG2_11(x) do{} while(0);143143- #if !defined(QL_DEBUG_LEVEL_3)144144- #define DEBUG2_3_11(x) do{} while(0);145145- #endif146146- #endif104104+#define DEBUG11(x) do{} while(0)147105 #if !defined(QL_DEBUG_LEVEL_3)148148- #define DEBUG3_11(x) do{} while(0);106106+ #define DEBUG3_11(x) do{} while(0)149107 #endif150108#endif151109152110#if defined(QL_DEBUG_LEVEL_12)153153-#define DEBUG12(x) do {x;} while (0);111111+#define DEBUG12(x) do {x;} while (0)154112#else155155-#define DEBUG12(x) do {} while (0);113113+#define DEBUG12(x) do {} while (0)156114#endif157115158116#if defined(QL_DEBUG_LEVEL_13)159117#define DEBUG13(x) do {x;} while (0)160160-#if !defined(DEBUG2_13)161161-#define DEBUG2_13(x) do {x;} while(0)162162-#endif163118#else164119#define DEBUG13(x) do {} while (0)165165-#if !defined(QL_DEBUG_LEVEL_2)166166-#define DEBUG2_13(x) do {} while(0)167167-#endif168120#endif169121170122#if defined(QL_DEBUG_LEVEL_14)···128176/*129177 * Firmware Dump structure definition130178 */131131-#define FW_DUMP_SIZE_128K 0xBC000132132-#define FW_DUMP_SIZE_512K 0x2FC000133133-#define FW_DUMP_SIZE_1M 0x5FC000134179135180struct qla2300_fw_dump {136181 uint16_t hccr;···173224 uint16_t risc_ram[0xf000];174225};175226176176-#define FW_DUMP_SIZE_24XX 0x2B0000177177-178227struct qla24xx_fw_dump {179228 uint32_t host_status;180229 uint32_t host_reg[32];···203256 uint32_t fb_hdw_reg[176];204257 uint32_t code_ram[0x2000];205258 uint32_t ext_mem[1];259259+};260260+261261+#define EFT_NUM_BUFFERS 4262262+#define EFT_BYTES_PER_BUFFER 0x4000263263+#define EFT_SIZE ((EFT_BYTES_PER_BUFFER) * (EFT_NUM_BUFFERS))264264+265265+struct qla2xxx_fw_dump {266266+ uint8_t signature[4];267267+ uint32_t version;268268+269269+ uint32_t fw_major_version;270270+ uint32_t fw_minor_version;271271+ uint32_t fw_subminor_version;272272+ uint32_t fw_attributes;273273+274274+ uint32_t vendor;275275+ uint32_t device;276276+ uint32_t subsystem_vendor;277277+ uint32_t subsystem_device;278278+279279+ uint32_t fixed_size;280280+ uint32_t mem_size;281281+ uint32_t req_q_size;282282+ uint32_t rsp_q_size;283283+284284+ uint32_t eft_size;285285+ uint32_t eft_addr_l;286286+ uint32_t eft_addr_h;287287+288288+ uint32_t header_size;289289+290290+ union {291291+ struct qla2100_fw_dump isp21;292292+ struct qla2300_fw_dump isp23;293293+ struct qla24xx_fw_dump isp24;294294+ } isp;206295};
···16721672scsi_reset_provider(struct scsi_device *dev, int flag)16731673{16741674 struct scsi_cmnd *scmd = scsi_get_command(dev, GFP_KERNEL);16751675+ struct Scsi_Host *shost = dev->host;16751676 struct request req;16771677+ unsigned long flags;16761678 int rtn;1677167916781680 scmd->request = &req;···17011699 */17021700 scmd->pid = 0;1703170117021702+ spin_lock_irqsave(shost->host_lock, flags);17031703+ shost->tmf_in_progress = 1;17041704+ spin_unlock_irqrestore(shost->host_lock, flags);17051705+17041706 switch (flag) {17051707 case SCSI_TRY_RESET_DEVICE:17061708 rtn = scsi_try_bus_device_reset(scmd);···17221716 default:17231717 rtn = FAILED;17241718 }17191719+17201720+ spin_lock_irqsave(shost->host_lock, flags);17211721+ shost->tmf_in_progress = 0;17221722+ spin_unlock_irqrestore(shost->host_lock, flags);17231723+17241724+ /*17251725+ * be sure to wake up anyone who was sleeping or had their queue17261726+ * suspended while we performed the TMF.17271727+ */17281728+ SCSI_LOG_ERROR_RECOVERY(3,17291729+ printk("%s: waking up host to restart after TMF\n",17301730+ __FUNCTION__));17311731+17321732+ wake_up(&shost->host_wait);17331733+17341734+ scsi_run_host_queues(shost);1725173517261736 scsi_next_command(scmd);17271737 return rtn;
+51-73
drivers/scsi/scsi_lib.c
···855855 * b) We can just use scsi_requeue_command() here. This would856856 * be used if we just wanted to retry, for example.857857 */858858-void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes,859859- unsigned int block_bytes)858858+void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)860859{861860 int result = cmd->result;862861 int this_count = cmd->bufflen;···920921 * Next deal with any sectors which we were able to correctly921922 * handle.922923 */923923- if (good_bytes >= 0) {924924- SCSI_LOG_HLCOMPLETE(1, printk("%ld sectors total, %d bytes done.\n",925925- req->nr_sectors, good_bytes));926926- SCSI_LOG_HLCOMPLETE(1, printk("use_sg is %d\n", cmd->use_sg));924924+ SCSI_LOG_HLCOMPLETE(1, printk("%ld sectors total, "925925+ "%d bytes done.\n",926926+ req->nr_sectors, good_bytes));927927+ SCSI_LOG_HLCOMPLETE(1, printk("use_sg is %d\n", cmd->use_sg));927928928928- if (clear_errors)929929- req->errors = 0;930930- /*931931- * If multiple sectors are requested in one buffer, then932932- * they will have been finished off by the first command.933933- * If not, then we have a multi-buffer command.934934- *935935- * If block_bytes != 0, it means we had a medium error936936- * of some sort, and that we want to mark some number of937937- * sectors as not uptodate. Thus we want to inhibit938938- * requeueing right here - we will requeue down below939939- * when we handle the bad sectors.940940- */929929+ if (clear_errors)930930+ req->errors = 0;941931942942- /*943943- * If the command completed without error, then either944944- * finish off the rest of the command, or start a new one.945945- */946946- if (scsi_end_request(cmd, 1, good_bytes, result == 0) == NULL)947947- return;948948- }949949- /*950950- * Now, if we were good little boys and girls, Santa left us a request951951- * sense buffer. We can extract information from this, so we952952- * can choose a block to remap, etc.932932+ /* A number of bytes were successfully read. If there933933+ * are leftovers and there is some kind of error934934+ * (result != 0), retry the rest.935935+ */936936+ if (scsi_end_request(cmd, 1, good_bytes, result == 0) == NULL)937937+ return;938938+939939+ /* good_bytes = 0, or (inclusive) there were leftovers and940940+ * result = 0, so scsi_end_request couldn't retry.953941 */954942 if (sense_valid && !sense_deferred) {955943 switch (sshdr.sense_key) {956944 case UNIT_ATTENTION:957945 if (cmd->device->removable) {958958- /* detected disc change. set a bit 946946+ /* Detected disc change. Set a bit959947 * and quietly refuse further access.960948 */961949 cmd->device->changed = 1;962962- scsi_end_request(cmd, 0,963963- this_count, 1);950950+ scsi_end_request(cmd, 0, this_count, 1);964951 return;965952 } else {966966- /*967967- * Must have been a power glitch, or a968968- * bus reset. Could not have been a969969- * media change, so we just retry the970970- * request and see what happens. 971971- */953953+ /* Must have been a power glitch, or a954954+ * bus reset. Could not have been a955955+ * media change, so we just retry the956956+ * request and see what happens.957957+ */972958 scsi_requeue_command(q, cmd);973959 return;974960 }975961 break;976962 case ILLEGAL_REQUEST:977977- /*978978- * If we had an ILLEGAL REQUEST returned, then we may979979- * have performed an unsupported command. The only980980- * thing this should be would be a ten byte read where981981- * only a six byte read was supported. Also, on a982982- * system where READ CAPACITY failed, we may have read983983- * past the end of the disk.984984- */963963+ /* If we had an ILLEGAL REQUEST returned, then964964+ * we may have performed an unsupported965965+ * command. The only thing this should be966966+ * would be a ten byte read where only a six967967+ * byte read was supported. Also, on a system968968+ * where READ CAPACITY failed, we may have969969+ * read past the end of the disk.970970+ */985971 if ((cmd->device->use_10_for_rw &&986972 sshdr.asc == 0x20 && sshdr.ascq == 0x00) &&987973 (cmd->cmnd[0] == READ_10 ||988974 cmd->cmnd[0] == WRITE_10)) {989975 cmd->device->use_10_for_rw = 0;990990- /*991991- * This will cause a retry with a 6-byte992992- * command.976976+ /* This will cause a retry with a977977+ * 6-byte command.993978 */994979 scsi_requeue_command(q, cmd);995995- result = 0;980980+ return;996981 } else {997982 scsi_end_request(cmd, 0, this_count, 1);998983 return;999984 }1000985 break;1001986 case NOT_READY:10021002- /*10031003- * If the device is in the process of becoming987987+ /* If the device is in the process of becoming1004988 * ready, or has a temporary blockage, retry.1005989 */1006990 if (sshdr.asc == 0x04) {···10031021 }10041022 if (!(req->flags & REQ_QUIET)) {10051023 scmd_printk(KERN_INFO, cmd,10061006- "Device not ready: ");10241024+ "Device not ready: ");10071025 scsi_print_sense_hdr("", &sshdr);10081026 }10091027 scsi_end_request(cmd, 0, this_count, 1);···10111029 case VOLUME_OVERFLOW:10121030 if (!(req->flags & REQ_QUIET)) {10131031 scmd_printk(KERN_INFO, cmd,10141014- "Volume overflow, CDB: ");10321032+ "Volume overflow, CDB: ");10151033 __scsi_print_command(cmd->data_cmnd);10161034 scsi_print_sense("", cmd);10171035 }10181018- scsi_end_request(cmd, 0, block_bytes, 1);10361036+ /* See SSC3rXX or current. */10371037+ scsi_end_request(cmd, 0, this_count, 1);10191038 return;10201039 default:10211040 break;10221041 }10231023- } /* driver byte != 0 */10421042+ }10241043 if (host_byte(result) == DID_RESET) {10251025- /*10261026- * Third party bus reset or reset for error10271027- * recovery reasons. Just retry the request10281028- * and see what happens. 10441044+ /* Third party bus reset or reset for error recovery10451045+ * reasons. Just retry the request and see what10461046+ * happens.10291047 */10301048 scsi_requeue_command(q, cmd);10311049 return;···10331051 if (result) {10341052 if (!(req->flags & REQ_QUIET)) {10351053 scmd_printk(KERN_INFO, cmd,10361036- "SCSI error: return code = 0x%x\n", result);10371037-10541054+ "SCSI error: return code = 0x%08x\n",10551055+ result);10381056 if (driver_byte(result) & DRIVER_SENSE)10391057 scsi_print_sense("", cmd);10401058 }10411041- /*10421042- * Mark a single buffer as not uptodate. Queue the remainder.10431043- * We sometimes get this cruft in the event that a medium error10441044- * isn't properly reported.10451045- */10461046- block_bytes = req->hard_cur_sectors << 9;10471047- if (!block_bytes)10481048- block_bytes = req->data_len;10491049- scsi_end_request(cmd, 0, block_bytes, 1);10501059 }10601060+ scsi_end_request(cmd, 0, this_count, !result);10511061}10521062EXPORT_SYMBOL(scsi_io_completion);10531063···11431169 * successfully. Since this is a REQ_BLOCK_PC command the11441170 * caller should check the request's errors value11451171 */11461146- scsi_io_completion(cmd, cmd->bufflen, 0);11721172+ scsi_io_completion(cmd, cmd->bufflen);11471173}1148117411491175static void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd)···20242050 switch (oldstate) {20252051 case SDEV_CREATED:20262052 case SDEV_RUNNING:20532053+ case SDEV_QUIESCE:20272054 case SDEV_OFFLINE:20282055 case SDEV_BLOCK:20292056 break;···2035206020362061 case SDEV_DEL:20372062 switch (oldstate) {20632063+ case SDEV_CREATED:20642064+ case SDEV_RUNNING:20652065+ case SDEV_OFFLINE:20382066 case SDEV_CANCEL:20392067 break;20402068 default:
+1-1
drivers/scsi/scsi_priv.h
···116116 * classes.117117 */118118119119-#define SCSI_DEVICE_BLOCK_MAX_TIMEOUT (HZ*60)119119+#define SCSI_DEVICE_BLOCK_MAX_TIMEOUT 600 /* units in seconds */120120extern int scsi_internal_device_block(struct scsi_device *sdev);121121extern int scsi_internal_device_unblock(struct scsi_device *sdev);122122
···368368 * should insulate the loss of a remote port.369369 * The maximum will be capped by the value of SCSI_DEVICE_BLOCK_MAX_TIMEOUT.370370 */371371-static unsigned int fc_dev_loss_tmo = SCSI_DEVICE_BLOCK_MAX_TIMEOUT;371371+static unsigned int fc_dev_loss_tmo = 60; /* seconds */372372373373module_param_named(dev_loss_tmo, fc_dev_loss_tmo, int, S_IRUGO|S_IWUSR);374374MODULE_PARM_DESC(dev_loss_tmo,···12841284 * @work: Work to queue for execution.12851285 *12861286 * Return value:12871287- * 0 on success / != 0 for error12871287+ * 1 - work queued for execution12881288+ * 0 - work is already queued12891289+ * -EINVAL - work queue doesn't exist12881290 **/12891291static int12901292fc_queue_work(struct Scsi_Host *shost, struct work_struct *work)···14361434 struct Scsi_Host *shost = rport_to_shost(rport);14371435 unsigned long flags;1438143614391439- scsi_target_unblock(&rport->dev);14401440-14411437 spin_lock_irqsave(shost->host_lock, flags);14421438 if (rport->flags & FC_RPORT_DEVLOSS_PENDING) {14431439 spin_unlock_irqrestore(shost->host_lock, flags);···14761476 transport_remove_device(dev);14771477 device_del(dev);14781478 transport_destroy_device(dev);14791479- put_device(&shost->shost_gendev);14791479+ put_device(&shost->shost_gendev); /* for fc_host->rport list */14801480+ put_device(dev); /* for self-reference */14801481}1481148214821483···15381537 else15391538 rport->scsi_target_id = -1;15401539 list_add_tail(&rport->peers, &fc_host->rports);15411541- get_device(&shost->shost_gendev);15401540+ get_device(&shost->shost_gendev); /* for fc_host->rport list */1542154115431542 spin_unlock_irqrestore(shost->host_lock, flags);1544154315451544 dev = &rport->dev;15461546- device_initialize(dev);15471547- dev->parent = get_device(&shost->shost_gendev);15451545+ device_initialize(dev); /* takes self reference */15461546+ dev->parent = get_device(&shost->shost_gendev); /* parent reference */15481547 dev->release = fc_rport_dev_release;15491548 sprintf(dev->bus_id, "rport-%d:%d-%d",15501549 shost->host_no, channel, rport->number);···1568156715691568delete_rport:15701569 transport_destroy_device(dev);15711571- put_device(dev->parent);15721570 spin_lock_irqsave(shost->host_lock, flags);15731571 list_del(&rport->peers);15741574- put_device(&shost->shost_gendev);15721572+ put_device(&shost->shost_gendev); /* for fc_host->rport list */15751573 spin_unlock_irqrestore(shost->host_lock, flags);15761574 put_device(dev->parent);15771575 kfree(rport);···1707170717081708 spin_unlock_irqrestore(shost->host_lock, flags);1709170917101710+ scsi_target_unblock(&rport->dev);17111711+17101712 return rport;17111713 }17121714 }···17641762 /* initiate a scan of the target */17651763 rport->flags |= FC_RPORT_SCAN_PENDING;17661764 scsi_queue_work(shost, &rport->scan_work);17671767- }17681768-17691769- spin_unlock_irqrestore(shost->host_lock, flags);17651765+ spin_unlock_irqrestore(shost->host_lock, flags);17661766+ scsi_target_unblock(&rport->dev);17671767+ } else17681768+ spin_unlock_irqrestore(shost->host_lock, flags);1770176917711770 return rport;17721771 }···19411938 rport->flags |= FC_RPORT_SCAN_PENDING;19421939 scsi_queue_work(shost, &rport->scan_work);19431940 spin_unlock_irqrestore(shost->host_lock, flags);19411941+ scsi_target_unblock(&rport->dev);19441942 }19451943}19461944EXPORT_SYMBOL(fc_remote_port_rolechg);···19741970 dev_printk(KERN_ERR, &rport->dev,19751971 "blocked FC remote port time out: no longer"19761972 " a FCP target, removing starget\n");19771977- fc_queue_work(shost, &rport->stgt_delete_work);19781973 spin_unlock_irqrestore(shost->host_lock, flags);19741974+ scsi_target_unblock(&rport->dev);19751975+ fc_queue_work(shost, &rport->stgt_delete_work);19791976 return;19801977 }19811978···20402035 * went away and didn't come back - we'll remove20412036 * all attached scsi devices.20422037 */20432043- fc_queue_work(shost, &rport->stgt_delete_work);20442044-20452038 spin_unlock_irqrestore(shost->host_lock, flags);20392039+20402040+ scsi_target_unblock(&rport->dev);20412041+ fc_queue_work(shost, &rport->stgt_delete_work);20462042}2047204320482044/**20492045 * fc_scsi_scan_rport - called to perform a scsi scan on a remote port.20502050- *20512051- * Will unblock the target (in case it went away and has now come back),20522052- * then invoke a scan.20532046 *20542047 * @data: remote port to be scanned.20552048 **/···2060205720612058 if ((rport->port_state == FC_PORTSTATE_ONLINE) &&20622059 (rport->roles & FC_RPORT_ROLE_FCP_TARGET)) {20632063- scsi_target_unblock(&rport->dev);20642060 scsi_scan_target(&rport->dev, rport->channel,20652061 rport->scsi_target_id, SCAN_WILD_CARD, 1);20662062 }
+382-310
drivers/scsi/scsi_transport_iscsi.c
···228228static void iscsi_session_release(struct device *dev)229229{230230 struct iscsi_cls_session *session = iscsi_dev_to_session(dev);231231- struct iscsi_transport *transport = session->transport;232231 struct Scsi_Host *shost;233232234233 shost = iscsi_session_to_shost(session);235234 scsi_host_put(shost);236236- kfree(session->targetname);237235 kfree(session);238238- module_put(transport->owner);239236}240237241238static int iscsi_is_session_dev(const struct device *dev)···248251249252 mutex_lock(&ihost->mutex);250253 list_for_each_entry(session, &ihost->sessions, host_list) {251251- if ((channel == SCAN_WILD_CARD ||252252- channel == session->channel) &&254254+ if ((channel == SCAN_WILD_CARD || channel == 0) &&253255 (id == SCAN_WILD_CARD || id == session->target_id))254254- scsi_scan_target(&session->dev, session->channel,256256+ scsi_scan_target(&session->dev, 0,255257 session->target_id, lun, 1);256258 }257259 mutex_unlock(&ihost->mutex);···287291}288292EXPORT_SYMBOL_GPL(iscsi_block_session);289293294294+struct iscsi_cls_session *295295+iscsi_alloc_session(struct Scsi_Host *shost,296296+ struct iscsi_transport *transport)297297+{298298+ struct iscsi_cls_session *session;299299+300300+ session = kzalloc(sizeof(*session) + transport->sessiondata_size,301301+ GFP_KERNEL);302302+ if (!session)303303+ return NULL;304304+305305+ session->transport = transport;306306+ session->recovery_tmo = 120;307307+ INIT_WORK(&session->recovery_work, session_recovery_timedout, session);308308+ INIT_LIST_HEAD(&session->host_list);309309+ INIT_LIST_HEAD(&session->sess_list);310310+311311+ /* this is released in the dev's release function */312312+ scsi_host_get(shost);313313+ session->dev.parent = &shost->shost_gendev;314314+ session->dev.release = iscsi_session_release;315315+ device_initialize(&session->dev);316316+ if (transport->sessiondata_size)317317+ session->dd_data = &session[1];318318+ return session;319319+}320320+EXPORT_SYMBOL_GPL(iscsi_alloc_session);321321+322322+int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)323323+{324324+ struct Scsi_Host *shost = iscsi_session_to_shost(session);325325+ struct iscsi_host *ihost;326326+ int err;327327+328328+ ihost = shost->shost_data;329329+ session->sid = iscsi_session_nr++;330330+ session->target_id = target_id;331331+332332+ snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u",333333+ session->sid);334334+ err = device_add(&session->dev);335335+ if (err) {336336+ dev_printk(KERN_ERR, &session->dev, "iscsi: could not "337337+ "register session's dev\n");338338+ goto release_host;339339+ }340340+ transport_register_device(&session->dev);341341+342342+ mutex_lock(&ihost->mutex);343343+ list_add(&session->host_list, &ihost->sessions);344344+ mutex_unlock(&ihost->mutex);345345+ return 0;346346+347347+release_host:348348+ scsi_host_put(shost);349349+ return err;350350+}351351+EXPORT_SYMBOL_GPL(iscsi_add_session);352352+290353/**291354 * iscsi_create_session - create iscsi class session292355 * @shost: scsi host···355300 **/356301struct iscsi_cls_session *357302iscsi_create_session(struct Scsi_Host *shost,358358- struct iscsi_transport *transport, int channel)303303+ struct iscsi_transport *transport,304304+ unsigned int target_id)359305{360360- struct iscsi_host *ihost;361306 struct iscsi_cls_session *session;362362- int err;363307364364- if (!try_module_get(transport->owner))308308+ session = iscsi_alloc_session(shost, transport);309309+ if (!session)365310 return NULL;366311367367- session = kzalloc(sizeof(*session) + transport->sessiondata_size,368368- GFP_KERNEL);369369- if (!session)370370- goto module_put;371371- session->transport = transport;372372- session->recovery_tmo = 120;373373- INIT_WORK(&session->recovery_work, session_recovery_timedout, session);374374- INIT_LIST_HEAD(&session->host_list);375375- INIT_LIST_HEAD(&session->sess_list);376376-377377- if (transport->sessiondata_size)378378- session->dd_data = &session[1];379379-380380- /* this is released in the dev's release function */381381- scsi_host_get(shost);382382- ihost = shost->shost_data;383383-384384- session->sid = iscsi_session_nr++;385385- session->channel = channel;386386- session->target_id = ihost->next_target_id++;387387-388388- snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u",389389- session->sid);390390- session->dev.parent = &shost->shost_gendev;391391- session->dev.release = iscsi_session_release;392392- err = device_register(&session->dev);393393- if (err) {394394- dev_printk(KERN_ERR, &session->dev, "iscsi: could not "395395- "register session's dev\n");396396- goto free_session;312312+ if (iscsi_add_session(session, target_id)) {313313+ iscsi_free_session(session);314314+ return NULL;397315 }398398- transport_register_device(&session->dev);399399-400400- mutex_lock(&ihost->mutex);401401- list_add(&session->host_list, &ihost->sessions);402402- mutex_unlock(&ihost->mutex);403403-404316 return session;405405-406406-free_session:407407- kfree(session);408408-module_put:409409- module_put(transport->owner);410410- return NULL;411317}412412-413318EXPORT_SYMBOL_GPL(iscsi_create_session);414319415415-/**416416- * iscsi_destroy_session - destroy iscsi session417417- * @session: iscsi_session418418- *419419- * Can be called by a LLD or iscsi_transport. There must not be420420- * any running connections.421421- **/422422-int iscsi_destroy_session(struct iscsi_cls_session *session)320320+void iscsi_remove_session(struct iscsi_cls_session *session)423321{424322 struct Scsi_Host *shost = iscsi_session_to_shost(session);425323 struct iscsi_host *ihost = shost->shost_data;···384376 list_del(&session->host_list);385377 mutex_unlock(&ihost->mutex);386378379379+ scsi_remove_target(&session->dev);380380+387381 transport_unregister_device(&session->dev);388388- device_unregister(&session->dev);389389- return 0;382382+ device_del(&session->dev);383383+}384384+EXPORT_SYMBOL_GPL(iscsi_remove_session);385385+386386+void iscsi_free_session(struct iscsi_cls_session *session)387387+{388388+ put_device(&session->dev);390389}391390391391+EXPORT_SYMBOL_GPL(iscsi_free_session);392392+393393+/**394394+ * iscsi_destroy_session - destroy iscsi session395395+ * @session: iscsi_session396396+ *397397+ * Can be called by a LLD or iscsi_transport. There must not be398398+ * any running connections.399399+ **/400400+int iscsi_destroy_session(struct iscsi_cls_session *session)401401+{402402+ iscsi_remove_session(session);403403+ iscsi_free_session(session);404404+ return 0;405405+}392406EXPORT_SYMBOL_GPL(iscsi_destroy_session);407407+408408+static void mempool_zone_destroy(struct mempool_zone *zp)409409+{410410+ mempool_destroy(zp->pool);411411+ kfree(zp);412412+}413413+414414+static void*415415+mempool_zone_alloc_skb(gfp_t gfp_mask, void *pool_data)416416+{417417+ struct mempool_zone *zone = pool_data;418418+419419+ return alloc_skb(zone->size, gfp_mask);420420+}421421+422422+static void423423+mempool_zone_free_skb(void *element, void *pool_data)424424+{425425+ kfree_skb(element);426426+}427427+428428+static struct mempool_zone *429429+mempool_zone_init(unsigned max, unsigned size, unsigned hiwat)430430+{431431+ struct mempool_zone *zp;432432+433433+ zp = kzalloc(sizeof(*zp), GFP_KERNEL);434434+ if (!zp)435435+ return NULL;436436+437437+ zp->size = size;438438+ zp->hiwat = hiwat;439439+ INIT_LIST_HEAD(&zp->freequeue);440440+ spin_lock_init(&zp->freelock);441441+ atomic_set(&zp->allocated, 0);442442+443443+ zp->pool = mempool_create(max, mempool_zone_alloc_skb,444444+ mempool_zone_free_skb, zp);445445+ if (!zp->pool) {446446+ kfree(zp);447447+ return NULL;448448+ }449449+450450+ return zp;451451+}393452394453static void iscsi_conn_release(struct device *dev)395454{396455 struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev);397456 struct device *parent = conn->dev.parent;398457399399- kfree(conn->persistent_address);458458+ mempool_zone_destroy(conn->z_pdu);459459+ mempool_zone_destroy(conn->z_error);460460+400461 kfree(conn);401462 put_device(parent);402463}···473396static int iscsi_is_conn_dev(const struct device *dev)474397{475398 return dev->release == iscsi_conn_release;399399+}400400+401401+static int iscsi_create_event_pools(struct iscsi_cls_conn *conn)402402+{403403+ conn->z_pdu = mempool_zone_init(Z_MAX_PDU,404404+ NLMSG_SPACE(sizeof(struct iscsi_uevent) +405405+ sizeof(struct iscsi_hdr) +406406+ DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH),407407+ Z_HIWAT_PDU);408408+ if (!conn->z_pdu) {409409+ dev_printk(KERN_ERR, &conn->dev, "iscsi: can not allocate "410410+ "pdu zone for new conn\n");411411+ return -ENOMEM;412412+ }413413+414414+ conn->z_error = mempool_zone_init(Z_MAX_ERROR,415415+ NLMSG_SPACE(sizeof(struct iscsi_uevent)),416416+ Z_HIWAT_ERROR);417417+ if (!conn->z_error) {418418+ dev_printk(KERN_ERR, &conn->dev, "iscsi: can not allocate "419419+ "error zone for new conn\n");420420+ mempool_zone_destroy(conn->z_pdu);421421+ return -ENOMEM;422422+ }423423+ return 0;476424}477425478426/**···532430 conn->transport = transport;533431 conn->cid = cid;534432433433+ if (iscsi_create_event_pools(conn))434434+ goto free_conn;435435+535436 /* this is released in the dev's release function */536437 if (!get_device(&session->dev))537537- goto free_conn;438438+ goto free_conn_pools;538439539440 snprintf(conn->dev.bus_id, BUS_ID_SIZE, "connection%d:%u",540441 session->sid, cid);···554449555450release_parent_ref:556451 put_device(&session->dev);452452+free_conn_pools:453453+557454free_conn:558455 kfree(conn);559456 return NULL;···603496 return (struct list_head *)&skb->cb;604497}605498606606-static void*607607-mempool_zone_alloc_skb(gfp_t gfp_mask, void *pool_data)608608-{609609- struct mempool_zone *zone = pool_data;610610-611611- return alloc_skb(zone->size, gfp_mask);612612-}613613-614614-static void615615-mempool_zone_free_skb(void *element, void *pool_data)616616-{617617- kfree_skb(element);618618-}619619-620499static void621500mempool_zone_complete(struct mempool_zone *zone)622501{···622529 spin_unlock_irqrestore(&zone->freelock, flags);623530}624531625625-static struct mempool_zone *626626-mempool_zone_init(unsigned max, unsigned size, unsigned hiwat)627627-{628628- struct mempool_zone *zp;629629-630630- zp = kzalloc(sizeof(*zp), GFP_KERNEL);631631- if (!zp)632632- return NULL;633633-634634- zp->size = size;635635- zp->hiwat = hiwat;636636- INIT_LIST_HEAD(&zp->freequeue);637637- spin_lock_init(&zp->freelock);638638- atomic_set(&zp->allocated, 0);639639-640640- zp->pool = mempool_create(max, mempool_zone_alloc_skb,641641- mempool_zone_free_skb, zp);642642- if (!zp->pool) {643643- kfree(zp);644644- return NULL;645645- }646646-647647- return zp;648648-}649649-650650-static void mempool_zone_destroy(struct mempool_zone *zp)651651-{652652- mempool_destroy(zp->pool);653653- kfree(zp);654654-}655655-656532static struct sk_buff*657533mempool_zone_get_skb(struct mempool_zone *zone)658534{···631569 if (skb)632570 atomic_inc(&zone->allocated);633571 return skb;572572+}573573+574574+static int575575+iscsi_broadcast_skb(struct mempool_zone *zone, struct sk_buff *skb)576576+{577577+ unsigned long flags;578578+ int rc;579579+580580+ skb_get(skb);581581+ rc = netlink_broadcast(nls, skb, 0, 1, GFP_KERNEL);582582+ if (rc < 0) {583583+ mempool_free(skb, zone->pool);584584+ printk(KERN_ERR "iscsi: can not broadcast skb (%d)\n", rc);585585+ return rc;586586+ }587587+588588+ spin_lock_irqsave(&zone->freelock, flags);589589+ INIT_LIST_HEAD(skb_to_lh(skb));590590+ list_add(skb_to_lh(skb), &zone->freequeue);591591+ spin_unlock_irqrestore(&zone->freelock, flags);592592+ return 0;634593}635594636595static int···749666 ev->r.connerror.cid = conn->cid;750667 ev->r.connerror.sid = iscsi_conn_get_sid(conn);751668752752- iscsi_unicast_skb(conn->z_error, skb, priv->daemon_pid);669669+ iscsi_broadcast_skb(conn->z_error, skb);753670754671 dev_printk(KERN_INFO, &conn->dev, "iscsi: detected conn error (%d)\n",755672 error);···850767 return err;851768}852769770770+/**771771+ * iscsi_if_destroy_session_done - send session destr. completion event772772+ * @conn: last connection for session773773+ *774774+ * This is called by HW iscsi LLDs to notify userpsace that its HW has775775+ * removed a session.776776+ **/777777+int iscsi_if_destroy_session_done(struct iscsi_cls_conn *conn)778778+{779779+ struct iscsi_internal *priv;780780+ struct iscsi_cls_session *session;781781+ struct Scsi_Host *shost;782782+ struct iscsi_uevent *ev;783783+ struct sk_buff *skb;784784+ struct nlmsghdr *nlh;785785+ unsigned long flags;786786+ int rc, len = NLMSG_SPACE(sizeof(*ev));787787+788788+ priv = iscsi_if_transport_lookup(conn->transport);789789+ if (!priv)790790+ return -EINVAL;791791+792792+ session = iscsi_dev_to_session(conn->dev.parent);793793+ shost = iscsi_session_to_shost(session);794794+795795+ mempool_zone_complete(conn->z_pdu);796796+797797+ skb = mempool_zone_get_skb(conn->z_pdu);798798+ if (!skb) {799799+ dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "800800+ "session creation event\n");801801+ return -ENOMEM;802802+ }803803+804804+ nlh = __nlmsg_put(skb, priv->daemon_pid, 0, 0, (len - sizeof(*nlh)), 0);805805+ ev = NLMSG_DATA(nlh);806806+ ev->transport_handle = iscsi_handle(conn->transport);807807+ ev->type = ISCSI_KEVENT_DESTROY_SESSION;808808+ ev->r.d_session.host_no = shost->host_no;809809+ ev->r.d_session.sid = session->sid;810810+811811+ /*812812+ * this will occur if the daemon is not up, so we just warn813813+ * the user and when the daemon is restarted it will handle it814814+ */815815+ rc = iscsi_broadcast_skb(conn->z_pdu, skb);816816+ if (rc < 0)817817+ dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "818818+ "session destruction event. Check iscsi daemon\n");819819+820820+ spin_lock_irqsave(&sesslock, flags);821821+ list_del(&session->sess_list);822822+ spin_unlock_irqrestore(&sesslock, flags);823823+824824+ spin_lock_irqsave(&connlock, flags);825825+ conn->active = 0;826826+ list_del(&conn->conn_list);827827+ spin_unlock_irqrestore(&connlock, flags);828828+829829+ return rc;830830+}831831+EXPORT_SYMBOL_GPL(iscsi_if_destroy_session_done);832832+833833+/**834834+ * iscsi_if_create_session_done - send session creation completion event835835+ * @conn: leading connection for session836836+ *837837+ * This is called by HW iscsi LLDs to notify userpsace that its HW has838838+ * created a session or a existing session is back in the logged in state.839839+ **/840840+int iscsi_if_create_session_done(struct iscsi_cls_conn *conn)841841+{842842+ struct iscsi_internal *priv;843843+ struct iscsi_cls_session *session;844844+ struct Scsi_Host *shost;845845+ struct iscsi_uevent *ev;846846+ struct sk_buff *skb;847847+ struct nlmsghdr *nlh;848848+ unsigned long flags;849849+ int rc, len = NLMSG_SPACE(sizeof(*ev));850850+851851+ priv = iscsi_if_transport_lookup(conn->transport);852852+ if (!priv)853853+ return -EINVAL;854854+855855+ session = iscsi_dev_to_session(conn->dev.parent);856856+ shost = iscsi_session_to_shost(session);857857+858858+ mempool_zone_complete(conn->z_pdu);859859+860860+ skb = mempool_zone_get_skb(conn->z_pdu);861861+ if (!skb) {862862+ dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "863863+ "session creation event\n");864864+ return -ENOMEM;865865+ }866866+867867+ nlh = __nlmsg_put(skb, priv->daemon_pid, 0, 0, (len - sizeof(*nlh)), 0);868868+ ev = NLMSG_DATA(nlh);869869+ ev->transport_handle = iscsi_handle(conn->transport);870870+ ev->type = ISCSI_UEVENT_CREATE_SESSION;871871+ ev->r.c_session_ret.host_no = shost->host_no;872872+ ev->r.c_session_ret.sid = session->sid;873873+874874+ /*875875+ * this will occur if the daemon is not up, so we just warn876876+ * the user and when the daemon is restarted it will handle it877877+ */878878+ rc = iscsi_broadcast_skb(conn->z_pdu, skb);879879+ if (rc < 0)880880+ dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "881881+ "session creation event. Check iscsi daemon\n");882882+883883+ spin_lock_irqsave(&sesslock, flags);884884+ list_add(&session->sess_list, &sesslist);885885+ spin_unlock_irqrestore(&sesslock, flags);886886+887887+ spin_lock_irqsave(&connlock, flags);888888+ list_add(&conn->conn_list, &connlist);889889+ conn->active = 1;890890+ spin_unlock_irqrestore(&connlock, flags);891891+ return rc;892892+}893893+EXPORT_SYMBOL_GPL(iscsi_if_create_session_done);894894+853895static int854896iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_uevent *ev)855897{···1020812 return -ENOMEM;1021813 }102281410231023- conn->z_pdu = mempool_zone_init(Z_MAX_PDU,10241024- NLMSG_SPACE(sizeof(struct iscsi_uevent) +10251025- sizeof(struct iscsi_hdr) +10261026- DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH),10271027- Z_HIWAT_PDU);10281028- if (!conn->z_pdu) {10291029- dev_printk(KERN_ERR, &conn->dev, "iscsi: can not allocate "10301030- "pdu zone for new conn\n");10311031- goto destroy_conn;10321032- }10331033-10341034- conn->z_error = mempool_zone_init(Z_MAX_ERROR,10351035- NLMSG_SPACE(sizeof(struct iscsi_uevent)),10361036- Z_HIWAT_ERROR);10371037- if (!conn->z_error) {10381038- dev_printk(KERN_ERR, &conn->dev, "iscsi: can not allocate "10391039- "error zone for new conn\n");10401040- goto free_pdu_pool;10411041- }10421042-1043815 ev->r.c_conn_ret.sid = session->sid;1044816 ev->r.c_conn_ret.cid = conn->cid;1045817···1029841 spin_unlock_irqrestore(&connlock, flags);10308421031843 return 0;10321032-10331033-free_pdu_pool:10341034- mempool_zone_destroy(conn->z_pdu);10351035-destroy_conn:10361036- if (transport->destroy_conn)10371037- transport->destroy_conn(conn->dd_data);10381038- return -ENOMEM;1039844}10408451041846static int···1036855{1037856 unsigned long flags;1038857 struct iscsi_cls_conn *conn;10391039- struct mempool_zone *z_error, *z_pdu;10408581041859 conn = iscsi_conn_lookup(ev->u.d_conn.sid, ev->u.d_conn.cid);1042860 if (!conn)···1045865 list_del(&conn->conn_list);1046866 spin_unlock_irqrestore(&connlock, flags);104786710481048- z_pdu = conn->z_pdu;10491049- z_error = conn->z_error;10501050-1051868 if (transport->destroy_conn)1052869 transport->destroy_conn(conn);10531053-10541054- mempool_zone_destroy(z_pdu);10551055- mempool_zone_destroy(z_error);10561056-1057870 return 0;10581058-}10591059-10601060-static void10611061-iscsi_copy_param(struct iscsi_uevent *ev, uint32_t *value, char *data)10621062-{10631063- if (ev->u.set_param.len != sizeof(uint32_t))10641064- BUG();10651065- memcpy(value, data, min_t(uint32_t, sizeof(uint32_t),10661066- ev->u.set_param.len));1067871}10688721069873static int···1056892 char *data = (char*)ev + sizeof(*ev);1057893 struct iscsi_cls_conn *conn;1058894 struct iscsi_cls_session *session;10591059- int err = 0;10601060- uint32_t value = 0;895895+ int err = 0, value = 0;10618961062897 session = iscsi_session_lookup(ev->u.set_param.sid);1063898 conn = iscsi_conn_lookup(ev->u.set_param.sid, ev->u.set_param.cid);···10659021066903 switch (ev->u.set_param.param) {1067904 case ISCSI_PARAM_SESS_RECOVERY_TMO:10681068- iscsi_copy_param(ev, &value, data);905905+ sscanf(data, "%d", &value);1069906 if (value != 0)1070907 session->recovery_tmo = value;1071908 break;10721072- case ISCSI_PARAM_TARGET_NAME:10731073- /* this should not change between logins */10741074- if (session->targetname)10751075- return 0;10761076-10771077- session->targetname = kstrdup(data, GFP_KERNEL);10781078- if (!session->targetname)10791079- return -ENOMEM;10801080- break;10811081- case ISCSI_PARAM_TPGT:10821082- iscsi_copy_param(ev, &value, data);10831083- session->tpgt = value;10841084- break;10851085- case ISCSI_PARAM_PERSISTENT_PORT:10861086- iscsi_copy_param(ev, &value, data);10871087- conn->persistent_port = value;10881088- break;10891089- case ISCSI_PARAM_PERSISTENT_ADDRESS:10901090- /*10911091- * this is the address returned in discovery so it should10921092- * not change between logins.10931093- */10941094- if (conn->persistent_address)10951095- return 0;10961096-10971097- conn->persistent_address = kstrdup(data, GFP_KERNEL);10981098- if (!conn->persistent_address)10991099- return -ENOMEM;11001100- break;1101909 default:11021102- iscsi_copy_param(ev, &value, data);11031103- err = transport->set_param(conn, ev->u.set_param.param, value);910910+ err = transport->set_param(conn, ev->u.set_param.param,911911+ data, ev->u.set_param.len);1104912 }11059131106914 return err;···1109975 break;1110976 }1111977 return rc;978978+}979979+980980+static int981981+iscsi_tgt_dscvr(struct iscsi_transport *transport,982982+ struct iscsi_uevent *ev)983983+{984984+ struct sockaddr *dst_addr;985985+986986+ if (!transport->tgt_dscvr)987987+ return -EINVAL;988988+989989+ dst_addr = (struct sockaddr *)((char*)ev + sizeof(*ev));990990+ return transport->tgt_dscvr(ev->u.tgt_dscvr.type,991991+ ev->u.tgt_dscvr.host_no,992992+ ev->u.tgt_dscvr.enable, dst_addr);1112993}11139941114995static int···12141065 case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT:12151066 err = iscsi_if_transport_ep(transport, ev, nlh->nlmsg_type);12161067 break;10681068+ case ISCSI_UEVENT_TGT_DSCVR:10691069+ err = iscsi_tgt_dscvr(transport, ev);10701070+ break;12171071 default:12181072 err = -EINVAL;12191073 break;···12991147/*13001148 * iSCSI connection attrs13011149 */13021302-#define iscsi_conn_int_attr_show(param, format) \11501150+#define iscsi_conn_attr_show(param) \13031151static ssize_t \13041304-show_conn_int_param_##param(struct class_device *cdev, char *buf) \13051305-{ \13061306- uint32_t value = 0; \13071307- struct iscsi_cls_conn *conn = iscsi_cdev_to_conn(cdev); \13081308- struct iscsi_transport *t = conn->transport; \13091309- \13101310- t->get_conn_param(conn, param, &value); \13111311- return snprintf(buf, 20, format"\n", value); \13121312-}13131313-13141314-#define iscsi_conn_int_attr(field, param, format) \13151315- iscsi_conn_int_attr_show(param, format) \13161316-static ISCSI_CLASS_ATTR(conn, field, S_IRUGO, show_conn_int_param_##param, \13171317- NULL);13181318-13191319-iscsi_conn_int_attr(max_recv_dlength, ISCSI_PARAM_MAX_RECV_DLENGTH, "%u");13201320-iscsi_conn_int_attr(max_xmit_dlength, ISCSI_PARAM_MAX_XMIT_DLENGTH, "%u");13211321-iscsi_conn_int_attr(header_digest, ISCSI_PARAM_HDRDGST_EN, "%d");13221322-iscsi_conn_int_attr(data_digest, ISCSI_PARAM_DATADGST_EN, "%d");13231323-iscsi_conn_int_attr(ifmarker, ISCSI_PARAM_IFMARKER_EN, "%d");13241324-iscsi_conn_int_attr(ofmarker, ISCSI_PARAM_OFMARKER_EN, "%d");13251325-iscsi_conn_int_attr(persistent_port, ISCSI_PARAM_PERSISTENT_PORT, "%d");13261326-iscsi_conn_int_attr(port, ISCSI_PARAM_CONN_PORT, "%d");13271327-iscsi_conn_int_attr(exp_statsn, ISCSI_PARAM_EXP_STATSN, "%u");13281328-13291329-#define iscsi_conn_str_attr_show(param) \13301330-static ssize_t \13311331-show_conn_str_param_##param(struct class_device *cdev, char *buf) \11521152+show_conn_param_##param(struct class_device *cdev, char *buf) \13321153{ \13331154 struct iscsi_cls_conn *conn = iscsi_cdev_to_conn(cdev); \13341155 struct iscsi_transport *t = conn->transport; \13351335- return t->get_conn_str_param(conn, param, buf); \11561156+ return t->get_conn_param(conn, param, buf); \13361157}1337115813381338-#define iscsi_conn_str_attr(field, param) \13391339- iscsi_conn_str_attr_show(param) \13401340-static ISCSI_CLASS_ATTR(conn, field, S_IRUGO, show_conn_str_param_##param, \11591159+#define iscsi_conn_attr(field, param) \11601160+ iscsi_conn_attr_show(param) \11611161+static ISCSI_CLASS_ATTR(conn, field, S_IRUGO, show_conn_param_##param, \13411162 NULL);1342116313431343-iscsi_conn_str_attr(persistent_address, ISCSI_PARAM_PERSISTENT_ADDRESS);13441344-iscsi_conn_str_attr(address, ISCSI_PARAM_CONN_ADDRESS);11641164+iscsi_conn_attr(max_recv_dlength, ISCSI_PARAM_MAX_RECV_DLENGTH);11651165+iscsi_conn_attr(max_xmit_dlength, ISCSI_PARAM_MAX_XMIT_DLENGTH);11661166+iscsi_conn_attr(header_digest, ISCSI_PARAM_HDRDGST_EN);11671167+iscsi_conn_attr(data_digest, ISCSI_PARAM_DATADGST_EN);11681168+iscsi_conn_attr(ifmarker, ISCSI_PARAM_IFMARKER_EN);11691169+iscsi_conn_attr(ofmarker, ISCSI_PARAM_OFMARKER_EN);11701170+iscsi_conn_attr(persistent_port, ISCSI_PARAM_PERSISTENT_PORT);11711171+iscsi_conn_attr(port, ISCSI_PARAM_CONN_PORT);11721172+iscsi_conn_attr(exp_statsn, ISCSI_PARAM_EXP_STATSN);11731173+iscsi_conn_attr(persistent_address, ISCSI_PARAM_PERSISTENT_ADDRESS);11741174+iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS);1345117513461176#define iscsi_cdev_to_session(_cdev) \13471177 iscsi_dev_to_session(_cdev->dev)···13311197/*13321198 * iSCSI session attrs13331199 */13341334-#define iscsi_session_int_attr_show(param, format) \12001200+#define iscsi_session_attr_show(param) \13351201static ssize_t \13361336-show_session_int_param_##param(struct class_device *cdev, char *buf) \13371337-{ \13381338- uint32_t value = 0; \13391339- struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); \13401340- struct iscsi_transport *t = session->transport; \13411341- \13421342- t->get_session_param(session, param, &value); \13431343- return snprintf(buf, 20, format"\n", value); \13441344-}13451345-13461346-#define iscsi_session_int_attr(field, param, format) \13471347- iscsi_session_int_attr_show(param, format) \13481348-static ISCSI_CLASS_ATTR(sess, field, S_IRUGO, show_session_int_param_##param, \13491349- NULL);13501350-13511351-iscsi_session_int_attr(initial_r2t, ISCSI_PARAM_INITIAL_R2T_EN, "%d");13521352-iscsi_session_int_attr(max_outstanding_r2t, ISCSI_PARAM_MAX_R2T, "%hu");13531353-iscsi_session_int_attr(immediate_data, ISCSI_PARAM_IMM_DATA_EN, "%d");13541354-iscsi_session_int_attr(first_burst_len, ISCSI_PARAM_FIRST_BURST, "%u");13551355-iscsi_session_int_attr(max_burst_len, ISCSI_PARAM_MAX_BURST, "%u");13561356-iscsi_session_int_attr(data_pdu_in_order, ISCSI_PARAM_PDU_INORDER_EN, "%d");13571357-iscsi_session_int_attr(data_seq_in_order, ISCSI_PARAM_DATASEQ_INORDER_EN, "%d");13581358-iscsi_session_int_attr(erl, ISCSI_PARAM_ERL, "%d");13591359-iscsi_session_int_attr(tpgt, ISCSI_PARAM_TPGT, "%d");13601360-13611361-#define iscsi_session_str_attr_show(param) \13621362-static ssize_t \13631363-show_session_str_param_##param(struct class_device *cdev, char *buf) \12021202+show_session_param_##param(struct class_device *cdev, char *buf) \13641203{ \13651204 struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); \13661205 struct iscsi_transport *t = session->transport; \13671367- return t->get_session_str_param(session, param, buf); \12061206+ return t->get_session_param(session, param, buf); \13681207}1369120813701370-#define iscsi_session_str_attr(field, param) \13711371- iscsi_session_str_attr_show(param) \13721372-static ISCSI_CLASS_ATTR(sess, field, S_IRUGO, show_session_str_param_##param, \12091209+#define iscsi_session_attr(field, param) \12101210+ iscsi_session_attr_show(param) \12111211+static ISCSI_CLASS_ATTR(sess, field, S_IRUGO, show_session_param_##param, \13731212 NULL);1374121313751375-iscsi_session_str_attr(targetname, ISCSI_PARAM_TARGET_NAME);12141214+iscsi_session_attr(targetname, ISCSI_PARAM_TARGET_NAME);12151215+iscsi_session_attr(initial_r2t, ISCSI_PARAM_INITIAL_R2T_EN);12161216+iscsi_session_attr(max_outstanding_r2t, ISCSI_PARAM_MAX_R2T);12171217+iscsi_session_attr(immediate_data, ISCSI_PARAM_IMM_DATA_EN);12181218+iscsi_session_attr(first_burst_len, ISCSI_PARAM_FIRST_BURST);12191219+iscsi_session_attr(max_burst_len, ISCSI_PARAM_MAX_BURST);12201220+iscsi_session_attr(data_pdu_in_order, ISCSI_PARAM_PDU_INORDER_EN);12211221+iscsi_session_attr(data_seq_in_order, ISCSI_PARAM_DATASEQ_INORDER_EN);12221222+iscsi_session_attr(erl, ISCSI_PARAM_ERL);12231223+iscsi_session_attr(tpgt, ISCSI_PARAM_TPGT);1376122413771377-/*13781378- * Private session and conn attrs. userspace uses several iscsi values13791379- * to identify each session between reboots. Some of these values may not13801380- * be present in the iscsi_transport/LLD driver becuase userspace handles13811381- * login (and failback for login redirect) so for these type of drivers13821382- * the class manages the attrs and values for the iscsi_transport/LLD13831383- */13841225#define iscsi_priv_session_attr_show(field, format) \13851226static ssize_t \13861386-show_priv_session_##field(struct class_device *cdev, char *buf) \12271227+show_priv_session_##field(struct class_device *cdev, char *buf) \13871228{ \13881388- struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); \12291229+ struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev);\13891230 return sprintf(buf, format"\n", session->field); \13901231}13911232···13681259 iscsi_priv_session_attr_show(field, format) \13691260static ISCSI_CLASS_ATTR(priv_sess, field, S_IRUGO, show_priv_session_##field, \13701261 NULL)13711371-iscsi_priv_session_attr(targetname, "%s");13721372-iscsi_priv_session_attr(tpgt, "%d");13731262iscsi_priv_session_attr(recovery_tmo, "%d");13741374-13751375-#define iscsi_priv_conn_attr_show(field, format) \13761376-static ssize_t \13771377-show_priv_conn_##field(struct class_device *cdev, char *buf) \13781378-{ \13791379- struct iscsi_cls_conn *conn = iscsi_cdev_to_conn(cdev); \13801380- return sprintf(buf, format"\n", conn->field); \13811381-}13821382-13831383-#define iscsi_priv_conn_attr(field, format) \13841384- iscsi_priv_conn_attr_show(field, format) \13851385-static ISCSI_CLASS_ATTR(priv_conn, field, S_IRUGO, show_priv_conn_##field, \13861386- NULL)13871387-iscsi_priv_conn_attr(persistent_address, "%s");13881388-iscsi_priv_conn_attr(persistent_port, "%d");1389126313901264#define SETUP_PRIV_SESSION_RD_ATTR(field) \13911265do { \···13761284 count++; \13771285} while (0)1378128612871287+13791288#define SETUP_SESSION_RD_ATTR(field, param_flag) \13801289do { \13811290 if (tt->param_mask & param_flag) { \13821291 priv->session_attrs[count] = &class_device_attr_sess_##field; \13831292 count++; \13841293 } \13851385-} while (0)13861386-13871387-#define SETUP_PRIV_CONN_RD_ATTR(field) \13881388-do { \13891389- priv->conn_attrs[count] = &class_device_attr_priv_conn_##field; \13901390- count++; \13911294} while (0)1392129513931296#define SETUP_CONN_RD_ATTR(field, param_flag) \···14751388 if (!priv)14761389 return NULL;14771390 INIT_LIST_HEAD(&priv->list);13911391+ priv->daemon_pid = -1;14781392 priv->iscsi_transport = tt;14791393 priv->t.user_scan = iscsi_user_scan;14801394···15121424 SETUP_CONN_RD_ATTR(address, ISCSI_CONN_ADDRESS);15131425 SETUP_CONN_RD_ATTR(port, ISCSI_CONN_PORT);15141426 SETUP_CONN_RD_ATTR(exp_statsn, ISCSI_EXP_STATSN);15151515-15161516- if (tt->param_mask & ISCSI_PERSISTENT_ADDRESS)15171517- SETUP_CONN_RD_ATTR(persistent_address, ISCSI_PERSISTENT_ADDRESS);15181518- else15191519- SETUP_PRIV_CONN_RD_ATTR(persistent_address);15201520-15211521- if (tt->param_mask & ISCSI_PERSISTENT_PORT)15221522- SETUP_CONN_RD_ATTR(persistent_port, ISCSI_PERSISTENT_PORT);15231523- else15241524- SETUP_PRIV_CONN_RD_ATTR(persistent_port);14271427+ SETUP_CONN_RD_ATTR(persistent_address, ISCSI_PERSISTENT_ADDRESS);14281428+ SETUP_CONN_RD_ATTR(persistent_port, ISCSI_PERSISTENT_PORT);1525142915261430 BUG_ON(count > ISCSI_CONN_ATTRS);15271431 priv->conn_attrs[count] = NULL;···15331453 SETUP_SESSION_RD_ATTR(data_pdu_in_order, ISCSI_PDU_INORDER_EN);15341454 SETUP_SESSION_RD_ATTR(data_seq_in_order, ISCSI_DATASEQ_INORDER_EN);15351455 SETUP_SESSION_RD_ATTR(erl, ISCSI_ERL);14561456+ SETUP_SESSION_RD_ATTR(targetname, ISCSI_TARGET_NAME);14571457+ SETUP_SESSION_RD_ATTR(tpgt, ISCSI_TPGT);15361458 SETUP_PRIV_SESSION_RD_ATTR(recovery_tmo);15371537-15381538- if (tt->param_mask & ISCSI_TARGET_NAME)15391539- SETUP_SESSION_RD_ATTR(targetname, ISCSI_TARGET_NAME);15401540- else15411541- SETUP_PRIV_SESSION_RD_ATTR(targetname);15421542-15431543- if (tt->param_mask & ISCSI_TPGT)15441544- SETUP_SESSION_RD_ATTR(tpgt, ISCSI_TPGT);15451545- else15461546- SETUP_PRIV_SESSION_RD_ATTR(tpgt);1547145915481460 BUG_ON(count > ISCSI_SESSION_ATTRS);15491461 priv->session_attrs[count] = NULL;
+332-37
drivers/scsi/scsi_transport_sas.c
···174174175175static int do_sas_phy_delete(struct device *dev, void *data)176176{177177- if (scsi_is_sas_phy(dev))177177+ int pass = (int)(unsigned long)data;178178+179179+ if (pass == 0 && scsi_is_sas_port(dev))180180+ sas_port_delete(dev_to_sas_port(dev));181181+ else if (pass == 1 && scsi_is_sas_phy(dev))178182 sas_phy_delete(dev_to_phy(dev));179183 return 0;180184}185185+186186+/**187187+ * sas_remove_children -- tear down a devices SAS data structures188188+ * @dev: device belonging to the sas object189189+ *190190+ * Removes all SAS PHYs and remote PHYs for a given object191191+ */192192+void sas_remove_children(struct device *dev)193193+{194194+ device_for_each_child(dev, (void *)0, do_sas_phy_delete);195195+ device_for_each_child(dev, (void *)1, do_sas_phy_delete);196196+}197197+EXPORT_SYMBOL(sas_remove_children);181198182199/**183200 * sas_remove_host -- tear down a Scsi_Host's SAS data structures···205188 */206189void sas_remove_host(struct Scsi_Host *shost)207190{208208- device_for_each_child(&shost->shost_gendev, NULL, do_sas_phy_delete);191191+ sas_remove_children(&shost->shost_gendev);209192}210193EXPORT_SYMBOL(sas_remove_host);211194212195213196/*214214- * SAS Port attributes197197+ * SAS Phy attributes215198 */216199217200#define sas_phy_show_simple(field, name, format_string, cast) \···327310sas_phy_simple_attr(identify.sas_address, sas_address, "0x%016llx\n",328311 unsigned long long);329312sas_phy_simple_attr(identify.phy_identifier, phy_identifier, "%d\n", u8);330330-sas_phy_simple_attr(port_identifier, port_identifier, "%d\n", u8);313313+//sas_phy_simple_attr(port_identifier, port_identifier, "%d\n", u8);331314sas_phy_linkspeed_attr(negotiated_linkrate);332315sas_phy_linkspeed_attr(minimum_linkrate_hw);333316sas_phy_linkspeed_attr(minimum_linkrate);···395378 device_initialize(&phy->dev);396379 phy->dev.parent = get_device(parent);397380 phy->dev.release = sas_phy_release;381381+ INIT_LIST_HEAD(&phy->port_siblings);398382 if (scsi_is_sas_expander_device(parent)) {399383 struct sas_rphy *rphy = dev_to_rphy(parent);400400- sprintf(phy->dev.bus_id, "phy-%d-%d:%d", shost->host_no,384384+ sprintf(phy->dev.bus_id, "phy-%d:%d:%d", shost->host_no,401385 rphy->scsi_target_id, number);402386 } else403387 sprintf(phy->dev.bus_id, "phy-%d:%d", shost->host_no, number);···458440{459441 struct device *dev = &phy->dev;460442461461- if (phy->rphy)462462- sas_rphy_delete(phy->rphy);443443+ /* this happens if the phy is still part of a port when deleted */444444+ BUG_ON(!list_empty(&phy->port_siblings));463445464446 transport_remove_device(dev);465447 device_del(dev);···480462 return dev->release == sas_phy_release;481463}482464EXPORT_SYMBOL(scsi_is_sas_phy);465465+466466+/*467467+ * SAS Port attributes468468+ */469469+#define sas_port_show_simple(field, name, format_string, cast) \470470+static ssize_t \471471+show_sas_port_##name(struct class_device *cdev, char *buf) \472472+{ \473473+ struct sas_port *port = transport_class_to_sas_port(cdev); \474474+ \475475+ return snprintf(buf, 20, format_string, cast port->field); \476476+}477477+478478+#define sas_port_simple_attr(field, name, format_string, type) \479479+ sas_port_show_simple(field, name, format_string, (type)) \480480+static CLASS_DEVICE_ATTR(name, S_IRUGO, show_sas_port_##name, NULL)481481+482482+sas_port_simple_attr(num_phys, num_phys, "%d\n", int);483483+484484+static DECLARE_TRANSPORT_CLASS(sas_port_class,485485+ "sas_port", NULL, NULL, NULL);486486+487487+static int sas_port_match(struct attribute_container *cont, struct device *dev)488488+{489489+ struct Scsi_Host *shost;490490+ struct sas_internal *i;491491+492492+ if (!scsi_is_sas_port(dev))493493+ return 0;494494+ shost = dev_to_shost(dev->parent);495495+496496+ if (!shost->transportt)497497+ return 0;498498+ if (shost->transportt->host_attrs.ac.class !=499499+ &sas_host_class.class)500500+ return 0;501501+502502+ i = to_sas_internal(shost->transportt);503503+ return &i->port_attr_cont.ac == cont;504504+}505505+506506+507507+static void sas_port_release(struct device *dev)508508+{509509+ struct sas_port *port = dev_to_sas_port(dev);510510+511511+ BUG_ON(!list_empty(&port->phy_list));512512+513513+ put_device(dev->parent);514514+ kfree(port);515515+}516516+517517+static void sas_port_create_link(struct sas_port *port,518518+ struct sas_phy *phy)519519+{520520+ sysfs_create_link(&port->dev.kobj, &phy->dev.kobj, phy->dev.bus_id);521521+ sysfs_create_link(&phy->dev.kobj, &port->dev.kobj, "port");522522+}523523+524524+static void sas_port_delete_link(struct sas_port *port,525525+ struct sas_phy *phy)526526+{527527+ sysfs_remove_link(&port->dev.kobj, phy->dev.bus_id);528528+ sysfs_remove_link(&phy->dev.kobj, "port");529529+}530530+531531+/** sas_port_alloc - allocate and initialize a SAS port structure532532+ *533533+ * @parent: parent device534534+ * @port_id: port number535535+ *536536+ * Allocates a SAS port structure. It will be added to the device tree537537+ * below the device specified by @parent which must be either a Scsi_Host538538+ * or a sas_expander_device.539539+ *540540+ * Returns %NULL on error541541+ */542542+struct sas_port *sas_port_alloc(struct device *parent, int port_id)543543+{544544+ struct Scsi_Host *shost = dev_to_shost(parent);545545+ struct sas_port *port;546546+547547+ port = kzalloc(sizeof(*port), GFP_KERNEL);548548+ if (!port)549549+ return NULL;550550+551551+ port->port_identifier = port_id;552552+553553+ device_initialize(&port->dev);554554+555555+ port->dev.parent = get_device(parent);556556+ port->dev.release = sas_port_release;557557+558558+ mutex_init(&port->phy_list_mutex);559559+ INIT_LIST_HEAD(&port->phy_list);560560+561561+ if (scsi_is_sas_expander_device(parent)) {562562+ struct sas_rphy *rphy = dev_to_rphy(parent);563563+ sprintf(port->dev.bus_id, "port-%d:%d:%d", shost->host_no,564564+ rphy->scsi_target_id, port->port_identifier);565565+ } else566566+ sprintf(port->dev.bus_id, "port-%d:%d", shost->host_no,567567+ port->port_identifier);568568+569569+ transport_setup_device(&port->dev);570570+571571+ return port;572572+}573573+EXPORT_SYMBOL(sas_port_alloc);574574+575575+/**576576+ * sas_port_add - add a SAS port to the device hierarchy577577+ *578578+ * @port: port to be added579579+ *580580+ * publishes a port to the rest of the system581581+ */582582+int sas_port_add(struct sas_port *port)583583+{584584+ int error;585585+586586+ /* No phys should be added until this is made visible */587587+ BUG_ON(!list_empty(&port->phy_list));588588+589589+ error = device_add(&port->dev);590590+591591+ if (error)592592+ return error;593593+594594+ transport_add_device(&port->dev);595595+ transport_configure_device(&port->dev);596596+597597+ return 0;598598+}599599+EXPORT_SYMBOL(sas_port_add);600600+601601+/**602602+ * sas_port_free -- free a SAS PORT603603+ * @port: SAS PORT to free604604+ *605605+ * Frees the specified SAS PORT.606606+ *607607+ * Note:608608+ * This function must only be called on a PORT that has not609609+ * sucessfully been added using sas_port_add().610610+ */611611+void sas_port_free(struct sas_port *port)612612+{613613+ transport_destroy_device(&port->dev);614614+ put_device(&port->dev);615615+}616616+EXPORT_SYMBOL(sas_port_free);617617+618618+/**619619+ * sas_port_delete -- remove SAS PORT620620+ * @port: SAS PORT to remove621621+ *622622+ * Removes the specified SAS PORT. If the SAS PORT has an623623+ * associated phys, unlink them from the port as well.624624+ */625625+void sas_port_delete(struct sas_port *port)626626+{627627+ struct device *dev = &port->dev;628628+ struct sas_phy *phy, *tmp_phy;629629+630630+ if (port->rphy) {631631+ sas_rphy_delete(port->rphy);632632+ port->rphy = NULL;633633+ }634634+635635+ mutex_lock(&port->phy_list_mutex);636636+ list_for_each_entry_safe(phy, tmp_phy, &port->phy_list,637637+ port_siblings) {638638+ sas_port_delete_link(port, phy);639639+ list_del_init(&phy->port_siblings);640640+ }641641+ mutex_unlock(&port->phy_list_mutex);642642+643643+ transport_remove_device(dev);644644+ device_del(dev);645645+ transport_destroy_device(dev);646646+ put_device(dev);647647+}648648+EXPORT_SYMBOL(sas_port_delete);649649+650650+/**651651+ * scsi_is_sas_port -- check if a struct device represents a SAS port652652+ * @dev: device to check653653+ *654654+ * Returns:655655+ * %1 if the device represents a SAS Port, %0 else656656+ */657657+int scsi_is_sas_port(const struct device *dev)658658+{659659+ return dev->release == sas_port_release;660660+}661661+EXPORT_SYMBOL(scsi_is_sas_port);662662+663663+/**664664+ * sas_port_add_phy - add another phy to a port to form a wide port665665+ * @port: port to add the phy to666666+ * @phy: phy to add667667+ *668668+ * When a port is initially created, it is empty (has no phys). All669669+ * ports must have at least one phy to operated, and all wide ports670670+ * must have at least two. The current code makes no difference671671+ * between ports and wide ports, but the only object that can be672672+ * connected to a remote device is a port, so ports must be formed on673673+ * all devices with phys if they're connected to anything.674674+ */675675+void sas_port_add_phy(struct sas_port *port, struct sas_phy *phy)676676+{677677+ mutex_lock(&port->phy_list_mutex);678678+ if (unlikely(!list_empty(&phy->port_siblings))) {679679+ /* make sure we're already on this port */680680+ struct sas_phy *tmp;681681+682682+ list_for_each_entry(tmp, &port->phy_list, port_siblings)683683+ if (tmp == phy)684684+ break;685685+ /* If this trips, you added a phy that was already686686+ * part of a different port */687687+ if (unlikely(tmp != phy)) {688688+ dev_printk(KERN_ERR, &port->dev, "trying to add phy %s fails: it's already part of another port\n", phy->dev.bus_id);689689+ BUG();690690+ }691691+ } else {692692+ sas_port_create_link(port, phy);693693+ list_add_tail(&phy->port_siblings, &port->phy_list);694694+ port->num_phys++;695695+ }696696+ mutex_unlock(&port->phy_list_mutex);697697+}698698+EXPORT_SYMBOL(sas_port_add_phy);699699+700700+/**701701+ * sas_port_delete_phy - remove a phy from a port or wide port702702+ * @port: port to remove the phy from703703+ * @phy: phy to remove704704+ *705705+ * This operation is used for tearing down ports again. It must be706706+ * done to every port or wide port before calling sas_port_delete.707707+ */708708+void sas_port_delete_phy(struct sas_port *port, struct sas_phy *phy)709709+{710710+ mutex_lock(&port->phy_list_mutex);711711+ sas_port_delete_link(port, phy);712712+ list_del_init(&phy->port_siblings);713713+ port->num_phys--;714714+ mutex_unlock(&port->phy_list_mutex);715715+}716716+EXPORT_SYMBOL(sas_port_delete_phy);483717484718/*485719 * SAS remote PHY attributes.···1037767 * Returns:1038768 * SAS PHY allocated or %NULL if the allocation failed.1039769 */10401040-struct sas_rphy *sas_end_device_alloc(struct sas_phy *parent)770770+struct sas_rphy *sas_end_device_alloc(struct sas_port *parent)1041771{1042772 struct Scsi_Host *shost = dev_to_shost(&parent->dev);1043773 struct sas_end_device *rdev;···1050780 device_initialize(&rdev->rphy.dev);1051781 rdev->rphy.dev.parent = get_device(&parent->dev);1052782 rdev->rphy.dev.release = sas_end_device_release;10531053- sprintf(rdev->rphy.dev.bus_id, "end_device-%d:%d-%d",10541054- shost->host_no, parent->port_identifier, parent->number);783783+ if (scsi_is_sas_expander_device(parent->dev.parent)) {784784+ struct sas_rphy *rphy = dev_to_rphy(parent->dev.parent);785785+ sprintf(rdev->rphy.dev.bus_id, "end_device-%d:%d:%d",786786+ shost->host_no, rphy->scsi_target_id, parent->port_identifier);787787+ } else788788+ sprintf(rdev->rphy.dev.bus_id, "end_device-%d:%d",789789+ shost->host_no, parent->port_identifier);1055790 rdev->rphy.identify.device_type = SAS_END_DEVICE;1056791 sas_rphy_initialize(&rdev->rphy);1057792 transport_setup_device(&rdev->rphy.dev);···1073798 * Returns:1074799 * SAS PHY allocated or %NULL if the allocation failed.1075800 */10761076-struct sas_rphy *sas_expander_alloc(struct sas_phy *parent,801801+struct sas_rphy *sas_expander_alloc(struct sas_port *parent,1077802 enum sas_device_type type)1078803{1079804 struct Scsi_Host *shost = dev_to_shost(&parent->dev);···1112837 */1113838int sas_rphy_add(struct sas_rphy *rphy)1114839{11151115- struct sas_phy *parent = dev_to_phy(rphy->dev.parent);840840+ struct sas_port *parent = dev_to_sas_port(rphy->dev.parent);1116841 struct Scsi_Host *shost = dev_to_shost(parent->dev.parent);1117842 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);1118843 struct sas_identify *identify = &rphy->identify;···1185910sas_rphy_delete(struct sas_rphy *rphy)1186911{1187912 struct device *dev = &rphy->dev;11881188- struct sas_phy *parent = dev_to_phy(dev->parent);913913+ struct sas_port *parent = dev_to_sas_port(dev->parent);1189914 struct Scsi_Host *shost = dev_to_shost(parent->dev.parent);1190915 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);1191916···1195920 break;1196921 case SAS_EDGE_EXPANDER_DEVICE:1197922 case SAS_FANOUT_EXPANDER_DEVICE:11981198- device_for_each_child(dev, NULL, do_sas_phy_delete);923923+ sas_remove_children(dev);1199924 break;1200925 default:1201926 break;···12429671243968 mutex_lock(&sas_host->lock);1244969 list_for_each_entry(rphy, &sas_host->rphy_list, list) {12451245- struct sas_phy *parent = dev_to_phy(rphy->dev.parent);970970+ struct sas_port *parent = dev_to_sas_port(rphy->dev.parent);12469711247972 if (rphy->identify.device_type != SAS_END_DEVICE ||1248973 rphy->scsi_target_id == -1)···12781003#define SETUP_OPTIONAL_RPORT_ATTRIBUTE(field, func) \12791004 SETUP_TEMPLATE(rphy_attrs, field, S_IRUGO, i->f->func)1280100512811281-#define SETUP_PORT_ATTRIBUTE(field) \10061006+#define SETUP_PHY_ATTRIBUTE(field) \12821007 SETUP_TEMPLATE(phy_attrs, field, S_IRUGO, 1)1283100812841284-#define SETUP_OPTIONAL_PORT_ATTRIBUTE(field, func) \10091009+#define SETUP_PORT_ATTRIBUTE(field) \10101010+ SETUP_TEMPLATE(port_attrs, field, S_IRUGO, 1)10111011+10121012+#define SETUP_OPTIONAL_PHY_ATTRIBUTE(field, func) \12851013 SETUP_TEMPLATE(phy_attrs, field, S_IRUGO, i->f->func)1286101412871287-#define SETUP_PORT_ATTRIBUTE_WRONLY(field) \10151015+#define SETUP_PHY_ATTRIBUTE_WRONLY(field) \12881016 SETUP_TEMPLATE(phy_attrs, field, S_IWUGO, 1)1289101712901290-#define SETUP_OPTIONAL_PORT_ATTRIBUTE_WRONLY(field, func) \10181018+#define SETUP_OPTIONAL_PHY_ATTRIBUTE_WRONLY(field, func) \12911019 SETUP_TEMPLATE(phy_attrs, field, S_IWUGO, i->f->func)1292102012931021#define SETUP_END_DEV_ATTRIBUTE(field) \···13261048 i->phy_attr_cont.ac.match = sas_phy_match;13271049 transport_container_register(&i->phy_attr_cont);1328105010511051+ i->port_attr_cont.ac.class = &sas_port_class.class;10521052+ i->port_attr_cont.ac.attrs = &i->port_attrs[0];10531053+ i->port_attr_cont.ac.match = sas_port_match;10541054+ transport_container_register(&i->port_attr_cont);10551055+13291056 i->rphy_attr_cont.ac.class = &sas_rphy_class.class;13301057 i->rphy_attr_cont.ac.attrs = &i->rphy_attrs[0];13311058 i->rphy_attr_cont.ac.match = sas_rphy_match;···13491066 i->f = ft;1350106713511068 count = 0;10691069+ SETUP_PORT_ATTRIBUTE(num_phys);13521070 i->host_attrs[count] = NULL;1353107113541072 count = 0;13551355- SETUP_PORT_ATTRIBUTE(initiator_port_protocols);13561356- SETUP_PORT_ATTRIBUTE(target_port_protocols);13571357- SETUP_PORT_ATTRIBUTE(device_type);13581358- SETUP_PORT_ATTRIBUTE(sas_address);13591359- SETUP_PORT_ATTRIBUTE(phy_identifier);13601360- SETUP_PORT_ATTRIBUTE(port_identifier);13611361- SETUP_PORT_ATTRIBUTE(negotiated_linkrate);13621362- SETUP_PORT_ATTRIBUTE(minimum_linkrate_hw);13631363- SETUP_PORT_ATTRIBUTE(minimum_linkrate);13641364- SETUP_PORT_ATTRIBUTE(maximum_linkrate_hw);13651365- SETUP_PORT_ATTRIBUTE(maximum_linkrate);10731073+ SETUP_PHY_ATTRIBUTE(initiator_port_protocols);10741074+ SETUP_PHY_ATTRIBUTE(target_port_protocols);10751075+ SETUP_PHY_ATTRIBUTE(device_type);10761076+ SETUP_PHY_ATTRIBUTE(sas_address);10771077+ SETUP_PHY_ATTRIBUTE(phy_identifier);10781078+ //SETUP_PHY_ATTRIBUTE(port_identifier);10791079+ SETUP_PHY_ATTRIBUTE(negotiated_linkrate);10801080+ SETUP_PHY_ATTRIBUTE(minimum_linkrate_hw);10811081+ SETUP_PHY_ATTRIBUTE(minimum_linkrate);10821082+ SETUP_PHY_ATTRIBUTE(maximum_linkrate_hw);10831083+ SETUP_PHY_ATTRIBUTE(maximum_linkrate);1366108413671367- SETUP_PORT_ATTRIBUTE(invalid_dword_count);13681368- SETUP_PORT_ATTRIBUTE(running_disparity_error_count);13691369- SETUP_PORT_ATTRIBUTE(loss_of_dword_sync_count);13701370- SETUP_PORT_ATTRIBUTE(phy_reset_problem_count);13711371- SETUP_OPTIONAL_PORT_ATTRIBUTE_WRONLY(link_reset, phy_reset);13721372- SETUP_OPTIONAL_PORT_ATTRIBUTE_WRONLY(hard_reset, phy_reset);10851085+ SETUP_PHY_ATTRIBUTE(invalid_dword_count);10861086+ SETUP_PHY_ATTRIBUTE(running_disparity_error_count);10871087+ SETUP_PHY_ATTRIBUTE(loss_of_dword_sync_count);10881088+ SETUP_PHY_ATTRIBUTE(phy_reset_problem_count);10891089+ SETUP_OPTIONAL_PHY_ATTRIBUTE_WRONLY(link_reset, phy_reset);10901090+ SETUP_OPTIONAL_PHY_ATTRIBUTE_WRONLY(hard_reset, phy_reset);13731091 i->phy_attrs[count] = NULL;10921092+10931093+ count = 0;10941094+ SETUP_PORT_ATTRIBUTE(num_phys);10951095+ i->port_attrs[count] = NULL;1374109613751097 count = 0;13761098 SETUP_RPORT_ATTRIBUTE(rphy_initiator_port_protocols);···1419113114201132 transport_container_unregister(&i->t.host_attrs);14211133 transport_container_unregister(&i->phy_attr_cont);11341134+ transport_container_unregister(&i->port_attr_cont);14221135 transport_container_unregister(&i->rphy_attr_cont);14231136 transport_container_unregister(&i->end_dev_attr_cont);14241137 transport_container_unregister(&i->expander_attr_cont);···14381149 error = transport_class_register(&sas_phy_class);14391150 if (error)14401151 goto out_unregister_transport;14411441- error = transport_class_register(&sas_rphy_class);11521152+ error = transport_class_register(&sas_port_class);14421153 if (error)14431154 goto out_unregister_phy;11551155+ error = transport_class_register(&sas_rphy_class);11561156+ if (error)11571157+ goto out_unregister_port;14441158 error = transport_class_register(&sas_end_dev_class);14451159 if (error)14461160 goto out_unregister_rphy;···14571165 transport_class_unregister(&sas_end_dev_class);14581166 out_unregister_rphy:14591167 transport_class_unregister(&sas_rphy_class);11681168+ out_unregister_port:11691169+ transport_class_unregister(&sas_port_class);14601170 out_unregister_phy:14611171 transport_class_unregister(&sas_phy_class);14621172 out_unregister_transport:···14721178{14731179 transport_class_unregister(&sas_host_class);14741180 transport_class_unregister(&sas_phy_class);11811181+ transport_class_unregister(&sas_port_class);14751182 transport_class_unregister(&sas_rphy_class);14761183 transport_class_unregister(&sas_end_dev_class);14771184 transport_class_unregister(&sas_expander_class);
+2-1
drivers/scsi/scsicam.c
···5757int scsicam_bios_param(struct block_device *bdev, sector_t capacity, int *ip)5858{5959 unsigned char *p;6060+ u64 capacity64 = capacity; /* Suppress gcc warning */6061 int ret;61626263 p = scsi_bios_ptable(bdev);···6968 (unsigned int *)ip + 0, (unsigned int *)ip + 1);7069 kfree(p);71707272- if (ret == -1) {7171+ if (ret == -1 && capacity64 < (1ULL << 32)) {7372 /* pick some standard mapping with at most 1024 cylinders,7473 and at most 62 sectors per track - this works up to7574 7905 MB */
+88-81
drivers/scsi/sd.c
···207207 return count;208208}209209210210+static ssize_t sd_store_allow_restart(struct class_device *cdev, const char *buf,211211+ size_t count)212212+{213213+ struct scsi_disk *sdkp = to_scsi_disk(cdev);214214+ struct scsi_device *sdp = sdkp->device;215215+216216+ if (!capable(CAP_SYS_ADMIN))217217+ return -EACCES;218218+219219+ if (sdp->type != TYPE_DISK)220220+ return -EINVAL;221221+222222+ sdp->allow_restart = simple_strtoul(buf, NULL, 10);223223+224224+ return count;225225+}226226+210227static ssize_t sd_show_cache_type(struct class_device *cdev, char *buf)211228{212229 struct scsi_disk *sdkp = to_scsi_disk(cdev);···239222 return snprintf(buf, 20, "%u\n", sdkp->DPOFUA);240223}241224225225+static ssize_t sd_show_allow_restart(struct class_device *cdev, char *buf)226226+{227227+ struct scsi_disk *sdkp = to_scsi_disk(cdev);228228+229229+ return snprintf(buf, 40, "%d\n", sdkp->device->allow_restart);230230+}231231+242232static struct class_device_attribute sd_disk_attrs[] = {243233 __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type,244234 sd_store_cache_type),245235 __ATTR(FUA, S_IRUGO, sd_show_fua, NULL),236236+ __ATTR(allow_restart, S_IRUGO|S_IWUSR, sd_show_allow_restart,237237+ sd_store_allow_restart),246238 __ATTR_NULL,247239};248240···916890static void sd_rw_intr(struct scsi_cmnd * SCpnt)917891{918892 int result = SCpnt->result;919919- int this_count = SCpnt->request_bufflen;920920- int good_bytes = (result == 0 ? this_count : 0);921921- sector_t block_sectors = 1;922922- u64 first_err_block;923923- sector_t error_sector;893893+ unsigned int xfer_size = SCpnt->request_bufflen;894894+ unsigned int good_bytes = result ? 0 : xfer_size;895895+ u64 start_lba = SCpnt->request->sector;896896+ u64 bad_lba;924897 struct scsi_sense_hdr sshdr;925898 int sense_valid = 0;926899 int sense_deferred = 0;···930905 if (sense_valid)931906 sense_deferred = scsi_sense_is_deferred(&sshdr);932907 }933933-934908#ifdef CONFIG_SCSI_LOGGING935909 SCSI_LOG_HLCOMPLETE(1, printk("sd_rw_intr: %s: res=0x%x\n", 936910 SCpnt->request->rq_disk->disk_name, result));···939915 sshdr.sense_key, sshdr.asc, sshdr.ascq));940916 }941917#endif942942- /*943943- Handle MEDIUM ERRORs that indicate partial success. Since this is a944944- relatively rare error condition, no care is taken to avoid945945- unnecessary additional work such as memcpy's that could be avoided.946946- */947947- if (driver_byte(result) != 0 &&948948- sense_valid && !sense_deferred) {949949- switch (sshdr.sense_key) {950950- case MEDIUM_ERROR:951951- if (!blk_fs_request(SCpnt->request))952952- break;953953- info_valid = scsi_get_sense_info_fld(954954- SCpnt->sense_buffer, SCSI_SENSE_BUFFERSIZE,955955- &first_err_block);956956- /*957957- * May want to warn and skip if following cast results958958- * in actual truncation (if sector_t < 64 bits)959959- */960960- error_sector = (sector_t)first_err_block;961961- if (SCpnt->request->bio != NULL)962962- block_sectors = bio_sectors(SCpnt->request->bio);963963- switch (SCpnt->device->sector_size) {964964- case 1024:965965- error_sector <<= 1;966966- if (block_sectors < 2)967967- block_sectors = 2;968968- break;969969- case 2048:970970- error_sector <<= 2;971971- if (block_sectors < 4)972972- block_sectors = 4;973973- break;974974- case 4096:975975- error_sector <<=3;976976- if (block_sectors < 8)977977- block_sectors = 8;978978- break;979979- case 256:980980- error_sector >>= 1;981981- break;982982- default:983983- break;984984- }918918+ if (driver_byte(result) != DRIVER_SENSE &&919919+ (!sense_valid || sense_deferred))920920+ goto out;985921986986- error_sector &= ~(block_sectors - 1);987987- good_bytes = (error_sector - SCpnt->request->sector) << 9;988988- if (good_bytes < 0 || good_bytes >= this_count)989989- good_bytes = 0;922922+ switch (sshdr.sense_key) {923923+ case HARDWARE_ERROR:924924+ case MEDIUM_ERROR:925925+ if (!blk_fs_request(SCpnt->request))926926+ goto out;927927+ info_valid = scsi_get_sense_info_fld(SCpnt->sense_buffer,928928+ SCSI_SENSE_BUFFERSIZE,929929+ &bad_lba);930930+ if (!info_valid)931931+ goto out;932932+ if (xfer_size <= SCpnt->device->sector_size)933933+ goto out;934934+ switch (SCpnt->device->sector_size) {935935+ case 256:936936+ start_lba <<= 1;990937 break;991991-992992- case RECOVERED_ERROR: /* an error occurred, but it recovered */993993- case NO_SENSE: /* LLDD got sense data */994994- /*995995- * Inform the user, but make sure that it's not treated996996- * as a hard error.997997- */998998- scsi_print_sense("sd", SCpnt);999999- SCpnt->result = 0;10001000- memset(SCpnt->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);10011001- good_bytes = this_count;938938+ case 512:1002939 break;10031003-10041004- case ILLEGAL_REQUEST:10051005- if (SCpnt->device->use_10_for_rw &&10061006- (SCpnt->cmnd[0] == READ_10 ||10071007- SCpnt->cmnd[0] == WRITE_10))10081008- SCpnt->device->use_10_for_rw = 0;10091009- if (SCpnt->device->use_10_for_ms &&10101010- (SCpnt->cmnd[0] == MODE_SENSE_10 ||10111011- SCpnt->cmnd[0] == MODE_SELECT_10))10121012- SCpnt->device->use_10_for_ms = 0;940940+ case 1024:941941+ start_lba >>= 1;1013942 break;10141014-943943+ case 2048:944944+ start_lba >>= 2;945945+ break;946946+ case 4096:947947+ start_lba >>= 3;948948+ break;1015949 default:950950+ /* Print something here with limiting frequency. */951951+ goto out;1016952 break;1017953 }954954+ /* This computation should always be done in terms of955955+ * the resolution of the device's medium.956956+ */957957+ good_bytes = (bad_lba - start_lba)*SCpnt->device->sector_size;958958+ break;959959+ case RECOVERED_ERROR:960960+ case NO_SENSE:961961+ /* Inform the user, but make sure that it's not treated962962+ * as a hard error.963963+ */964964+ scsi_print_sense("sd", SCpnt);965965+ SCpnt->result = 0;966966+ memset(SCpnt->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);967967+ good_bytes = xfer_size;968968+ break;969969+ case ILLEGAL_REQUEST:970970+ if (SCpnt->device->use_10_for_rw &&971971+ (SCpnt->cmnd[0] == READ_10 ||972972+ SCpnt->cmnd[0] == WRITE_10))973973+ SCpnt->device->use_10_for_rw = 0;974974+ if (SCpnt->device->use_10_for_ms &&975975+ (SCpnt->cmnd[0] == MODE_SENSE_10 ||976976+ SCpnt->cmnd[0] == MODE_SELECT_10))977977+ SCpnt->device->use_10_for_ms = 0;978978+ break;979979+ default:980980+ break;1018981 }10191019- /*10201020- * This calls the generic completion function, now that we know10211021- * how many actual sectors finished, and how many sectors we need10221022- * to say have failed.10231023- */10241024- scsi_io_completion(SCpnt, good_bytes, block_sectors << 9);982982+ out:983983+ scsi_io_completion(SCpnt, good_bytes);1025984}10269851027986static int media_not_present(struct scsi_disk *sdkp,
+9-1
drivers/scsi/sg.c
···14011401 Sg_device *sdp = NULL;14021402 struct cdev * cdev = NULL;14031403 int error, k;14041404+ unsigned long iflags;1404140514051406 disk = alloc_disk(1);14061407 if (!disk) {···1429142814301429 error = cdev_add(cdev, MKDEV(SCSI_GENERIC_MAJOR, k), 1);14311430 if (error)14321432- goto out;14311431+ goto cdev_add_err;1433143214341433 sdp->cdev = cdev;14351434 if (sg_sysfs_valid) {···14551454 "Attached scsi generic sg%d type %d\n", k,scsidp->type);1456145514571456 return 0;14571457+14581458+cdev_add_err:14591459+ write_lock_irqsave(&sg_dev_arr_lock, iflags);14601460+ kfree(sg_dev_arr[k]);14611461+ sg_dev_arr[k] = NULL;14621462+ sg_nr_dev--;14631463+ write_unlock_irqrestore(&sg_dev_arr_lock, iflags);1458146414591465out:14601466 put_disk(disk);
+1-1
drivers/scsi/sr.c
···292292 * how many actual sectors finished, and how many sectors we need293293 * to say have failed.294294 */295295- scsi_io_completion(SCpnt, good_bytes, block_sectors << 9);295295+ scsi_io_completion(SCpnt, good_bytes);296296}297297298298static int sr_init_command(struct scsi_cmnd * SCpnt)