drivers/net/dsa/bcm_sf2_cfp.c:890:21: sparse: sparse: incorrect type in argument 1 (different base types)

From: kbuild test robot
Date: Mon Jun 01 2020 - 06:26:15 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 3d77e6a8804abcc0504c904bd6e5cdf3a5cf8162
commit: 8b3abe304c5f1057b7bac70fd5576dfa67e3e2b3 net: dsa: bcm_sf2: Support specifying VLAN tag egress rule
date: 9 weeks ago
config: x86_64-randconfig-s022-20200601 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-243-gc100a7ab-dirty
git checkout 8b3abe304c5f1057b7bac70fd5576dfa67e3e2b3
# save the attached .config to linux build tree
make W=1 C=1 ARCH=x86_64 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@xxxxxxxxx>


sparse warnings: (new ones prefixed by >>)

drivers/net/dsa/bcm_sf2_cfp.c:352:44: sparse: sparse: incorrect type in initializer (different base types) @@ expected restricted __be16 [usertype] vlan_m_tci @@ got int @@
drivers/net/dsa/bcm_sf2_cfp.c:352:44: sparse: expected restricted __be16 [usertype] vlan_m_tci
drivers/net/dsa/bcm_sf2_cfp.c:352:44: sparse: got int
drivers/net/dsa/bcm_sf2_cfp.c:633:43: sparse: sparse: incorrect type in initializer (different base types) @@ expected restricted __be16 [usertype] vlan_m_tci @@ got int @@
drivers/net/dsa/bcm_sf2_cfp.c:633:43: sparse: expected restricted __be16 [usertype] vlan_m_tci
drivers/net/dsa/bcm_sf2_cfp.c:633:43: sparse: got int
drivers/net/dsa/bcm_sf2_cfp.c:890:21: sparse: sparse: cast from restricted __be32
>> drivers/net/dsa/bcm_sf2_cfp.c:890:21: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected unsigned int [usertype] val @@ got restricted __be32 @@
drivers/net/dsa/bcm_sf2_cfp.c:890:21: sparse: expected unsigned int [usertype] val
drivers/net/dsa/bcm_sf2_cfp.c:890:21: sparse: got restricted __be32
drivers/net/dsa/bcm_sf2_cfp.c:890:21: sparse: sparse: cast from restricted __be32
drivers/net/dsa/bcm_sf2_cfp.c:890:21: sparse: sparse: cast from restricted __be32
drivers/net/dsa/bcm_sf2_cfp.c:890:21: sparse: sparse: cast from restricted __be32
drivers/net/dsa/bcm_sf2_cfp.c:890:21: sparse: sparse: cast from restricted __be32
drivers/net/dsa/bcm_sf2_cfp.c:890:21: sparse: sparse: restricted __be32 degrades to integer

vim +890 drivers/net/dsa/bcm_sf2_cfp.c

845
846 static int bcm_sf2_cfp_rule_insert(struct dsa_switch *ds, int port,
847 struct ethtool_rx_flow_spec *fs)
848 {
849 struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
850 s8 cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
851 __u64 ring_cookie = fs->ring_cookie;
852 struct switchdev_obj_port_vlan vlan;
853 unsigned int queue_num, port_num;
854 u16 vid;
855 int ret;
856
857 /* This rule is a Wake-on-LAN filter and we must specifically
858 * target the CPU port in order for it to be working.
859 */
860 if (ring_cookie == RX_CLS_FLOW_WAKE)
861 ring_cookie = cpu_port * SF2_NUM_EGRESS_QUEUES;
862
863 /* We do not support discarding packets, check that the
864 * destination port is enabled and that we are within the
865 * number of ports supported by the switch
866 */
867 port_num = ring_cookie / SF2_NUM_EGRESS_QUEUES;
868
869 if (ring_cookie == RX_CLS_FLOW_DISC ||
870 !(dsa_is_user_port(ds, port_num) ||
871 dsa_is_cpu_port(ds, port_num)) ||
872 port_num >= priv->hw_params.num_ports)
873 return -EINVAL;
874
875 /* If the rule is matching a particular VLAN, make sure that we honor
876 * the matching and have it tagged or untagged on the destination port,
877 * we do this on egress with a VLAN entry. The egress tagging attribute
878 * is expected to be provided in h_ext.data[1] bit 0. A 1 means untagged,
879 * a 0 means tagged.
880 */
881 if (fs->flow_type & FLOW_EXT) {
882 /* We cannot support matching multiple VLAN IDs yet */
883 if ((be16_to_cpu(fs->m_ext.vlan_tci) & VLAN_VID_MASK) !=
884 VLAN_VID_MASK)
885 return -EINVAL;
886
887 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
888 vlan.vid_begin = vid;
889 vlan.vid_end = vid;
> 890 if (cpu_to_be32(fs->h_ext.data[1]) & 1)
891 vlan.flags = BRIDGE_VLAN_INFO_UNTAGGED;
892 else
893 vlan.flags = 0;
894
895 ret = ds->ops->port_vlan_prepare(ds, port_num, &vlan);
896 if (ret)
897 return ret;
898
899 ds->ops->port_vlan_add(ds, port_num, &vlan);
900 }
901
902 /*
903 * We have a small oddity where Port 6 just does not have a
904 * valid bit here (so we substract by one).
905 */
906 queue_num = ring_cookie % SF2_NUM_EGRESS_QUEUES;
907 if (port_num >= 7)
908 port_num -= 1;
909
910 switch (fs->flow_type & ~FLOW_EXT) {
911 case TCP_V4_FLOW:
912 case UDP_V4_FLOW:
913 ret = bcm_sf2_cfp_ipv4_rule_set(priv, port, port_num,
914 queue_num, fs);
915 break;
916 case TCP_V6_FLOW:
917 case UDP_V6_FLOW:
918 ret = bcm_sf2_cfp_ipv6_rule_set(priv, port, port_num,
919 queue_num, fs);
920 break;
921 default:
922 ret = -EINVAL;
923 break;
924 }
925
926 return ret;
927 }
928

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip