linux/drivers/target/target_core_fabric_lib.c
<<
>>
Prefs
   1/*******************************************************************************
   2 * Filename:  target_core_fabric_lib.c
   3 *
   4 * This file contains generic high level protocol identifier and PR
   5 * handlers for TCM fabric modules
   6 *
   7 * (c) Copyright 2010-2012 RisingTide Systems LLC.
   8 *
   9 * Nicholas A. Bellinger <nab@linux-iscsi.org>
  10 *
  11 * This program is free software; you can redistribute it and/or modify
  12 * it under the terms of the GNU General Public License as published by
  13 * the Free Software Foundation; either version 2 of the License, or
  14 * (at your option) any later version.
  15 *
  16 * This program is distributed in the hope that it will be useful,
  17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19 * GNU General Public License for more details.
  20 *
  21 * You should have received a copy of the GNU General Public License
  22 * along with this program; if not, write to the Free Software
  23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  24 *
  25 ******************************************************************************/
  26
  27#include <linux/kernel.h>
  28#include <linux/string.h>
  29#include <linux/ctype.h>
  30#include <linux/spinlock.h>
  31#include <linux/export.h>
  32#include <scsi/scsi.h>
  33#include <scsi/scsi_cmnd.h>
  34
  35#include <target/target_core_base.h>
  36#include <target/target_core_fabric.h>
  37#include <target/target_core_configfs.h>
  38
  39#include "target_core_internal.h"
  40#include "target_core_pr.h"
  41
  42/*
  43 * Handlers for Serial Attached SCSI (SAS)
  44 */
  45u8 sas_get_fabric_proto_ident(struct se_portal_group *se_tpg)
  46{
  47        /*
  48         * Return a SAS Serial SCSI Protocol identifier for loopback operations
  49         * This is defined in  section 7.5.1 Table 362 in spc4r17
  50         */
  51        return 0x6;
  52}
  53EXPORT_SYMBOL(sas_get_fabric_proto_ident);
  54
  55u32 sas_get_pr_transport_id(
  56        struct se_portal_group *se_tpg,
  57        struct se_node_acl *se_nacl,
  58        struct t10_pr_registration *pr_reg,
  59        int *format_code,
  60        unsigned char *buf)
  61{
  62        unsigned char *ptr;
  63        int ret;
  64
  65        /*
  66         * Set PROTOCOL IDENTIFIER to 6h for SAS
  67         */
  68        buf[0] = 0x06;
  69        /*
  70         * From spc4r17, 7.5.4.7 TransportID for initiator ports using SCSI
  71         * over SAS Serial SCSI Protocol
  72         */
  73        ptr = &se_nacl->initiatorname[4]; /* Skip over 'naa. prefix */
  74
  75        ret = hex2bin(&buf[4], ptr, 8);
  76        if (ret < 0)
  77                pr_debug("sas transport_id: invalid hex string\n");
  78
  79        /*
  80         * The SAS Transport ID is a hardcoded 24-byte length
  81         */
  82        return 24;
  83}
  84EXPORT_SYMBOL(sas_get_pr_transport_id);
  85
  86u32 sas_get_pr_transport_id_len(
  87        struct se_portal_group *se_tpg,
  88        struct se_node_acl *se_nacl,
  89        struct t10_pr_registration *pr_reg,
  90        int *format_code)
  91{
  92        *format_code = 0;
  93        /*
  94         * From spc4r17, 7.5.4.7 TransportID for initiator ports using SCSI
  95         * over SAS Serial SCSI Protocol
  96         *
  97         * The SAS Transport ID is a hardcoded 24-byte length
  98         */
  99        return 24;
 100}
 101EXPORT_SYMBOL(sas_get_pr_transport_id_len);
 102
 103/*
 104 * Used for handling SCSI fabric dependent TransportIDs in SPC-3 and above
 105 * Persistent Reservation SPEC_I_PT=1 and PROUT REGISTER_AND_MOVE operations.
 106 */
 107char *sas_parse_pr_out_transport_id(
 108        struct se_portal_group *se_tpg,
 109        const char *buf,
 110        u32 *out_tid_len,
 111        char **port_nexus_ptr)
 112{
 113        /*
 114         * Assume the FORMAT CODE 00b from spc4r17, 7.5.4.7 TransportID
 115         * for initiator ports using SCSI over SAS Serial SCSI Protocol
 116         *
 117         * The TransportID for a SAS Initiator Port is of fixed size of
 118         * 24 bytes, and SAS does not contain a I_T nexus identifier,
 119         * so we return the **port_nexus_ptr set to NULL.
 120         */
 121        *port_nexus_ptr = NULL;
 122        *out_tid_len = 24;
 123
 124        return (char *)&buf[4];
 125}
 126EXPORT_SYMBOL(sas_parse_pr_out_transport_id);
 127
 128/*
 129 * Handlers for Fibre Channel Protocol (FCP)
 130 */
 131u8 fc_get_fabric_proto_ident(struct se_portal_group *se_tpg)
 132{
 133        return 0x0;     /* 0 = fcp-2 per SPC4 section 7.5.1 */
 134}
 135EXPORT_SYMBOL(fc_get_fabric_proto_ident);
 136
 137u32 fc_get_pr_transport_id_len(
 138        struct se_portal_group *se_tpg,
 139        struct se_node_acl *se_nacl,
 140        struct t10_pr_registration *pr_reg,
 141        int *format_code)
 142{
 143        *format_code = 0;
 144        /*
 145         * The FC Transport ID is a hardcoded 24-byte length
 146         *arget_core_fabric_lib.c#L132" id="L132" class="line" name="L47" id="L17" id="L47" class="line"1ass=""L145"> 145   vers/target/target_core_fabric__lass="comment">/*
se_tpg,
  20      1   * This is defined in 1 sect1on 7.5.ref="+code=fc_get_fabric_proto_ident" class="sref">fc_get_fabric_proto_ident);(
 136
      1   */
 136
fc_get_pr_transport_id_len(
 138        struct  *se_tpg,
 139        struct EXPORT_SY1MBOL<153ode_acl *se_nacl,
 140        struct t10_pr_registration *pr_reg,
 141        int *u32  141        int *     e=se_portal_group" class1="sre1">se_portal_gr="drivers/target/target_core_fabric_lib.c#L61" id="L61" class="line" name="L61">  61{
s1_node_3" class="line" name="L143"> 143        *t10_pr_r="drivers/target/target_core_fabric_lib.c#L63" id="L63" class="line" name="L63">  63        int for1at_code,
  64
b16+code=out_tid_len" class="sref">out_tid_len,
  64
  42p1r;
 145ret1;

 145 145/*
 145 * This  program is distributed i"sre1o 6h for SAS
 145
 145buf[0] 1= 0x016 contain a I_T nexus identifier,[  13/*
 120      1   * From spc4r17, 7.5.41.7 Tr1nsportID for initiator ports using SCSid="L17" id="L47" class="line"1ass=""L145"> 145      1   * over SAS Serial SCS1I Pro171code=out_tid_len" class="srsref">se_nacl->initiatorname[4]; /* Skip over 'naa. prefix */ 125}
      1   */
 103ptr = &1amp;<1 href="+code=srgetabric_proto_ideniic_lib.c#L63" ii"L14"L144rt/target_core_fiic_lib.c#L63" ii"L14d="L7724; ) 3" class="line" name="L143"> 143        *t10_pr_re,
se_tpgse_nacl->);
 143        *ret = <1a hre1="+code=hex2biiiiiiiiiiiiiiiiit/target_core_fiic_lib.c#L63" ii"L14++5" class="line" name="L125"> 125}
 * Thiset" class="sref">ret1 <10)
 125}
 * but WWITHOUT ANY WARRANTY; witvers1ebug(  20(buf[4], ptr, 8);
se_nacl-> 136
/*
  77                      1   * The SAS Transport I1D is 180+code=hex2biiiiiiiiiiiiiiiiit/target_core_fas transport_id: invalid hex string\n");
  78
      1   */
  78
      1drivers/target/target_co1re_fa1ric_lib.c#L83"0" id=" class="line" name="L20">  20 114EXPORT_SY1MBOL<18 from spc4r17, 7.5.4.7 TransportID 146
 145u32 /*
se_p0" id=" class="line" name="L20">  20 * MERCHHANTABILITY or FITNESS FO" id1_node_.ref="+code=fc_get_fabric_proto_ident" class="sref">fc_get_fabric_proto_ident);(
  78
class="line" name="L78">  78
for1at_cod/target/target_core_forert_id);
 138        struct ( *se_tpg,
 139        struct fo1rmat_1ode = 0;
 110        /*
out_tid_len,
 111        char **      1   * From spc4r17, 7.5.41.7 Tr194ef">t10_pr_rr)
 112{
      1   * over SAS Serial SCS1I Pro1ocol 143        *      1   *
 114      1   * The SAS Transport I1D is 1 hardcoded 24-byte length
 118      1   */

 119
 120 145EXPORT_S2MBOL<20exus_ptr = NULL;
 122        * = 24;
 123
/*
 124        return (2ent"> * U2ed for handling SCSI fab2ic de204ef">t10_pr_re
 125}
 * P2rsistent Reservation SPE2_I_PT20="L126" class="line" name="L126"> 126 */<2span>
sas_parse_pr_out_traorert_id);
  78
 128 129 130u32 *<2 href21rget_core_fabric_lib.c#L131" id="L131" class="line" name="L131"> 131  42fc_get_fabric_proto_ideniib.c#g>);
 *se_tpg)
 132{
/*
 143        *    2    * Assume the FORMAT 2ODE 021rget/target_core_fabric_lib.c#L145" id="L145" class="line" name="L145"> 145    2    * for initiator port2 usin2 SCSI over SAS Serial SCSI Protocol 145 */<2    *
 145 131(  78
    2    * so we return the *2port_2exus_p6" class="line" name="L126"> 126    2    */
sas_parse_pr_out_traiib.c#g>);
  78
  42o2t_tid22="L11e_nacl" class="ef">out_tid_len,
);(
 138        struct <2/target/t2rget_core_fabric_lib.c#L224" i223ode_acl *se_tpg,
 139        struct <2har *)&am2;t10_pr_registration *se_nacl,
 140        struct <2s/target/2arget_core_fabric_lib.c#2126" 225ef">t10_pr_registration *pr_reg,
 141        int *EXPORT_S2MBOL<22)
 141        int *(  61{
/*
 143        * * H2ndlers for Fibre Channel2Proto22rget/target_colen" class="sref">out_tid_len,
 143        * */<2span>
 143        *u8   42pme" class="sref">initiatorname[4]; initirnam_sess_locksas_" class="line" name="L78">  78
/* 0 2 fcp-23rget/target_core_fabric_lib.c#L114" id="L114" class="line" name="L114"> 114  95EXPORT_S2MBOL<23SCSI over SAS Serial SCSI Protocol 131  78
u32   48
  48 * H2de=se_node_acl" class="s2ef">s23xus_ptr set to NULL.
 120 120for24col
 120[ 120f2rmat_24(SAS)
 120/*
 120 118    2    *arget_core_fabric_l2b.c#L232" id="L132" class="line" name="L47" t/tarADDITIONAL LENGTH fieldid="L120" class="line" name="L120"> 120 131se_tpg,
ptr, 8);
);
pme" class="sref">initiatorname[4]; /* Skip over 'naa. prefix */  78
      2   * This is defined in 2 sect24rget/target_core_fabric_lib.c#L80" id="L80" class="line" name="L80">  80      2   */
 120  82        return 24;
2target/ta2rget_core_fabric_lib.c#L253" i252code=out_tid_len" class="srtarget_core_fabric123" id++5" class="line" name="L125"> 125}
EXPORT_SY2MBOL<25rget/target_core_fabric_lib.c#L114" id="L114" class="line" name="L114"> 114 114u32  120    2e=se_portal_group" class2="sre25rget/target_core_fabric_lib.c#L117" id="L117" class="line" name="L117"> 117s25hardcoded 24-byte length
 117 117      2format_code" class="sref2">for25xus_ptr set to NULL.
 106b26sportID for initiator ports using SCSid="L17" id="L47" class="line"1ass=""L145"> 145)
 143        *p2r;
 114ret2;

 114 120/*
 145    2  program is distributed2i"sre26)
 143        *
 114buf[0] 2= 0x026 contain a I_T nexus identifier,  48/*
  48      2   * From spc4r17, 7.5.42.7 Tr2nsportID for initiator ports using SC  48 120      2   */
 120ptr = &2amp;<27(SAS)
 120 114ret = <2a hre27ardcoded 24-byte length
 114    2et" class="sref">ret2 <27rget/target_core_fabric_lib.c#L117" using SCS (see RFC 3720) _co/tarfge1 114
 114 114/*
 114      2   * The SAS Transport I2D is 28sportID for initiator ports using SC 145      2   */
, 8);

 145      2drivers/target/target_co2re_fa28;
, 8);

 145, 8);

 145EXPORT_SY2MBOL<284ef">t10_pr_re,
, 8);

 145, 8);

 145    2ref">u32   78
, 8);
  78
(  78
,
, 8);
  78
for290+code=hex2biiiiiiiiit/target_core_ftr, 8);
  78
      2rget_core_fabric_lib.c#L292" i291ug(  78
      2at_code" class="sref">fo2rmat_29;
, 8);
  78
/*
  78
t10_pr_re,
  78
 126      2   *
pme" class="sref">initiatorname[4]; initirnam_sess_locksas_" class="line" name="L78">  78
      2   * The SAS Transport I2D is 29rget/target_core_fabric_lib.c#L48" id="L48" class="line" name="L48">  48      2   */
  48
  48 120EXPORT_S3MBOL<30arget/target_core_fabric_lib.c#L82""id="L17" id="L47" class="line"1ass=""L145"> 145  78
/*
  77                 * U3ed for handling SCSI fab3ic de304ef">t10_pr_re,
  78
 * U3e  * over SAS Serial SCS3_I_PT30="L12class="line" name="L78">  78
 * U3e  *
  78
 * U3e  * The SAS Transport I3class307code=out_tid_len" class="srget_core_fabric_lib.c#L69"3]"L1(o/target_core_ftarget_core_fabric123" id=[="+c 0xff" class="line" name="L78">  78
 * U3e  */
  48 120u32 *<3 href31rget_core_fabric_lib.c#L131"using SCS 114  82        return 24;
