]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
igb: handle vlan types with checker enabled
authorJesse Brandeburg <jesse.brandeburg@intel.com>
Fri, 26 Mar 2021 00:38:28 +0000 (17:38 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 13 Aug 2021 07:46:33 +0000 (09:46 +0200)
BugLink: https://bugs.launchpad.net/bugs/1938713
[ Upstream commit c7cbfb028b95360403d579c47aaaeef1ff140964 ]

The sparse build (C=2) finds some issues with how the driver
dealt with the (very difficult) hardware that in some generations
uses little-endian, and in others uses big endian, for the VLAN
field. The code as written picks __le16 as a type and for some
hardware revisions we override it to __be16 as done in this
patch. This impacted the VF driver as well so fix it there too.

Also change the vlan_tci assignment to override the sparse
warning without changing functionality.

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/igbvf/netdev.c

index 7a4e2b014dd66c49b5d924c7076ee50b66646cce..c37f0590b3a4d6d602aa8b27ca8f67001370dd1e 100644 (file)
@@ -2651,7 +2651,8 @@ static int igb_parse_cls_flower(struct igb_adapter *adapter,
                        }
 
                        input->filter.match_flags |= IGB_FILTER_FLAG_VLAN_TCI;
-                       input->filter.vlan_tci = match.key->vlan_priority;
+                       input->filter.vlan_tci =
+                               (__force __be16)match.key->vlan_priority;
                }
        }
 
@@ -8255,7 +8256,7 @@ static void igb_process_skb_fields(struct igb_ring *rx_ring,
 
                if (igb_test_staterr(rx_desc, E1000_RXDEXT_STATERR_LB) &&
                    test_bit(IGB_RING_FLAG_RX_LB_VLAN_BSWAP, &rx_ring->flags))
-                       vid = be16_to_cpu(rx_desc->wb.upper.vlan);
+                       vid = be16_to_cpu((__force __be16)rx_desc->wb.upper.vlan);
                else
                        vid = le16_to_cpu(rx_desc->wb.upper.vlan);
 
index 0f2b68f4bb0fea5874e3073f7fa9ce8a0b40a6ea..77cb2ab7dab404189acfe0cc1db4d125e7e6f569 100644 (file)
@@ -83,14 +83,14 @@ static int igbvf_desc_unused(struct igbvf_ring *ring)
 static void igbvf_receive_skb(struct igbvf_adapter *adapter,
                              struct net_device *netdev,
                              struct sk_buff *skb,
-                             u32 status, u16 vlan)
+                             u32 status, __le16 vlan)
 {
        u16 vid;
 
        if (status & E1000_RXD_STAT_VP) {
                if ((adapter->flags & IGBVF_FLAG_RX_LB_VLAN_BSWAP) &&
                    (status & E1000_RXDEXT_STATERR_LB))
-                       vid = be16_to_cpu(vlan) & E1000_RXD_SPC_VLAN_MASK;
+                       vid = be16_to_cpu((__force __be16)vlan) & E1000_RXD_SPC_VLAN_MASK;
                else
                        vid = le16_to_cpu(vlan) & E1000_RXD_SPC_VLAN_MASK;
                if (test_bit(vid, adapter->active_vlans))