drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c:544:31: sparse: sparse: incorrect type in assignment (different base types)

From: kernel test robot
Date: Wed Jan 13 2021 - 03:11:15 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: e609571b5ffa3528bf85292de1ceaddac342bc1c
commit: dc1a9bf2c8169d9f607502162af1858a73a18cb8 octeontx2-pf: Add UDP segmentation offload support
date: 4 months ago
config: alpha-randconfig-s032-20210113 (attached as .config)
compiler: alpha-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-208-g46a52ca4-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=dc1a9bf2c8169d9f607502162af1858a73a18cb8
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout dc1a9bf2c8169d9f607502162af1858a73a18cb8
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=alpha

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


"sparse warnings: (new ones prefixed by >>)"
>> drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c:544:31: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [usertype] iplen @@ got restricted __be16 [usertype] @@
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c:544:31: sparse: expected unsigned short [usertype] iplen
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c:544:31: sparse: got restricted __be16 [usertype]
>> drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c:546:54: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __be16 [usertype] tot_len @@ got unsigned short [usertype] iplen @@
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c:546:54: sparse: expected restricted __be16 [usertype] tot_len
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c:546:54: sparse: got unsigned short [usertype] iplen
>> drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c:549:60: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __be16 [usertype] payload_len @@ got unsigned short [usertype] iplen @@
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c:549:60: sparse: expected restricted __be16 [usertype] payload_len
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c:549:60: sparse: got unsigned short [usertype] iplen

vim +544 drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c

503
504 /* Add SQE extended header subdescriptor */
505 static void otx2_sqe_add_ext(struct otx2_nic *pfvf, struct otx2_snd_queue *sq,
506 struct sk_buff *skb, int *offset)
507 {
508 struct nix_sqe_ext_s *ext;
509
510 ext = (struct nix_sqe_ext_s *)(sq->sqe_base + *offset);
511 ext->subdc = NIX_SUBDC_EXT;
512 if (skb_shinfo(skb)->gso_size) {
513 ext->lso = 1;
514 ext->lso_sb = skb_transport_offset(skb) + tcp_hdrlen(skb);
515 ext->lso_mps = skb_shinfo(skb)->gso_size;
516
517 /* Only TSOv4 and TSOv6 GSO offloads are supported */
518 if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4) {
519 ext->lso_format = pfvf->hw.lso_tsov4_idx;
520
521 /* HW adds payload size to 'ip_hdr->tot_len' while
522 * sending TSO segment, hence set payload length
523 * in IP header of the packet to just header length.
524 */
525 ip_hdr(skb)->tot_len =
526 htons(ext->lso_sb - skb_network_offset(skb));
527 } else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6) {
528 ext->lso_format = pfvf->hw.lso_tsov6_idx;
529
530 ipv6_hdr(skb)->payload_len =
531 htons(ext->lso_sb - skb_network_offset(skb));
532 } else if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) {
533 __be16 l3_proto = vlan_get_protocol(skb);
534 struct udphdr *udph = udp_hdr(skb);
535 u16 iplen;
536
537 ext->lso_sb = skb_transport_offset(skb) +
538 sizeof(struct udphdr);
539
540 /* HW adds payload size to length fields in IP and
541 * UDP headers while segmentation, hence adjust the
542 * lengths to just header sizes.
543 */
> 544 iplen = htons(ext->lso_sb - skb_network_offset(skb));
545 if (l3_proto == htons(ETH_P_IP)) {
> 546 ip_hdr(skb)->tot_len = iplen;
547 ext->lso_format = pfvf->hw.lso_udpv4_idx;
548 } else {
> 549 ipv6_hdr(skb)->payload_len = iplen;
550 ext->lso_format = pfvf->hw.lso_udpv6_idx;
551 }
552
553 udph->len = htons(sizeof(struct udphdr));
554 }
555 } else if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) {
556 ext->tstmp = 1;
557 }
558
559 *offset += sizeof(*ext);
560 }
561

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

Attachment: .config.gz
Description: application/gzip