[PATCH] include: mdio: Guard inline function with CONFIG_MDIO

Alistair Francis posted 1 patch 2 weeks, 6 days ago
include/linux/mdio.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
[PATCH] include: mdio: Guard inline function with CONFIG_MDIO
Posted by Alistair Francis 2 weeks, 6 days ago
The static inline functions mdio45_ethtool_gset() and
mdio45_ethtool_ksettings_get() call mdio45_ethtool_gset_npage() and
mdio45_ethtool_ksettings_get_npage() which are both guarded by
CONFIG_MDIO. So let's only expose mdio45_ethtool_gset() and
mdio45_ethtool_ksettings_get() if CONFIG_MDIO is defined.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 include/linux/mdio.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index efeca5bd7600b..558311d9d7cad 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -165,11 +165,13 @@ extern int mdio_set_flag(const struct mdio_if_info *mdio,
 			 bool sense);
 extern int mdio45_links_ok(const struct mdio_if_info *mdio, u32 mmds);
 extern int mdio45_nway_restart(const struct mdio_if_info *mdio);
+
+#ifdef CONFIG_MDIO
 extern void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,
 				      struct ethtool_cmd *ecmd,
 				      u32 npage_adv, u32 npage_lpa);
-extern void
-mdio45_ethtool_ksettings_get_npage(const struct mdio_if_info *mdio,
+
+extern void mdio45_ethtool_ksettings_get_npage(const struct mdio_if_info *mdio,
 				   struct ethtool_link_ksettings *cmd,
 				   u32 npage_adv, u32 npage_lpa);
 
@@ -205,6 +207,7 @@ mdio45_ethtool_ksettings_get(const struct mdio_if_info *mdio,
 {
 	mdio45_ethtool_ksettings_get_npage(mdio, cmd, 0, 0);
 }
+#endif
 
 extern int mdio_mii_ioctl(const struct mdio_if_info *mdio,
 			  struct mii_ioctl_data *mii_data, int cmd);
-- 
2.47.0
Re: [PATCH] include: mdio: Guard inline function with CONFIG_MDIO
Posted by kernel test robot 2 weeks, 5 days ago
Hi Alistair,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on horms-ipvs/master v6.12-rc6 next-20241104]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Alistair-Francis/include-mdio-Guard-inline-function-with-CONFIG_MDIO/20241104-151211
base:   linus/master
patch link:    https://lore.kernel.org/r/20241104070950.502719-1-alistair.francis%40wdc.com
patch subject: [PATCH] include: mdio: Guard inline function with CONFIG_MDIO
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20241105/202411050638.SOJYVz2a-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 639a7ac648f1e50ccd2556e17d401c04f9cce625)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241105/202411050638.SOJYVz2a-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411050638.SOJYVz2a-lkp@intel.com/

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

   In file included from drivers/net/mdio.c:10:
   In file included from include/linux/ethtool.h:18:
   In file included from include/linux/if_ether.h:19:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:10:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/net/mdio.c:10:
   In file included from include/linux/ethtool.h:18:
   In file included from include/linux/if_ether.h:19:
   In file included from include/linux/skbuff.h:28:
   In file included from include/linux/dma-mapping.h:11:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:95:
   include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     548 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     561 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
         |                                                           ^
   include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
     102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
         |                                                      ^
   In file included from drivers/net/mdio.c:10:
   In file included from include/linux/ethtool.h:18:
   In file included from include/linux/if_ether.h:19:
   In file included from include/linux/skbuff.h:28:
   In file included from include/linux/dma-mapping.h:11:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:95:
   include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     574 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
         |                                                           ^
   include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
     115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
         |                                                      ^
   In file included from drivers/net/mdio.c:10:
   In file included from include/linux/ethtool.h:18:
   In file included from include/linux/if_ether.h:19:
   In file included from include/linux/skbuff.h:28:
   In file included from include/linux/dma-mapping.h:11:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:95:
   include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     585 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     595 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     605 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     693 |         readsb(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     701 |         readsw(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     709 |         readsl(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     718 |         writesb(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     727 |         writesw(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     736 |         writesl(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
>> drivers/net/mdio.c:183:6: warning: no previous prototype for function 'mdio45_ethtool_gset_npage' [-Wmissing-prototypes]
     183 | void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,
         |      ^
   drivers/net/mdio.c:183:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
     183 | void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,
         | ^
         | static 
>> drivers/net/mdio.c:355:6: warning: no previous prototype for function 'mdio45_ethtool_ksettings_get_npage' [-Wmissing-prototypes]
     355 | void mdio45_ethtool_ksettings_get_npage(const struct mdio_if_info *mdio,
         |      ^
   drivers/net/mdio.c:355:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
     355 | void mdio45_ethtool_ksettings_get_npage(const struct mdio_if_info *mdio,
         | ^
         | static 
   18 warnings generated.
--
   In file included from drivers/net/ethernet/sfc/falcon/net_driver.h:13:
   In file included from include/linux/netdevice.h:38:
   In file included from include/net/net_namespace.h:43:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:10:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/net/ethernet/sfc/falcon/qt202x_phy.c:13:
   In file included from drivers/net/ethernet/sfc/falcon/efx.h:11:
   In file included from drivers/net/ethernet/sfc/falcon/net_driver.h:13:
   In file included from include/linux/netdevice.h:38:
   In file included from include/net/net_namespace.h:43:
   In file included from include/linux/skbuff.h:28:
   In file included from include/linux/dma-mapping.h:11:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:95:
   include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     548 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     561 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
         |                                                           ^
   include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
     102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
         |                                                      ^
   In file included from drivers/net/ethernet/sfc/falcon/qt202x_phy.c:13:
   In file included from drivers/net/ethernet/sfc/falcon/efx.h:11:
   In file included from drivers/net/ethernet/sfc/falcon/net_driver.h:13:
   In file included from include/linux/netdevice.h:38:
   In file included from include/net/net_namespace.h:43:
   In file included from include/linux/skbuff.h:28:
   In file included from include/linux/dma-mapping.h:11:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:95:
   include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     574 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
         |                                                           ^
   include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
     115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
         |                                                      ^
   In file included from drivers/net/ethernet/sfc/falcon/qt202x_phy.c:13:
   In file included from drivers/net/ethernet/sfc/falcon/efx.h:11:
   In file included from drivers/net/ethernet/sfc/falcon/net_driver.h:13:
   In file included from include/linux/netdevice.h:38:
   In file included from include/net/net_namespace.h:43:
   In file included from include/linux/skbuff.h:28:
   In file included from include/linux/dma-mapping.h:11:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:95:
   include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     585 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     595 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     605 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     693 |         readsb(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     701 |         readsw(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     709 |         readsl(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     718 |         writesb(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     727 |         writesw(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     736 |         writesl(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
>> drivers/net/ethernet/sfc/falcon/qt202x_phy.c:440:2: error: call to undeclared function 'mdio45_ethtool_ksettings_get'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     440 |         mdio45_ethtool_ksettings_get(&efx->mdio, cmd);
         |         ^
   16 warnings and 1 error generated.
--
   In file included from drivers/net/ethernet/sfc/falcon/tenxpress.c:8:
   In file included from include/linux/rtnetlink.h:7:
   In file included from include/linux/netdevice.h:38:
   In file included from include/net/net_namespace.h:43:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:10:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/net/ethernet/sfc/falcon/tenxpress.c:8:
   In file included from include/linux/rtnetlink.h:7:
   In file included from include/linux/netdevice.h:38:
   In file included from include/net/net_namespace.h:43:
   In file included from include/linux/skbuff.h:28:
   In file included from include/linux/dma-mapping.h:11:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:95:
   include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     548 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     561 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
         |                                                           ^
   include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
     102 | #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
         |                                                      ^
   In file included from drivers/net/ethernet/sfc/falcon/tenxpress.c:8:
   In file included from include/linux/rtnetlink.h:7:
   In file included from include/linux/netdevice.h:38:
   In file included from include/net/net_namespace.h:43:
   In file included from include/linux/skbuff.h:28:
   In file included from include/linux/dma-mapping.h:11:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:95:
   include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     574 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
         |                                                           ^
   include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
     115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
         |                                                      ^
   In file included from drivers/net/ethernet/sfc/falcon/tenxpress.c:8:
   In file included from include/linux/rtnetlink.h:7:
   In file included from include/linux/netdevice.h:38:
   In file included from include/net/net_namespace.h:43:
   In file included from include/linux/skbuff.h:28:
   In file included from include/linux/dma-mapping.h:11:
   In file included from include/linux/scatterlist.h:9:
   In file included from arch/s390/include/asm/io.h:95:
   include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     585 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     595 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     605 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     693 |         readsb(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     701 |         readsw(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     709 |         readsl(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     718 |         writesb(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     727 |         writesw(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     736 |         writesl(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
>> drivers/net/ethernet/sfc/falcon/tenxpress.c:453:2: error: call to undeclared function 'mdio45_ethtool_ksettings_get_npage'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     453 |         mdio45_ethtool_ksettings_get_npage(&efx->mdio, cmd, adv, lpa);
         |         ^
   16 warnings and 1 error generated.
..


vim +/mdio45_ethtool_ksettings_get +440 drivers/net/ethernet/sfc/falcon/qt202x_phy.c

8ceee660aacb29 drivers/net/sfc/xfp_phy.c                    Ben Hutchings   2008-04-27  436  
e938ed150f1ed9 drivers/net/ethernet/sfc/falcon/qt202x_phy.c Philippe Reynes 2017-01-01  437  static void qt202x_phy_get_link_ksettings(struct ef4_nic *efx,
e938ed150f1ed9 drivers/net/ethernet/sfc/falcon/qt202x_phy.c Philippe Reynes 2017-01-01  438  					  struct ethtool_link_ksettings *cmd)
68e7f45e118f98 drivers/net/sfc/xfp_phy.c                    Ben Hutchings   2009-04-29  439  {
e938ed150f1ed9 drivers/net/ethernet/sfc/falcon/qt202x_phy.c Philippe Reynes 2017-01-01 @440  	mdio45_ethtool_ksettings_get(&efx->mdio, cmd);
68e7f45e118f98 drivers/net/sfc/xfp_phy.c                    Ben Hutchings   2009-04-29  441  }
8ceee660aacb29 drivers/net/sfc/xfp_phy.c                    Ben Hutchings   2008-04-27  442  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH] include: mdio: Guard inline function with CONFIG_MDIO
Posted by kernel test robot 2 weeks, 5 days ago
Hi Alistair,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on horms-ipvs/master v6.12-rc6 next-20241104]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Alistair-Francis/include-mdio-Guard-inline-function-with-CONFIG_MDIO/20241104-151211
base:   linus/master
patch link:    https://lore.kernel.org/r/20241104070950.502719-1-alistair.francis%40wdc.com
patch subject: [PATCH] include: mdio: Guard inline function with CONFIG_MDIO
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20241104/202411042118.dhgElzHF-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241104/202411042118.dhgElzHF-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411042118.dhgElzHF-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/net/mdio.c:183:6: warning: no previous prototype for 'mdio45_ethtool_gset_npage' [-Wmissing-prototypes]
     183 | void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/net/mdio.c:355:6: warning: no previous prototype for 'mdio45_ethtool_ksettings_get_npage' [-Wmissing-prototypes]
     355 | void mdio45_ethtool_ksettings_get_npage(const struct mdio_if_info *mdio,
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/mdio45_ethtool_gset_npage +183 drivers/net/mdio.c

1b1c2e95103ce3 Ben Hutchings   2009-04-29  168  
1b1c2e95103ce3 Ben Hutchings   2009-04-29  169  /**
1b1c2e95103ce3 Ben Hutchings   2009-04-29  170   * mdio45_ethtool_gset_npage - get settings for ETHTOOL_GSET
1b1c2e95103ce3 Ben Hutchings   2009-04-29  171   * @mdio: MDIO interface
1b1c2e95103ce3 Ben Hutchings   2009-04-29  172   * @ecmd: Ethtool request structure
1b1c2e95103ce3 Ben Hutchings   2009-04-29  173   * @npage_adv: Modes currently advertised on next pages
1b1c2e95103ce3 Ben Hutchings   2009-04-29  174   * @npage_lpa: Modes advertised by link partner on next pages
1b1c2e95103ce3 Ben Hutchings   2009-04-29  175   *
8ae6daca85c8bb David Decotigny 2011-04-27  176   * The @ecmd parameter is expected to have been cleared before calling
8ae6daca85c8bb David Decotigny 2011-04-27  177   * mdio45_ethtool_gset_npage().
8ae6daca85c8bb David Decotigny 2011-04-27  178   *
1b1c2e95103ce3 Ben Hutchings   2009-04-29  179   * Since the CSRs for auto-negotiation using next pages are not fully
1b1c2e95103ce3 Ben Hutchings   2009-04-29  180   * standardised, this function does not attempt to decode them.  The
1b1c2e95103ce3 Ben Hutchings   2009-04-29  181   * caller must pass them in.
1b1c2e95103ce3 Ben Hutchings   2009-04-29  182   */
1b1c2e95103ce3 Ben Hutchings   2009-04-29 @183  void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,
1b1c2e95103ce3 Ben Hutchings   2009-04-29  184  			       struct ethtool_cmd *ecmd,
1b1c2e95103ce3 Ben Hutchings   2009-04-29  185  			       u32 npage_adv, u32 npage_lpa)
1b1c2e95103ce3 Ben Hutchings   2009-04-29  186  {
1b1c2e95103ce3 Ben Hutchings   2009-04-29  187  	int reg;
707394972093e2 David Decotigny 2011-04-27  188  	u32 speed;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  189  
9c4df53bc3f9c7 Ben Hutchings   2012-02-29  190  	BUILD_BUG_ON(MDIO_SUPPORTS_C22 != ETH_MDIO_SUPPORTS_C22);
9c4df53bc3f9c7 Ben Hutchings   2012-02-29  191  	BUILD_BUG_ON(MDIO_SUPPORTS_C45 != ETH_MDIO_SUPPORTS_C45);
9c4df53bc3f9c7 Ben Hutchings   2012-02-29  192  
1b1c2e95103ce3 Ben Hutchings   2009-04-29  193  	ecmd->transceiver = XCVR_INTERNAL;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  194  	ecmd->phy_address = mdio->prtad;
0c09c1a49cc7b8 Ben Hutchings   2009-04-29  195  	ecmd->mdio_support =
0c09c1a49cc7b8 Ben Hutchings   2009-04-29  196  		mdio->mode_support & (MDIO_SUPPORTS_C45 | MDIO_SUPPORTS_C22);
1b1c2e95103ce3 Ben Hutchings   2009-04-29  197  
1b1c2e95103ce3 Ben Hutchings   2009-04-29  198  	reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
1b1c2e95103ce3 Ben Hutchings   2009-04-29  199  			      MDIO_CTRL2);
1b1c2e95103ce3 Ben Hutchings   2009-04-29  200  	switch (reg & MDIO_PMA_CTRL2_TYPE) {
1b1c2e95103ce3 Ben Hutchings   2009-04-29  201  	case MDIO_PMA_CTRL2_10GBT:
1b1c2e95103ce3 Ben Hutchings   2009-04-29  202  	case MDIO_PMA_CTRL2_1000BT:
1b1c2e95103ce3 Ben Hutchings   2009-04-29  203  	case MDIO_PMA_CTRL2_100BTX:
1b1c2e95103ce3 Ben Hutchings   2009-04-29  204  	case MDIO_PMA_CTRL2_10BT:
1b1c2e95103ce3 Ben Hutchings   2009-04-29  205  		ecmd->port = PORT_TP;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  206  		ecmd->supported = SUPPORTED_TP;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  207  		reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
1b1c2e95103ce3 Ben Hutchings   2009-04-29  208  				      MDIO_SPEED);
1b1c2e95103ce3 Ben Hutchings   2009-04-29  209  		if (reg & MDIO_SPEED_10G)
1b1c2e95103ce3 Ben Hutchings   2009-04-29  210  			ecmd->supported |= SUPPORTED_10000baseT_Full;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  211  		if (reg & MDIO_PMA_SPEED_1000)
1b1c2e95103ce3 Ben Hutchings   2009-04-29  212  			ecmd->supported |= (SUPPORTED_1000baseT_Full |
1b1c2e95103ce3 Ben Hutchings   2009-04-29  213  					    SUPPORTED_1000baseT_Half);
1b1c2e95103ce3 Ben Hutchings   2009-04-29  214  		if (reg & MDIO_PMA_SPEED_100)
1b1c2e95103ce3 Ben Hutchings   2009-04-29  215  			ecmd->supported |= (SUPPORTED_100baseT_Full |
1b1c2e95103ce3 Ben Hutchings   2009-04-29  216  					    SUPPORTED_100baseT_Half);
1b1c2e95103ce3 Ben Hutchings   2009-04-29  217  		if (reg & MDIO_PMA_SPEED_10)
1b1c2e95103ce3 Ben Hutchings   2009-04-29  218  			ecmd->supported |= (SUPPORTED_10baseT_Full |
1b1c2e95103ce3 Ben Hutchings   2009-04-29  219  					    SUPPORTED_10baseT_Half);
1b1c2e95103ce3 Ben Hutchings   2009-04-29  220  		ecmd->advertising = ADVERTISED_TP;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  221  		break;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  222  
1b1c2e95103ce3 Ben Hutchings   2009-04-29  223  	case MDIO_PMA_CTRL2_10GBCX4:
894b19a6b343ce Ben Hutchings   2009-04-29  224  		ecmd->port = PORT_OTHER;
894b19a6b343ce Ben Hutchings   2009-04-29  225  		ecmd->supported = 0;
894b19a6b343ce Ben Hutchings   2009-04-29  226  		ecmd->advertising = 0;
894b19a6b343ce Ben Hutchings   2009-04-29  227  		break;
894b19a6b343ce Ben Hutchings   2009-04-29  228  
1b1c2e95103ce3 Ben Hutchings   2009-04-29  229  	case MDIO_PMA_CTRL2_10GBKX4:
1b1c2e95103ce3 Ben Hutchings   2009-04-29  230  	case MDIO_PMA_CTRL2_10GBKR:
1b1c2e95103ce3 Ben Hutchings   2009-04-29  231  	case MDIO_PMA_CTRL2_1000BKX:
1b1c2e95103ce3 Ben Hutchings   2009-04-29  232  		ecmd->port = PORT_OTHER;
894b19a6b343ce Ben Hutchings   2009-04-29  233  		ecmd->supported = SUPPORTED_Backplane;
894b19a6b343ce Ben Hutchings   2009-04-29  234  		reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
894b19a6b343ce Ben Hutchings   2009-04-29  235  				      MDIO_PMA_EXTABLE);
894b19a6b343ce Ben Hutchings   2009-04-29  236  		if (reg & MDIO_PMA_EXTABLE_10GBKX4)
894b19a6b343ce Ben Hutchings   2009-04-29  237  			ecmd->supported |= SUPPORTED_10000baseKX4_Full;
894b19a6b343ce Ben Hutchings   2009-04-29  238  		if (reg & MDIO_PMA_EXTABLE_10GBKR)
894b19a6b343ce Ben Hutchings   2009-04-29  239  			ecmd->supported |= SUPPORTED_10000baseKR_Full;
894b19a6b343ce Ben Hutchings   2009-04-29  240  		if (reg & MDIO_PMA_EXTABLE_1000BKX)
894b19a6b343ce Ben Hutchings   2009-04-29  241  			ecmd->supported |= SUPPORTED_1000baseKX_Full;
894b19a6b343ce Ben Hutchings   2009-04-29  242  		reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
894b19a6b343ce Ben Hutchings   2009-04-29  243  				      MDIO_PMA_10GBR_FECABLE);
894b19a6b343ce Ben Hutchings   2009-04-29  244  		if (reg & MDIO_PMA_10GBR_FECABLE_ABLE)
894b19a6b343ce Ben Hutchings   2009-04-29  245  			ecmd->supported |= SUPPORTED_10000baseR_FEC;
894b19a6b343ce Ben Hutchings   2009-04-29  246  		ecmd->advertising = ADVERTISED_Backplane;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  247  		break;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  248  
1b1c2e95103ce3 Ben Hutchings   2009-04-29  249  	/* All the other defined modes are flavours of optical */
1b1c2e95103ce3 Ben Hutchings   2009-04-29  250  	default:
1b1c2e95103ce3 Ben Hutchings   2009-04-29  251  		ecmd->port = PORT_FIBRE;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  252  		ecmd->supported = SUPPORTED_FIBRE;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  253  		ecmd->advertising = ADVERTISED_FIBRE;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  254  		break;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  255  	}
1b1c2e95103ce3 Ben Hutchings   2009-04-29  256  
1b1c2e95103ce3 Ben Hutchings   2009-04-29  257  	if (mdio->mmds & MDIO_DEVS_AN) {
1b1c2e95103ce3 Ben Hutchings   2009-04-29  258  		ecmd->supported |= SUPPORTED_Autoneg;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  259  		reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_AN,
1b1c2e95103ce3 Ben Hutchings   2009-04-29  260  				      MDIO_CTRL1);
1b1c2e95103ce3 Ben Hutchings   2009-04-29  261  		if (reg & MDIO_AN_CTRL1_ENABLE) {
1b1c2e95103ce3 Ben Hutchings   2009-04-29  262  			ecmd->autoneg = AUTONEG_ENABLE;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  263  			ecmd->advertising |=
1b1c2e95103ce3 Ben Hutchings   2009-04-29  264  				ADVERTISED_Autoneg |
1b1c2e95103ce3 Ben Hutchings   2009-04-29  265  				mdio45_get_an(mdio, MDIO_AN_ADVERTISE) |
1b1c2e95103ce3 Ben Hutchings   2009-04-29  266  				npage_adv;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  267  		} else {
1b1c2e95103ce3 Ben Hutchings   2009-04-29  268  			ecmd->autoneg = AUTONEG_DISABLE;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  269  		}
1b1c2e95103ce3 Ben Hutchings   2009-04-29  270  	} else {
1b1c2e95103ce3 Ben Hutchings   2009-04-29  271  		ecmd->autoneg = AUTONEG_DISABLE;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  272  	}
1b1c2e95103ce3 Ben Hutchings   2009-04-29  273  
1b1c2e95103ce3 Ben Hutchings   2009-04-29  274  	if (ecmd->autoneg) {
1b1c2e95103ce3 Ben Hutchings   2009-04-29  275  		u32 modes = 0;
0c09c1a49cc7b8 Ben Hutchings   2009-04-29  276  		int an_stat = mdio->mdio_read(mdio->dev, mdio->prtad,
0c09c1a49cc7b8 Ben Hutchings   2009-04-29  277  					      MDIO_MMD_AN, MDIO_STAT1);
1b1c2e95103ce3 Ben Hutchings   2009-04-29  278  
1b1c2e95103ce3 Ben Hutchings   2009-04-29  279  		/* If AN is complete and successful, report best common
1b1c2e95103ce3 Ben Hutchings   2009-04-29  280  		 * mode, otherwise report best advertised mode. */
0c09c1a49cc7b8 Ben Hutchings   2009-04-29  281  		if (an_stat & MDIO_AN_STAT1_COMPLETE) {
0c09c1a49cc7b8 Ben Hutchings   2009-04-29  282  			ecmd->lp_advertising =
0c09c1a49cc7b8 Ben Hutchings   2009-04-29  283  				mdio45_get_an(mdio, MDIO_AN_LPA) | npage_lpa;
0c09c1a49cc7b8 Ben Hutchings   2009-04-29  284  			if (an_stat & MDIO_AN_STAT1_LPABLE)
0c09c1a49cc7b8 Ben Hutchings   2009-04-29  285  				ecmd->lp_advertising |= ADVERTISED_Autoneg;
0c09c1a49cc7b8 Ben Hutchings   2009-04-29  286  			modes = ecmd->advertising & ecmd->lp_advertising;
0c09c1a49cc7b8 Ben Hutchings   2009-04-29  287  		}
0c09c1a49cc7b8 Ben Hutchings   2009-04-29  288  		if ((modes & ~ADVERTISED_Autoneg) == 0)
1b1c2e95103ce3 Ben Hutchings   2009-04-29  289  			modes = ecmd->advertising;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  290  
894b19a6b343ce Ben Hutchings   2009-04-29  291  		if (modes & (ADVERTISED_10000baseT_Full |
894b19a6b343ce Ben Hutchings   2009-04-29  292  			     ADVERTISED_10000baseKX4_Full |
894b19a6b343ce Ben Hutchings   2009-04-29  293  			     ADVERTISED_10000baseKR_Full)) {
707394972093e2 David Decotigny 2011-04-27  294  			speed = SPEED_10000;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  295  			ecmd->duplex = DUPLEX_FULL;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  296  		} else if (modes & (ADVERTISED_1000baseT_Full |
894b19a6b343ce Ben Hutchings   2009-04-29  297  				    ADVERTISED_1000baseT_Half |
894b19a6b343ce Ben Hutchings   2009-04-29  298  				    ADVERTISED_1000baseKX_Full)) {
707394972093e2 David Decotigny 2011-04-27  299  			speed = SPEED_1000;
894b19a6b343ce Ben Hutchings   2009-04-29  300  			ecmd->duplex = !(modes & ADVERTISED_1000baseT_Half);
1b1c2e95103ce3 Ben Hutchings   2009-04-29  301  		} else if (modes & (ADVERTISED_100baseT_Full |
1b1c2e95103ce3 Ben Hutchings   2009-04-29  302  				    ADVERTISED_100baseT_Half)) {
707394972093e2 David Decotigny 2011-04-27  303  			speed = SPEED_100;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  304  			ecmd->duplex = !!(modes & ADVERTISED_100baseT_Full);
1b1c2e95103ce3 Ben Hutchings   2009-04-29  305  		} else {
707394972093e2 David Decotigny 2011-04-27  306  			speed = SPEED_10;
1b1c2e95103ce3 Ben Hutchings   2009-04-29  307  			ecmd->duplex = !!(modes & ADVERTISED_10baseT_Full);
1b1c2e95103ce3 Ben Hutchings   2009-04-29  308  		}
1b1c2e95103ce3 Ben Hutchings   2009-04-29  309  	} else {
1b1c2e95103ce3 Ben Hutchings   2009-04-29  310  		/* Report forced settings */
1b1c2e95103ce3 Ben Hutchings   2009-04-29  311  		reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
1b1c2e95103ce3 Ben Hutchings   2009-04-29  312  				      MDIO_CTRL1);
707394972093e2 David Decotigny 2011-04-27  313  		speed = (((reg & MDIO_PMA_CTRL1_SPEED1000) ? 100 : 1)
707394972093e2 David Decotigny 2011-04-27  314  			 * ((reg & MDIO_PMA_CTRL1_SPEED100) ? 100 : 10));
1b1c2e95103ce3 Ben Hutchings   2009-04-29  315  		ecmd->duplex = (reg & MDIO_CTRL1_FULLDPLX ||
707394972093e2 David Decotigny 2011-04-27  316  				speed == SPEED_10000);
1b1c2e95103ce3 Ben Hutchings   2009-04-29  317  	}
d005ba6cc82440 Ben Hutchings   2009-06-10  318  
707394972093e2 David Decotigny 2011-04-27  319  	ethtool_cmd_speed_set(ecmd, speed);
707394972093e2 David Decotigny 2011-04-27  320  
d005ba6cc82440 Ben Hutchings   2009-06-10  321  	/* 10GBASE-T MDI/MDI-X */
707394972093e2 David Decotigny 2011-04-27  322  	if (ecmd->port == PORT_TP
707394972093e2 David Decotigny 2011-04-27  323  	    && (ethtool_cmd_speed(ecmd) == SPEED_10000)) {
d005ba6cc82440 Ben Hutchings   2009-06-10  324  		switch (mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
d005ba6cc82440 Ben Hutchings   2009-06-10  325  					MDIO_PMA_10GBT_SWAPPOL)) {
d005ba6cc82440 Ben Hutchings   2009-06-10  326  		case MDIO_PMA_10GBT_SWAPPOL_ABNX | MDIO_PMA_10GBT_SWAPPOL_CDNX:
d005ba6cc82440 Ben Hutchings   2009-06-10  327  			ecmd->eth_tp_mdix = ETH_TP_MDI;
d005ba6cc82440 Ben Hutchings   2009-06-10  328  			break;
d005ba6cc82440 Ben Hutchings   2009-06-10  329  		case 0:
d005ba6cc82440 Ben Hutchings   2009-06-10  330  			ecmd->eth_tp_mdix = ETH_TP_MDI_X;
d005ba6cc82440 Ben Hutchings   2009-06-10  331  			break;
d005ba6cc82440 Ben Hutchings   2009-06-10  332  		default:
d005ba6cc82440 Ben Hutchings   2009-06-10  333  			/* It's complicated... */
d005ba6cc82440 Ben Hutchings   2009-06-10  334  			ecmd->eth_tp_mdix = ETH_TP_MDI_INVALID;
d005ba6cc82440 Ben Hutchings   2009-06-10  335  			break;
d005ba6cc82440 Ben Hutchings   2009-06-10  336  		}
d005ba6cc82440 Ben Hutchings   2009-06-10  337  	}
1b1c2e95103ce3 Ben Hutchings   2009-04-29  338  }
1b1c2e95103ce3 Ben Hutchings   2009-04-29  339  EXPORT_SYMBOL(mdio45_ethtool_gset_npage);
1b1c2e95103ce3 Ben Hutchings   2009-04-29  340  
8e4881aa1d5d2f Philippe Reynes 2017-01-01  341  /**
8e4881aa1d5d2f Philippe Reynes 2017-01-01  342   * mdio45_ethtool_ksettings_get_npage - get settings for ETHTOOL_GLINKSETTINGS
8e4881aa1d5d2f Philippe Reynes 2017-01-01  343   * @mdio: MDIO interface
8e4881aa1d5d2f Philippe Reynes 2017-01-01  344   * @cmd: Ethtool request structure
8e4881aa1d5d2f Philippe Reynes 2017-01-01  345   * @npage_adv: Modes currently advertised on next pages
8e4881aa1d5d2f Philippe Reynes 2017-01-01  346   * @npage_lpa: Modes advertised by link partner on next pages
8e4881aa1d5d2f Philippe Reynes 2017-01-01  347   *
8e4881aa1d5d2f Philippe Reynes 2017-01-01  348   * The @cmd parameter is expected to have been cleared before calling
8e4881aa1d5d2f Philippe Reynes 2017-01-01  349   * mdio45_ethtool_ksettings_get_npage().
8e4881aa1d5d2f Philippe Reynes 2017-01-01  350   *
8e4881aa1d5d2f Philippe Reynes 2017-01-01  351   * Since the CSRs for auto-negotiation using next pages are not fully
8e4881aa1d5d2f Philippe Reynes 2017-01-01  352   * standardised, this function does not attempt to decode them.  The
8e4881aa1d5d2f Philippe Reynes 2017-01-01  353   * caller must pass them in.
8e4881aa1d5d2f Philippe Reynes 2017-01-01  354   */
8e4881aa1d5d2f Philippe Reynes 2017-01-01 @355  void mdio45_ethtool_ksettings_get_npage(const struct mdio_if_info *mdio,
8e4881aa1d5d2f Philippe Reynes 2017-01-01  356  					struct ethtool_link_ksettings *cmd,
8e4881aa1d5d2f Philippe Reynes 2017-01-01  357  					u32 npage_adv, u32 npage_lpa)
8e4881aa1d5d2f Philippe Reynes 2017-01-01  358  {
8e4881aa1d5d2f Philippe Reynes 2017-01-01  359  	int reg;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  360  	u32 speed, supported = 0, advertising = 0, lp_advertising = 0;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  361  
8e4881aa1d5d2f Philippe Reynes 2017-01-01  362  	BUILD_BUG_ON(MDIO_SUPPORTS_C22 != ETH_MDIO_SUPPORTS_C22);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  363  	BUILD_BUG_ON(MDIO_SUPPORTS_C45 != ETH_MDIO_SUPPORTS_C45);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  364  
8e4881aa1d5d2f Philippe Reynes 2017-01-01  365  	cmd->base.phy_address = mdio->prtad;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  366  	cmd->base.mdio_support =
8e4881aa1d5d2f Philippe Reynes 2017-01-01  367  		mdio->mode_support & (MDIO_SUPPORTS_C45 | MDIO_SUPPORTS_C22);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  368  
8e4881aa1d5d2f Philippe Reynes 2017-01-01  369  	reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
8e4881aa1d5d2f Philippe Reynes 2017-01-01  370  			      MDIO_CTRL2);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  371  	switch (reg & MDIO_PMA_CTRL2_TYPE) {
8e4881aa1d5d2f Philippe Reynes 2017-01-01  372  	case MDIO_PMA_CTRL2_10GBT:
8e4881aa1d5d2f Philippe Reynes 2017-01-01  373  	case MDIO_PMA_CTRL2_1000BT:
8e4881aa1d5d2f Philippe Reynes 2017-01-01  374  	case MDIO_PMA_CTRL2_100BTX:
8e4881aa1d5d2f Philippe Reynes 2017-01-01  375  	case MDIO_PMA_CTRL2_10BT:
8e4881aa1d5d2f Philippe Reynes 2017-01-01  376  		cmd->base.port = PORT_TP;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  377  		supported = SUPPORTED_TP;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  378  		reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
8e4881aa1d5d2f Philippe Reynes 2017-01-01  379  				      MDIO_SPEED);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  380  		if (reg & MDIO_SPEED_10G)
8e4881aa1d5d2f Philippe Reynes 2017-01-01  381  			supported |= SUPPORTED_10000baseT_Full;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  382  		if (reg & MDIO_PMA_SPEED_1000)
8e4881aa1d5d2f Philippe Reynes 2017-01-01  383  			supported |= (SUPPORTED_1000baseT_Full |
8e4881aa1d5d2f Philippe Reynes 2017-01-01  384  					    SUPPORTED_1000baseT_Half);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  385  		if (reg & MDIO_PMA_SPEED_100)
8e4881aa1d5d2f Philippe Reynes 2017-01-01  386  			supported |= (SUPPORTED_100baseT_Full |
8e4881aa1d5d2f Philippe Reynes 2017-01-01  387  					    SUPPORTED_100baseT_Half);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  388  		if (reg & MDIO_PMA_SPEED_10)
8e4881aa1d5d2f Philippe Reynes 2017-01-01  389  			supported |= (SUPPORTED_10baseT_Full |
8e4881aa1d5d2f Philippe Reynes 2017-01-01  390  					    SUPPORTED_10baseT_Half);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  391  		advertising = ADVERTISED_TP;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  392  		break;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  393  
8e4881aa1d5d2f Philippe Reynes 2017-01-01  394  	case MDIO_PMA_CTRL2_10GBCX4:
8e4881aa1d5d2f Philippe Reynes 2017-01-01  395  		cmd->base.port = PORT_OTHER;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  396  		supported = 0;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  397  		advertising = 0;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  398  		break;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  399  
8e4881aa1d5d2f Philippe Reynes 2017-01-01  400  	case MDIO_PMA_CTRL2_10GBKX4:
8e4881aa1d5d2f Philippe Reynes 2017-01-01  401  	case MDIO_PMA_CTRL2_10GBKR:
8e4881aa1d5d2f Philippe Reynes 2017-01-01  402  	case MDIO_PMA_CTRL2_1000BKX:
8e4881aa1d5d2f Philippe Reynes 2017-01-01  403  		cmd->base.port = PORT_OTHER;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  404  		supported = SUPPORTED_Backplane;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  405  		reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
8e4881aa1d5d2f Philippe Reynes 2017-01-01  406  				      MDIO_PMA_EXTABLE);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  407  		if (reg & MDIO_PMA_EXTABLE_10GBKX4)
8e4881aa1d5d2f Philippe Reynes 2017-01-01  408  			supported |= SUPPORTED_10000baseKX4_Full;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  409  		if (reg & MDIO_PMA_EXTABLE_10GBKR)
8e4881aa1d5d2f Philippe Reynes 2017-01-01  410  			supported |= SUPPORTED_10000baseKR_Full;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  411  		if (reg & MDIO_PMA_EXTABLE_1000BKX)
8e4881aa1d5d2f Philippe Reynes 2017-01-01  412  			supported |= SUPPORTED_1000baseKX_Full;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  413  		reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
8e4881aa1d5d2f Philippe Reynes 2017-01-01  414  				      MDIO_PMA_10GBR_FECABLE);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  415  		if (reg & MDIO_PMA_10GBR_FECABLE_ABLE)
8e4881aa1d5d2f Philippe Reynes 2017-01-01  416  			supported |= SUPPORTED_10000baseR_FEC;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  417  		advertising = ADVERTISED_Backplane;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  418  		break;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  419  
8e4881aa1d5d2f Philippe Reynes 2017-01-01  420  	/* All the other defined modes are flavours of optical */
8e4881aa1d5d2f Philippe Reynes 2017-01-01  421  	default:
8e4881aa1d5d2f Philippe Reynes 2017-01-01  422  		cmd->base.port = PORT_FIBRE;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  423  		supported = SUPPORTED_FIBRE;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  424  		advertising = ADVERTISED_FIBRE;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  425  		break;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  426  	}
8e4881aa1d5d2f Philippe Reynes 2017-01-01  427  
8e4881aa1d5d2f Philippe Reynes 2017-01-01  428  	if (mdio->mmds & MDIO_DEVS_AN) {
8e4881aa1d5d2f Philippe Reynes 2017-01-01  429  		supported |= SUPPORTED_Autoneg;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  430  		reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_AN,
8e4881aa1d5d2f Philippe Reynes 2017-01-01  431  				      MDIO_CTRL1);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  432  		if (reg & MDIO_AN_CTRL1_ENABLE) {
8e4881aa1d5d2f Philippe Reynes 2017-01-01  433  			cmd->base.autoneg = AUTONEG_ENABLE;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  434  			advertising |=
8e4881aa1d5d2f Philippe Reynes 2017-01-01  435  				ADVERTISED_Autoneg |
8e4881aa1d5d2f Philippe Reynes 2017-01-01  436  				mdio45_get_an(mdio, MDIO_AN_ADVERTISE) |
8e4881aa1d5d2f Philippe Reynes 2017-01-01  437  				npage_adv;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  438  		} else {
8e4881aa1d5d2f Philippe Reynes 2017-01-01  439  			cmd->base.autoneg = AUTONEG_DISABLE;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  440  		}
8e4881aa1d5d2f Philippe Reynes 2017-01-01  441  	} else {
8e4881aa1d5d2f Philippe Reynes 2017-01-01  442  		cmd->base.autoneg = AUTONEG_DISABLE;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  443  	}
8e4881aa1d5d2f Philippe Reynes 2017-01-01  444  
8e4881aa1d5d2f Philippe Reynes 2017-01-01  445  	if (cmd->base.autoneg) {
8e4881aa1d5d2f Philippe Reynes 2017-01-01  446  		u32 modes = 0;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  447  		int an_stat = mdio->mdio_read(mdio->dev, mdio->prtad,
8e4881aa1d5d2f Philippe Reynes 2017-01-01  448  					      MDIO_MMD_AN, MDIO_STAT1);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  449  
8e4881aa1d5d2f Philippe Reynes 2017-01-01  450  		/* If AN is complete and successful, report best common
8e4881aa1d5d2f Philippe Reynes 2017-01-01  451  		 * mode, otherwise report best advertised mode.
8e4881aa1d5d2f Philippe Reynes 2017-01-01  452  		 */
8e4881aa1d5d2f Philippe Reynes 2017-01-01  453  		if (an_stat & MDIO_AN_STAT1_COMPLETE) {
8e4881aa1d5d2f Philippe Reynes 2017-01-01  454  			lp_advertising =
8e4881aa1d5d2f Philippe Reynes 2017-01-01  455  				mdio45_get_an(mdio, MDIO_AN_LPA) | npage_lpa;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  456  			if (an_stat & MDIO_AN_STAT1_LPABLE)
8e4881aa1d5d2f Philippe Reynes 2017-01-01  457  				lp_advertising |= ADVERTISED_Autoneg;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  458  			modes = advertising & lp_advertising;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  459  		}
8e4881aa1d5d2f Philippe Reynes 2017-01-01  460  		if ((modes & ~ADVERTISED_Autoneg) == 0)
8e4881aa1d5d2f Philippe Reynes 2017-01-01  461  			modes = advertising;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  462  
8e4881aa1d5d2f Philippe Reynes 2017-01-01  463  		if (modes & (ADVERTISED_10000baseT_Full |
8e4881aa1d5d2f Philippe Reynes 2017-01-01  464  			     ADVERTISED_10000baseKX4_Full |
8e4881aa1d5d2f Philippe Reynes 2017-01-01  465  			     ADVERTISED_10000baseKR_Full)) {
8e4881aa1d5d2f Philippe Reynes 2017-01-01  466  			speed = SPEED_10000;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  467  			cmd->base.duplex = DUPLEX_FULL;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  468  		} else if (modes & (ADVERTISED_1000baseT_Full |
8e4881aa1d5d2f Philippe Reynes 2017-01-01  469  				    ADVERTISED_1000baseT_Half |
8e4881aa1d5d2f Philippe Reynes 2017-01-01  470  				    ADVERTISED_1000baseKX_Full)) {
8e4881aa1d5d2f Philippe Reynes 2017-01-01  471  			speed = SPEED_1000;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  472  			cmd->base.duplex = !(modes & ADVERTISED_1000baseT_Half);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  473  		} else if (modes & (ADVERTISED_100baseT_Full |
8e4881aa1d5d2f Philippe Reynes 2017-01-01  474  				    ADVERTISED_100baseT_Half)) {
8e4881aa1d5d2f Philippe Reynes 2017-01-01  475  			speed = SPEED_100;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  476  			cmd->base.duplex = !!(modes & ADVERTISED_100baseT_Full);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  477  		} else {
8e4881aa1d5d2f Philippe Reynes 2017-01-01  478  			speed = SPEED_10;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  479  			cmd->base.duplex = !!(modes & ADVERTISED_10baseT_Full);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  480  		}
8e4881aa1d5d2f Philippe Reynes 2017-01-01  481  	} else {
8e4881aa1d5d2f Philippe Reynes 2017-01-01  482  		/* Report forced settings */
8e4881aa1d5d2f Philippe Reynes 2017-01-01  483  		reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
8e4881aa1d5d2f Philippe Reynes 2017-01-01  484  				      MDIO_CTRL1);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  485  		speed = (((reg & MDIO_PMA_CTRL1_SPEED1000) ? 100 : 1)
8e4881aa1d5d2f Philippe Reynes 2017-01-01  486  			 * ((reg & MDIO_PMA_CTRL1_SPEED100) ? 100 : 10));
8e4881aa1d5d2f Philippe Reynes 2017-01-01  487  		cmd->base.duplex = (reg & MDIO_CTRL1_FULLDPLX ||
8e4881aa1d5d2f Philippe Reynes 2017-01-01  488  				    speed == SPEED_10000);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  489  	}
8e4881aa1d5d2f Philippe Reynes 2017-01-01  490  
8e4881aa1d5d2f Philippe Reynes 2017-01-01  491  	cmd->base.speed = speed;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  492  
8e4881aa1d5d2f Philippe Reynes 2017-01-01  493  	ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
8e4881aa1d5d2f Philippe Reynes 2017-01-01  494  						supported);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  495  	ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
8e4881aa1d5d2f Philippe Reynes 2017-01-01  496  						advertising);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  497  	ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.lp_advertising,
8e4881aa1d5d2f Philippe Reynes 2017-01-01  498  						lp_advertising);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  499  
8e4881aa1d5d2f Philippe Reynes 2017-01-01  500  	/* 10GBASE-T MDI/MDI-X */
8e4881aa1d5d2f Philippe Reynes 2017-01-01  501  	if (cmd->base.port == PORT_TP && (cmd->base.speed == SPEED_10000)) {
8e4881aa1d5d2f Philippe Reynes 2017-01-01  502  		switch (mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
8e4881aa1d5d2f Philippe Reynes 2017-01-01  503  					MDIO_PMA_10GBT_SWAPPOL)) {
8e4881aa1d5d2f Philippe Reynes 2017-01-01  504  		case MDIO_PMA_10GBT_SWAPPOL_ABNX | MDIO_PMA_10GBT_SWAPPOL_CDNX:
8e4881aa1d5d2f Philippe Reynes 2017-01-01  505  			cmd->base.eth_tp_mdix = ETH_TP_MDI;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  506  			break;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  507  		case 0:
8e4881aa1d5d2f Philippe Reynes 2017-01-01  508  			cmd->base.eth_tp_mdix = ETH_TP_MDI_X;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  509  			break;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  510  		default:
8e4881aa1d5d2f Philippe Reynes 2017-01-01  511  			/* It's complicated... */
8e4881aa1d5d2f Philippe Reynes 2017-01-01  512  			cmd->base.eth_tp_mdix = ETH_TP_MDI_INVALID;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  513  			break;
8e4881aa1d5d2f Philippe Reynes 2017-01-01  514  		}
8e4881aa1d5d2f Philippe Reynes 2017-01-01  515  	}
8e4881aa1d5d2f Philippe Reynes 2017-01-01  516  }
8e4881aa1d5d2f Philippe Reynes 2017-01-01  517  EXPORT_SYMBOL(mdio45_ethtool_ksettings_get_npage);
8e4881aa1d5d2f Philippe Reynes 2017-01-01  518  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH] include: mdio: Guard inline function with CONFIG_MDIO
Posted by Andrew Lunn 2 weeks, 5 days ago
On Mon, Nov 04, 2024 at 05:09:50PM +1000, Alistair Francis wrote:
> The static inline functions mdio45_ethtool_gset() and
> mdio45_ethtool_ksettings_get() call mdio45_ethtool_gset_npage() and
> mdio45_ethtool_ksettings_get_npage() which are both guarded by
> CONFIG_MDIO. So let's only expose mdio45_ethtool_gset() and
> mdio45_ethtool_ksettings_get() if CONFIG_MDIO is defined.