3s/target/3arget_core_fabric_lib.c#3113" 312code=out_tid_len" class="srtarget_core_fabric123" id=+= 23" class="line" name="L123"> 123
/*
 124        return (3ent">    3    * Assume the FORMAT 3ODE 031rget/target_cion 7.5_len" class="srtarget_core_fabric123" id3" class="line" name="L123"> 123
 * U3    * for initiator port3 usin31="L126" class="line" name="L126"> 126 */<3    *
sas_parse_pr_out_traiib.c#g>);(
  78
 128out_tid_len,
);(
 128se_tpg,
 139        struct <3ent">    3    */
se_nacl,
 140        struct <3"+code=po3t_nexus_ptr" class="sref3>port321ug( *pr_reg,
 141        int *o3t_tid322code=out_tidi href="drivers/target/target_core_fabric_lib.c#L142" id="L14 class="line" name="L77">  77                 143        *t10_pr_r.ref="+code=fc_ef">out_tid_len,
 143        *  78
EXPORT_S3MBOL<326get/target_colen" class="srspin_lock_irqfabric_lib.c#L14pin_lock_irq+code=ptr" class="sref">pme" class="sref">initiatorname[4]; initirnam_sess_locksas_" class="line" name="L78">  78
initiatorname[4]; /* Skip over 'naa. prefix */  78
/*
  48 * H3ndlers for Fibre Channel3Proto32l (FCP)
 120 */<3span>
 145u8  125}
  48/* 0 3 fcp-33(SAS)
  48  48EXPORT_S3MBOL<33SCSI over SAS Serial SCSI Protocol<="d="L120" class="line" name="L120"> 120  48u32   48/* 145 * H3de=se_node_acl" class="s3ef">s33rget/target_caf (t/target_core_frore_fabric_lib.c#L141" id="L14>[4];  143        *
 145for341ug(
 145;
 125}
f3rmat_34rget/target_c} else" class="line" name="L125"> 125}
/*
t10_pr_re,
 143        *pme" class="sref">initiatorname[4]; initirnam_sess_locksas_" class="line" name="L78">  78
    3    *arget_core_fabric_l3b.c#L346get/target_core_fabric_lib.c#L114" id="L114" class="line" name="L114"> 114  48se_tpg,
  48      3   * This is defined in 3 sect34xus_ptr set to NULL.
 120      3   */
 145  78
  77                EXPORT_SY3MBOL<35rget/target_ctarget_co/target_core_ftarget_core_fabric123" id=+= t/target_core_fradd
  78
 145u32  120    3e=se_portal_group" class3="sre35rget/target_core_fabric_lib.c#L117" i 114s35hardcoded 24-byte length
 145 123
      3format_code" class="sref3">for35ref">class="line" name="L78">  78
