Subject: Re: [PATCH net-next v5 3/3] tsnep: Add TSN endpoint Ethernet MAC driver

From: kernel test robot <[email-masked]>
Date: Fri, 19 Nov 2021 01:31:08 +0800

Hi Gerhard,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Gerhard-Engleder/TSN-endpoint-Ethernet-MAC-driver/20211116-052158
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git a5bdc36354cbf1a1a91396f4da548ff484686305
config: m68k-randconfig-r004-20211118 (attached as .config)
compiler: m68k-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/3252efb6502fdfc25aa357f7dca6290ba9b140e9
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Gerhard-Engleder/TSN-endpoint-Ethernet-MAC-driver/20211116-052158
        git checkout 3252efb6502fdfc25aa357f7dca6290ba9b140e9
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=m68k SHELL=/bin/bash drivers/net/ethernet/engleder/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email-masked]>

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/swab.h:5,
                    from include/uapi/linux/byteorder/big_endian.h:13,
                    from include/linux/byteorder/big_endian.h:5,
                    from arch/m68k/include/uapi/asm/byteorder.h:5,
                    from include/asm-generic/bitops/le.h:7,
                    from arch/m68k/include/asm/bitops.h:529,
                    from include/linux/bitops.h:33,
                    from include/linux/log2.h:12,
                    from include/asm-generic/div64.h:55,
                    from arch/m68k/include/asm/div64.h:6,
                    from include/linux/math.h:5,
                    from include/linux/math64.h:6,
                    from include/linux/time64.h:5,
                    from include/linux/restart_block.h:10,
                    from include/linux/thread_info.h:14,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/m68k/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from arch/m68k/include/asm/irqflags.h:6,
                    from include/linux/irqflags.h:16,
                    from arch/m68k/include/asm/atomic.h:6,
                    from include/linux/atomic.h:7,
                    from include/linux/rcupdate.h:25,
                    from include/linux/rculist.h:11,
                    from include/linux/pid.h:5,
                    from include/linux/sched.h:14,
                    from include/linux/ratelimit.h:6,
                    from include/linux/dev_printk.h:16,
                    from include/linux/device.h:15,
                    from include/linux/platform_device.h:13,
                    from drivers/net/ethernet/engleder/tsnep.h:9,
                    from drivers/net/ethernet/engleder/tsnep_main.c:18:
   drivers/net/ethernet/engleder/tsnep_main.c: In function 'tsnep_tx_activate':
>> drivers/net/ethernet/engleder/tsnep_main.c:292:36: error: 'struct tsnep_tx_entry' has no member named 'len'
     292 |                 __cpu_to_le32(entry->len & TSNEP_DESC_LENGTH_MASK);
         |                                    ^~
   include/uapi/linux/swab.h:118:39: note: in definition of macro '__swab32'
     118 |         (__builtin_constant_p((__u32)(x)) ?     \
         |                                       ^
   drivers/net/ethernet/engleder/tsnep_main.c:292:17: note: in expansion of macro '__cpu_to_le32'
     292 |                 __cpu_to_le32(entry->len & TSNEP_DESC_LENGTH_MASK);
         |                 ^~~~~~~~~~~~~
>> drivers/net/ethernet/engleder/tsnep_main.c:292:36: error: 'struct tsnep_tx_entry' has no member named 'len'
     292 |                 __cpu_to_le32(entry->len & TSNEP_DESC_LENGTH_MASK);
         |                                    ^~
   include/uapi/linux/swab.h:19:19: note: in definition of macro '___constant_swab32'
      19 |         (((__u32)(x) & (__u32)0x000000ffUL) << 24) |            \
         |                   ^
   include/uapi/linux/byteorder/big_endian.h:33:43: note: in expansion of macro '__swab32'
      33 | #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
         |                                           ^~~~~~~~
   drivers/net/ethernet/engleder/tsnep_main.c:292:17: note: in expansion of macro '__cpu_to_le32'
     292 |                 __cpu_to_le32(entry->len & TSNEP_DESC_LENGTH_MASK);
         |                 ^~~~~~~~~~~~~
>> drivers/net/ethernet/engleder/tsnep_main.c:292:36: error: 'struct tsnep_tx_entry' has no member named 'len'
     292 |                 __cpu_to_le32(entry->len & TSNEP_DESC_LENGTH_MASK);
         |                                    ^~
   include/uapi/linux/swab.h:20:19: note: in definition of macro '___constant_swab32'
      20 |         (((__u32)(x) & (__u32)0x0000ff00UL) <<  8) |            \
         |                   ^
   include/uapi/linux/byteorder/big_endian.h:33:43: note: in expansion of macro '__swab32'
      33 | #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
         |                                           ^~~~~~~~
   drivers/net/ethernet/engleder/tsnep_main.c:292:17: note: in expansion of macro '__cpu_to_le32'
     292 |                 __cpu_to_le32(entry->len & TSNEP_DESC_LENGTH_MASK);
         |                 ^~~~~~~~~~~~~
>> drivers/net/ethernet/engleder/tsnep_main.c:292:36: error: 'struct tsnep_tx_entry' has no member named 'len'
     292 |                 __cpu_to_le32(entry->len & TSNEP_DESC_LENGTH_MASK);
         |                                    ^~
   include/uapi/linux/swab.h:21:19: note: in definition of macro '___constant_swab32'
      21 |         (((__u32)(x) & (__u32)0x00ff0000UL) >>  8) |            \
         |                   ^
   include/uapi/linux/byteorder/big_endian.h:33:43: note: in expansion of macro '__swab32'
      33 | #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
         |                                           ^~~~~~~~
   drivers/net/ethernet/engleder/tsnep_main.c:292:17: note: in expansion of macro '__cpu_to_le32'
     292 |                 __cpu_to_le32(entry->len & TSNEP_DESC_LENGTH_MASK);
         |                 ^~~~~~~~~~~~~
>> drivers/net/ethernet/engleder/tsnep_main.c:292:36: error: 'struct tsnep_tx_entry' has no member named 'len'
     292 |                 __cpu_to_le32(entry->len & TSNEP_DESC_LENGTH_MASK);
         |                                    ^~
   include/uapi/linux/swab.h:22:19: note: in definition of macro '___constant_swab32'
      22 |         (((__u32)(x) & (__u32)0xff000000UL) >> 24)))
         |                   ^
   include/uapi/linux/byteorder/big_endian.h:33:43: note: in expansion of macro '__swab32'
      33 | #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
         |                                           ^~~~~~~~
   drivers/net/ethernet/engleder/tsnep_main.c:292:17: note: in expansion of macro '__cpu_to_le32'
     292 |                 __cpu_to_le32(entry->len & TSNEP_DESC_LENGTH_MASK);
         |                 ^~~~~~~~~~~~~
>> drivers/net/ethernet/engleder/tsnep_main.c:292:36: error: 'struct tsnep_tx_entry' has no member named 'len'
     292 |                 __cpu_to_le32(entry->len & TSNEP_DESC_LENGTH_MASK);
         |                                    ^~
   include/uapi/linux/swab.h:120:19: note: in definition of macro '__swab32'
     120 |         __fswab32(x))
         |                   ^
   drivers/net/ethernet/engleder/tsnep_main.c:292:17: note: in expansion of macro '__cpu_to_le32'
     292 |                 __cpu_to_le32(entry->len & TSNEP_DESC_LENGTH_MASK);
         |                 ^~~~~~~~~~~~~
   drivers/net/ethernet/engleder/tsnep_main.c: In function 'tsnep_tx_unmap':
>> drivers/net/ethernet/engleder/tsnep_main.c:343:32: warning: variable 'entry' set but not used [-Wunused-but-set-variable]
     343 |         struct tsnep_tx_entry *entry;
         |                                ^~~~~
   drivers/net/ethernet/engleder/tsnep_main.c: In function 'tsnep_rx_ring_cleanup':
>> drivers/net/ethernet/engleder/tsnep_main.c:543:26: error: 'struct tsnep_rx_entry' has no member named 'dma'
     543 |                 if (entry->dma)
         |                          ^~
   In file included from drivers/net/ethernet/engleder/tsnep.h:10,
                    from drivers/net/ethernet/engleder/tsnep_main.c:18:
   drivers/net/ethernet/engleder/tsnep_main.c:544:55: error: 'struct tsnep_rx_entry' has no member named 'dma'
     544 |                         dma_unmap_single(dmadev, entry->dma, entry->len,
         |                                                       ^~
   include/linux/dma-mapping.h:407:64: note: in definition of macro 'dma_unmap_single'
     407 | #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, 0)
         |                                                                ^
>> drivers/net/ethernet/engleder/tsnep_main.c:544:67: error: 'struct tsnep_rx_entry' has no member named 'len'
     544 |                         dma_unmap_single(dmadev, entry->dma, entry->len,
         |                                                                   ^~
   include/linux/dma-mapping.h:407:67: note: in definition of macro 'dma_unmap_single'
     407 | #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, 0)
         |                                                                   ^
   drivers/net/ethernet/engleder/tsnep_main.c: In function 'tsnep_rx_activate':
   drivers/net/ethernet/engleder/tsnep_main.c:638:34: error: 'struct tsnep_rx_entry' has no member named 'len'
     638 |         entry->properties = entry->len & TSNEP_DESC_LENGTH_MASK;
         |                                  ^~
   drivers/net/ethernet/engleder/tsnep_main.c: In function 'tsnep_rx_poll':
>> drivers/net/ethernet/engleder/tsnep_main.c:666:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     666 |         int length;
         |         ^~~
>> drivers/net/ethernet/engleder/tsnep_main.c:679:17: error: 'dma' undeclared (first use in this function)
     679 |                 dma = entry->dma;
         |                 ^~~
   drivers/net/ethernet/engleder/tsnep_main.c:679:17: note: each undeclared identifier is reported only once for each function it appears in
   drivers/net/ethernet/engleder/tsnep_main.c:679:28: error: 'struct tsnep_rx_entry' has no member named 'dma'
     679 |                 dma = entry->dma;
         |                            ^~
>> drivers/net/ethernet/engleder/tsnep_main.c:680:17: error: 'len' undeclared (first use in this function)
     680 |                 len = entry->len;
         |                 ^~~
   drivers/net/ethernet/engleder/tsnep_main.c:680:28: error: 'struct tsnep_rx_entry' has no member named 'len'
     680 |                 len = entry->len;
         |                            ^~

vim +292 drivers/net/ethernet/engleder/tsnep_main.c

   243	
   244	static void tsnep_tx_activate(struct tsnep_tx *tx, int index, bool last)
   245	{
   246		struct tsnep_tx_entry *entry = &tx->entry[index];
   247	
   248		entry->properties = 0;
   249		if (entry->skb) {
   250			entry->properties =
   251				skb_pagelen(entry->skb) & TSNEP_DESC_LENGTH_MASK;
   252			entry->properties |= TSNEP_DESC_INTERRUPT_FLAG;
   253			if (skb_shinfo(entry->skb)->tx_flags & SKBTX_IN_PROGRESS)
   254				entry->properties |= TSNEP_DESC_EXTENDED_WRITEBACK_FLAG;
   255	
   256			/* toggle user flag to prevent false acknowledge
   257			 *
   258			 * Only the first fragment is acknowledged. For all other
   259			 * fragments no acknowledge is done and the last written owner
   260			 * counter stays in the writeback descriptor. Therefore, it is
   261			 * possible that the last written owner counter is identical to
   262			 * the new incremented owner counter and a false acknowledge is
   263			 * detected before the real acknowledge has been done by
   264			 * hardware.
   265			 *
   266			 * The user flag is used to prevent this situation. The user
   267			 * flag is copied to the writeback descriptor by the hardware
   268			 * and is used as additional acknowledge data. By toggeling the
   269			 * user flag only for the first fragment (which is
   270			 * acknowledged), it is guaranteed that the last acknowledge
   271			 * done for this descriptor has used a different user flag and
   272			 * cannot be detected as false acknowledge.
   273			 */
   274			entry->owner_user_flag = !entry->owner_user_flag;
   275		}
   276		if (last)
   277			entry->properties |= TSNEP_TX_DESC_LAST_FRAGMENT_FLAG;
   278		if (index == tx->increment_owner_counter) {
   279			tx->owner_counter++;
   280			if (tx->owner_counter == 4)
   281				tx->owner_counter = 1;
   282			tx->increment_owner_counter--;
   283			if (tx->increment_owner_counter < 0)
   284				tx->increment_owner_counter = TSNEP_RING_SIZE - 1;
   285		}
   286		entry->properties |=
   287			(tx->owner_counter << TSNEP_DESC_OWNER_COUNTER_SHIFT) &
   288			TSNEP_DESC_OWNER_COUNTER_MASK;
   289		if (entry->owner_user_flag)
   290			entry->properties |= TSNEP_TX_DESC_OWNER_USER_FLAG;
   291		entry->desc->more_properties =
 > 292			__cpu_to_le32(entry->len & TSNEP_DESC_LENGTH_MASK);
   293	
   294		dma_wmb();
   295	
   296		entry->desc->properties = __cpu_to_le32(entry->properties);
   297	}
   298	
   299	static int tsnep_tx_desc_available(struct tsnep_tx *tx)
   300	{
   301		if (tx->read <= tx->write)
   302			return TSNEP_RING_SIZE - tx->write + tx->read - 1;
   303		else
   304			return tx->read - tx->write - 1;
   305	}
   306	
   307	static int tsnep_tx_map(struct sk_buff *skb, struct tsnep_tx *tx, int count)
   308	{
   309		struct device *dmadev = tx->adapter->dmadev;
   310		struct tsnep_tx_entry *entry;
   311		unsigned int len;
   312		dma_addr_t dma;
   313		int i;
   314	
   315		for (i = 0; i < count; i++) {
   316			entry = &tx->entry[(tx->write + i) % TSNEP_RING_SIZE];
   317	
   318			if (i == 0) {
   319				len = skb_headlen(skb);
   320				dma = dma_map_single(dmadev, skb->data, len,
   321						     DMA_TO_DEVICE);
   322			} else {
   323				len = skb_frag_size(&skb_shinfo(skb)->frags[i - 1]);
   324				dma = skb_frag_dma_map(dmadev,
   325						       &skb_shinfo(skb)->frags[i - 1],
   326						       0, len, DMA_TO_DEVICE);
   327			}
   328			if (dma_mapping_error(dmadev, dma))
   329				return -ENOMEM;
   330	
   331			dma_unmap_len_set(entry, len, len);
   332			dma_unmap_addr_set(entry, dma, dma);
   333	
   334			entry->desc->tx = __cpu_to_le64(dma);
   335		}
   336	
   337		return 0;
   338	}
   339	
   340	static void tsnep_tx_unmap(struct tsnep_tx *tx, int count)
   341	{
   342		struct device *dmadev = tx->adapter->dmadev;
 > 343		struct tsnep_tx_entry *entry;
   344		int i;
   345	
   346		for (i = 0; i < count; i++) {
   347			entry = &tx->entry[(tx->read + i) % TSNEP_RING_SIZE];
   348	
   349			if (dma_unmap_len(entry, len)) {
   350				if (i == 0)
   351					dma_unmap_single(dmadev,
   352							 dma_unmap_addr(entry, dma),
   353							 dma_unmap_len(entry, len),
   354							 DMA_TO_DEVICE);
   355				else
   356					dma_unmap_page(dmadev,
   357						       dma_unmap_addr(entry, dma),
   358						       dma_unmap_len(entry, len),
   359						       DMA_TO_DEVICE);
   360				dma_unmap_len_set(entry, len, 0);
   361			}
   362		}
   363	}
   364	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email-masked]