Why? Are you fixing a linker error? A compiler error?

In general, we don't want #ifdef if they are not necessary, because
they reduce the effectiveness of build testing.

	Andrew
Re: [PATCH] include: mdio: Guard inline function with CONFIG_MDIO
Posted by Alistair Francis 2 weeks, 5 days ago
On Mon, Nov 4, 2024 at 11:49 PM Andrew Lunn <andrew@lunn.ch> wrote:
>
> On Mon, Nov 04, 2024 at 05:09:50PM +1000, Alistair Francis wrote:
> > The static inline functions mdio45_ethtool_gset() and
> > mdio45_ethtool_ksettings_get() call mdio45_ethtool_gset_npage() and
> > mdio45_ethtool_ksettings_get_npage() which are both guarded by
> > CONFIG_MDIO. So let's only expose mdio45_ethtool_gset() and
> > mdio45_ethtool_ksettings_get() if CONFIG_MDIO is defined.
>
> Why? Are you fixing a linker error? A compiler error?

I'm investigating generating Rust bindings for static inline functions
(like mdio45_ethtool_gset() for example). But it fails to build when
there are functions defined in header files that call C functions that
aren't built due to Kconfig options.

This is one of those cases where mdio45_ethtool_gset() is always
included, but mdio45_ethtool_gset_npage() is conditionally built.