b360+code=hex2biion 7.5_len" class="srtarget_core_fabric123" id3" class="line" name="L123"> 123
 126p36="L11e_nacl" class="_parse_pr_out_transport_id" class="sref">sas_parse_pr_out_traiib.c#g>);(
  78
ret3;
 124        return (3=rget/tar3get_core_fabric_lib.c#L635" id36 from/target/target_core_fiib.c#rt_id);
 128/*
t10_pr_registration *se_tpg,
 139        struct <3ant">    3  program is distributed3i"sre36)
 139        struct <3aef="+cod3   */
out_tid_len,
 139        struct <3aclass="s3class="sref">buf[0] 3= 0x036
NULL;
  77                /*
 143        *      3   * From spc4r17, 7.5.43.7 Tr370NULL;
" id3" class="line" name="L123"> 123
out_tid_len,
  78
      3   */
  78
ptr = &3amp;<373code=out_tid_len" class="sre    *arget/d_len" class="sradd/target_core_fabricadd/tar"L14 class="line" name="L78">  78
t10_pr_r.ref="+code=fc_e class="sref">fc_get_fabric_proto_idenet/target_core_fabric_lib.c#L142" id="L14 = parse_pr_out_traget_core_fabric_lib.c#L69" id[="+c 0xc0" class="line" name="L78">  78
ret = <3a hre375code=out_tid_re_fabric_lib.c#L145" id="L145" class="line" name="L145"> 145    3et" class="sref">ret3 <37rget/target_core_fabric_lib.c#L117" * Checkfrget="drivers/tar0baabrr1b#L/span>
 145
 145 145/*
 106      3   * The SAS Transport I3D is 38sportID for initiator ports using SCid="L145" class="line" name="L145"> 145      3   */
 117      3drivers/target/target_co3re_fa38arget/target_core_fabric_lib.c#L73" i            " idfdevic"drget 114
 106EXPORT_SY3MBOL<38 from spc4r17, 7.5.4.7 TransportID 117
 117    3ref">u32   48 145( 143        *,
NULL;
r_er"sas_pa");
 143        *for390+code=hex2biiiiiiiiie,
);
pet/target_core_fabric_lib.c#L142" id="L14  class="line" name="L78">  78
      3rget_core_fabric_lib.c#L392" i391ug(  78
      3at_code" class="sref">fo3rmat_39;
 126/*
 114 114
 106      3   *
 145      3   * The SAS Transport I3D is 39rget/target_cdaf (t/target_core_f/target/target_core_fabric_lib.c#L123" id !="_len" class="sr id=ore_fabric_lib. id="L14) 3" class="line" name="L143"> 143        *      3   */
  78
