Commit 27ffa273 authored by Alexander Lobakin's avatar Alexander Lobakin Committed by Tony Nguyen

ice: switch: unobscurify bitops loop in ice_fill_adv_dummy_packet()

A loop performing header modification according to the provided mask
in ice_fill_adv_dummy_packet() is very cryptic (and error-prone).
Replace two identical cast-deferences with a variable. Replace three
struct-member-array-accesses with a variable. Invert the condition,
reduce the indentation by one -> eliminate line wraps.
Signed-off-by: default avatarAlexander Lobakin <alexandr.lobakin@intel.com>
Reviewed-by: default avatarMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
Tested-by: default avatarMarcin Szycik <marcin.szycik@linux.intel.com>
Tested-by: default avatarSandeep Penigalapati <sandeep.penigalapati@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 135a161a
...@@ -5810,13 +5810,15 @@ ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt, ...@@ -5810,13 +5810,15 @@ ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
* indicated by the mask to make sure we don't improperly write * indicated by the mask to make sure we don't improperly write
* over any significant packet data. * over any significant packet data.
*/ */
for (j = 0; j < len / sizeof(u16); j++) for (j = 0; j < len / sizeof(u16); j++) {
if (lkups[i].m_raw[j]) u16 *ptr = (u16 *)(pkt + offset);
((u16 *)(pkt + offset))[j] = u16 mask = lkups[i].m_raw[j];
(((u16 *)(pkt + offset))[j] &
~lkups[i].m_raw[j]) | if (!mask)
(lkups[i].h_raw[j] & continue;
lkups[i].m_raw[j]);
ptr[j] = (ptr[j] & ~mask) | (lkups[i].h_raw[j] & mask);
}
} }
s_rule->pdata.lkup_tx_rx.hdr_len = cpu_to_le16(pkt_len); s_rule->pdata.lkup_tx_rx.hdr_len = cpu_to_le16(pkt_len);
......
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