Alistair

>
> In general, we don't want #ifdef if they are not necessary, because
> they reduce the effectiveness of build testing.
>
>         Andrew
Re: [PATCH] include: mdio: Guard inline function with CONFIG_MDIO
Posted by Andrew Lunn 2 weeks, 5 days ago
On Tue, Nov 05, 2024 at 10:21:15AM +1000, Alistair Francis wrote:
> On Mon, Nov 4, 2024 at 11:49 PM Andrew Lunn <andrew@lunn.ch> wrote:
> >
> > On Mon, Nov 04, 2024 at 05:09:50PM +1000, Alistair Francis wrote:
> > > The static inline functions mdio45_ethtool_gset() and
> > > mdio45_ethtool_ksettings_get() call mdio45_ethtool_gset_npage() and
> > > mdio45_ethtool_ksettings_get_npage() which are both guarded by
> > > CONFIG_MDIO. So let's only expose mdio45_ethtool_gset() and
> > > mdio45_ethtool_ksettings_get() if CONFIG_MDIO is defined.
> >
> > Why? Are you fixing a linker error? A compiler error?
> 
> I'm investigating generating Rust bindings for static inline functions
> (like mdio45_ethtool_gset() for example). But it fails to build when
> there are functions defined in header files that call C functions that
> aren't built due to Kconfig options.

