Message ID | 20220127154009.623304-3-alexandr.lobakin@intel.com (mailing list archive) |
---|---|
State | Awaiting Upstream |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | ice: switch: debloat packet templates code | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net-next |
netdev/apply | fail | Patch does not apply to net-next |
>-----Original Message----- >From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of >Alexander Lobakin >Sent: Thursday, January 27, 2022 9:10 PM >To: intel-wired-lan@lists.osuosl.org >Cc: Szapar-Mudlaw, Martyna <martyna.szapar-mudlaw@intel.com>; >netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Jakub Kicinski ><kuba@kernel.org>; David S. Miller <davem@davemloft.net> >Subject: [Intel-wired-lan] [PATCH v2 net-next 2/4] 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: Alexander Lobakin <alexandr.lobakin@intel.com> >--- > drivers/net/ethernet/intel/ice/ice_switch.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) > Tested-by: Sandeep Penigalapati <sandeep.penigalapati@intel.com>
diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c index 7f7e929e73a8..b6b6e8f5d358 100644 --- a/drivers/net/ethernet/intel/ice/ice_switch.c +++ b/drivers/net/ethernet/intel/ice/ice_switch.c @@ -5266,13 +5266,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 * over any significant packet data. */ - for (j = 0; j < len / sizeof(u16); j++) - if (lkups[i].m_raw[j]) - ((u16 *)(pkt + offset))[j] = - (((u16 *)(pkt + offset))[j] & - ~lkups[i].m_raw[j]) | - (lkups[i].h_raw[j] & - lkups[i].m_raw[j]); + for (j = 0; j < len / sizeof(u16); j++) { + u16 *ptr = (u16 *)(pkt + offset); + u16 mask = lkups[i].m_raw[j]; + + if (!mask) + continue; + + ptr[j] = (ptr[j] & ~mask) | (lkups[i].h_raw[j] & mask); + } } s_rule->pdata.lkup_tx_rx.hdr_len = cpu_to_le16(pkt_len);
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: Alexander Lobakin <alexandr.lobakin@intel.com> --- drivers/net/ethernet/intel/ice/ice_switch.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)