linux/drivers/scsi/sd_dif.c
<<
n> 2" /spa3.1 2" /form.1 2" a n> 2" href="../linux+v3.9.5/drivers/scsi/sd_dif.c">n> 2" img src="../.static/gfx/right.png" alt=">>">n> /spa3.1n> spa3 class="lxr_search">n> n> 2" input typ4.1hidden" nam4.1navtarget" v3.14.1">n> 2" input typ4.1text" nam4.1search" id.1search">n> 2" butt typ4.1submit">Search spa3 class="lxr_prefs".1 2" a href="+prefs?return=drivers/scsi/sd_dif.c"n> 2" onclick="return ajax_prefs();">n> 2"Prefs1 2" /a>n> /spa3.1 2" " /div.1 2" " form ac="v3="ajax+*" method="post" onsubmit="return false;">n> input typ4.1hidden" nam4.1ajax_lookup" id.1ajax_lookup" v3.14.1">n 2" " /form.1n 2" " div class="headingbott m">1 div id.1file_contents".
" "1
/a>
spa3 class="comment">/*
/spa3.1" "2
/a>
spa3 class="comment"> * sd_dif.c - SCSI Data Integrity Field
/spa3.1" "3
/a>
spa3 class="comment"> *
/spa3.1" "4
/a>
spa3 class="comment"> * Copyright (C) 2007, 2008 Oracle Corpora="v3
/spa3.1" "5
/a>
spa3 class="comment"> * Written by: Martin K. Petersen <martin.petersen@oracle.com>
/spa3.1" "6
/a>
spa3 class="comment"> *
/spa3.1" "7
/a>
spa3 class="comment"> * This program is free software; you ca3 redistribute it and/or
/spa3.1" "8
/a>
spa3 class="comment"> * modify it under the terms of the GNU General Public License vers"v3
/spa3.1" "9
/a>
spa3 class="comment"> * 2 as published by the Free Software Founda="v3.
/spa3.1" on va>
spa3 class="comment"> *
/spa3.1" 11
/a>
spa3 class="comment"> * This program is distributed in the hope that it will be useful, but
/spa3.1" 12
/a>
spa3 class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of
/spa3.1" 13
/a>
spa3 class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
/spa3.1" 14
/a>
spa3 class="comment"> * General Public License for more details.
/spa3.1" 15
/a>
spa3 class="comment"> *
/spa3.1" 16
/a>
spa3 class="comment"> * You should have received a copy of the GNU General Public License
/spa3.1" 17
/a>
spa3 class="comment"> * along with this program; see the file COPYING.  If not, write to
/spa3.1" 18
/a>
spa3 class="comment"> * the Free Software Founda="v3, 675 Mass Ave, Cambridge, MA 02139,
/spa3.1" 19
/a>
spa3 class="comment"> * USA.
/spa3.1" 2n va>
spa3 class="comment"> *
/spa3.1" 21
/a>
spa3 class="comment"> */
/spa3.1" 22
/a>1" 23
/a>#include <linux/blkdev.h
/a>>1" 24
/a>#include <linux/crc-t10dif.h
/a>>1" 25
/a>1" 26
/a>#include <scsi/scsi.h
/a>>1" 27
/a>#include <scsi/scsi_cmnd.h
/a>>1" 28
/a>#include <scsi/scsi_dbg.h
/a>>1" 29
/a>#include <scsi/scsi_device.h
/a>>1" 30
/a>#include <scsi/scsi_driver.h
/a>>1" 31
/a>#include <scsi/scsi_eh.h
/a>>1" 32
/a>#include <scsi/scsi_host.h
/a>>1" 33
/a>#include <scsi/scsi_ioctl.h
/a>>1" 34
/a>#include <scsi/scsicam.h
/a>>1" 35
/a>1" 36
/a>#include <net/checksum.h
/a>>1" 37
/a>1" 38
/a>#include "sd.h
/a>"1" 39
/a>1" 40
/a>typ4def"
a href="+code=__u16" class="sref">__u16
/a> (
a href="+code=csum_fn" class="sref">csum_fn
/a>) (void *, unsigned int);1" 41
/a>1" 42
/a>static"
a href="+code=__u16" class="sref">__u16
/a> 
a href="+code=sd_dif_crc_fn" class="sref">sd_dif_crc_fn
/a>(void *
a href="+code=da=a" class="sref">da=a
/a>, unsigned int 
a href="+code=len" class="sref">len
/a>)1" 43
/a>{1" 44
/a>        return 
a href="+code=cpu_to_be16" class="sref">cpu_to_be16
/a>(
a href="+code=crc_t10dif" class="sref">crc_t10dif
/a>(
a href="+code=da=a" class="sref">da=a
/a>, 
a href="+code=len" class="sref">len
/a>));1" 45
/a>}1" 46
/a>1" 47
/a>static"
a href="+code=__u16" class="sref">__u16
/a> 
a href="+code=sd_dif_ip_fn" class="sref">sd_dif_ip_fn
/a>(void *
a href="+code=da=a" class="sref">da=a
/a>, unsigned int 
a href="+code=len" class="sref">len
/a>)1" 48
/a>{1" 49
/a>        return 
a href="+code=ip_compute_csum" class="sref">ip_compute_csum
/a>(
a href="+code=da=a" class="sref">da=a
/a>, 
a href="+code=len" class="sref">len
/a>);1" 50
/a>}1" 51
/a>1" 52
/a>
spa3 class="comment">/*
/spa3.1" 53
/a>
spa3 class="comment"> * Typ4 1 and Typ4 2 protec="v3 use the sam4 format: 16 bit guard tag,
/spa3.1" 54
/a>
spa3 class="comment"> * 16 bit app tag, 32 bit reference tag.
/spa3.1" 55
/a>
spa3 class="comment"> */
/spa3.1" 56
/a>static"void 
a href="+code=sd_dif_typ41_generate" class="sref">sd_dif_typ41_generate
/a>(struct 
a href="+code=blk_integrity_exchg" class="sref">blk_integrity_exchg
/a> *
a href="+code=bix" class="sref">bix
/a>, 
a href="+code=csum_fn" class="sref">csum_fn
/a> *
a href="+code=fn" class="sref">fn
/a>)1" 57
/a>{1" 58
/a>        void *
a href="+code=buf" class="sref">buf
/a> = 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=da=a_buf" class="sref">da=a_buf
/a>;1" 59
/a>        struct 
a href="+code=sd_dif_tuple" class="sref">sd_dif_tuple
/a> *
a href="+code=sdt" class="sref">sdt
/a> = 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=prot_buf" class="sref">prot_buf
/a>;1" 60
/a>        
a href="+code=sec=or_t" class="sref">sec=or_t
/a> 
a href="+code=sec=or" class="sref">sec=or
/a> = 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=sec=or" class="sref">sec=or
/a>;1" 61
/a>        unsigned int 
a href="+code=i" class="sref">i
/a>;1" 62
/a>1" 63
/a>        for (
a href="+code=i" class="sref">i
/a> = 0 ; 
a href="+code=i" class="sref">i
/a> < 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=da=a_size" class="sref">da=a_size
/a> ; 
a href="+code=i" class="sref">i
/a> += 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=sec=or_size" class="sref">sec=or_size
/a>, 
a href="+code=sdt" class="sref">sdt
/a>++) {1" 64
/a>                
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=guard_tag" class="sref">guard_tag
/a> = 
a href="+code=fn" class="sref">fn
/a>(
a href="+code=buf" class="sref">buf
/a>, 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=sec=or_size" class="sref">sec=or_size
/a>);1" 65
/a>                
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=ref_tag" class="sref">ref_tag
/a> = 
a href="+code=cpu_to_be32" class="sref">cpu_to_be32
/a>(
a href="+code=sec=or" class="sref">sec=or
/a> & 0xffffffff);1" 66
/a>                
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=app_tag" class="sref">app_tag
/a> = 0;1" 67
/a>1" 68
/a>                
a href="+code=buf" class="sref">buf
/a> += 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=sec=or_size" class="sref">sec=or_size
/a>;1" 69
/a>                
a href="+code=sec=or" class="sref">sec=or
/a>++;1" 70
/a>        }1" 71
/a>}1" 72
/a>1" 73
/a>static"void 
a href="+code=sd_dif_typ41_generate_crc" class="sref">sd_dif_typ41_generate_crc
/a>(struct 
a href="+code=blk_integrity_exchg" class="sref">blk_integrity_exchg
/a> *
a href="+code=bix" class="sref">bix
/a>)1" 74
/a>{1" 75
/a>        
a href="+code=sd_dif_typ41_generate" class="sref">sd_dif_typ41_generate
/a>(
a href="+code=bix" class="sref">bix
/a>, 
a href="+code=sd_dif_crc_fn" class="sref">sd_dif_crc_fn
/a>);1" 76
/a>}1" 77
/a>1" 78
/a>static"void 
a href="+code=sd_dif_typ41_generate_ip" class="sref">sd_dif_typ41_generate_ip
/a>(struct 
a href="+code=blk_integrity_exchg" class="sref">blk_integrity_exchg
/a> *
a href="+code=bix" class="sref">bix
/a>)1" 79
/a>{1" 80
/a>        
a href="+code=sd_dif_typ41_generate" class="sref">sd_dif_typ41_generate
/a>(
a href="+code=bix" class="sref">bix
/a>, 
a href="+code=sd_dif_ip_fn" class="sref">sd_dif_ip_fn
/a>);1" 81
/a>}1" 82
/a>1" 83
/a>static"int 
a href="+code=sd_dif_typ41_verify" class="sref">sd_dif_typ41_verify
/a>(struct 
a href="+code=blk_integrity_exchg" class="sref">blk_integrity_exchg
/a> *
a href="+code=bix" class="sref">bix
/a>, 
a href="+code=csum_fn" class="sref">csum_fn
/a> *
a href="+code=fn" class="sref">fn
/a>)1" 84
/a>{1" 85
/a>        void *
a href="+code=buf" class="sref">buf
/a> = 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=da=a_buf" class="sref">da=a_buf
/a>;1" 86
/a>        struct 
a href="+code=sd_dif_tuple" class="sref">sd_dif_tuple
/a> *
a href="+code=sdt" class="sref">sdt
/a> = 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=prot_buf" class="sref">prot_buf
/a>;1" 87
/a>        
a href="+code=sec=or_t" class="sref">sec=or_t
/a> 
a href="+code=sec=or" class="sref">sec=or
/a> = 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=sec=or" class="sref">sec=or
/a>;1" 88
/a>        unsigned int 
a href="+code=i" class="sref">i
/a>;1" 89
/a>        
a href="+code=__u16" class="sref">__u16
/a> 
a href="+code=csum" class="sref">csum
/a>;1" 90
/a>1" 91
/a>        for (
a href="+code=i" class="sref">i
/a> = 0 ; 
a href="+code=i" class="sref">i
/a> < 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=da=a_size" class="sref">da=a_size
/a> ; 
a href="+code=i" class="sref">i
/a> += 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=sec=or_size" class="sref">sec=or_size
/a>, 
a href="+code=sdt" class="sref">sdt
/a>++) {1" 92
/a>                
spa3 class="comment">/* Unwritten sec=ors */
/spa3.1" 93
/a>                if (
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=app_tag" class="sref">app_tag
/a> == 0xffff)1" 94
/a>                        return 0;1" 95
/a>1" 96
/a>                
spa3 class="comment">/* Bad ref tag received from disk */
/spa3.1" 97
/a>                if (
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=ref_tag" class="sref">ref_tag
/a> == 0xffffffff) {1" 98
/a>                        
a href="+code=printk" class="sref">printk
/a>(
a href="+code=KERN_ERR" class="sref">KERN_ERR
/a>1" 99
/a>                               
spa3 class="string">"%s: bad phys ref tag on sec=or %lu\n""100
/a>                               
a href="+code=bix" class="sref">bix
/a>->
a href="+code=disk_nam4" class="sref">disk_nam4
/a>, (unsigned long)
a href="+code=sec=or" class="sref">sec=or
/a>);1"101
/a>                        return -
a href="+code=EIO" class="sref">EIO
/a>;1"102
/a>                }1"103
/a>1"104
/a>                if (
a href="+code=be32_to_cpu" class="sref">be32_to_cpu
/a>(
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=ref_tag" class="sref">ref_tag
/a>) != (
a href="+code=sec=or" class="sref">sec=or
/a> & 0xffffffff)) {1"105
/a>                        
a href="+code=printk" class="sref">printk
/a>(
a href="+code=KERN_ERR" class="sref">KERN_ERR
/a>1"106
/a>                               
spa3 class="string">"%s: ref tag error on sec=or %lu (rcvd %u)\n""107
/a>                               
a href="+code=bix" class="sref">bix
/a>->
a href="+code=disk_nam4" class="sref">disk_nam4
/a>, (unsigned long)
a href="+code=sec=or" class="sref">sec=or
/a>,1"108
/a>                               
a href="+code=be32_to_cpu" class="sref">be32_to_cpu
/a>(
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=ref_tag" class="sref">ref_tag
/a>));1"109
/a>                        return -
a href="+code=EIO" class="sref">EIO
/a>;1"110
/a>                }1"111
/a>1"112
/a>                
a href="+code=csum" class="sref">csum
/a> = 
a href="+code=fn" class="sref">fn
/a>(
a href="+code=buf" class="sref">buf
/a>, 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=sec=or_size" class="sref">sec=or_size
/a>);1"113
/a>1"114
/a>                if (
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=guard_tag" class="sref">guard_tag
/a> != 
a href="+code=csum" class="sref">csum
/a>) {1"115
/a>                        
a href="+code=printk" class="sref">printk
/a>(
a href="+code=KERN_ERR" class="sref">KERN_ERR
/a> 
spa3 class="string">"%s: guard tag error on sec=or %lu ""116
/a>                               
spa3 class="string">"(rcvd %04x, da=a %04x)\n"bix
/a>->
a href="+code=disk_nam4" class="sref">disk_nam4
/a>,1"117
/a>                               (unsigned long)
a href="+code=sec=or" class="sref">sec=or
/a>,1"118
/a>                               
a href="+code=be16_to_cpu" class="sref">be16_to_cpu
/a>(
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=guard_tag" class="sref">guard_tag
/a>), 
a href="+code=be16_to_cpu" class="sref">be16_to_cpu
/a>(
a href="+code=csum" class="sref">csum
/a>));1"119
/a>                        return -
a href="+code=EIO" class="sref">EIO
/a>;1"120
/a>                }1"121
/a>1"122
/a>                
a href="+code=buf" class="sref">buf
/a> += 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=sec=or_size" class="sref">sec=or_size
/a>;1"123
/a>                
a href="+code=sec=or" class="sref">sec=or
/a>++;1"124
/a>        }1"125
/a>1"126
/a>        return 0;1"127
/a>}1"128
/a>1"129
/a>static"int 
a href="+code=sd_dif_typ41_verify_crc" class="sref">sd_dif_typ41_verify_crc
/a>(struct 
a href="+code=blk_integrity_exchg" class="sref">blk_integrity_exchg
/a> *
a href="+code=bix" class="sref">bix
/a>)1"130
/a>{1"131
/a>        return 
a href="+code=sd_dif_typ41_verify" class="sref">sd_dif_typ41_verify
/a>(
a href="+code=bix" class="sref">bix
/a>, 
a href="+code=sd_dif_crc_fn" class="sref">sd_dif_crc_fn
/a>);1"132
/a>}1"133
/a>1"134
/a>static"int 
a href="+code=sd_dif_typ41_verify_ip" class="sref">sd_dif_typ41_verify_ip
/a>(struct 
a href="+code=blk_integrity_exchg" class="sref">blk_integrity_exchg
/a> *
a href="+code=bix" class="sref">bix
/a>)1"135
/a>{1"136
/a>        return 
a href="+code=sd_dif_typ41_verify" class="sref">sd_dif_typ41_verify
/a>(
a href="+code=bix" class="sref">bix
/a>, 
a href="+code=sd_dif_ip_fn" class="sref">sd_dif_ip_fn
/a>);1"137
/a>}1"138
/a>1"139
/a>
spa3 class="comment">/*
/spa3.1"14n va>
spa3 class="comment"> * Func="v3s for interleaving and deinterleaving applica="v3 tags
/spa3.1"141
/a>
spa3 class="comment"> */
/spa3.1"142
/a>static"void 
a href="+code=sd_dif_typ41_set_tag" class="sref">sd_dif_typ41_set_tag
/a>(void *
a href="+code=prot" class="sref">prot
/a>, void *
a href="+code=tag_buf" class="sref">tag_buf
/a>, unsigned int 
a href="+code=sec=ors" class="sref">sec=ors
/a>)1"143
/a>{1"144
/a>        struct 
a href="+code=sd_dif_tuple" class="sref">sd_dif_tuple
/a> *
a href="+code=sdt" class="sref">sdt
/a> = 
a href="+code=prot" class="sref">prot
/a>;1"145
/a>        
a href="+code=u8" class="sref">u8
/a> *
a href="+code=tag" class="sref">tag
/a> = 
a href="+code=tag_buf" class="sref">tag_buf
/a>;1"146
/a>        unsigned int 
a href="+code=i" class="sref">i
/a>, 
a href="+code=j" class="sref">j
/a>;1"147
/a>1"148
/a>        for (
a href="+code=i" class="sref">i
/a> = 0, 
a href="+code=j" class="sref">j
/a> = 0 ; 
a href="+code=i" class="sref">i
/a> < 
a href="+code=sec=ors" class="sref">sec=ors
/a> ; 
a href="+code=i" class="sref">i
/a>++, 
a href="+code=j" class="sref">j
/a> += 2, 
a href="+code=sdt" class="sref">sdt
/a>++) {1"149
/a>                
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=app_tag" class="sref">app_tag
/a> = 
a href="+code=tag" class="sref">tag
/a>[
a href="+code=j" class="sref">j
/a>] << 8 | 
a href="+code=tag" class="sref">tag
/a>[
a href="+code=j" class="sref">j
/a>+1];1"150
/a>                
a href="+code=BUG_ON" class="sref">BUG_ON
/a>(
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=app_tag" class="sref">app_tag
/a> == 0xffff);1"151
/a>        }1"152
/a>}1"153
/a>1"154
/a>static"void 
a href="+code=sd_dif_typ41_get_tag" class="sref">sd_dif_typ41_get_tag
/a>(void *
a href="+code=prot" class="sref">prot
/a>, void *
a href="+code=tag_buf" class="sref">tag_buf
/a>, unsigned int 
a href="+code=sec=ors" class="sref">sec=ors
/a>)1"155
/a>{1"156
/a>        struct 
a href="+code=sd_dif_tuple" class="sref">sd_dif_tuple
/a> *
a href="+code=sdt" class="sref">sdt
/a> = 
a href="+code=prot" class="sref">prot
/a>;1"157
/a>        
a href="+code=u8" class="sref">u8
/a> *
a href="+code=tag" class="sref">tag
/a> = 
a href="+code=tag_buf" class="sref">tag_buf
/a>;1"158
/a>        unsigned int 
a href="+code=i" class="sref">i
/a>, 
a href="+code=j" class="sref">j
/a>;1"159
/a>1"160
/a>        for (
a href="+code=i" class="sref">i
/a> = 0, 
a href="+code=j" class="sref">j
/a> = 0 ; 
a href="+code=i" class="sref">i
/a> < 
a href="+code=sec=ors" class="sref">sec=ors
/a> ; 
a href="+code=i" class="sref">i
/a>++, 
a href="+code=j" class="sref">j
/a> += 2, 
a href="+code=sdt" class="sref">sdt
/a>++) {1"161
/a>                
a href="+code=tag" class="sref">tag
/a>[
a href="+code=j" class="sref">j
/a>] = (
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=app_tag" class="sref">app_tag
/a> & 0xff00) >> 8;1"162
/a>                
a href="+code=tag" class="sref">tag
/a>[
a href="+code=j" class="sref">j
/a>+1] = 
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=app_tag" class="sref">app_tag
/a> & 0xff;1"163
/a>        }1"164
/a>}1"165
/a>1"166
/a>static"struct 
a href="+code=blk_integrity" class="sref">blk_integrity
/a> 
a href="+code=dif_typ41_integrity_crc" class="sref">dif_typ41_integrity_crc
/a> = {1"167
/a>        .
a href="+code=nam4" class="sref">nam4
/a>                   = 
spa3 class="string">"T10-DIF-TYPE1-CRC""168
/a>        .
a href="+code=generate_fn" class="sref">generate_fn
/a>            = 
a href="+code=sd_dif_typ41_generate_crc" class="sref">sd_dif_typ41_generate_crc
/a>,1"169
/a>        .
a href="+code=verify_fn" class="sref">verify_fn
/a>              = 
a href="+code=sd_dif_typ41_verify_crc" class="sref">sd_dif_typ41_verify_crc
/a>,1"170
/a>        .
a href="+code=get_tag_fn" class="sref">get_tag_fn
/a>             = 
a href="+code=sd_dif_typ41_get_tag" class="sref">sd_dif_typ41_get_tag
/a>,1"171
/a>        .
a href="+code=set_tag_fn" class="sref">set_tag_fn
/a>             = 
a href="+code=sd_dif_typ41_set_tag" class="sref">sd_dif_typ41_set_tag
/a>,1"172
/a>        .
a href="+code=tuple_size" class="sref">tuple_size
/a>             = sizeof(struct 
a href="+code=sd_dif_tuple" class="sref">sd_dif_tuple
/a>),1"173
/a>        .
a href="+code=tag_size" class="sref">tag_size
/a>               = 0,1"174
/a>};1"175
/a>1"176
/a>static"struct 
a href="+code=blk_integrity" class="sref">blk_integrity
/a> 
a href="+code=dif_typ41_integrity_ip" class="sref">dif_typ41_integrity_ip
/a> = {1"177
/a>        .
a href="+code=nam4" class="sref">nam4
/a>                   = 
spa3 class="string">"T10-DIF-TYPE1-IP""178
/a>        .
a href="+code=generate_fn" class="sref">generate_fn
/a>            = 
a href="+code=sd_dif_typ41_generate_ip" class="sref">sd_dif_typ41_generate_ip
/a>,1"179
/a>        .
a href="+code=verify_fn" class="sref">verify_fn
/a>              = 
a href="+code=sd_dif_typ41_verify_ip" class="sref">sd_dif_typ41_verify_ip
/a>,1"180
/a>        .
a href="+code=get_tag_fn" class="sref">get_tag_fn
/a>             = 
a href="+code=sd_dif_typ41_get_tag" class="sref">sd_dif_typ41_get_tag
/a>,1"181
/a>        .
a href="+code=set_tag_fn" class="sref">set_tag_fn
/a>             = 
a href="+code=sd_dif_typ41_set_tag" class="sref">sd_dif_typ41_set_tag
/a>,1"182
/a>        .
a href="+code=tuple_size" class="sref">tuple_size
/a>             = sizeof(struct 
a href="+code=sd_dif_tuple" class="sref">sd_dif_tuple
/a>),1"183
/a>        .
a href="+code=tag_size" class="sref">tag_size
/a>               = 0,1"184
/a>};1"185
/a>1"186
/a>1"187
/a>
spa3 class="comment">/*
/spa3.1"188
/a>
spa3 class="comment"> * Typ4 3 protec="v3 has a"16-bit guard tag and 16 + 32 bits of opaque
/spa3.1"189
/a>
spa3 class="comment"> * tag space.
/spa3.1"19n va>
spa3 class="comment"> */
/spa3.1"191
/a>static"void 
a href="+code=sd_dif_typ43_generate" class="sref">sd_dif_typ43_generate
/a>(struct 
a href="+code=blk_integrity_exchg" class="sref">blk_integrity_exchg
/a> *
a href="+code=bix" class="sref">bix
/a>, 
a href="+code=csum_fn" class="sref">csum_fn
/a> *
a href="+code=fn" class="sref">fn
/a>)1"192
/a>{1"193
/a>        void *
a href="+code=buf" class="sref">buf
/a> = 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=da=a_buf" class="sref">da=a_buf
/a>;1"194
/a>        struct 
a href="+code=sd_dif_tuple" class="sref">sd_dif_tuple
/a> *
a href="+code=sdt" class="sref">sdt
/a> = 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=prot_buf" class="sref">prot_buf
/a>;1"195
/a>        unsigned int 
a href="+code=i" class="sref">i
/a>;1"196
/a>1"197
/a>        for (
a href="+code=i" class="sref">i
/a> = 0 ; 
a href="+code=i" class="sref">i
/a> < 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=da=a_size" class="sref">da=a_size
/a> ; 
a href="+code=i" class="sref">i
/a> += 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=sec=or_size" class="sref">sec=or_size
/a>, 
a href="+code=sdt" class="sref">sdt
/a>++) {1"198
/a>                
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=guard_tag" class="sref">guard_tag
/a> = 
a href="+code=fn" class="sref">fn
/a>(
a href="+code=buf" class="sref">buf
/a>, 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=sec=or_size" class="sref">sec=or_size
/a>);1"199
/a>                
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=ref_tag" class="sref">ref_tag
/a> = 0;1"200
/a>                
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=app_tag" class="sref">app_tag
/a> = 0;1"201
/a>1"202
/a>                
a href="+code=buf" class="sref">buf
/a> += 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=sec=or_size" class="sref">sec=or_size
/a>;1"203
/a>        }1"204
/a>}1"205
/a>1"206
/a>static"void 
a href="+code=sd_dif_typ43_generate_crc" class="sref">sd_dif_typ43_generate_crc
/a>(struct 
a href="+code=blk_integrity_exchg" class="sref">blk_integrity_exchg
/a> *
a href="+code=bix" class="sref">bix
/a>)1"207
/a>{1"208
/a>        
a href="+code=sd_dif_typ43_generate" class="sref">sd_dif_typ43_generate
/a>(
a href="+code=bix" class="sref">bix
/a>, 
a href="+code=sd_dif_crc_fn" class="sref">sd_dif_crc_fn
/a>);1"209
/a>}1"210
/a>1"211
/a>static"void 
a href="+code=sd_dif_typ43_generate_ip" class="sref">sd_dif_typ43_generate_ip
/a>(struct 
a href="+code=blk_integrity_exchg" class="sref">blk_integrity_exchg
/a> *
a href="+code=bix" class="sref">bix
/a>)1"212
/a>{1"213
/a>        
a href="+code=sd_dif_typ43_generate" class="sref">sd_dif_typ43_generate
/a>(
a href="+code=bix" class="sref">bix
/a>, 
a href="+code=sd_dif_ip_fn" class="sref">sd_dif_ip_fn
/a>);1"214
/a>}1"215
/a>1"216
/a>static"int 
a href="+code=sd_dif_typ43_verify" class="sref">sd_dif_typ43_verify
/a>(struct 
a href="+code=blk_integrity_exchg" class="sref">blk_integrity_exchg
/a> *
a href="+code=bix" class="sref">bix
/a>, 
a href="+code=csum_fn" class="sref">csum_fn
/a> *
a href="+code=fn" class="sref">fn
/a>)1"217
/a>{1"218
/a>        void *
a href="+code=buf" class="sref">buf
/a> = 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=da=a_buf" class="sref">da=a_buf
/a>;1"219
/a>        struct 
a href="+code=sd_dif_tuple" class="sref">sd_dif_tuple
/a> *
a href="+code=sdt" class="sref">sdt
/a> = 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=prot_buf" class="sref">prot_buf
/a>;1"220
/a>        
a href="+code=sec=or_t" class="sref">sec=or_t
/a> 
a href="+code=sec=or" class="sref">sec=or
/a> = 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=sec=or" class="sref">sec=or
/a>;1"221
/a>        unsigned int 
a href="+code=i" class="sref">i
/a>;1"222
/a>        
a href="+code=__u16" class="sref">__u16
/a> 
a href="+code=csum" class="sref">csum
/a>;1"223
/a>1"224
/a>        for (
a href="+code=i" class="sref">i
/a> = 0 ; 
a href="+code=i" class="sref">i
/a> < 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=da=a_size" class="sref">da=a_size
/a> ; 
a href="+code=i" class="sref">i
/a> += 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=sec=or_size" class="sref">sec=or_size
/a>, 
a href="+code=sdt" class="sref">sdt
/a>++) {1"225
/a>                
spa3 class="comment">/* Unwritten sec=ors */
/spa3.1"226
/a>                if (
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=app_tag" class="sref">app_tag
/a> == 0xffff && 
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=ref_tag" class="sref">ref_tag
/a> == 0xffffffff)1"227
/a>                        return 0;1"228
/a>1"229
/a>                
a href="+code=csum" class="sref">csum
/a> = 
a href="+code=fn" class="sref">fn
/a>(
a href="+code=buf" class="sref">buf
/a>, 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=sec=or_size" class="sref">sec=or_size
/a>);1"230
/a>1"231
/a>                if (
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=guard_tag" class="sref">guard_tag
/a> != 
a href="+code=csum" class="sref">csum
/a>) {1"232
/a>                        
a href="+code=printk" class="sref">printk
/a>(
a href="+code=KERN_ERR" class="sref">KERN_ERR
/a> 
spa3 class="string">"%s: guard tag error on sec=or %lu ""233
/a>                               
spa3 class="string">"(rcvd %04x, da=a %04x)\n"bix
/a>->
a href="+code=disk_nam4" class="sref">disk_nam4
/a>,1"234
/a>                               (unsigned long)
a href="+code=sec=or" class="sref">sec=or
/a>,1"235
/a>                               
a href="+code=be16_to_cpu" class="sref">be16_to_cpu
/a>(
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=guard_tag" class="sref">guard_tag
/a>), 
a href="+code=be16_to_cpu" class="sref">be16_to_cpu
/a>(
a href="+code=csum" class="sref">csum
/a>));1"236
/a>                        return -
a href="+code=EIO" class="sref">EIO
/a>;1"237
/a>                }1"238
/a>1"239
/a>                
a href="+code=buf" class="sref">buf
/a> += 
a href="+code=bix" class="sref">bix
/a>->
a href="+code=sec=or_size" class="sref">sec=or_size
/a>;1"240
/a>                
a href="+code=sec=or" class="sref">sec=or
/a>++;1"241
/a>        }1"242
/a>1"243
/a>        return 0;1"244
/a>}1"245
/a>1"246
/a>static"int 
a href="+code=sd_dif_typ43_verify_crc" class="sref">sd_dif_typ43_verify_crc
/a>(struct 
a href="+code=blk_integrity_exchg" class="sref">blk_integrity_exchg
/a> *
a href="+code=bix" class="sref">bix
/a>)1"247
/a>{1"248
/a>        return 
a href="+code=sd_dif_typ43_verify" class="sref">sd_dif_typ43_verify
/a>(
a href="+code=bix" class="sref">bix
/a>, 
a href="+code=sd_dif_crc_fn" class="sref">sd_dif_crc_fn
/a>);1"249
/a>}1"250
/a>1"251
/a>static"int 
a href="+code=sd_dif_typ43_verify_ip" class="sref">sd_dif_typ43_verify_ip
/a>(struct 
a href="+code=blk_integrity_exchg" class="sref">blk_integrity_exchg
/a> *
a href="+code=bix" class="sref">bix
/a>)1"252
/a>{1"253
/a>        return 
a href="+code=sd_dif_typ43_verify" class="sref">sd_dif_typ43_verify
/a>(
a href="+code=bix" class="sref">bix
/a>, 
a href="+code=sd_dif_ip_fn" class="sref">sd_dif_ip_fn
/a>);1"254
/a>}1"255
/a>1"256
/a>static"void 
a href="+code=sd_dif_typ43_set_tag" class="sref">sd_dif_typ43_set_tag
/a>(void *
a href="+code=prot" class="sref">prot
/a>, void *
a href="+code=tag_buf" class="sref">tag_buf
/a>, unsigned int 
a href="+code=sec=ors" class="sref">sec=ors
/a>)1"257
/a>{1"258
/a>        struct 
a href="+code=sd_dif_tuple" class="sref">sd_dif_tuple
/a> *
a href="+code=sdt" class="sref">sdt
/a> = 
a href="+code=prot" class="sref">prot
/a>;1"259
/a>        
a href="+code=u8" class="sref">u8
/a> *
a href="+code=tag" class="sref">tag
/a> = 
a href="+code=tag_buf" class="sref">tag_buf
/a>;1"260
/a>        unsigned int 
a href="+code=i" class="sref">i
/a>, 
a href="+code=j" class="sref">j
/a>;1"261
/a>1"262
/a>        for (
a href="+code=i" class="sref">i
/a> = 0, 
a href="+code=j" class="sref">j
/a> = 0 ; 
a href="+code=i" class="sref">i
/a> < 
a href="+code=sec=ors" class="sref">sec=ors
/a> ; 
a href="+code=i" class="sref">i
/a>++, 
a href="+code=j" class="sref">j
/a> += 6, 
a href="+code=sdt" class="sref">sdt
/a>++) {1"263
/a>                
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=app_tag" class="sref">app_tag
/a> = 
a href="+code=tag" class="sref">tag
/a>[
a href="+code=j" class="sref">j
/a>] << 8 | 
a href="+code=tag" class="sref">tag
/a>[
a href="+code=j" class="sref">j
/a>+1];1"264
/a>                
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=ref_tag" class="sref">ref_tag
/a> = 
a href="+code=tag" class="sref">tag
/a>[
a href="+code=j" class="sref">j
/a>+2] << 24 | 
a href="+code=tag" class="sref">tag
/a>[
a href="+code=j" class="sref">j
/a>+3] << 16 |1"265
/a>                        
a href="+code=tag" class="sref">tag
/a>[
a href="+code=j" class="sref">j
/a>+4] << 8 | 
a href="+code=tag" class="sref">tag
/a>[
a href="+code=j" class="sref">j
/a>+5];1"266
/a>        }1"267
/a>}1"268
/a>1"269
/a>static"void 
a href="+code=sd_dif_typ43_get_tag" class="sref">sd_dif_typ43_get_tag
/a>(void *
a href="+code=prot" class="sref">prot
/a>, void *
a href="+code=tag_buf" class="sref">tag_buf
/a>, unsigned int 
a href="+code=sec=ors" class="sref">sec=ors
/a>)1"270
/a>{1"271
/a>        struct 
a href="+code=sd_dif_tuple" class="sref">sd_dif_tuple
/a> *
a href="+code=sdt" class="sref">sdt
/a> = 
a href="+code=prot" class="sref">prot
/a>;1"272
/a>        
a href="+code=u8" class="sref">u8
/a> *
a href="+code=tag" class="sref">tag
/a> = 
a href="+code=tag_buf" class="sref">tag_buf
/a>;1"273
/a>        unsigned int 
a href="+code=i" class="sref">i
/a>, 
a href="+code=j" class="sref">j
/a>;1"274
/a>1"275
/a>        for (
a href="+code=i" class="sref">i
/a> = 0, 
a href="+code=j" class="sref">j
/a> = 0 ; 
a href="+code=i" class="sref">i
/a> < 
a href="+code=sec=ors" class="sref">sec=ors
/a> ; 
a href="+code=i" class="sref">i
/a>++, 
a href="+code=j" class="sref">j
/a> += 2, 
a href="+code=sdt" class="sref">sdt
/a>++) {1"276
/a>                
a href="+code=tag" class="sref">tag
/a>[
a href="+code=j" class="sref">j
/a>] = (
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=app_tag" class="sref">app_tag
/a> & 0xff00) >> 8;1"277
/a>                
a href="+code=tag" class="sref">tag
/a>[
a href="+code=j" class="sref">j
/a>+1] = 
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=app_tag" class="sref">app_tag
/a> & 0xff;1"278
/a>                
a href="+code=tag" class="sref">tag
/a>[
a href="+code=j" class="sref">j
/a>+2] = (
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=ref_tag" class="sref">ref_tag
/a> & 0xff000000) >> 24;1"279
/a>                
a href="+code=tag" class="sref">tag
/a>[
a href="+code=j" class="sref">j
/a>+3] = (
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=ref_tag" class="sref">ref_tag
/a> & 0xff0000) >> 16;1"280
/a>                
a href="+code=tag" class="sref">tag
/a>[
a href="+code=j" class="sref">j
/a>+4] = (
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=ref_tag" class="sref">ref_tag
/a> & 0xff00) >> 8;1"281
/a>                
a href="+code=tag" class="sref">tag
/a>[
a href="+code=j" class="sref">j
/a>+5] = 
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=ref_tag" class="sref">ref_tag
/a> & 0xff;1"282
/a>                
a href="+code=BUG_ON" class="sref">BUG_ON
/a>(
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=app_tag" class="sref">app_tag
/a> == 0xffff || 
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=ref_tag" class="sref">ref_tag
/a> == 0xffffffff);1"283
/a>        }1"284
/a>}1"285
/a>1"286
/a>static"struct 
a href="+code=blk_integrity" class="sref">blk_integrity
/a> 
a href="+code=dif_typ43_integrity_crc" class="sref">dif_typ43_integrity_crc
/a> = {1"287
/a>        .
a href="+code=nam4" class="sref">nam4
/a>                   = 
spa3 class="string">"T10-DIF-TYPE3-CRC""288
/a>        .
a href="+code=generate_fn" class="sref">generate_fn
/a>            = 
a href="+code=sd_dif_typ43_generate_crc" class="sref">sd_dif_typ43_generate_crc
/a>,1"289
/a>        .
a href="+code=verify_fn" class="sref">verify_fn
/a>              = 
a href="+code=sd_dif_typ43_verify_crc" class="sref">sd_dif_typ43_verify_crc
/a>,1"290
/a>        .
a href="+code=get_tag_fn" class="sref">get_tag_fn
/a>             = 
a href="+code=sd_dif_typ43_get_tag" class="sref">sd_dif_typ43_get_tag
/a>,1"291
/a>        .
a href="+code=set_tag_fn" class="sref">set_tag_fn
/a>             = 
a href="+code=sd_dif_typ43_set_tag" class="sref">sd_dif_typ43_set_tag
/a>,1"292
/a>        .
a href="+code=tuple_size" class="sref">tuple_size
/a>             = sizeof(struct 
a href="+code=sd_dif_tuple" class="sref">sd_dif_tuple
/a>),1"293
/a>        .
a href="+code=tag_size" class="sref">tag_size
/a>               = 0,1"294
/a>};1"295
/a>1"296
/a>static"struct 
a href="+code=blk_integrity" class="sref">blk_integrity
/a> 
a href="+code=dif_typ43_integrity_ip" class="sref">dif_typ43_integrity_ip
/a> = {1"297
/a>        .
a href="+code=nam4" class="sref">nam4
/a>                   = 
spa3 class="string">"T10-DIF-TYPE3-IP""298
/a>        .
a href="+code=generate_fn" class="sref">generate_fn
/a>            = 
a href="+code=sd_dif_typ43_generate_ip" class="sref">sd_dif_typ43_generate_ip
/a>,1"299
/a>        .
a href="+code=verify_fn" class="sref">verify_fn
/a>              = 
a href="+code=sd_dif_typ43_verify_ip" class="sref">sd_dif_typ43_verify_ip
/a>,1"300
/a>        .
a href="+code=get_tag_fn" class="sref">get_tag_fn
/a>             = 
a href="+code=sd_dif_typ43_get_tag" class="sref">sd_dif_typ43_get_tag
/a>,1"301
/a>        .
a href="+code=set_tag_fn" class="sref">set_tag_fn
/a>             = 
a href="+code=sd_dif_typ43_set_tag" class="sref">sd_dif_typ43_set_tag
/a>,1"302
/a>        .
a href="+code=tuple_size" class="sref">tuple_size
/a>             = sizeof(struct 
a href="+code=sd_dif_tuple" class="sref">sd_dif_tuple
/a>),1"303
/a>        .
a href="+code=tag_size" class="sref">tag_size
/a>               = 0,1"304
/a>};1"305
/a>1"306
/a>
spa3 class="comment">/*
/spa3.1"307
/a>
spa3 class="comment"> * Configure exchange of protec="v3 informa="v3 between OS and HBA.
/spa3.1"308
/a>
spa3 class="comment"> */
/spa3.1"309
/a>void 
a href="+code=sd_dif_config_host" class="sref">sd_dif_config_host
/a>(struct 
a href="+code=scsi_disk" class="sref">scsi_disk
/a> *
a href="+code=sdkp" class="sref">sdkp
/a>)1"310
/a>{1"311
/a>        struct 
a href="+code=scsi_device" class="sref">scsi_device
/a> *
a href="+code=sdp" class="sref">sdp
/a> = 
a href="+code=sdkp" class="sref">sdkp
/a>->
a href="+code=device" class="sref">device
/a>;1"312
/a>        struct 
a href="+code=gendisk" class="sref">gendisk
/a> *
a href="+code=disk" class="sref">disk
/a> = 
a href="+code=sdkp" class="sref">sdkp
/a>->
a href="+code=disk" class="sref">disk
/a>;1"313
/a>        
a href="+code=u8" class="sref">u8
/a> 
a href="+code=typ4" class="sref">typ4
/a> = 
a href="+code=sdkp" class="sref">sdkp
/a>->
a href="+code=protec="v3_typ4" class="sref">protec="v3_typ4
/a>;1"314
/a>        int 
a href="+code=dif" class="sref">dif
/a>, 
a href="+code=dix" class="sref">dix
/a>;1"315
/a>1"316
/a>        
a href="+code=dif" class="sref">dif
/a> = 
a href="+code=scsi_host_dif_capable" class="sref">scsi_host_dif_capable
/a>(
a href="+code=sdp" class="sref">sdp
/a>->
a href="+code=host" class="sref">host
/a>, 
a href="+code=typ4" class="sref">typ4
/a>);1"317
/a>        
a href="+code=dix" class="sref">dix
/a> = 
a href="+code=scsi_host_dix_capable" class="sref">scsi_host_dix_capable
/a>(
a href="+code=sdp" class="sref">sdp
/a>->
a href="+code=host" class="sref">host
/a>, 
a href="+code=typ4" class="sref">typ4
/a>);1"318
/a>1"319
/a>        if (!
a href="+code=dix" class="sref">dix
/a> && 
a href="+code=scsi_host_dix_capable" class="sref">scsi_host_dix_capable
/a>(
a href="+code=sdp" class="sref">sdp
/a>->
a href="+code=host" class="sref">host
/a>, 0)) {1"320
/a>                
a href="+code=dif" class="sref">dif
/a> = 0; 
a href="+code=dix" class="sref">dix
/a> = 1;1"321
/a>        }1"322
/a>1"323
/a>        if (!
a href="+code=dix" class="sref">dix
/a>)1"324
/a>                return;1"325
/a>1"326
/a>        
spa3 class="comment">/* Enable DMA of protec="v3 informa="v3 */
/spa3.1"327
/a>        if (
a href="+code=scsi_host_get_guard" class="sref">scsi_host_get_guard
/a>(
a href="+code=sdkp" class="sref">sdkp
/a>->
a href="+code=device" class="sref">device
/a>->
a href="+code=host" class="sref">host
/a>) & 
a href="+code=SHOST_DIX_GUARD_IP" class="sref">SHOST_DIX_GUARD_IP
/a>)1"328
/a>                if (
a href="+code=typ4" class="sref">typ4
/a> == 
a href="+code=SD_DIF_TYPE3_PROTECTION" class="sref">SD_DIF_TYPE3_PROTECTION
/a>)1"329
/a>                        
a href="+code=blk_integrity_register" class="sref">blk_integrity_register
/a>(
a href="+code=disk" class="sref">disk
/a>, &
a href="+code=dif_typ43_integrity_ip" class="sref">dif_typ43_integrity_ip
/a>);1"330
/a>                else1"331
/a>                        
a href="+code=blk_integrity_register" class="sref">blk_integrity_register
/a>(
a href="+code=disk" class="sref">disk
/a>, &
a href="+code=dif_typ41_integrity_ip" class="sref">dif_typ41_integrity_ip
/a>);1"332
/a>        else1"333
/a>                if (
a href="+code=typ4" class="sref">typ4
/a> == 
a href="+code=SD_DIF_TYPE3_PROTECTION" class="sref">SD_DIF_TYPE3_PROTECTION
/a>)1"334
/a>                        
a href="+code=blk_integrity_register" class="sref">blk_integrity_register
/a>(
a href="+code=disk" class="sref">disk
/a>, &
a href="+code=dif_typ43_integrity_crc" class="sref">dif_typ43_integrity_crc
/a>);1"335
/a>                else1"336
/a>                        
a href="+code=blk_integrity_register" class="sref">blk_integrity_register
/a>(
a href="+code=disk" class="sref">disk
/a>, &
a href="+code=dif_typ41_integrity_crc" class="sref">dif_typ41_integrity_crc
/a>);1"337
/a>1"338
/a>        
a href="+code=sd_printk" class="sref">sd_printk
/a>(
a href="+code=KERN_NOTICE" class="sref">KERN_NOTICE
/a>, 
a href="+code=sdkp" class="sref">sdkp
/a>,1"339
/a>                  
spa3 class="string">"Enabling DIX %s protec="v3\n"disk
/a>->
a href="+code=integrity" class="sref">integrity
/a>->
a href="+code=nam4" class="sref">nam4
/a>);1"340
/a>1"341
/a>        
spa3 class="comment">/* Signal to block layer that we support sec=or tagging */
/spa3.1"342
/a>        if (
a href="+code=dif" class="sref">dif
/a> && 
a href="+code=typ4" class="sref">typ4
/a> && 
a href="+code=sdkp" class="sref">sdkp
/a>->
a href="+code=ATO" class="sref">ATO
/a>) {1"343
/a>                if (
a href="+code=typ4" class="sref">typ4
/a> == 
a href="+code=SD_DIF_TYPE3_PROTECTION" class="sref">SD_DIF_TYPE3_PROTECTION
/a>)1"344
/a>                        
a href="+code=disk" class="sref">disk
/a>->
a href="+code=integrity" class="sref">integrity
/a>->
a href="+code=tag_size" class="sref">tag_size
/a> = sizeof(
a href="+code=u16" class="sref">u16
/a>) + sizeof(
a href="+code=u32" class="sref">u32
/a>);1"345
/a>                else1"346
/a>                        
a href="+code=disk" class="sref">disk
/a>->
a href="+code=integrity" class="sref">integrity
/a>->
a href="+code=tag_size" class="sref">tag_size
/a> = sizeof(
a href="+code=u16" class="sref">u16
/a>);1"347
/a>1"348
/a>                
a href="+code=sd_printk" class="sref">sd_printk
/a>(
a href="+code=KERN_NOTICE" class="sref">KERN_NOTICE
/a>, 
a href="+code=sdkp" class="sref">sdkp
/a>, 
spa3 class="string">"DIF applica="v3 tag size %u\n""349
/a>                          
a href="+code=disk" class="sref">disk
/a>->
a href="+code=integrity" class="sref">integrity
/a>->
a href="+code=tag_size" class="sref">tag_size
/a>);1"350
/a>        }1"351
/a>}1"352
/a>1"353
/a>
spa3 class="comment">/*
/spa3.1"354
/a>
spa3 class="comment"> * The virtual start sec=or is the one that was originally submitted
/spa3.1"355
/a>
spa3 class="comment"> * by the block layer.  Due to parti="v3ing, MD/DM clv3ing, etc. the
/spa3.1"356
/a>
spa3 class="comment"> * actual physical start sec=or is likely to be different.  Remap
/spa3.1"357
/a>
spa3 class="comment"> * protec="v3 informa="v3 to ma=ch the physical LBA.
/spa3.1"358
/a>
spa3 class="comment"> *
/spa3.1"359
/a>
spa3 class="comment"> * From a protocol perspec="ve there's a slight difference between
/spa3.1"360
/a>
spa3 class="comment"> * Typ4 1 and 2.  The latter uses 32-byte CDBs exclusively, and the
/spa3.1"361
/a>
spa3 class="comment"> * reference tag is seeded in the CDB.  This gives us the potential to
/spa3.1"362
/a>
spa3 class="comment"> * avoid virt->phys remapping during write.  However, at read time we
/spa3.1"363
/a>
spa3 class="comment"> * don't know whether the virt sec=or is the sam4 as when we wrote it
/spa3.1"364
/a>
spa3 class="comment"> * (we could be reading from real disk as opposed to MD/DM device.  So
/spa3.1"365
/a>
spa3 class="comment"> * we always remap Typ4 2 making it identical to Typ4 1.
/spa3.1"366
/a>
spa3 class="comment"> *
/spa3.1"367
/a>
spa3 class="comment"> * Typ4 3 does not have a reference tag so no remapping is required.
/spa3.1"368
/a>
spa3 class="comment"> */
/spa3.1"369
/a>void 
a href="+code=sd_dif_prepare" class="sref">sd_dif_prepare
/a>(struct 
a href="+code=request" class="sref">request
/a> *
a href="+code=rq" class="sref">rq
/a>, 
a href="+code=sec=or_t" class="sref">sec=or_t
/a> 
a href="+code=hw_sec=or" class="sref">hw_sec=or
/a>,1"370
/a>                    unsigned int 
a href="+code=sec=or_sz" class="sref">sec=or_sz
/a>)1"371
/a>{1"372
/a>        const int 
a href="+code=tuple_sz" class="sref">tuple_sz
/a> = sizeof(struct 
a href="+code=sd_dif_tuple" class="sref">sd_dif_tuple
/a>);1"373
/a>        struct 
a href="+code=bio" class="sref">bio
/a> *
a href="+code=bio" class="sref">bio
/a>;1"374
/a>        struct 
a href="+code=scsi_disk" class="sref">scsi_disk
/a> *
a href="+code=sdkp" class="sref">sdkp
/a>;1"375
/a>        struct 
a href="+code=sd_dif_tuple" class="sref">sd_dif_tuple
/a> *
a href="+code=sdt" class="sref">sdt
/a>;1"376
/a>        unsigned int 
a href="+code=i" class="sref">i
/a>, 
a href="+code=j" class="sref">j
/a>;1"377
/a>        
a href="+code=u32" class="sref">u32
/a> 
a href="+code=phys" class="sref">phys
/a>, 
a href="+code=virt" class="sref">virt
/a>;1"378
/a>1"379
/a>        
a href="+code=sdkp" class="sref">sdkp
/a> = 
a href="+code=rq" class="sref">rq
/a>->
a href="+code=bio" class="sref">bio
/a>->
a href="+code=bi_bdev" class="sref">bi_bdev
/a>->
a href="+code=bd_disk" class="sref">bd_disk
/a>->
a href="+code=private_da=a" class="sref">private_da=a
/a>;1"380
/a>1"381
/a>        if (
a href="+code=sdkp" class="sref">sdkp
/a>->
a href="+code=protec="v3_typ4" class="sref">protec="v3_typ4
/a> == 
a href="+code=SD_DIF_TYPE3_PROTECTION" class="sref">SD_DIF_TYPE3_PROTECTION
/a>)1"382
/a>                return;1"383
/a>1"384
/a>        
a href="+code=phys" class="sref">phys
/a> = 
a href="+code=hw_sec=or" class="sref">hw_sec=or
/a> & 0xffffffff;1"385
/a>1"386
/a>        
a href="+code=__rq_for_each_bio" class="sref">__rq_for_each_bio
/a>(
a href="+code=bio" class="sref">bio
/a>, 
a href="+code=rq" class="sref">rq
/a>) {1"387
/a>                struct 
a href="+code=bio_vec" class="sref">bio_vec
/a> *
a href="+code=iv" class="sref">iv
/a>;1"388
/a>1"389
/a>                
spa3 class="comment">/* Already remapped? */
/spa3.1"390
/a>                if (
a href="+code=bio_flagged" class="sref">bio_flagged
/a>(
a href="+code=bio" class="sref">bio
/a>, 
a href="+code=BIO_MAPPED_INTEGRITY" class="sref">BIO_MAPPED_INTEGRITY
/a>))1"391
/a>                        break;1"392
/a>1"393
/a>                
a href="+code=virt" class="sref">virt
/a> = 
a href="+code=bio" class="sref">bio
/a>->
a href="+code=bi_integrity" class="sref">bi_integrity
/a>->
a href="+code=bip_sec=or" class="sref">bip_sec=or
/a> & 0xffffffff;1"394
/a>1"395
/a>                
a href="+code=bip_for_each_vec" class="sref">bip_for_each_vec
/a>(
a href="+code=iv" class="sref">iv
/a>, 
a href="+code=bio" class="sref">bio
/a>->
a href="+code=bi_integrity" class="sref">bi_integrity
/a>, 
a href="+code=i" class="sref">i
/a>) {1"396
/a>                        
a href="+code=sdt" class="sref">sdt
/a> = 
a href="+code=kmap_atomic" class="sref">kmap_atomic
/a>(
a href="+code=iv" class="sref">iv
/a>->
a href="+code=bv_pag4" class="sref">bv_pag4
/a>)1"397
/a>                                + 
a href="+code=iv" class="sref">iv
/a>->
a href="+code=bv_offset" class="sref">bv_offset
/a>;1"398
/a>1"399
/a>                        for (
a href="+code=j" class="sref">j
/a> = 0 ; 
a href="+code=j" class="sref">j
/a> < 
a href="+code=iv" class="sref">iv
/a>->
a href="+code=bv_len" class="sref">bv_len
/a> ; 
a href="+code=j" class="sref">j
/a> += 
a href="+code=tuple_sz" class="sref">tuple_sz
/a>, 
a href="+code=sdt" class="sref">sdt
/a>++) {1"400
/a>1"401
/a>                                if (
a href="+code=be32_to_cpu" class="sref">be32_to_cpu
/a>(
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=ref_tag" class="sref">ref_tag
/a>) == 
a href="+code=virt" class="sref">virt
/a>)1"402
/a>                                        
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=ref_tag" class="sref">ref_tag
/a> = 
a href="+code=cpu_to_be32" class="sref">cpu_to_be32
/a>(
a href="+code=phys" class="sref">phys
/a>);1"403
/a>1"404
/a>                                
a href="+code=virt" class="sref">virt
/a>++;1"405
/a>                                
a href="+code=phys" class="sref">phys
/a>++;1"406
/a>                        }1"407
/a>1"408
/a>                        
a href="+code=kunmap_atomic" class="sref">kunmap_atomic
/a>(
a href="+code=sdt" class="sref">sdt
/a>);1"409
/a>                }1"410
/a>1"411
/a>                
a href="+code=bio" class="sref">bio
/a>->
a href="+code=bi_flags" class="sref">bi_flags
/a> |= (1 << 
a href="+code=BIO_MAPPED_INTEGRITY" class="sref">BIO_MAPPED_INTEGRITY
/a>);1"412
/a>        }1"413
/a>}1"414
/a>1"415
/a>
spa3 class="comment">/*
/spa3.1"416
/a>
spa3 class="comment"> * Remap physical sec=or values in the reference tag to the virtual
/spa3.1"417
/a>
spa3 class="comment"> * values expec=ed by the block layer.
/spa3.1"418
/a>
spa3 class="comment"> */
/spa3.1"419
/a>void 
a href="+code=sd_dif_complete" class="sref">sd_dif_complete
/a>(struct 
a href="+code=scsi_cmnd" class="sref">scsi_cmnd
/a> *
a href="+code=scmd" class="sref">scmd
/a>, unsigned int 
a href="+code=good_bytes" class="sref">good_bytes
/a>)1"420
/a>{1"421
/a>        const int 
a href="+code=tuple_sz" class="sref">tuple_sz
/a> = sizeof(struct 
a href="+code=sd_dif_tuple" class="sref">sd_dif_tuple
/a>);1"422
/a>        struct 
a href="+code=scsi_disk" class="sref">scsi_disk
/a> *
a href="+code=sdkp" class="sref">sdkp
/a>;1"423
/a>        struct 
a href="+code=bio" class="sref">bio
/a> *
a href="+code=bio" class="sref">bio
/a>;1"424
/a>        struct 
a href="+code=sd_dif_tuple" class="sref">sd_dif_tuple
/a> *
a href="+code=sdt" class="sref">sdt
/a>;1"425
/a>        unsigned int 
a href="+code=i" class="sref">i
/a>, 
a href="+code=j" class="sref">j
/a>, 
a href="+code=sec=ors" class="sref">sec=ors
/a>, 
a href="+code=sec=or_sz" class="sref">sec=or_sz
/a>;1"426
/a>        
a href="+code=u32" class="sref">u32
/a> 
a href="+code=phys" class="sref">phys
/a>, 
a href="+code=virt" class="sref">virt
/a>;1"427
/a>1"428
/a>        
a href="+code=sdkp" class="sref">sdkp
/a> = 
a href="+code=scsi_disk" class="sref">scsi_disk
/a>(
a href="+code=scmd" class="sref">scmd
/a>->
a href="+code=request" class="sref">request
/a>->
a href="+code=rq_disk" class="sref">rq_disk
/a>);1"429
/a>1"430
/a>        if (
a href="+code=sdkp" class="sref">sdkp
/a>->
a href="+code=protec="v3_typ4" class="sref">protec="v3_typ4
/a> == 
a href="+code=SD_DIF_TYPE3_PROTECTION" class="sref">SD_DIF_TYPE3_PROTECTION
/a> || 
a href="+code=good_bytes" class="sref">good_bytes
/a> == 0)1"431
/a>                return;1"432
/a>1"433
/a>        
a href="+code=sec=or_sz" class="sref">sec=or_sz
/a> = 
a href="+code=scmd" class="sref">scmd
/a>->
a href="+code=device" class="sref">device
/a>->
a href="+code=sec=or_size" class="sref">sec=or_size
/a>;1"434
/a>        
a href="+code=sec=ors" class="sref">sec=ors
/a> = 
a href="+code=good_bytes" class="sref">good_bytes
/a> / 
a href="+code=sec=or_sz" class="sref">sec=or_sz
/a>;1"435
/a>1"436
/a>        
a href="+code=phys" class="sref">phys
/a> = 
a href="+code=blk_rq_pos" class="sref">blk_rq_pos
/a>(
a href="+code=scmd" class="sref">scmd
/a>->
a href="+code=request" class="sref">request
/a>) & 0xffffffff;1"437
/a>        if (
a href="+code=sec=or_sz" class="sref">sec=or_sz
/a> =="4096)1"438
/a>                
a href="+code=phys" class="sref">phys
/a> >>= 3;1"439
/a>1"440
/a>        
a href="+code=__rq_for_each_bio" class="sref">__rq_for_each_bio
/a>(
a href="+code=bio" class="sref">bio
/a>, 
a href="+code=scmd" class="sref">scmd
/a>->
a href="+code=request" class="sref">request
/a>) {1"441
/a>                struct 
a href="+code=bio_vec" class="sref">bio_vec
/a> *
a href="+code=iv" class="sref">iv
/a>;1"442
/a>1"443
/a>                
a href="+code=virt" class="sref">virt
/a> = 
a href="+code=bio" class="sref">bio
/a>->
a href="+code=bi_integrity" class="sref">bi_integrity
/a>->
a href="+code=bip_sec=or" class="sref">bip_sec=or
/a> & 0xffffffff;1"444
/a>1"445
/a>                
a href="+code=bip_for_each_vec" class="sref">bip_for_each_vec
/a>(
a href="+code=iv" class="sref">iv
/a>, 
a href="+code=bio" class="sref">bio
/a>->
a href="+code=bi_integrity" class="sref">bi_integrity
/a>, 
a href="+code=i" class="sref">i
/a>) {1"446
/a>                        
a href="+code=sdt" class="sref">sdt
/a> = 
a href="+code=kmap_atomic" class="sref">kmap_atomic
/a>(
a href="+code=iv" class="sref">iv
/a>->
a href="+code=bv_pag4" class="sref">bv_pag4
/a>)1"447
/a>                                + 
a href="+code=iv" class="sref">iv
/a>->
a href="+code=bv_offset" class="sref">bv_offset
/a>;1"448
/a>1"449
/a>                        for (
a href="+code=j" class="sref">j
/a> = 0 ; 
a href="+code=j" class="sref">j
/a> < 
a href="+code=iv" class="sref">iv
/a>->
a href="+code=bv_len" class="sref">bv_len
/a> ; 
a href="+code=j" class="sref">j
/a> += 
a href="+code=tuple_sz" class="sref">tuple_sz
/a>, 
a href="+code=sdt" class="sref">sdt
/a>++) {1"450
/a>1"451
/a>                                if (
a href="+code=sec=ors" class="sref">sec=ors
/a> == 0) {1"452
/a>                                        
a href="+code=kunmap_atomic" class="sref">kunmap_atomic
/a>(
a href="+code=sdt" class="sref">sdt
/a>);1"453
/a>                                        return;1"454
/a>                                }1"455
/a>1"456
/a>                                if (
a href="+code=be32_to_cpu" class="sref">be32_to_cpu
/a>(
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=ref_tag" class="sref">ref_tag
/a>) == 
a href="+code=phys" class="sref">phys
/a>)1"457
/a>                                        
a href="+code=sdt" class="sref">sdt
/a>->
a href="+code=ref_tag" class="sref">ref_tag
/a> = 
a href="+code=cpu_to_be32" class="sref">cpu_to_be32
/a>(
a href="+code=virt" class="sref">virt
/a>);1"458
/a>1"459
/a>                                
a href="+code=virt" class="sref">virt
/a>++;1"460
/a>                                
a href="+code=phys" class="sref">phys
/a>++;1"461
/a>                                
a href="+code=sec=ors" class="sref">sec=ors
/a>--;1"462
/a>                        }1"463
/a>1"464
/a>                        
a href="+code=kunmap_atomic" class="sref">kunmap_atomic
/a>(
a href="+code=sdt" class="sref">sdt
/a>);1"465
/a>                }1"466
/a>        }1"467
/a>}1"468
/a>1"469
/a>
lxr.linux.no kindly hos=ed by Redpill Linpro AS /a>, provider of Linux consulting and operat"v3s services since 1995.