,
  78
  78
ptr, 8);
  78
fo403" i40;

 145/*

 145/*t10_pr_re,
  78
 * U4e  * over SAS Serial SCS4_I_PT40"+code=hex2biiiiiiiiiaf (t/target_core_fradd
  77                 * U4e  *
  78
 * U4e  * The SAS Transport I4class40"L128" class="line" name="L128"> 128 * U4e  */
( 143        *);
 143 Extracts/tadd/tar: %hu #L78" id="L78" class="line" name="L143"> 143        *u32 *<4 href410+code=hex2biiiiiiiiie,
,
);
 143        *(padd/target_core_fabricadd/tar"L14+4,  class="sref">pget/target_core_fabric.c#L123" id) class="line" name="L78">  78
;
  78
/*/*
 125}
    4    * Assume the FORMAT 4ODE 0414ef">t10_pr_re,
  78
 * U4    * for initiator port4 usin41"+code=hex2bi6" class="line" name="L126"> 126 */<4    *
 114 114 * U4    * 24 bytes, and SAS 4oes n41 contain a I_T nexus identifier, 114 120    4    */
 145 143        *o4t_tid42;
NULL;
" id="L_len" class="srstrs="sref">NULL;strs="sas_p=ptr" class="sref">ptr, 8);
  78