Since this does not appear to be an issue for C, i assume these
functions are not actually used in that configuration. And this is
probably not an issue specific to MDIO. It will probably appear all
over the kernel. Adding lots of #ifdef in header files will probably
not be liked.

Does Rust have the concept of inline functions? If it is never used,
it never gets compiled? Or at least, it gets optimised out before it
gets linked, which i think is your issue here.

	Andrew
Re: [PATCH] include: mdio: Guard inline function with CONFIG_MDIO
Posted by Alistair Francis 2 weeks, 5 days ago
On Tue, Nov 5, 2024 at 10:37 AM Andrew Lunn <andrew@lunn.ch> wrote:
>
> On Tue, Nov 05, 2024 at 10:21:15AM +1000, Alistair Francis wrote:
> > On Mon, Nov 4, 2024 at 11:49 PM Andrew Lunn <andrew@lunn.ch> wrote:
> > >
> > > On Mon, Nov 04, 2024 at 05:09:50PM +1000, Alistair Francis wrote:
> > > > The static inline functions mdio45_ethtool_gset() and
> > > > mdio45_ethtool_ksettings_get() call mdio45_ethtool_gset_npage() and
> > > > mdio45_ethtool_ksettings_get_npage() which are both guarded by
> > > > CONFIG_MDIO. So let's only expose mdio45_ethtool_gset() and
> > > > mdio45_ethtool_ksettings_get() if CONFIG_MDIO is defined.
> > >
> > > Why? Are you fixing a linker error? A compiler error?
> >
> > I'm investigating generating Rust bindings for static inline functions
> > (like mdio45_ethtool_gset() for example). But it fails to build when
> > there are functions defined in header files that call C functions that
> > aren't built due to Kconfig options.
>
> Since this does not appear to be an issue for C, i assume these
> functions are not actually used in that configuration. And this is
> probably not an issue specific to MDIO. It will probably appear all
> over the kernel. Adding lots of #ifdef in header files will probably
> not be liked.

