1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * iSCSI Transport BSG Interface 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Copyright (C) 2009 James Smart, Emulex Corporation 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun #ifndef SCSI_BSG_ISCSI_H 9*4882a593Smuzhiyun #define SCSI_BSG_ISCSI_H 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun /* 12*4882a593Smuzhiyun * This file intended to be included by both kernel and user space 13*4882a593Smuzhiyun */ 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun #include <scsi/scsi.h> 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun /* 18*4882a593Smuzhiyun * iSCSI Transport SGIO v4 BSG Message Support 19*4882a593Smuzhiyun */ 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun /* Default BSG request timeout (in seconds) */ 22*4882a593Smuzhiyun #define ISCSI_DEFAULT_BSG_TIMEOUT (10 * HZ) 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun /* 26*4882a593Smuzhiyun * Request Message Codes supported by the iSCSI Transport 27*4882a593Smuzhiyun */ 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun /* define the class masks for the message codes */ 30*4882a593Smuzhiyun #define ISCSI_BSG_CLS_MASK 0xF0000000 /* find object class */ 31*4882a593Smuzhiyun #define ISCSI_BSG_HST_MASK 0x80000000 /* iscsi host class */ 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun /* iscsi host Message Codes */ 34*4882a593Smuzhiyun #define ISCSI_BSG_HST_VENDOR (ISCSI_BSG_HST_MASK | 0x000000FF) 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun /* 38*4882a593Smuzhiyun * iSCSI Host Messages 39*4882a593Smuzhiyun */ 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun /* ISCSI_BSG_HST_VENDOR : */ 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun /* Request: 44*4882a593Smuzhiyun * Note: When specifying vendor_id, be sure to read the Vendor Type and ID 45*4882a593Smuzhiyun * formatting requirements specified in scsi_netlink.h 46*4882a593Smuzhiyun */ 47*4882a593Smuzhiyun struct iscsi_bsg_host_vendor { 48*4882a593Smuzhiyun /* 49*4882a593Smuzhiyun * Identifies the vendor that the message is formatted for. This 50*4882a593Smuzhiyun * should be the recipient of the message. 51*4882a593Smuzhiyun */ 52*4882a593Smuzhiyun uint64_t vendor_id; 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun /* start of vendor command area */ 55*4882a593Smuzhiyun uint32_t vendor_cmd[]; 56*4882a593Smuzhiyun }; 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun /* Response: 59*4882a593Smuzhiyun */ 60*4882a593Smuzhiyun struct iscsi_bsg_host_vendor_reply { 61*4882a593Smuzhiyun /* start of vendor response area */ 62*4882a593Smuzhiyun uint32_t vendor_rsp[0]; 63*4882a593Smuzhiyun }; 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun /* request (CDB) structure of the sg_io_v4 */ 67*4882a593Smuzhiyun struct iscsi_bsg_request { 68*4882a593Smuzhiyun uint32_t msgcode; 69*4882a593Smuzhiyun union { 70*4882a593Smuzhiyun struct iscsi_bsg_host_vendor h_vendor; 71*4882a593Smuzhiyun } rqst_data; 72*4882a593Smuzhiyun } __attribute__((packed)); 73*4882a593Smuzhiyun 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun /* response (request sense data) structure of the sg_io_v4 */ 76*4882a593Smuzhiyun struct iscsi_bsg_reply { 77*4882a593Smuzhiyun /* 78*4882a593Smuzhiyun * The completion result. Result exists in two forms: 79*4882a593Smuzhiyun * if negative, it is an -Exxx system errno value. There will 80*4882a593Smuzhiyun * be no further reply information supplied. 81*4882a593Smuzhiyun * else, it's the 4-byte scsi error result, with driver, host, 82*4882a593Smuzhiyun * msg and status fields. The per-msgcode reply structure 83*4882a593Smuzhiyun * will contain valid data. 84*4882a593Smuzhiyun */ 85*4882a593Smuzhiyun uint32_t result; 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun /* If there was reply_payload, how much was recevied ? */ 88*4882a593Smuzhiyun uint32_t reply_payload_rcv_len; 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun union { 91*4882a593Smuzhiyun struct iscsi_bsg_host_vendor_reply vendor_reply; 92*4882a593Smuzhiyun } reply_data; 93*4882a593Smuzhiyun }; 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun 96*4882a593Smuzhiyun #endif /* SCSI_BSG_ISCSI_H */ 97