NULL;
" id"t3" class="line" name="L143"> 143        *    4;t10_pr_re,
NULL;
r_er"sas_pa");
 143        *,
);
 143        * */<4L" class="sref">EXPORT_S4MBOL<426code=out_tidtarget_ctarget_ccccccccc=ptr" class="sref">ptr, 8);
  78
  78
/*
 126 * H4ndlers for Fibre Channel4Proto42rget/target_ce,
NULL;
" idd="a");

 145 */<4span>
NULL;
" idd+= 5 pan>
 145u8  145;
NULL;
NULL;
" id3" class="line" name="L123"> 123
/* 0 4 fcp-43rget/target_ctarget_core_fabric_lib.c#L114" id="L114" class="line" name="L114"> 114  48EXPORT_S4MBOL<43SCSI over SAS Serial SCSI Protocol<=target_ce 12 ASCII /taractorsgrepresns.arge/tarIS/ta_co/tarrs/target/t="L48" class="line" name="L48">  48 */<4rget_core_fabric_lib.c#L437" i432" id="L132" class="line" name="L47"target_ce rget="lparisgetagainst /tarruncargei" idfsessrger#39;"dIS/taL/sp="L48" class="line" name="L48">  48u32   48/* 145 * H4de=se_node_acl" class="s4ef">s43rget/target_ce,
 143        *NULL;
" id") 3" class="line" name="L143"> 143        *for441ug(NULL;
" id++5" class="line" name="L125"> 125}
;
 125}
f4rmat_44rget/target_ctarget_ccccccccc6" class="line" name="L126"> 126/*
t10_pr_re,
<<<<<<<<NULL;
" idd="alen" class="srgolowt_get_core_fabric.olowt_sas_pe/target/target_csref">NULL;
" id"5" class="line" name="L125"> 125}
,
NULL;
" id++5" class="line" name="L125"> 125}
 */<4    *arget_core_fabric_l4b.c#L446code=out_tidtarget_c6" class="line" name="L126"> 126 126/*se_tpg,
 126 * H4   * This is defined in 4 sect44rget/target_cion 7.5(/targe)=ptr" class="sref">ptr, 8);
 125}
      4   */
 126p_parse_pr_out_transport_id" class="sref">sas_parse_pr_out_traiib.c#rt_id);
 125}



TtarorigiealLLXR softwareLXR fabrucorycode, /tis experiric_alL" nsrgeta class="lmailto:lxr@abrux.no">lxr@abrux.nocode.
lxr.abrux.no kindly hosted a class="lhttp://www.redpill-abrpro.no">Redpill Lbrpro AScode, provider