Re: [PATCH 5/5] RDMA/rxe: Move crc32 init code to rxe_icrc.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Bob,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on rdma/for-next]
[also build test WARNING on next-20210630]
[cannot apply to v5.13]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Bob-Pearson/RDMA-rxe-Move-ICRC-checking-to-a-subroutine/20210630-051423
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
config: riscv-randconfig-s032-20210630 (attached as .config)
compiler: riscv64-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-341-g8af24329-dirty
        # https://github.com/0day-ci/linux/commit/e231ff2c1bb74fd5f86e9e1a7d43770a98209bf9
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Bob-Pearson/RDMA-rxe-Move-ICRC-checking-to-a-subroutine/20210630-051423
        git checkout e231ff2c1bb74fd5f86e9e1a7d43770a98209bf9
        # 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=riscv 

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/infiniband/sw/rxe/rxe_icrc.c:56:33: sparse: sparse: incorrect type in argument 1 (different base types) @@     expected unsigned int [usertype] crc @@     got restricted __be32 [usertype] crc @@
   drivers/infiniband/sw/rxe/rxe_icrc.c:56:33: sparse:     expected unsigned int [usertype] crc
   drivers/infiniband/sw/rxe/rxe_icrc.c:56:33: sparse:     got restricted __be32 [usertype] crc
>> drivers/infiniband/sw/rxe/rxe_icrc.c:56:32: sparse: sparse: incorrect type in return expression (different base types) @@     expected restricted __be32 @@     got unsigned int @@
   drivers/infiniband/sw/rxe/rxe_icrc.c:56:32: sparse:     expected restricted __be32
   drivers/infiniband/sw/rxe/rxe_icrc.c:56:32: sparse:     got unsigned int
>> drivers/infiniband/sw/rxe/rxe_icrc.c:91:13: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __be32 [usertype] crc @@     got unsigned int @@
   drivers/infiniband/sw/rxe/rxe_icrc.c:91:13: sparse:     expected restricted __be32 [usertype] crc
   drivers/infiniband/sw/rxe/rxe_icrc.c:91:13: sparse:     got unsigned int
>> drivers/infiniband/sw/rxe/rxe_icrc.c:127:16: sparse: sparse: incorrect type in return expression (different base types) @@     expected unsigned int @@     got restricted __be32 [assigned] [usertype] crc @@
   drivers/infiniband/sw/rxe/rxe_icrc.c:127:16: sparse:     expected unsigned int
   drivers/infiniband/sw/rxe/rxe_icrc.c:127:16: sparse:     got restricted __be32 [assigned] [usertype] crc
>> drivers/infiniband/sw/rxe/rxe_icrc.c:147:23: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __be32 [usertype] computed_icrc @@     got unsigned int @@
   drivers/infiniband/sw/rxe/rxe_icrc.c:147:23: sparse:     expected restricted __be32 [usertype] computed_icrc
   drivers/infiniband/sw/rxe/rxe_icrc.c:147:23: sparse:     got unsigned int
>> drivers/infiniband/sw/rxe/rxe_icrc.c:179:14: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __be32 [usertype] icrc @@     got unsigned int @@
   drivers/infiniband/sw/rxe/rxe_icrc.c:179:14: sparse:     expected restricted __be32 [usertype] icrc
   drivers/infiniband/sw/rxe/rxe_icrc.c:179:14: sparse:     got unsigned int

vim +56 drivers/infiniband/sw/rxe/rxe_icrc.c

e231ff2c1bb74fd5 Bob Pearson 2021-06-29   32  
e231ff2c1bb74fd5 Bob Pearson 2021-06-29   33  /**
e231ff2c1bb74fd5 Bob Pearson 2021-06-29   34   * rxe_crc32 - Compute cumulative crc32 for a contiguous segment
46bb188d442e9494 Bob Pearson 2021-06-29   35   * @rxe: rdma_rxe device object
46bb188d442e9494 Bob Pearson 2021-06-29   36   * @crc: starting crc32 value from previous segments
46bb188d442e9494 Bob Pearson 2021-06-29   37   * @addr: starting address of segment
46bb188d442e9494 Bob Pearson 2021-06-29   38   * @len: length of the segment in bytes
46bb188d442e9494 Bob Pearson 2021-06-29   39   *
e231ff2c1bb74fd5 Bob Pearson 2021-06-29   40   * Returns the crc32 cumulative checksum including the segment starting
e231ff2c1bb74fd5 Bob Pearson 2021-06-29   41   * from crc.
46bb188d442e9494 Bob Pearson 2021-06-29   42   */
e231ff2c1bb74fd5 Bob Pearson 2021-06-29   43  static __be32 rxe_crc32(struct rxe_dev *rxe, __be32 crc, void *addr,
e231ff2c1bb74fd5 Bob Pearson 2021-06-29   44  			size_t len)
46bb188d442e9494 Bob Pearson 2021-06-29   45  {
e231ff2c1bb74fd5 Bob Pearson 2021-06-29   46  	__be32 icrc;
46bb188d442e9494 Bob Pearson 2021-06-29   47  	int err;
46bb188d442e9494 Bob Pearson 2021-06-29   48  
46bb188d442e9494 Bob Pearson 2021-06-29   49  	SHASH_DESC_ON_STACK(shash, rxe->tfm);
46bb188d442e9494 Bob Pearson 2021-06-29   50  
46bb188d442e9494 Bob Pearson 2021-06-29   51  	shash->tfm = rxe->tfm;
e231ff2c1bb74fd5 Bob Pearson 2021-06-29   52  	*(__be32 *)shash_desc_ctx(shash) = crc;
46bb188d442e9494 Bob Pearson 2021-06-29   53  	err = crypto_shash_update(shash, addr, len);
46bb188d442e9494 Bob Pearson 2021-06-29   54  	if (unlikely(err)) {
46bb188d442e9494 Bob Pearson 2021-06-29   55  		pr_warn_ratelimited("failed crc calculation, err: %d\n", err);
46bb188d442e9494 Bob Pearson 2021-06-29  @56  		return crc32_le(crc, addr, len);
46bb188d442e9494 Bob Pearson 2021-06-29   57  	}
46bb188d442e9494 Bob Pearson 2021-06-29   58  
e231ff2c1bb74fd5 Bob Pearson 2021-06-29   59  	icrc = *(__be32 *)shash_desc_ctx(shash);
46bb188d442e9494 Bob Pearson 2021-06-29   60  	barrier_data(shash_desc_ctx(shash));
46bb188d442e9494 Bob Pearson 2021-06-29   61  
46bb188d442e9494 Bob Pearson 2021-06-29   62  	return icrc;
46bb188d442e9494 Bob Pearson 2021-06-29   63  }
46bb188d442e9494 Bob Pearson 2021-06-29   64  
46bb188d442e9494 Bob Pearson 2021-06-29   65  /**
46bb188d442e9494 Bob Pearson 2021-06-29   66   * rxe_icrc_hdr - Compute a partial ICRC for the IB transport headers.
e231ff2c1bb74fd5 Bob Pearson 2021-06-29   67   * @pkt: packet information
e231ff2c1bb74fd5 Bob Pearson 2021-06-29   68   * @skb: packet buffer
46bb188d442e9494 Bob Pearson 2021-06-29   69   *
46bb188d442e9494 Bob Pearson 2021-06-29   70   * Returns the partial ICRC
46bb188d442e9494 Bob Pearson 2021-06-29   71   */
46bb188d442e9494 Bob Pearson 2021-06-29   72  static u32 rxe_icrc_hdr(struct rxe_pkt_info *pkt, struct sk_buff *skb)
8700e3e7c4857d28 Moni Shoua  2016-06-16   73  {
8700e3e7c4857d28 Moni Shoua  2016-06-16   74  	struct udphdr *udph;
8700e3e7c4857d28 Moni Shoua  2016-06-16   75  	struct rxe_bth *bth;
e231ff2c1bb74fd5 Bob Pearson 2021-06-29   76  	__be32 crc;
8700e3e7c4857d28 Moni Shoua  2016-06-16   77  	int length;
8700e3e7c4857d28 Moni Shoua  2016-06-16   78  	int hdr_size = sizeof(struct udphdr) +
8700e3e7c4857d28 Moni Shoua  2016-06-16   79  		(skb->protocol == htons(ETH_P_IP) ?
8700e3e7c4857d28 Moni Shoua  2016-06-16   80  		sizeof(struct iphdr) : sizeof(struct ipv6hdr));
8700e3e7c4857d28 Moni Shoua  2016-06-16   81  	/* pseudo header buffer size is calculate using ipv6 header size since
8700e3e7c4857d28 Moni Shoua  2016-06-16   82  	 * it is bigger than ipv4
8700e3e7c4857d28 Moni Shoua  2016-06-16   83  	 */
8700e3e7c4857d28 Moni Shoua  2016-06-16   84  	u8 pshdr[sizeof(struct udphdr) +
8700e3e7c4857d28 Moni Shoua  2016-06-16   85  		sizeof(struct ipv6hdr) +
8700e3e7c4857d28 Moni Shoua  2016-06-16   86  		RXE_BTH_BYTES];
8700e3e7c4857d28 Moni Shoua  2016-06-16   87  
8700e3e7c4857d28 Moni Shoua  2016-06-16   88  	/* This seed is the result of computing a CRC with a seed of
8700e3e7c4857d28 Moni Shoua  2016-06-16   89  	 * 0xfffffff and 8 bytes of 0xff representing a masked LRH.
8700e3e7c4857d28 Moni Shoua  2016-06-16   90  	 */
8700e3e7c4857d28 Moni Shoua  2016-06-16  @91  	crc = 0xdebb20e3;
8700e3e7c4857d28 Moni Shoua  2016-06-16   92  
8700e3e7c4857d28 Moni Shoua  2016-06-16   93  	if (skb->protocol == htons(ETH_P_IP)) { /* IPv4 */
e231ff2c1bb74fd5 Bob Pearson 2021-06-29   94  		struct iphdr *ip4h = NULL;
e231ff2c1bb74fd5 Bob Pearson 2021-06-29   95  
8700e3e7c4857d28 Moni Shoua  2016-06-16   96  		memcpy(pshdr, ip_hdr(skb), hdr_size);
8700e3e7c4857d28 Moni Shoua  2016-06-16   97  		ip4h = (struct iphdr *)pshdr;
8700e3e7c4857d28 Moni Shoua  2016-06-16   98  		udph = (struct udphdr *)(ip4h + 1);
8700e3e7c4857d28 Moni Shoua  2016-06-16   99  
8700e3e7c4857d28 Moni Shoua  2016-06-16  100  		ip4h->ttl = 0xff;
8700e3e7c4857d28 Moni Shoua  2016-06-16  101  		ip4h->check = CSUM_MANGLED_0;
8700e3e7c4857d28 Moni Shoua  2016-06-16  102  		ip4h->tos = 0xff;
8700e3e7c4857d28 Moni Shoua  2016-06-16  103  	} else {				/* IPv6 */
e231ff2c1bb74fd5 Bob Pearson 2021-06-29  104  		struct ipv6hdr *ip6h = NULL;
e231ff2c1bb74fd5 Bob Pearson 2021-06-29  105  
8700e3e7c4857d28 Moni Shoua  2016-06-16  106  		memcpy(pshdr, ipv6_hdr(skb), hdr_size);
8700e3e7c4857d28 Moni Shoua  2016-06-16  107  		ip6h = (struct ipv6hdr *)pshdr;
8700e3e7c4857d28 Moni Shoua  2016-06-16  108  		udph = (struct udphdr *)(ip6h + 1);
8700e3e7c4857d28 Moni Shoua  2016-06-16  109  
8700e3e7c4857d28 Moni Shoua  2016-06-16  110  		memset(ip6h->flow_lbl, 0xff, sizeof(ip6h->flow_lbl));
8700e3e7c4857d28 Moni Shoua  2016-06-16  111  		ip6h->priority = 0xf;
8700e3e7c4857d28 Moni Shoua  2016-06-16  112  		ip6h->hop_limit = 0xff;
8700e3e7c4857d28 Moni Shoua  2016-06-16  113  	}
8700e3e7c4857d28 Moni Shoua  2016-06-16  114  
e231ff2c1bb74fd5 Bob Pearson 2021-06-29  115  	bth = (struct rxe_bth *)(udph + 1);
e231ff2c1bb74fd5 Bob Pearson 2021-06-29  116  	memcpy(bth, pkt->hdr, RXE_BTH_BYTES);
8700e3e7c4857d28 Moni Shoua  2016-06-16  117  
8700e3e7c4857d28 Moni Shoua  2016-06-16  118  	/* exclude bth.resv8a */
8700e3e7c4857d28 Moni Shoua  2016-06-16  119  	bth->qpn |= cpu_to_be32(~BTH_QPN_MASK);
8700e3e7c4857d28 Moni Shoua  2016-06-16  120  
8700e3e7c4857d28 Moni Shoua  2016-06-16  121  	length = hdr_size + RXE_BTH_BYTES;
cee2688e3cd60e0d yonatanc    2017-04-20  122  	crc = rxe_crc32(pkt->rxe, crc, pshdr, length);
8700e3e7c4857d28 Moni Shoua  2016-06-16  123  
8700e3e7c4857d28 Moni Shoua  2016-06-16  124  	/* And finish to compute the CRC on the remainder of the headers. */
cee2688e3cd60e0d yonatanc    2017-04-20  125  	crc = rxe_crc32(pkt->rxe, crc, pkt->hdr + RXE_BTH_BYTES,
8700e3e7c4857d28 Moni Shoua  2016-06-16  126  			rxe_opcode[pkt->opcode].length - RXE_BTH_BYTES);
8700e3e7c4857d28 Moni Shoua  2016-06-16 @127  	return crc;
8700e3e7c4857d28 Moni Shoua  2016-06-16  128  }
0ce4db51163d271a Bob Pearson 2021-06-29  129  
0ce4db51163d271a Bob Pearson 2021-06-29  130  /**
0ce4db51163d271a Bob Pearson 2021-06-29  131   * rxe_icrc_check - Compute ICRC for a packet and compare to the ICRC
0ce4db51163d271a Bob Pearson 2021-06-29  132   *		    delivered in the packet.
46bb188d442e9494 Bob Pearson 2021-06-29  133   * @skb: packet buffer with packet info in skb->cb[] (receive path)
0ce4db51163d271a Bob Pearson 2021-06-29  134   *
46bb188d442e9494 Bob Pearson 2021-06-29  135   * Returns 0 if the ICRCs match or an error on failure
0ce4db51163d271a Bob Pearson 2021-06-29  136   */
0ce4db51163d271a Bob Pearson 2021-06-29  137  int rxe_icrc_check(struct sk_buff *skb)
0ce4db51163d271a Bob Pearson 2021-06-29  138  {
0ce4db51163d271a Bob Pearson 2021-06-29  139  	struct rxe_pkt_info *pkt = SKB_TO_PKT(skb);
0ce4db51163d271a Bob Pearson 2021-06-29  140  	__be32 *icrcp;
e231ff2c1bb74fd5 Bob Pearson 2021-06-29  141  	__be32 packet_icrc;
e231ff2c1bb74fd5 Bob Pearson 2021-06-29  142  	__be32 computed_icrc;
0ce4db51163d271a Bob Pearson 2021-06-29  143  
0ce4db51163d271a Bob Pearson 2021-06-29  144  	icrcp = (__be32 *)(pkt->hdr + pkt->paylen - RXE_ICRC_SIZE);
e231ff2c1bb74fd5 Bob Pearson 2021-06-29  145  	packet_icrc = *icrcp;
0ce4db51163d271a Bob Pearson 2021-06-29  146  
e231ff2c1bb74fd5 Bob Pearson 2021-06-29 @147  	computed_icrc = rxe_icrc_hdr(pkt, skb);
e231ff2c1bb74fd5 Bob Pearson 2021-06-29  148  	computed_icrc = rxe_crc32(pkt->rxe, computed_icrc,
e231ff2c1bb74fd5 Bob Pearson 2021-06-29  149  		(u8 *)payload_addr(pkt), payload_size(pkt) + bth_pad(pkt));
e231ff2c1bb74fd5 Bob Pearson 2021-06-29  150  	computed_icrc = ~computed_icrc;
0ce4db51163d271a Bob Pearson 2021-06-29  151  
e231ff2c1bb74fd5 Bob Pearson 2021-06-29  152  	if (unlikely(computed_icrc != packet_icrc)) {
0ce4db51163d271a Bob Pearson 2021-06-29  153  		if (skb->protocol == htons(ETH_P_IPV6))
0ce4db51163d271a Bob Pearson 2021-06-29  154  			pr_warn_ratelimited("bad ICRC from %pI6c\n",
0ce4db51163d271a Bob Pearson 2021-06-29  155  					    &ipv6_hdr(skb)->saddr);
0ce4db51163d271a Bob Pearson 2021-06-29  156  		else if (skb->protocol == htons(ETH_P_IP))
0ce4db51163d271a Bob Pearson 2021-06-29  157  			pr_warn_ratelimited("bad ICRC from %pI4\n",
0ce4db51163d271a Bob Pearson 2021-06-29  158  					    &ip_hdr(skb)->saddr);
0ce4db51163d271a Bob Pearson 2021-06-29  159  		else
0ce4db51163d271a Bob Pearson 2021-06-29  160  			pr_warn_ratelimited("bad ICRC from unknown\n");
0ce4db51163d271a Bob Pearson 2021-06-29  161  
0ce4db51163d271a Bob Pearson 2021-06-29  162  		return -EINVAL;
0ce4db51163d271a Bob Pearson 2021-06-29  163  	}
0ce4db51163d271a Bob Pearson 2021-06-29  164  
0ce4db51163d271a Bob Pearson 2021-06-29  165  	return 0;
0ce4db51163d271a Bob Pearson 2021-06-29  166  }
a142747477c2d184 Bob Pearson 2021-06-29  167  
46bb188d442e9494 Bob Pearson 2021-06-29  168  /**
46bb188d442e9494 Bob Pearson 2021-06-29  169   * rxe_icrc_generate - Compute ICRC for a packet.
46bb188d442e9494 Bob Pearson 2021-06-29  170   * @pkt: packet information
46bb188d442e9494 Bob Pearson 2021-06-29  171   * @skb: packet buffer
46bb188d442e9494 Bob Pearson 2021-06-29  172   */
a142747477c2d184 Bob Pearson 2021-06-29  173  void rxe_icrc_generate(struct rxe_pkt_info *pkt, struct sk_buff *skb)
a142747477c2d184 Bob Pearson 2021-06-29  174  {
a142747477c2d184 Bob Pearson 2021-06-29  175  	__be32 *icrcp;
e231ff2c1bb74fd5 Bob Pearson 2021-06-29  176  	__be32 icrc;
a142747477c2d184 Bob Pearson 2021-06-29  177  
a142747477c2d184 Bob Pearson 2021-06-29  178  	icrcp = (__be32 *)(pkt->hdr + pkt->paylen - RXE_ICRC_SIZE);
a142747477c2d184 Bob Pearson 2021-06-29 @179  	icrc = rxe_icrc_hdr(pkt, skb);

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

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux