Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ptp_clock: Allow for it to be optional

In order to break the hard dependency between the PTP clock subsystem and
ethernet drivers capable of being clock providers, this patch provides
simple PTP stub functions to allow linkage of those drivers into the
kernel even when the PTP subsystem is configured out. Drivers must be
ready to accept NULL from ptp_clock_register() in that case.

And to make it possible for PTP to be configured out, the select statement
in those driver's Kconfig menu entries is converted to the new "imply"
statement. This way the PTP subsystem may have Kconfig dependencies of
its own, such as POSIX_TIMERS, without having to make those ethernet
drivers unavailable if POSIX timers are cconfigured out. And when support
for POSIX timers is selected again then the default config option for PTP
clock support will automatically be adjusted accordingly.

The pch_gbe driver is a bit special as it relies on extra code in
drivers/ptp/ptp_pch.c. Therefore we let the make process descend into
drivers/ptp/ even if PTP_1588_CLOCK is unselected.

Signed-off-by: Nicolas Pitre <nico@linaro.org>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Acked-by: Edward Cree <ecree@solarflare.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <john.stultz@linaro.org>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Cc: Paul Bolle <pebolle@tiscali.nl>
Cc: linux-kbuild@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: Michal Marek <mmarek@suse.com>
Link: http://lkml.kernel.org/r/1478841010-28605-4-git-send-email-nicolas.pitre@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Nicolas Pitre and committed by
Thomas Gleixner
d1cbfd77 32ce5ac8

+69 -50
+1 -1
drivers/Makefile
··· 107 107 obj-$(CONFIG_RTC_LIB) += rtc/ 108 108 obj-y += i2c/ media/ 109 109 obj-$(CONFIG_PPS) += pps/ 110 - obj-$(CONFIG_PTP_1588_CLOCK) += ptp/ 110 + obj-y += ptp/ 111 111 obj-$(CONFIG_W1) += w1/ 112 112 obj-y += power/ 113 113 obj-$(CONFIG_HWMON) += hwmon/
+1 -1
drivers/net/ethernet/adi/Kconfig
··· 58 58 config BFIN_MAC_USE_HWSTAMP 59 59 bool "Use IEEE 1588 hwstamp" 60 60 depends on BFIN_MAC && BF518 61 - select PTP_1588_CLOCK 61 + imply PTP_1588_CLOCK 62 62 default y 63 63 ---help--- 64 64 To support the IEEE 1588 Precision Time Protocol (PTP), select y here
+1 -1
drivers/net/ethernet/amd/Kconfig
··· 177 177 depends on ARM64 || COMPILE_TEST 178 178 select BITREVERSE 179 179 select CRC32 180 - select PTP_1588_CLOCK 180 + imply PTP_1588_CLOCK 181 181 ---help--- 182 182 This driver supports the AMD 10GbE Ethernet device found on an 183 183 AMD SoC.
+4 -2
drivers/net/ethernet/amd/xgbe/xgbe-main.c
··· 773 773 goto err_wq; 774 774 } 775 775 776 - xgbe_ptp_register(pdata); 776 + if (IS_REACHABLE(CONFIG_PTP_1588_CLOCK)) 777 + xgbe_ptp_register(pdata); 777 778 778 779 xgbe_debugfs_init(pdata); 779 780 ··· 813 812 814 813 xgbe_debugfs_exit(pdata); 815 814 816 - xgbe_ptp_unregister(pdata); 815 + if (IS_REACHABLE(CONFIG_PTP_1588_CLOCK)) 816 + xgbe_ptp_unregister(pdata); 817 817 818 818 flush_workqueue(pdata->an_workqueue); 819 819 destroy_workqueue(pdata->an_workqueue);
+2 -2
drivers/net/ethernet/broadcom/Kconfig
··· 110 110 depends on PCI 111 111 select PHYLIB 112 112 select HWMON 113 - select PTP_1588_CLOCK 113 + imply PTP_1588_CLOCK 114 114 ---help--- 115 115 This driver supports Broadcom Tigon3 based gigabit Ethernet cards. 116 116 ··· 120 120 config BNX2X 121 121 tristate "Broadcom NetXtremeII 10Gb support" 122 122 depends on PCI 123 - select PTP_1588_CLOCK 123 + imply PTP_1588_CLOCK 124 124 select FW_LOADER 125 125 select ZLIB_INFLATE 126 126 select LIBCRC32C
+1 -1
drivers/net/ethernet/cavium/Kconfig
··· 53 53 config LIQUIDIO 54 54 tristate "Cavium LiquidIO support" 55 55 depends on 64BIT 56 - select PTP_1588_CLOCK 56 + imply PTP_1588_CLOCK 57 57 select FW_LOADER 58 58 select LIBCRC32C 59 59 ---help---
+1 -1
drivers/net/ethernet/freescale/Kconfig
··· 25 25 ARCH_MXC || SOC_IMX28) 26 26 default ARCH_MXC || SOC_IMX28 if ARM 27 27 select PHYLIB 28 - select PTP_1588_CLOCK 28 + imply PTP_1588_CLOCK 29 29 ---help--- 30 30 Say Y here if you want to use the built-in 10/100 Fast ethernet 31 31 controller on some Motorola ColdFire and Freescale i.MX processors.
+5 -5
drivers/net/ethernet/intel/Kconfig
··· 58 58 tristate "Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support" 59 59 depends on PCI && (!SPARC32 || BROKEN) 60 60 select CRC32 61 - select PTP_1588_CLOCK 61 + imply PTP_1588_CLOCK 62 62 ---help--- 63 63 This driver supports the PCI-Express Intel(R) PRO/1000 gigabit 64 64 ethernet family of adapters. For PCI or PCI-X e1000 adapters, ··· 83 83 config IGB 84 84 tristate "Intel(R) 82575/82576 PCI-Express Gigabit Ethernet support" 85 85 depends on PCI 86 - select PTP_1588_CLOCK 86 + imply PTP_1588_CLOCK 87 87 select I2C 88 88 select I2C_ALGOBIT 89 89 ---help--- ··· 156 156 tristate "Intel(R) 10GbE PCI Express adapters support" 157 157 depends on PCI 158 158 select MDIO 159 - select PTP_1588_CLOCK 159 + imply PTP_1588_CLOCK 160 160 ---help--- 161 161 This driver supports Intel(R) 10GbE PCI Express family of 162 162 adapters. For more information on how to identify your adapter, go ··· 213 213 214 214 config I40E 215 215 tristate "Intel(R) Ethernet Controller XL710 Family support" 216 - select PTP_1588_CLOCK 216 + imply PTP_1588_CLOCK 217 217 depends on PCI 218 218 ---help--- 219 219 This driver supports Intel(R) Ethernet Controller XL710 Family of ··· 264 264 tristate "Intel(R) FM10000 Ethernet Switch Host Interface Support" 265 265 default n 266 266 depends on PCI_MSI 267 - select PTP_1588_CLOCK 267 + imply PTP_1588_CLOCK 268 268 ---help--- 269 269 This driver supports Intel(R) FM10000 Ethernet Switch Host 270 270 Interface. For more information on how to identify your adapter,
+1 -1
drivers/net/ethernet/mellanox/mlx4/Kconfig
··· 7 7 depends on MAY_USE_DEVLINK 8 8 depends on PCI 9 9 select MLX4_CORE 10 - select PTP_1588_CLOCK 10 + imply PTP_1588_CLOCK 11 11 ---help--- 12 12 This driver supports Mellanox Technologies ConnectX Ethernet 13 13 devices.
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/Kconfig
··· 14 14 config MLX5_CORE_EN 15 15 bool "Mellanox Technologies ConnectX-4 Ethernet support" 16 16 depends on NETDEVICES && ETHERNET && PCI && MLX5_CORE 17 - select PTP_1588_CLOCK 17 + imply PTP_1588_CLOCK 18 18 default n 19 19 ---help--- 20 20 Ethernet support in Mellanox Technologies ConnectX-4 NIC.
+1 -1
drivers/net/ethernet/renesas/Kconfig
··· 37 37 select MII 38 38 select MDIO_BITBANG 39 39 select PHYLIB 40 - select PTP_1588_CLOCK 40 + imply PTP_1588_CLOCK 41 41 help 42 42 Renesas Ethernet AVB device driver. 43 43 This driver supports the following SoCs:
+1 -1
drivers/net/ethernet/samsung/Kconfig
··· 21 21 depends on HAS_IOMEM && HAS_DMA 22 22 select PHYLIB 23 23 select CRC32 24 - select PTP_1588_CLOCK 24 + imply PTP_1588_CLOCK 25 25 ---help--- 26 26 This is the driver for the SXGBE 10G Ethernet IP block found on 27 27 Samsung platforms.
+1 -1
drivers/net/ethernet/sfc/Kconfig
··· 5 5 select CRC32 6 6 select I2C 7 7 select I2C_ALGOBIT 8 - select PTP_1588_CLOCK 8 + imply PTP_1588_CLOCK 9 9 ---help--- 10 10 This driver supports 10/40-gigabit Ethernet cards based on 11 11 the Solarflare SFC4000, SFC9000-family and SFC9100-family
+1 -1
drivers/net/ethernet/stmicro/stmmac/Kconfig
··· 4 4 select MII 5 5 select PHYLIB 6 6 select CRC32 7 - select PTP_1588_CLOCK 7 + imply PTP_1588_CLOCK 8 8 select RESET_CONTROLLER 9 9 ---help--- 10 10 This is the driver for the Ethernet IPs are built around a
+1 -1
drivers/net/ethernet/ti/Kconfig
··· 76 76 config TI_CPTS 77 77 bool "TI Common Platform Time Sync (CPTS) Support" 78 78 depends on TI_CPSW 79 - select PTP_1588_CLOCK 79 + imply PTP_1588_CLOCK 80 80 ---help--- 81 81 This driver supports the Common Platform Time Sync unit of 82 82 the CPSW Ethernet Switch. The unit can time stamp PTP UDP/IPv4
+1 -1
drivers/net/ethernet/tile/Kconfig
··· 9 9 select CRC32 10 10 select TILE_GXIO_MPIPE if TILEGX 11 11 select HIGH_RES_TIMERS if TILEGX 12 - select PTP_1588_CLOCK if TILEGX 12 + imply PTP_1588_CLOCK if TILEGX 13 13 ---help--- 14 14 This is a standard Linux network device driver for the 15 15 on-chip Tilera Gigabit Ethernet and XAUI interfaces.
+4 -4
drivers/ptp/Kconfig
··· 28 28 config PTP_1588_CLOCK_GIANFAR 29 29 tristate "Freescale eTSEC as PTP clock" 30 30 depends on GIANFAR 31 - select PTP_1588_CLOCK 31 + depends on PTP_1588_CLOCK 32 32 default y 33 33 help 34 34 This driver adds support for using the eTSEC as a PTP ··· 42 42 config PTP_1588_CLOCK_IXP46X 43 43 tristate "Intel IXP46x as PTP clock" 44 44 depends on IXP4XX_ETH 45 - select PTP_1588_CLOCK 45 + depends on PTP_1588_CLOCK 46 46 default y 47 47 help 48 48 This driver adds support for using the IXP46X as a PTP ··· 60 60 tristate "Driver for the National Semiconductor DP83640 PHYTER" 61 61 depends on NETWORK_PHY_TIMESTAMPING 62 62 depends on PHYLIB 63 - select PTP_1588_CLOCK 63 + depends on PTP_1588_CLOCK 64 64 ---help--- 65 65 Supports the DP83640 PHYTER with IEEE 1588 features. 66 66 ··· 76 76 tristate "Intel PCH EG20T as PTP clock" 77 77 depends on X86_32 || COMPILE_TEST 78 78 depends on HAS_IOMEM && NET 79 - select PTP_1588_CLOCK 79 + imply PTP_1588_CLOCK 80 80 help 81 81 This driver adds support for using the PCH EG20T as a PTP 82 82 clock. The hardware supports time stamping of PTP packets
+41 -24
include/linux/ptp_clock_kernel.h
··· 122 122 123 123 struct ptp_clock; 124 124 125 - /** 126 - * ptp_clock_register() - register a PTP hardware clock driver 127 - * 128 - * @info: Structure describing the new clock. 129 - * @parent: Pointer to the parent device of the new clock. 130 - * 131 - * Returns a valid pointer on success or PTR_ERR on failure. If PHC 132 - * support is missing at the configuration level, this function 133 - * returns NULL, and drivers are expected to gracefully handle that 134 - * case separately. 135 - */ 136 - 137 - extern struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info, 138 - struct device *parent); 139 - 140 - /** 141 - * ptp_clock_unregister() - unregister a PTP hardware clock driver 142 - * 143 - * @ptp: The clock to remove from service. 144 - */ 145 - 146 - extern int ptp_clock_unregister(struct ptp_clock *ptp); 147 - 148 - 149 125 enum ptp_clock_events { 150 126 PTP_CLOCK_ALARM, 151 127 PTP_CLOCK_EXTTS, ··· 146 170 struct pps_event_time pps_times; 147 171 }; 148 172 }; 173 + 174 + #if IS_REACHABLE(CONFIG_PTP_1588_CLOCK) 175 + 176 + /** 177 + * ptp_clock_register() - register a PTP hardware clock driver 178 + * 179 + * @info: Structure describing the new clock. 180 + * @parent: Pointer to the parent device of the new clock. 181 + * 182 + * Returns a valid pointer on success or PTR_ERR on failure. If PHC 183 + * support is missing at the configuration level, this function 184 + * returns NULL, and drivers are expected to gracefully handle that 185 + * case separately. 186 + */ 187 + 188 + extern struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info, 189 + struct device *parent); 190 + 191 + /** 192 + * ptp_clock_unregister() - unregister a PTP hardware clock driver 193 + * 194 + * @ptp: The clock to remove from service. 195 + */ 196 + 197 + extern int ptp_clock_unregister(struct ptp_clock *ptp); 149 198 150 199 /** 151 200 * ptp_clock_event() - notify the PTP layer about an event ··· 202 201 203 202 int ptp_find_pin(struct ptp_clock *ptp, 204 203 enum ptp_pin_function func, unsigned int chan); 204 + 205 + #else 206 + static inline struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info, 207 + struct device *parent) 208 + { return NULL; } 209 + static inline int ptp_clock_unregister(struct ptp_clock *ptp) 210 + { return 0; } 211 + static inline void ptp_clock_event(struct ptp_clock *ptp, 212 + struct ptp_clock_event *event) 213 + { } 214 + static inline int ptp_clock_index(struct ptp_clock *ptp) 215 + { return -1; } 216 + static inline int ptp_find_pin(struct ptp_clock *ptp, 217 + enum ptp_pin_function func, unsigned int chan) 218 + { return -1; } 219 + #endif 205 220 206 221 #endif