From patchwork Wed May 26 17:23:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 448701 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0CBDC47082 for ; Wed, 26 May 2021 17:22:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 877A9613C3 for ; Wed, 26 May 2021 17:22:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235159AbhEZRYI (ORCPT ); Wed, 26 May 2021 13:24:08 -0400 Received: from mga07.intel.com ([134.134.136.100]:18168 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234602AbhEZRXt (ORCPT ); Wed, 26 May 2021 13:23:49 -0400 IronPort-SDR: KlkDHya3DCZEX6QdzCgF4xE/cVxb+yGBG3ILQOwwOHp8zIcyA1ydcjHC0iV+xxsGt99YX5UKtz 5lyD0N3T4zpg== X-IronPort-AV: E=McAfee;i="6200,9189,9996"; a="266415785" X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="266415785" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2021 10:21:26 -0700 IronPort-SDR: NV9bFYTIxu14FQ1KrmdREVcJ/yTQrgs/MsPoYYSVr2oxuPP5b0STwoXl4jBj8EfmtxMcqeN9v1 EJNKP3dQjo+w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="443149196" Received: from anguy11-desk2.jf.intel.com ([10.166.244.147]) by orsmga008.jf.intel.com with ESMTP; 26 May 2021 10:21:26 -0700 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org Cc: Jesse Brandeburg , netdev@vger.kernel.org, sassmann@redhat.com, anthony.l.nguyen@intel.com Subject: [PATCH net-next 01/11] e100: handle eeprom as little endian Date: Wed, 26 May 2021 10:23:36 -0700 Message-Id: <20210526172346.3515587-2-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210526172346.3515587-1-anthony.l.nguyen@intel.com> References: <20210526172346.3515587-1-anthony.l.nguyen@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jesse Brandeburg Sparse tool was warning on some implicit conversions from little endian data read from the EEPROM on the e100 cards. Fix these by being explicit about the conversions using le16_to_cpu(). Signed-off-by: Jesse Brandeburg Signed-off-by: Tony Nguyen --- Warning Detail: CHECK .../intel/e100.c .../intel/e100.c:1398:32: warning: restricted __le16 degrades to integer .../intel/e100.c:1518:29: warning: restricted __le16 degrades to integer .../intel/e100.c:2272:24: warning: restricted __le16 degrades to integer .../intel/e100.c:2273:25: warning: restricted __le16 degrades to integer .../intel/e100.c:2274:25: warning: restricted __le16 degrades to integer .../intel/e100.c:2929:24: warning: restricted __le16 degrades to integer --- drivers/net/ethernet/intel/e100.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c index f8d78af76d7d..1b0958bd24f6 100644 --- a/drivers/net/ethernet/intel/e100.c +++ b/drivers/net/ethernet/intel/e100.c @@ -1395,7 +1395,7 @@ static int e100_phy_check_without_mii(struct nic *nic) u8 phy_type; int without_mii; - phy_type = (nic->eeprom[eeprom_phy_iface] >> 8) & 0x0f; + phy_type = (le16_to_cpu(nic->eeprom[eeprom_phy_iface]) >> 8) & 0x0f; switch (phy_type) { case NoSuchPhy: /* Non-MII PHY; UNTESTED! */ @@ -1515,7 +1515,7 @@ static int e100_phy_init(struct nic *nic) mdio_write(netdev, nic->mii.phy_id, MII_BMCR, bmcr); } else if ((nic->mac >= mac_82550_D102) || ((nic->flags & ich) && (mdio_read(netdev, nic->mii.phy_id, MII_TPISTATUS) & 0x8000) && - (nic->eeprom[eeprom_cnfg_mdix] & eeprom_mdix_enabled))) { + (le16_to_cpu(nic->eeprom[eeprom_cnfg_mdix]) & eeprom_mdix_enabled))) { /* enable/disable MDI/MDI-X auto-switching. */ mdio_write(netdev, nic->mii.phy_id, MII_NCONFIG, nic->mii.force_media ? 0 : NCONFIG_AUTO_SWITCH); @@ -2269,9 +2269,9 @@ static int e100_asf(struct nic *nic) { /* ASF can be enabled from eeprom */ return (nic->pdev->device >= 0x1050) && (nic->pdev->device <= 0x1057) && - (nic->eeprom[eeprom_config_asf] & eeprom_asf) && - !(nic->eeprom[eeprom_config_asf] & eeprom_gcl) && - ((nic->eeprom[eeprom_smbus_addr] & 0xFF) != 0xFE); + (le16_to_cpu(nic->eeprom[eeprom_config_asf]) & eeprom_asf) && + !(le16_to_cpu(nic->eeprom[eeprom_config_asf]) & eeprom_gcl) && + ((le16_to_cpu(nic->eeprom[eeprom_smbus_addr]) & 0xFF) != 0xFE); } static int e100_up(struct nic *nic) @@ -2926,7 +2926,7 @@ static int e100_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* Wol magic packet can be enabled from eeprom */ if ((nic->mac >= mac_82558_D101_A4) && - (nic->eeprom[eeprom_id] & eeprom_id_wol)) { + (le16_to_cpu(nic->eeprom[eeprom_id]) & eeprom_id_wol)) { nic->flags |= wol_magic; device_set_wakeup_enable(&pdev->dev, true); } From patchwork Wed May 26 17:23:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 448700 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CAA6C47088 for ; Wed, 26 May 2021 17:22:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2944A600D1 for ; Wed, 26 May 2021 17:22:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234501AbhEZRYT (ORCPT ); Wed, 26 May 2021 13:24:19 -0400 Received: from mga07.intel.com ([134.134.136.100]:18091 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234395AbhEZRX7 (ORCPT ); Wed, 26 May 2021 13:23:59 -0400 IronPort-SDR: OZYUxUMqVVuRRnq1du0JbeF/Kbrdub0WgylukGsDt80eYAx4RfyusmyxorUrT8wrzy6zVDdrv+ 3NiMj8UztdZA== X-IronPort-AV: E=McAfee;i="6200,9189,9996"; a="266415790" X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="266415790" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2021 10:21:27 -0700 IronPort-SDR: dtViSMl6lTc5wMsACbeL3ov589GlfwH/YvQ25LlyVvqiO/N9SfEUeZnERyrA0FoL4LO/vSrA1K qaIgsqWadSyw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="443149216" Received: from anguy11-desk2.jf.intel.com ([10.166.244.147]) by orsmga008.jf.intel.com with ESMTP; 26 May 2021 10:21:26 -0700 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org Cc: Jesse Brandeburg , netdev@vger.kernel.org, sassmann@redhat.com, anthony.l.nguyen@intel.com, Dave Switzer Subject: [PATCH net-next 07/11] igb: override two checker warnings Date: Wed, 26 May 2021 10:23:42 -0700 Message-Id: <20210526172346.3515587-8-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210526172346.3515587-1-anthony.l.nguyen@intel.com> References: <20210526172346.3515587-1-anthony.l.nguyen@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jesse Brandeburg The igb PTP code was using htons() on a constant to try to byte swap the value before writing it to a register. This byte swap has the consequence of triggering sparse conflicts between the register write which expect cpu ordered input, and the code which generated a big endian constant. Just override the cast to make sure code doesn't change but silence the warning. Can't do a __swab16 in this case because big endian systems would then write the wrong value. Signed-off-by: Jesse Brandeburg Tested-by: Dave Switzer Signed-off-by: Tony Nguyen --- Warning Detail CHECK .../igb/igb_ptp.c .../igb/igb_ptp.c:1137:17: warning: incorrect type in argument 1 (different base types) .../igb/igb_ptp.c:1137:17: expected unsigned int val .../igb/igb_ptp.c:1137:17: got restricted __be16 [usertype] .../igb/igb_ptp.c:1142:25: warning: incorrect type in argument 1 (different base types) .../igb/igb_ptp.c:1142:25: expected unsigned int val .../igb/igb_ptp.c:1142:25: got restricted __be16 [usertype] --- drivers/net/ethernet/intel/igb/igb_ptp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c index ba61fe9bfaf4..de08ae8db4d5 100644 --- a/drivers/net/ethernet/intel/igb/igb_ptp.c +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c @@ -1134,12 +1134,12 @@ static int igb_ptp_set_timestamp_mode(struct igb_adapter *adapter, | E1000_FTQF_MASK); /* mask all inputs */ ftqf &= ~E1000_FTQF_MASK_PROTO_BP; /* enable protocol check */ - wr32(E1000_IMIR(3), htons(PTP_EV_PORT)); + wr32(E1000_IMIR(3), (__force unsigned int)htons(PTP_EV_PORT)); wr32(E1000_IMIREXT(3), (E1000_IMIREXT_SIZE_BP | E1000_IMIREXT_CTRL_BP)); if (hw->mac.type == e1000_82576) { /* enable source port check */ - wr32(E1000_SPQF(3), htons(PTP_EV_PORT)); + wr32(E1000_SPQF(3), (__force unsigned int)htons(PTP_EV_PORT)); ftqf &= ~E1000_FTQF_MASK_SOURCE_PORT_BP; } wr32(E1000_FTQF(3), ftqf); From patchwork Wed May 26 17:23:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 448699 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD479C4708A for ; Wed, 26 May 2021 17:23:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 92CBB613C7 for ; Wed, 26 May 2021 17:22:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235330AbhEZRY3 (ORCPT ); Wed, 26 May 2021 13:24:29 -0400 Received: from mga07.intel.com ([134.134.136.100]:18184 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234461AbhEZRYM (ORCPT ); Wed, 26 May 2021 13:24:12 -0400 IronPort-SDR: AJ4df8Ur6HbBBUNSjKNbQxyM02ZRhmpCvU2VieLDi1ZRolNtAe6ILCSglqMpU+jl9NB8Ta6ZgJ H2eUF8Mfsn9A== X-IronPort-AV: E=McAfee;i="6200,9189,9996"; a="266415792" X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="266415792" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2021 10:21:27 -0700 IronPort-SDR: vI6lLBhmgu+vxUr5vPuixu1MKztuQ0Y+6Eo4jDlXf0khGIopyUs4RCgKaF3uAM5sao/oD8MXdI It6dnWAeJ9Hw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="443149225" Received: from anguy11-desk2.jf.intel.com ([10.166.244.147]) by orsmga008.jf.intel.com with ESMTP; 26 May 2021 10:21:27 -0700 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org Cc: Jesse Brandeburg , netdev@vger.kernel.org, sassmann@redhat.com, anthony.l.nguyen@intel.com Subject: [PATCH net-next 09/11] igbvf: convert to strongly typed descriptors Date: Wed, 26 May 2021 10:23:44 -0700 Message-Id: <20210526172346.3515587-10-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210526172346.3515587-1-anthony.l.nguyen@intel.com> References: <20210526172346.3515587-1-anthony.l.nguyen@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jesse Brandeburg The igbvf driver for some reason never strongly typed it's descriptor formats. Make this driver like the rest of the Intel drivers and use __le* for our little endian descriptors. Signed-off-by: Jesse Brandeburg Signed-off-by: Tony Nguyen --- Warning Detail .../igbvf/netdev.c:203:48: warning: incorrect type in assignment (different base types) .../igbvf/netdev.c:203:48: expected unsigned long long [usertype] pkt_addr .../igbvf/netdev.c:203:48: got restricted __le64 [usertype] .../igbvf/netdev.c:205:48: warning: incorrect type in assignment (different base types) .../igbvf/netdev.c:205:48: expected unsigned long long [usertype] hdr_addr .../igbvf/netdev.c:205:48: got restricted __le64 [usertype] .../igbvf/netdev.c:207:48: warning: incorrect type in assignment (different base types) .../igbvf/netdev.c:207:48: expected unsigned long long [usertype] pkt_addr .../igbvf/netdev.c:207:48: got restricted __le64 [usertype] .../igbvf/netdev.c:261:19: warning: cast to restricted __le32 .../igbvf/netdev.c:276:25: warning: cast to restricted __le16 .../igbvf/netdev.c:282:26: warning: cast to restricted __le16 .../igbvf/netdev.c:356:52: warning: incorrect type in argument 5 (different base types) .../igbvf/netdev.c:356:52: expected restricted __le16 [usertype] vlan .../igbvf/netdev.c:356:52: got unsigned short [usertype] vlan .../igbvf/netdev.c:371:27: warning: cast to restricted __le32 .../igbvf/netdev.c:797:45: warning: restricted __le32 degrades to integer --- drivers/net/ethernet/intel/igbvf/vf.h | 42 +++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/intel/igbvf/vf.h b/drivers/net/ethernet/intel/igbvf/vf.h index c71b0d7dbcee..ba9bb3132d5d 100644 --- a/drivers/net/ethernet/intel/igbvf/vf.h +++ b/drivers/net/ethernet/intel/igbvf/vf.h @@ -35,31 +35,31 @@ struct e1000_hw; /* Receive Descriptor - Advanced */ union e1000_adv_rx_desc { struct { - u64 pkt_addr; /* Packet buffer address */ - u64 hdr_addr; /* Header buffer address */ + __le64 pkt_addr; /* Packet buffer address */ + __le64 hdr_addr; /* Header buffer address */ } read; struct { struct { union { - u32 data; + __le32 data; struct { - u16 pkt_info; /* RSS/Packet type */ + __le16 pkt_info; /* RSS/Packet type */ /* Split Header, hdr buffer length */ - u16 hdr_info; + __le16 hdr_info; } hs_rss; } lo_dword; union { - u32 rss; /* RSS Hash */ + __le32 rss; /* RSS Hash */ struct { - u16 ip_id; /* IP id */ - u16 csum; /* Packet Checksum */ + __le16 ip_id; /* IP id */ + __le16 csum; /* Packet Checksum */ } csum_ip; } hi_dword; } lower; struct { - u32 status_error; /* ext status/error */ - u16 length; /* Packet length */ - u16 vlan; /* VLAN tag */ + __le32 status_error; /* ext status/error */ + __le16 length; /* Packet length */ + __le16 vlan; /* VLAN tag */ } upper; } wb; /* writeback */ }; @@ -70,14 +70,14 @@ union e1000_adv_rx_desc { /* Transmit Descriptor - Advanced */ union e1000_adv_tx_desc { struct { - u64 buffer_addr; /* Address of descriptor's data buf */ - u32 cmd_type_len; - u32 olinfo_status; + __le64 buffer_addr; /* Address of descriptor's data buf */ + __le32 cmd_type_len; + __le32 olinfo_status; } read; struct { - u64 rsvd; /* Reserved */ - u32 nxtseq_seed; - u32 status; + __le64 rsvd; /* Reserved */ + __le32 nxtseq_seed; + __le32 status; } wb; }; @@ -94,10 +94,10 @@ union e1000_adv_tx_desc { /* Context descriptors */ struct e1000_adv_tx_context_desc { - u32 vlan_macip_lens; - u32 seqnum_seed; - u32 type_tucmd_mlhl; - u32 mss_l4len_idx; + __le32 vlan_macip_lens; + __le32 seqnum_seed; + __le32 type_tucmd_mlhl; + __le32 mss_l4len_idx; }; #define E1000_ADVTXD_MACLEN_SHIFT 9 /* Adv ctxt desc mac len shift */ From patchwork Wed May 26 17:23:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 448698 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77DE7C4708A for ; Wed, 26 May 2021 17:23:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E30A613C7 for ; Wed, 26 May 2021 17:23:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234139AbhEZRYh (ORCPT ); Wed, 26 May 2021 13:24:37 -0400 Received: from mga07.intel.com ([134.134.136.100]:18168 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232766AbhEZRYN (ORCPT ); Wed, 26 May 2021 13:24:13 -0400 IronPort-SDR: xHsJWVXUqR8jOn3dwyVfwsuXZ+Lic25p4sWfg5jmcwey1RQuSbX55csWv9Ro4e67kfjjbYp2K3 rzS535X0vFXA== X-IronPort-AV: E=McAfee;i="6200,9189,9996"; a="266415794" X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="266415794" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2021 10:21:27 -0700 IronPort-SDR: daWFghVrzDkBXmuneg6PjejjgHJB9siWn3HhNXJ0nt2y1bPSvQMVanY3XoACUviPayltHxwmhj XoSmvlDG3vnQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,331,1613462400"; d="scan'208";a="443149227" Received: from anguy11-desk2.jf.intel.com ([10.166.244.147]) by orsmga008.jf.intel.com with ESMTP; 26 May 2021 10:21:27 -0700 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org Cc: Jesse Brandeburg , netdev@vger.kernel.org, sassmann@redhat.com, anthony.l.nguyen@intel.com, Dave Switzer Subject: [PATCH net-next 10/11] ixgbe: use checker safe conversions Date: Wed, 26 May 2021 10:23:45 -0700 Message-Id: <20210526172346.3515587-11-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210526172346.3515587-1-anthony.l.nguyen@intel.com> References: <20210526172346.3515587-1-anthony.l.nguyen@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jesse Brandeburg 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 Tested-by: Dave Switzer Signed-off-by: Tony Nguyen --- 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);