Commit 5eaed68d authored by Max Gurtovoy's avatar Max Gurtovoy Committed by Jens Axboe

block: use symbolic constants for t10_pi type

Replace all hard-coded values with T10_PI_TYPES to make the code more
readable.
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarMax Gurtovoy <maxg@mellanox.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 7ad67ca5
...@@ -27,7 +27,7 @@ static __be16 t10_pi_ip_fn(void *data, unsigned int len) ...@@ -27,7 +27,7 @@ static __be16 t10_pi_ip_fn(void *data, unsigned int len)
* tag. * tag.
*/ */
static blk_status_t t10_pi_generate(struct blk_integrity_iter *iter, static blk_status_t t10_pi_generate(struct blk_integrity_iter *iter,
csum_fn *fn, unsigned int type) csum_fn *fn, enum t10_dif_type type)
{ {
unsigned int i; unsigned int i;
...@@ -37,7 +37,7 @@ static blk_status_t t10_pi_generate(struct blk_integrity_iter *iter, ...@@ -37,7 +37,7 @@ static blk_status_t t10_pi_generate(struct blk_integrity_iter *iter,
pi->guard_tag = fn(iter->data_buf, iter->interval); pi->guard_tag = fn(iter->data_buf, iter->interval);
pi->app_tag = 0; pi->app_tag = 0;
if (type == 1) if (type == T10_PI_TYPE1_PROTECTION)
pi->ref_tag = cpu_to_be32(lower_32_bits(iter->seed)); pi->ref_tag = cpu_to_be32(lower_32_bits(iter->seed));
else else
pi->ref_tag = 0; pi->ref_tag = 0;
...@@ -51,7 +51,7 @@ static blk_status_t t10_pi_generate(struct blk_integrity_iter *iter, ...@@ -51,7 +51,7 @@ static blk_status_t t10_pi_generate(struct blk_integrity_iter *iter,
} }
static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter, static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter,
csum_fn *fn, unsigned int type) csum_fn *fn, enum t10_dif_type type)
{ {
unsigned int i; unsigned int i;
...@@ -60,8 +60,8 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter, ...@@ -60,8 +60,8 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter,
__be16 csum; __be16 csum;
switch (type) { switch (type) {
case 1: case T10_PI_TYPE1_PROTECTION:
case 2: case T10_PI_TYPE2_PROTECTION:
if (pi->app_tag == T10_PI_APP_ESCAPE) if (pi->app_tag == T10_PI_APP_ESCAPE)
goto next; goto next;
...@@ -74,7 +74,7 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter, ...@@ -74,7 +74,7 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter,
return BLK_STS_PROTECTION; return BLK_STS_PROTECTION;
} }
break; break;
case 3: case T10_PI_TYPE3_PROTECTION:
if (pi->app_tag == T10_PI_APP_ESCAPE && if (pi->app_tag == T10_PI_APP_ESCAPE &&
pi->ref_tag == T10_PI_REF_ESCAPE) pi->ref_tag == T10_PI_REF_ESCAPE)
goto next; goto next;
...@@ -102,42 +102,42 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter, ...@@ -102,42 +102,42 @@ static blk_status_t t10_pi_verify(struct blk_integrity_iter *iter,
static blk_status_t t10_pi_type1_generate_crc(struct blk_integrity_iter *iter) static blk_status_t t10_pi_type1_generate_crc(struct blk_integrity_iter *iter)
{ {
return t10_pi_generate(iter, t10_pi_crc_fn, 1); return t10_pi_generate(iter, t10_pi_crc_fn, T10_PI_TYPE1_PROTECTION);
} }
static blk_status_t t10_pi_type1_generate_ip(struct blk_integrity_iter *iter) static blk_status_t t10_pi_type1_generate_ip(struct blk_integrity_iter *iter)
{ {
return t10_pi_generate(iter, t10_pi_ip_fn, 1); return t10_pi_generate(iter, t10_pi_ip_fn, T10_PI_TYPE1_PROTECTION);
} }
static blk_status_t t10_pi_type1_verify_crc(struct blk_integrity_iter *iter) static blk_status_t t10_pi_type1_verify_crc(struct blk_integrity_iter *iter)
{ {
return t10_pi_verify(iter, t10_pi_crc_fn, 1); return t10_pi_verify(iter, t10_pi_crc_fn, T10_PI_TYPE1_PROTECTION);
} }
static blk_status_t t10_pi_type1_verify_ip(struct blk_integrity_iter *iter) static blk_status_t t10_pi_type1_verify_ip(struct blk_integrity_iter *iter)
{ {
return t10_pi_verify(iter, t10_pi_ip_fn, 1); return t10_pi_verify(iter, t10_pi_ip_fn, T10_PI_TYPE1_PROTECTION);
} }
static blk_status_t t10_pi_type3_generate_crc(struct blk_integrity_iter *iter) static blk_status_t t10_pi_type3_generate_crc(struct blk_integrity_iter *iter)
{ {
return t10_pi_generate(iter, t10_pi_crc_fn, 3); return t10_pi_generate(iter, t10_pi_crc_fn, T10_PI_TYPE3_PROTECTION);
} }
static blk_status_t t10_pi_type3_generate_ip(struct blk_integrity_iter *iter) static blk_status_t t10_pi_type3_generate_ip(struct blk_integrity_iter *iter)
{ {
return t10_pi_generate(iter, t10_pi_ip_fn, 3); return t10_pi_generate(iter, t10_pi_ip_fn, T10_PI_TYPE3_PROTECTION);
} }
static blk_status_t t10_pi_type3_verify_crc(struct blk_integrity_iter *iter) static blk_status_t t10_pi_type3_verify_crc(struct blk_integrity_iter *iter)
{ {
return t10_pi_verify(iter, t10_pi_crc_fn, 3); return t10_pi_verify(iter, t10_pi_crc_fn, T10_PI_TYPE3_PROTECTION);
} }
static blk_status_t t10_pi_type3_verify_ip(struct blk_integrity_iter *iter) static blk_status_t t10_pi_type3_verify_ip(struct blk_integrity_iter *iter)
{ {
return t10_pi_verify(iter, t10_pi_ip_fn, 3); return t10_pi_verify(iter, t10_pi_ip_fn, T10_PI_TYPE3_PROTECTION);
} }
const struct blk_integrity_profile t10_pi_type1_crc = { const struct blk_integrity_profile t10_pi_type1_crc = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment