ice: use GENMASK instead of BIT(n) - 1 in pack functions
authorJacob Keller <jacob.e.keller@intel.com>
Tue, 27 Feb 2024 00:14:55 +0000 (16:14 -0800)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Mon, 4 Mar 2024 18:26:57 +0000 (10:26 -0800)
commita45d1bf516c097bb7ae4983d3128ebf139be952c
treef330139f9f25346f51c2862c376a126a5b7a433f
parent1260b45dbe2dbc415f3bc1e841c6c098083bcfb8
ice: use GENMASK instead of BIT(n) - 1 in pack functions

The functions used to pack the Tx and Rx context into the hardware format
rely on using BIT() and then subtracting 1 to get a bitmask. These
functions even have a comment about how x86 machines can't use this method
for certain widths because the SHL instructions will not work properly.

The Linux kernel already provides the GENMASK macro for generating a
suitable bitmask. Further, GENMASK is capable of generating the mask
including the shift_width. Since width is the total field width, take care
to subtract one to get the final bit position.

Since we now include the shifted bits as part of the mask, shift the source
value first before applying the mask.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_common.c