It's not actually a Rust issue, it's a problem with linking.

This is the type of errors I get

```
ld: vmlinux.o: in function `mdio45_ethtool_gset':
/scratch/alistair/software/linux/./include/linux/mdio.h:189:(.text+0x59e819):
undefined reference to `mdio45_ethtool_gset_npage'
ld: vmlinux.o: in function `mdio45_ethtool_ksettings_get':
/scratch/alistair/software/linux/./include/linux/mdio.h:206:(.text+0x59e839):
undefined reference to `mdio45_ethtool_ksettings_get_npage'
make[2]: *** [scripts/Makefile.vmlinux:34: vmlinux] Error 1
```

Which comes from autogenerated C code like this

```
void mdio45_ethtool_gset__extern(const struct mdio_if_info *mdio,
struct ethtool_cmd *ecmd) { mdio45_ethtool_gset(mdio, ecmd); }
```

mdio45_ethtool_gset__extern() is never called, so I'm not clear why
it's not optimised out.

It's not only MDIO that hits this, but so far there aren't too many
cases. That will obviously depend on the config used though.

There will be issues like this over the kernel. I'm not sure fixing
them all is the right approach as it might be too much work and too
hard to narrow down all occurance. But to me it seems like the corect
fix as the current code is calling a function that might not exist,
hence the patch :)

