diff options
author | 2018-11-19 12:59:01 +0000 | |
---|---|---|
committer | 2018-11-19 12:59:24 +0000 | |
commit | 29058550643267a554e0368806dece63b047c5cb (patch) | |
tree | a6f573fe3fbc14585529b83cfcc65da2dceefbf5 /drivers/common | |
parent | 8a853e3f0275efc8b05cb195085d45946942744a (diff) |
New upstream version 18.11-rc4upstream/18.11-rc4
Change-Id: I861e1a2f7df210f57f44f1ad56b9ef789a4675e3
Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
Diffstat (limited to 'drivers/common')
-rw-r--r-- | drivers/common/cpt/cpt_ucode.h | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h index c5a9f34b..5933ea77 100644 --- a/drivers/common/cpt/cpt_ucode.h +++ b/drivers/common/cpt/cpt_ucode.h @@ -3449,32 +3449,27 @@ find_kasumif9_direction_and_length(uint8_t *src, uint8_t *addr_direction) { uint8_t found = 0; + uint32_t pos; + uint8_t last_byte; while (!found && counter_num_bytes > 0) { counter_num_bytes--; if (src[counter_num_bytes] == 0x00) continue; - if (src[counter_num_bytes] == 0x80) { - *addr_direction = src[counter_num_bytes - 1] & 0x1; - *addr_length_in_bits = counter_num_bytes * 8 - 1; - found = 1; - } else { - int i = 0; - uint8_t last_byte = src[counter_num_bytes]; - for (i = 0; i < 8 && found == 0; i++) { - if (last_byte & (1 << i)) { - *addr_direction = (last_byte >> (i+1)) - & 0x1; - if (i != 6) - *addr_length_in_bits = - counter_num_bytes * 8 - + (8 - (i + 2)); - else - *addr_length_in_bits = - counter_num_bytes * 8; - found = 1; - } - } + pos = rte_bsf32(src[counter_num_bytes]); + if (pos == 7) { + if (likely(counter_num_bytes > 0)) { + last_byte = src[counter_num_bytes - 1]; + *addr_direction = last_byte & 0x1; + *addr_length_in_bits = counter_num_bytes * 8 + - 1; } + } else { + last_byte = src[counter_num_bytes]; + *addr_direction = (last_byte >> (pos + 1)) & 0x1; + *addr_length_in_bits = counter_num_bytes * 8 + + (8 - (pos + 2)); + } + found = 1; } } |