mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 13:41:48 -04:00
scsi: lpfc: Use the crc32c() function
lpfc_cgn_calc_crc32(data, size, crc) is really just an open-coded version of ~crc32c(bitrev32(crc), data, size). However, all callers pass crc == ~0, so it can be simplified even further to just ~crc32c(~0, data, size). Remove the crc argument and implement it that way. While we're at it, also use proper types in the function prototype. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Link: https://patch.msgid.link/20260316223631.72361-1-ebiggers@kernel.org Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
committed by
Martin K. Petersen
parent
98eff36164
commit
48b2de8505
@@ -1151,6 +1151,7 @@ config SCSI_LPFC
|
||||
depends on NVME_TARGET_FC || NVME_TARGET_FC=n
|
||||
depends on NVME_FC || NVME_FC=n
|
||||
select CRC_T10DIF
|
||||
select CRC32
|
||||
select IRQ_POLL
|
||||
help
|
||||
This lpfc driver supports the Emulex LightPulse
|
||||
|
||||
@@ -552,8 +552,6 @@ struct lpfc_cgn_info {
|
||||
);
|
||||
|
||||
__le32 cgn_info_crc;
|
||||
#define LPFC_CGN_CRC32_MAGIC_NUMBER 0x1EDC6F41
|
||||
#define LPFC_CGN_CRC32_SEED 0xFFFFFFFF
|
||||
};
|
||||
|
||||
#define LPFC_CGN_INFO_SZ (sizeof(struct lpfc_cgn_info) - \
|
||||
|
||||
@@ -86,7 +86,7 @@ void lpfc_cmf_stop(struct lpfc_hba *phba);
|
||||
void lpfc_init_congestion_stat(struct lpfc_hba *phba);
|
||||
void lpfc_init_congestion_buf(struct lpfc_hba *phba);
|
||||
int lpfc_sli4_cgn_params_read(struct lpfc_hba *phba);
|
||||
uint32_t lpfc_cgn_calc_crc32(void *bufp, uint32_t sz, uint32_t seed);
|
||||
uint32_t lpfc_cgn_calc_crc32(const void *data, size_t size);
|
||||
int lpfc_config_cgn_signal(struct lpfc_hba *phba);
|
||||
int lpfc_issue_cmf_sync_wqe(struct lpfc_hba *phba, u32 ms, u64 total);
|
||||
void lpfc_cgn_dump_rxmonitor(struct lpfc_hba *phba);
|
||||
|
||||
@@ -10301,10 +10301,8 @@ lpfc_els_rcv_fpin_cgn(struct lpfc_hba *phba, struct fc_tlv_desc *tlv)
|
||||
cpu_to_le16(value);
|
||||
cp->cgn_warn_freq =
|
||||
cpu_to_le16(value);
|
||||
crc = lpfc_cgn_calc_crc32
|
||||
(cp,
|
||||
LPFC_CGN_INFO_SZ,
|
||||
LPFC_CGN_CRC32_SEED);
|
||||
crc = lpfc_cgn_calc_crc32(
|
||||
cp, LPFC_CGN_INFO_SZ);
|
||||
cp->cgn_info_crc = cpu_to_le32(crc);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
*******************************************************************/
|
||||
|
||||
#include <linux/blkdev.h>
|
||||
#include <linux/crc32.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/idr.h>
|
||||
@@ -5634,8 +5635,7 @@ lpfc_cgn_update_stat(struct lpfc_hba *phba, uint32_t dtag)
|
||||
cp->cgn_stat_npm = value;
|
||||
}
|
||||
|
||||
value = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ,
|
||||
LPFC_CGN_CRC32_SEED);
|
||||
value = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ);
|
||||
cp->cgn_info_crc = cpu_to_le32(value);
|
||||
}
|
||||
|
||||
@@ -5897,8 +5897,7 @@ lpfc_cmf_stats_timer(struct hrtimer *timer)
|
||||
cp->cgn_warn_freq = cpu_to_le16(value);
|
||||
cp->cgn_alarm_freq = cpu_to_le16(value);
|
||||
|
||||
lvalue = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ,
|
||||
LPFC_CGN_CRC32_SEED);
|
||||
lvalue = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ);
|
||||
cp->cgn_info_crc = cpu_to_le32(lvalue);
|
||||
|
||||
hrtimer_forward_now(timer, ktime_set(0, LPFC_SEC_MIN * NSEC_PER_SEC));
|
||||
@@ -7121,8 +7120,7 @@ lpfc_cgn_params_parse(struct lpfc_hba *phba,
|
||||
cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0;
|
||||
cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1;
|
||||
cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2;
|
||||
crc = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ,
|
||||
LPFC_CGN_CRC32_SEED);
|
||||
crc = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ);
|
||||
cp->cgn_info_crc = cpu_to_le32(crc);
|
||||
}
|
||||
spin_unlock_irq(&phba->hbalock);
|
||||
@@ -13493,54 +13491,14 @@ lpfc_sli4_hba_unset(struct lpfc_hba *phba)
|
||||
phba->pport->work_port_events = 0;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
lpfc_cgn_crc32(uint32_t crc, u8 byte)
|
||||
{
|
||||
uint32_t msb = 0;
|
||||
uint32_t bit;
|
||||
|
||||
for (bit = 0; bit < 8; bit++) {
|
||||
msb = (crc >> 31) & 1;
|
||||
crc <<= 1;
|
||||
|
||||
if (msb ^ (byte & 1)) {
|
||||
crc ^= LPFC_CGN_CRC32_MAGIC_NUMBER;
|
||||
crc |= 1;
|
||||
}
|
||||
byte >>= 1;
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
lpfc_cgn_reverse_bits(uint32_t wd)
|
||||
{
|
||||
uint32_t result = 0;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
result <<= 1;
|
||||
result |= (1 & (wd >> i));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* The routine corresponds with the algorithm the HBA firmware
|
||||
* uses to validate the data integrity.
|
||||
*/
|
||||
uint32_t
|
||||
lpfc_cgn_calc_crc32(void *ptr, uint32_t byteLen, uint32_t crc)
|
||||
lpfc_cgn_calc_crc32(const void *data, size_t size)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t result;
|
||||
uint8_t *data = (uint8_t *)ptr;
|
||||
|
||||
for (i = 0; i < byteLen; ++i)
|
||||
crc = lpfc_cgn_crc32(crc, data[i]);
|
||||
|
||||
result = ~lpfc_cgn_reverse_bits(crc);
|
||||
return result;
|
||||
return ~crc32c(~0, data, size);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -13589,7 +13547,7 @@ lpfc_init_congestion_buf(struct lpfc_hba *phba)
|
||||
|
||||
cp->cgn_warn_freq = cpu_to_le16(LPFC_FPIN_INIT_FREQ);
|
||||
cp->cgn_alarm_freq = cpu_to_le16(LPFC_FPIN_INIT_FREQ);
|
||||
crc = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ, LPFC_CGN_CRC32_SEED);
|
||||
crc = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ);
|
||||
cp->cgn_info_crc = cpu_to_le32(crc);
|
||||
|
||||
phba->cgn_evt_timestamp = jiffies +
|
||||
@@ -13612,7 +13570,7 @@ lpfc_init_congestion_stat(struct lpfc_hba *phba)
|
||||
memset(&cp->cgn_stat, 0, sizeof(cp->cgn_stat));
|
||||
|
||||
lpfc_cgn_update_tstamp(phba, &cp->stat_start);
|
||||
crc = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ, LPFC_CGN_CRC32_SEED);
|
||||
crc = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ);
|
||||
cp->cgn_info_crc = cpu_to_le32(crc);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user