If it's not something that we think should be fixed then that's fine,
I can work around it.

Alistair

>
> Does Rust have the concept of inline functions? If it is never used,
> it never gets compiled? Or at least, it gets optimised out before it
> gets linked, which i think is your issue here.
>
>         Andrew
Re: [PATCH] include: mdio: Guard inline function with CONFIG_MDIO
Posted by Andrew Lunn 2 weeks, 5 days ago
> Which comes from autogenerated C code like this
> 
> ```
> void mdio45_ethtool_gset__extern(const struct mdio_if_info *mdio,
> struct ethtool_cmd *ecmd) { mdio45_ethtool_gset(mdio, ecmd); }
> ```
> 
> mdio45_ethtool_gset__extern() is never called, so I'm not clear why
> it's not optimised out.

I think you need to understand this first, before deciding on the path
forward.
 
> It's not only MDIO that hits this, but so far there aren't too many
> cases. That will obviously depend on the config used though.
> 
> There will be issues like this over the kernel. I'm not sure fixing
> them all is the right approach as it might be too much work and too
> hard to narrow down all occurance.

Actually, that is mostly just CPU cycles. There are build bots which
make builds with random configurations. Arnd Bergmann has one such
bot, for example. Systems like that will find the issues for you.

> But to me it seems like the correct
> fix as the current code is calling a function that might not exist,
> hence the patch :)

