49
49
## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
50
50
51
51
.macro LABEL prefix n
52
- \prefix\n\():
52
+ .L \prefix\n\():
53
53
.endm
54
54
55
55
.macro JMPTBL_ENTRY i
56
- .quad crc_ \i
56
+ .quad .Lcrc_ \i
57
57
.endm
58
58
59
59
.macro JNC_LESS_THAN j
60
- jnc less_than_ \j
60
+ jnc .Lless_than_ \j
61
61
.endm
62
62
63
63
# Define threshold where buffers are considered "small" and routed to more
@@ -108,30 +108,30 @@ SYM_FUNC_START(crc_pcl)
108
108
neg %bufp
109
109
and $7 , %bufp # calculate the unalignment amount of
110
110
# the address
111
- je proc_block # Skip if aligned
111
+ je .Lproc_block # Skip if aligned
112
112
113
113
## If len is less than 8 and we're unaligned, we need to jump
114
114
## to special code to avoid reading beyond the end of the buffer
115
115
cmp $8 , len
116
- jae do_align
116
+ jae .Ldo_align
117
117
# less_than_8 expects length in upper 3 bits of len_dw
118
118
# less_than_8_post_shl1 expects length = carryflag * 8 + len_dw[31:30]
119
119
shl $32 -3 +1 , len_dw
120
- jmp less_than_8_post_shl1
120
+ jmp .Lless_than_8_post_shl1
121
121
122
- do_align :
122
+ .Ldo_align :
123
123
#### Calculate CRC of unaligned bytes of the buffer (if any)
124
124
movq (bufptmp), tmp # load a quadward from the buffer
125
125
add %bufp, bufptmp # align buffer pointer for quadword
126
126
# processing
127
127
sub %bufp, len # update buffer length
128
- align_loop :
128
+ .Lalign_loop :
129
129
crc32b %bl , crc_init_dw # compute crc32 of 1-byte
130
130
shr $8 , tmp # get next byte
131
131
dec %bufp
132
- jne align_loop
132
+ jne .Lalign_loop
133
133
134
- proc_block :
134
+ .Lproc_block :
135
135
136
136
################################################################
137
137
## 2) PROCESS BLOCKS:
@@ -141,11 +141,11 @@ proc_block:
141
141
movq len, tmp # save num bytes in tmp
142
142
143
143
cmpq $128*24 , len
144
- jae full_block
144
+ jae .Lfull_block
145
145
146
- continue_block :
146
+ .Lcontinue_block :
147
147
cmpq $SMALL_SIZE, len
148
- jb small
148
+ jb .Lsmall
149
149
150
150
## len < 128*24
151
151
movq $2731 , %rax # 2731 = ceil(2^16 / 24)
@@ -175,7 +175,7 @@ continue_block:
175
175
################################################################
176
176
## 2a) PROCESS FULL BLOCKS:
177
177
################################################################
178
- full_block :
178
+ .Lfull_block :
179
179
movl $128 ,%eax
180
180
lea 128*8*2 (block_0), block_1
181
181
lea 128*8*3 (block_0), block_2
@@ -190,7 +190,6 @@ full_block:
190
190
## 3) CRC Array:
191
191
################################################################
192
192
193
- crc_array:
194
193
i =128
195
194
.rept 128 -1
196
195
.altmacro
@@ -243,28 +242,28 @@ LABEL crc_ 0
243
242
ENDBR
244
243
mov tmp, len
245
244
cmp $128*24 , tmp
246
- jae full_block
245
+ jae .Lfull_block
247
246
cmp $24 , tmp
248
- jae continue_block
247
+ jae .Lcontinue_block
249
248
250
- less_than_24 :
249
+ .Lless_than_24 :
251
250
shl $32 -4 , len_dw # less_than_16 expects length
252
251
# in upper 4 bits of len_dw
253
- jnc less_than_16
252
+ jnc .Lless_than_16
254
253
crc32q (bufptmp), crc_init
255
254
crc32q 8 (bufptmp), crc_init
256
- jz do_return
255
+ jz .Ldo_return
257
256
add $16 , bufptmp
258
257
# len is less than 8 if we got here
259
258
# less_than_8 expects length in upper 3 bits of len_dw
260
259
# less_than_8_post_shl1 expects length = carryflag * 8 + len_dw[31:30]
261
260
shl $2 , len_dw
262
- jmp less_than_8_post_shl1
261
+ jmp .Lless_than_8_post_shl1
263
262
264
263
#######################################################################
265
264
## 6) LESS THAN 256-bytes REMAIN AT THIS POINT (8-bits of len are full)
266
265
#######################################################################
267
- small :
266
+ .Lsmall :
268
267
shl $32 -8 , len_dw # Prepare len_dw for less_than_256
269
268
j =256
270
269
.rept 5 # j = {256, 128, 64, 32, 16}
@@ -280,32 +279,32 @@ LABEL less_than_ %j # less_than_j: Length should be in
280
279
crc32q i(bufptmp), crc_init # Compute crc32 of 8-byte data
281
280
i = i+8
282
281
.endr
283
- jz do_return # Return if remaining length is zero
282
+ jz .Ldo_return # Return if remaining length is zero
284
283
add $j, bufptmp # Advance buf
285
284
.endr
286
285
287
- less_than_8 : # Length should be stored in
286
+ .Lless_than_8 : # Length should be stored in
288
287
# upper 3 bits of len_dw
289
288
shl $1 , len_dw
290
- less_than_8_post_shl1 :
291
- jnc less_than_4
289
+ .Lless_than_8_post_shl1 :
290
+ jnc .Lless_than_4
292
291
crc32l (bufptmp), crc_init_dw # CRC of 4 bytes
293
- jz do_return # return if remaining data is zero
292
+ jz .Ldo_return # return if remaining data is zero
294
293
add $4 , bufptmp
295
- less_than_4 : # Length should be stored in
294
+ .Lless_than_4 : # Length should be stored in
296
295
# upper 2 bits of len_dw
297
296
shl $1 , len_dw
298
- jnc less_than_2
297
+ jnc .Lless_than_2
299
298
crc32w (bufptmp), crc_init_dw # CRC of 2 bytes
300
- jz do_return # return if remaining data is zero
299
+ jz .Ldo_return # return if remaining data is zero
301
300
add $2 , bufptmp
302
- less_than_2 : # Length should be stored in the MSB
301
+ .Lless_than_2 : # Length should be stored in the MSB
303
302
# of len_dw
304
303
shl $1 , len_dw
305
- jnc less_than_1
304
+ jnc .Lless_than_1
306
305
crc32b (bufptmp), crc_init_dw # CRC of 1 byte
307
- less_than_1 : # Length should be zero
308
- do_return :
306
+ .Lless_than_1 : # Length should be zero
307
+ .Ldo_return :
309
308
movq crc_init, %rax
310
309
popq %rsi
311
310
popq %rdi
0 commit comments