All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: davem@davemloft.net, kuba@kernel.org
Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>,
	netdev@vger.kernel.org, sassmann@redhat.com,
	anthony.l.nguyen@intel.com,
	Dave Switzer <david.switzer@intel.com>
Subject: [PATCH net-next 10/11] ixgbe: use checker safe conversions
Date: Wed, 26 May 2021 10:23:45 -0700	[thread overview]
Message-ID: <20210526172346.3515587-11-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20210526172346.3515587-1-anthony.l.nguyen@intel.com>

From: Jesse Brandeburg <jesse.brandeburg@intel.com>

The ixgbe hardware needs some very specific programming for
certain registers, which led to some misguided usage of ntohs
instead of using be16_to_cpu(), as well as a home grown swap
followed by an ntohs. Sparse didn't like this at all, and this
fixes the C=2 build, with code that uses native kernel interface.

Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Dave Switzer <david.switzer@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
Warning Details:
.../ixgbe/ixgbe_82599.c:1660:20: warning: cast to restricted __be16
.../ixgbe/ixgbe_82599.c:1660:20: warning: cast to restricted __be16
.../ixgbe/ixgbe_82599.c:1660:20: warning: cast to restricted __be16
.../ixgbe/ixgbe_82599.c:1660:20: warning: cast to restricted __be16
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
index e324e42fab2d..58ea959a4482 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
@@ -1514,8 +1514,7 @@ static u32 ixgbe_get_fdirtcpm_82599(union ixgbe_atr_input *input_mask)
 #define IXGBE_WRITE_REG_BE32(a, reg, value) \
 	IXGBE_WRITE_REG((a), (reg), IXGBE_STORE_AS_BE32(ntohl(value)))
 
-#define IXGBE_STORE_AS_BE16(_value) \
-	ntohs(((u16)(_value) >> 8) | ((u16)(_value) << 8))
+#define IXGBE_STORE_AS_BE16(_value) __swab16(ntohs((_value)))
 
 s32 ixgbe_fdir_set_input_mask_82599(struct ixgbe_hw *hw,
 				    union ixgbe_atr_input *input_mask)
@@ -1651,13 +1650,13 @@ s32 ixgbe_fdir_write_perfect_filter_82599(struct ixgbe_hw *hw,
 	IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRIPDA, input->formatted.dst_ip[0]);
 
 	/* record source and destination port (little-endian)*/
-	fdirport = ntohs(input->formatted.dst_port);
+	fdirport = be16_to_cpu(input->formatted.dst_port);
 	fdirport <<= IXGBE_FDIRPORT_DESTINATION_SHIFT;
-	fdirport |= ntohs(input->formatted.src_port);
+	fdirport |= be16_to_cpu(input->formatted.src_port);
 	IXGBE_WRITE_REG(hw, IXGBE_FDIRPORT, fdirport);
 
 	/* record vlan (little-endian) and flex_bytes(big-endian) */
-	fdirvlan = IXGBE_STORE_AS_BE16((__force u16)input->formatted.flex_bytes);
+	fdirvlan = IXGBE_STORE_AS_BE16(input->formatted.flex_bytes);
 	fdirvlan <<= IXGBE_FDIRVLAN_FLEX_SHIFT;
 	fdirvlan |= ntohs(input->formatted.vlan_id);
 	IXGBE_WRITE_REG(hw, IXGBE_FDIRVLAN, fdirvlan);
-- 
2.26.2


  parent reply	other threads:[~2021-05-26 17:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 17:23 [PATCH net-next 00/11][pull request] 1GbE Intel Wired LAN Driver Updates 2021-05-26 Tony Nguyen
2021-05-26 17:23 ` [PATCH net-next 01/11] e100: handle eeprom as little endian Tony Nguyen
2021-05-26 17:23 ` [PATCH net-next 02/11] intel: remove checker warning Tony Nguyen
2021-05-26 17:23 ` [PATCH net-next 03/11] fm10k: move error check Tony Nguyen
2021-05-26 17:23 ` [PATCH net-next 04/11] igb/igc: use strongly typed pointer Tony Nguyen
2021-05-26 17:23 ` [PATCH net-next 05/11] igb: handle vlan types with checker enabled Tony Nguyen
2021-05-26 17:23 ` [PATCH net-next 06/11] igb: fix assignment on big endian machines Tony Nguyen
2021-05-26 17:23 ` [PATCH net-next 07/11] igb: override two checker warnings Tony Nguyen
2021-05-26 17:23 ` [PATCH net-next 08/11] intel: call csum functions with well formatted arguments Tony Nguyen
2021-05-26 17:23 ` [PATCH net-next 09/11] igbvf: convert to strongly typed descriptors Tony Nguyen
2021-05-26 17:23 ` Tony Nguyen [this message]
2021-05-26 17:23 ` [PATCH net-next 11/11] ixgbe: reduce checker warnings Tony Nguyen
2021-05-26 17:42   ` Shannon Nelson
2021-05-27  1:40 ` [PATCH net-next 00/11][pull request] 1GbE Intel Wired LAN Driver Updates 2021-05-26 patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210526172346.3515587-11-anthony.l.nguyen@intel.com \
    --to=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=david.switzer@intel.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sassmann@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.