diff --git a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c index 23006a1f..40b86baa 100644 --- a/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c +++ b/drivers/net/ethernet/nvidia/nvethernet/ether_linux.c @@ -2477,12 +2477,14 @@ static int ether_mdio_read(struct mii_bus *bus, int phyaddr, int phyreg) (unsigned int)phyreg); } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) +#if defined(NV_MII_BUS_STRUCT_HAS_WRITE_C45) /* Linux v6.3 */ static int ether_mdio_write_c45(struct mii_bus *bus, int phyaddr, int devad, int regnum, u16 val) { return ether_mdio_write(bus, phyaddr, ether_mdio_c45_addr(devad, regnum), val); } +#endif +#if defined(NV_MII_BUS_STRUCT_HAS_READ_C45) /* Linux v6.3 */ static int ether_mdio_read_c45(struct mii_bus *bus, int phyaddr, int devad, int regnum) { return ether_mdio_read(bus, phyaddr, ether_mdio_c45_addr(devad, regnum)); @@ -2521,8 +2523,10 @@ static int ether_mdio_register(struct ether_priv_data *pdata) new_bus->name = "nvethernet_mdio_bus"; new_bus->read = ether_mdio_read; new_bus->write = ether_mdio_write; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) +#if defined(NV_MII_BUS_STRUCT_HAS_READ_C45) /* Linux v6.3 */ new_bus->read_c45 = ether_mdio_read_c45; +#endif +#if defined(NV_MII_BUS_STRUCT_HAS_WRITE_C45) /* Linux v6.3 */ new_bus->write_c45 = ether_mdio_write_c45; #endif ret = snprintf(new_bus->id, MII_BUS_ID_SIZE, "%s", dev_name(dev)); diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index 462c1a5a..c6ff7b07 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -116,6 +116,8 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages NV_CONFTEST_FUNCTION_COMPILE_TESTS += iio_dev_opaque_has_mlock NV_CONFTEST_FUNCTION_COMPILE_TESTS += iommu_map_has_gfp_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += kthread_complete_and_exit +NV_CONFTEST_FUNCTION_COMPILE_TESTS += mii_bus_struct_has_read_c45 +NV_CONFTEST_FUNCTION_COMPILE_TESTS += mii_bus_struct_has_write_c45 NV_CONFTEST_FUNCTION_COMPILE_TESTS += netif_set_tso_max_size NV_CONFTEST_FUNCTION_COMPILE_TESTS += netif_napi_add_weight NV_CONFTEST_FUNCTION_COMPILE_TESTS += pde_data diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index e686765c..fde017e8 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -6896,6 +6896,40 @@ compile_test() { compile_check_conftest "$CODE" "NV_KTHREAD_COMPLETE_AND_EXIT_PRESENT" "" "functions" ;; + mii_bus_struct_has_read_c45) + # + # Determine if the 'mii_bus' structure has 'read_c45' field. + # + # Added in commit 4e4aafcddbbf ("net: mdio: Add dedicated C45 API to + # MDIO bus drivers") in Linux v6.3. + # + + CODE=" + #include + int conftest_mii_bus_struct_has_read_c45(void) { + return offsetof(struct mii_bus, read_c45); + }" + + compile_check_conftest "$CODE" "NV_MII_BUS_STRUCT_HAS_READ_C45" "" "types" + ;; + + mii_bus_struct_has_write_c45) + # + # Determine if the 'mii_bus' structure has 'write_c45' field. + # + # Added in commit 4e4aafcddbbf ("net: mdio: Add dedicated C45 API to + # MDIO bus drivers") in Linux v6.3. + # + + CODE=" + #include + int conftest_mii_bus_struct_has_read_c45(void) { + return offsetof(struct mii_bus, write_c45); + }" + + compile_check_conftest "$CODE" "NV_MII_BUS_STRUCT_HAS_WRITE_C45" "" "types" + ;; + register_shrinker_has_fmt_arg) # # Determine if the 'register_shrinker' function