As 0-day has shown, another build bot, your patch is not correct and
causes problems. You can try again, but maybe first dig into the
linker.

Humm, interesting. I don't actually find anything calling
mdio45_ethtool_gset(). So you might be able to just remove it.  And
then i think you can remove mdio45_ethtool_gset_npage(). But i might
be wrong...

	Andrew
Re: [PATCH] include: mdio: Guard inline function with CONFIG_MDIO
Posted by kernel test robot 2 weeks, 5 days ago
Hi Alistair,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on horms-ipvs/master v6.12-rc6 next-20241104]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Alistair-Francis/include-mdio-Guard-inline-function-with-CONFIG_MDIO/20241104-151211
base:   linus/master
patch link:    https://lore.kernel.org/r/20241104070950.502719-1-alistair.francis%40wdc.com
patch subject: [PATCH] include: mdio: Guard inline function with CONFIG_MDIO
config: parisc-allmodconfig (https://download.01.org/0day-ci/archive/20241104/202411042121.OYNPibb0-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241104/202411042121.OYNPibb0-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411042121.OYNPibb0-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/net/ethernet/sfc/falcon/qt202x_phy.c: In function 'qt202x_phy_get_link_ksettings':
>> drivers/net/ethernet/sfc/falcon/qt202x_phy.c:440:9: error: implicit declaration of function 'mdio45_ethtool_ksettings_get' [-Wimplicit-function-declaration]
     440 |         mdio45_ethtool_ksettings_get(&efx->mdio, cmd);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
   drivers/net/ethernet/sfc/falcon/tenxpress.c: In function 'tenxpress_get_link_ksettings':
>> drivers/net/ethernet/sfc/falcon/tenxpress.c:453:9: error: implicit declaration of function 'mdio45_ethtool_ksettings_get_npage' [-Wimplicit-function-declaration]
     453 |         mdio45_ethtool_ksettings_get_npage(&efx->mdio, cmd, adv, lpa);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
   drivers/net/ethernet/sfc/falcon/txc43128_phy.c: In function 'txc43128_get_link_ksettings':
>> drivers/net/ethernet/sfc/falcon/txc43128_phy.c:543:9: error: implicit declaration of function 'mdio45_ethtool_ksettings_get' [-Wimplicit-function-declaration]
     543 |         mdio45_ethtool_ksettings_get(&efx->mdio, cmd);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/mdio45_ethtool_ksettings_get +440 drivers/net/ethernet/sfc/falcon/qt202x_phy.c

8ceee660aacb29 drivers/net/sfc/xfp_phy.c                    Ben Hutchings   2008-04-27  436  
e938ed150f1ed9 drivers/net/ethernet/sfc/falcon/qt202x_phy.c Philippe Reynes 2017-01-01  437  static void qt202x_phy_get_link_ksettings(struct ef4_nic *efx,
e938ed150f1ed9 drivers/net/ethernet/sfc/falcon/qt202x_phy.c Philippe Reynes 2017-01-01  438  					  struct ethtool_link_ksettings *cmd)
68e7f45e118f98 drivers/net/sfc/xfp_phy.c                    Ben Hutchings   2009-04-29  439  {
e938ed150f1ed9 drivers/net/ethernet/sfc/falcon/qt202x_phy.c Philippe Reynes 2017-01-01 @440  	mdio45_ethtool_ksettings_get(&efx->mdio, cmd);
68e7f45e118f98 drivers/net/sfc/xfp_phy.c                    Ben Hutchings   2009-04-29  441  }
8ceee660aacb29 drivers/net/sfc/xfp_phy.c                    Ben Hutchings   2008-04-27  442  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki