diff options
| author | Jack Meng <Jack.Meng@Sun.COM> | 2009-10-13 11:35:11 +0800 |
|---|---|---|
| committer | Jack Meng <Jack.Meng@Sun.COM> | 2009-10-13 11:35:11 +0800 |
| commit | d4b0f84707225327c617c6838361d3cfb7762b34 (patch) | |
| tree | 866f7193a5b621c77bac79cc25d661ea283a7c0c /usr/src/uts/common/io/idm | |
| parent | 943bc4a477315eff44b8005634d317c24293ce0b (diff) | |
| download | illumos-gate-d4b0f84707225327c617c6838361d3cfb7762b34.tar.gz | |
6868616 Using Intel CRC32 instruction to accelerate CRC32c algorithm
Contributed by Xinping Huang <xinping.huang@intel.com>
Diffstat (limited to 'usr/src/uts/common/io/idm')
| -rw-r--r-- | usr/src/uts/common/io/idm/idm_impl.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/usr/src/uts/common/io/idm/idm_impl.c b/usr/src/uts/common/io/idm/idm_impl.c index 62346f3590..273465734a 100644 --- a/usr/src/uts/common/io/idm/idm_impl.c +++ b/usr/src/uts/common/io/idm/idm_impl.c @@ -38,8 +38,15 @@ #include <sys/idm/idm.h> #include <sys/idm/idm_so.h> +#include <hd_crc.h> extern idm_transport_t idm_transport_list[]; +/* + * -1 - uninitialized + * 0 - applicable + * others - NA + */ +static int iscsi_crc32_hd = -1; void idm_pdu_rx(idm_conn_t *ic, idm_pdu_t *pdu) @@ -894,6 +901,16 @@ idm_crc32c(void *address, unsigned long length) ASSERT(address != NULL); + if (iscsi_crc32_hd == -1) { + if (hd_crc32_avail((uint32_t *)idm_crc32c_table) == B_TRUE) { + iscsi_crc32_hd = 0; + } else { + iscsi_crc32_hd = 1; + } + } + if (iscsi_crc32_hd == 0) + return (HW_CRC32(buffer, length, crc)); + while (length--) { crc = idm_crc32c_table[(crc ^ *buffer++) & 0xFFL] ^ (crc >> 8); @@ -927,6 +944,17 @@ idm_crc32c_continued(void *address, unsigned long length, uint32_t crc) ASSERT(address != NULL); + if (iscsi_crc32_hd == -1) { + if (hd_crc32_avail((uint32_t *)idm_crc32c_table) == B_TRUE) { + iscsi_crc32_hd = 0; + } else { + iscsi_crc32_hd = 1; + } + } + if (iscsi_crc32_hd == 0) + return (HW_CRC32_CONT(buffer, length, crc)); + + #ifdef _BIG_ENDIAN byte0 = (uint8_t)((crc >> 24) & 0xFF); byte1 = (uint8_t)((crc >> 16) & 0xFF); |
