Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a24006ed authored by Ben Hutchings's avatar Ben Hutchings Committed by David S. Miller
Browse files

ptp: Enable clock drivers along with associated net/PHY drivers



Where a PTP clock driver is associated with a net or PHY driver, it
should be enabled automatically whenever that driver is enabled.
Therefore:

- Make PTP clock drivers select rather than depending on PTP_1588_CLOCK
- Remove separate boolean options for PTP clock drivers that are built
  as part of net driver modules.  (This also fixes cases where the PTP
  subsystem is wrongly forced to be built-in.)
- Set 'default y' for PTP clock drivers that depend on specific net
  drivers but are built separately

Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 42a7ccef
Loading
Loading
Loading
Loading
+2 −24
Original line number Original line Diff line number Diff line
@@ -93,6 +93,7 @@ config E1000E
config IGB
config IGB
	tristate "Intel(R) 82575/82576 PCI-Express Gigabit Ethernet support"
	tristate "Intel(R) 82575/82576 PCI-Express Gigabit Ethernet support"
	depends on PCI
	depends on PCI
	select PTP_1588_CLOCK
	---help---
	---help---
	  This driver supports Intel(R) 82575/82576 gigabit ethernet family of
	  This driver supports Intel(R) 82575/82576 gigabit ethernet family of
	  adapters.  For more information on how to identify your adapter, go
	  adapters.  For more information on how to identify your adapter, go
@@ -120,18 +121,6 @@ config IGB_DCA
	  driver.  DCA is a method for warming the CPU cache before data
	  driver.  DCA is a method for warming the CPU cache before data
	  is used, with the intent of lessening the impact of cache misses.
	  is used, with the intent of lessening the impact of cache misses.


config IGB_PTP
	bool "PTP Hardware Clock (PHC)"
	default n
	depends on IGB
	select PTP_1588_CLOCK
	---help---
	  Say Y here if you want to use PTP Hardware Clock (PHC) in the
	  driver.  Only the basic clock operations have been implemented.

	  Every timestamp and clock read operations must consult the
	  overflow counter to form a correct time value.

config IGBVF
config IGBVF
	tristate "Intel(R) 82576 Virtual Function Ethernet support"
	tristate "Intel(R) 82576 Virtual Function Ethernet support"
	depends on PCI
	depends on PCI
@@ -179,6 +168,7 @@ config IXGBE
	tristate "Intel(R) 10GbE PCI Express adapters support"
	tristate "Intel(R) 10GbE PCI Express adapters support"
	depends on PCI && INET
	depends on PCI && INET
	select MDIO
	select MDIO
	select PTP_1588_CLOCK
	---help---
	---help---
	  This driver supports Intel(R) 10GbE PCI Express family of
	  This driver supports Intel(R) 10GbE PCI Express family of
	  adapters.  For more information on how to identify your adapter, go
	  adapters.  For more information on how to identify your adapter, go
@@ -221,18 +211,6 @@ config IXGBE_DCB


	  If unsure, say N.
	  If unsure, say N.


config IXGBE_PTP
	bool "PTP Clock Support"
	default n
	depends on IXGBE
	select PTP_1588_CLOCK
	---help---
	  Say Y here if you want support for 1588 Timestamping with a
	  PHC device, using the PTP 1588 Clock support. This is
	  required to enable timestamping support for the device.

	  If unsure, say N.

config IXGBEVF
config IXGBEVF
	tristate "Intel(R) 82599 Virtual Function Ethernet support"
	tristate "Intel(R) 82599 Virtual Function Ethernet support"
	depends on PCI_MSI
	depends on PCI_MSI
+1 −3
Original line number Original line Diff line number Diff line
@@ -34,6 +34,4 @@ obj-$(CONFIG_IGB) += igb.o


igb-objs := igb_main.o igb_ethtool.o e1000_82575.o \
igb-objs := igb_main.o igb_ethtool.o e1000_82575.o \
	    e1000_mac.o e1000_nvm.o e1000_phy.o e1000_mbx.o \
	    e1000_mac.o e1000_nvm.o e1000_phy.o e1000_mbx.o \
	    e1000_i210.o
	    e1000_i210.o igb_ptp.o

igb-$(CONFIG_IGB_PTP) += igb_ptp.o
+0 −6
Original line number Original line Diff line number Diff line
@@ -34,11 +34,9 @@
#include "e1000_mac.h"
#include "e1000_mac.h"
#include "e1000_82575.h"
#include "e1000_82575.h"


#ifdef CONFIG_IGB_PTP
#include <linux/clocksource.h>
#include <linux/clocksource.h>
#include <linux/net_tstamp.h>
#include <linux/net_tstamp.h>
#include <linux/ptp_clock_kernel.h>
#include <linux/ptp_clock_kernel.h>
#endif /* CONFIG_IGB_PTP */
#include <linux/bitops.h>
#include <linux/bitops.h>
#include <linux/if_vlan.h>
#include <linux/if_vlan.h>


@@ -376,7 +374,6 @@ struct igb_adapter {
	u32 wvbr;
	u32 wvbr;
	u32 *shadow_vfta;
	u32 *shadow_vfta;


#ifdef CONFIG_IGB_PTP
	struct ptp_clock *ptp_clock;
	struct ptp_clock *ptp_clock;
	struct ptp_clock_info ptp_caps;
	struct ptp_clock_info ptp_caps;
	struct delayed_work ptp_overflow_work;
	struct delayed_work ptp_overflow_work;
@@ -385,7 +382,6 @@ struct igb_adapter {
	spinlock_t tmreg_lock;
	spinlock_t tmreg_lock;
	struct cyclecounter cc;
	struct cyclecounter cc;
	struct timecounter tc;
	struct timecounter tc;
#endif /* CONFIG_IGB_PTP */


	char fw_version[32];
	char fw_version[32];
};
};
@@ -439,7 +435,6 @@ extern bool igb_has_link(struct igb_adapter *adapter);
extern void igb_set_ethtool_ops(struct net_device *);
extern void igb_set_ethtool_ops(struct net_device *);
extern void igb_power_up_link(struct igb_adapter *);
extern void igb_power_up_link(struct igb_adapter *);
extern void igb_set_fw_version(struct igb_adapter *);
extern void igb_set_fw_version(struct igb_adapter *);
#ifdef CONFIG_IGB_PTP
extern void igb_ptp_init(struct igb_adapter *adapter);
extern void igb_ptp_init(struct igb_adapter *adapter);
extern void igb_ptp_stop(struct igb_adapter *adapter);
extern void igb_ptp_stop(struct igb_adapter *adapter);
extern void igb_ptp_reset(struct igb_adapter *adapter);
extern void igb_ptp_reset(struct igb_adapter *adapter);
@@ -461,7 +456,6 @@ static inline void igb_ptp_rx_hwtstamp(struct igb_q_vector *q_vector,


extern int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
extern int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
				  struct ifreq *ifr, int cmd);
				  struct ifreq *ifr, int cmd);
#endif /* CONFIG_IGB_PTP */


static inline s32 igb_reset_phy(struct e1000_hw *hw)
static inline s32 igb_reset_phy(struct e1000_hw *hw)
{
{
+0 −2
Original line number Original line Diff line number Diff line
@@ -2310,7 +2310,6 @@ static int igb_get_ts_info(struct net_device *dev,
	struct igb_adapter *adapter = netdev_priv(dev);
	struct igb_adapter *adapter = netdev_priv(dev);


	switch (adapter->hw.mac.type) {
	switch (adapter->hw.mac.type) {
#ifdef CONFIG_IGB_PTP
	case e1000_82576:
	case e1000_82576:
	case e1000_82580:
	case e1000_82580:
	case e1000_i350:
	case e1000_i350:
@@ -2346,7 +2345,6 @@ static int igb_get_ts_info(struct net_device *dev,
				(1 << HWTSTAMP_FILTER_PTP_V2_EVENT);
				(1 << HWTSTAMP_FILTER_PTP_V2_EVENT);


		return 0;
		return 0;
#endif /* CONFIG_IGB_PTP */
	default:
	default:
		return -EOPNOTSUPP;
		return -EOPNOTSUPP;
	}
	}
+0 −28
Original line number Original line Diff line number Diff line
@@ -1708,10 +1708,8 @@ void igb_reset(struct igb_adapter *adapter)
	/* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
	/* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
	wr32(E1000_VET, ETHERNET_IEEE_VLAN_TYPE);
	wr32(E1000_VET, ETHERNET_IEEE_VLAN_TYPE);


#ifdef CONFIG_IGB_PTP
	/* Re-enable PTP, where applicable. */
	/* Re-enable PTP, where applicable. */
	igb_ptp_reset(adapter);
	igb_ptp_reset(adapter);
#endif /* CONFIG_IGB_PTP */


	igb_get_phy_info(hw);
	igb_get_phy_info(hw);
}
}
@@ -2119,10 +2117,8 @@ static int __devinit igb_probe(struct pci_dev *pdev,


#endif
#endif


#ifdef CONFIG_IGB_PTP
	/* do hw tstamp init after resetting */
	/* do hw tstamp init after resetting */
	igb_ptp_init(adapter);
	igb_ptp_init(adapter);
#endif /* CONFIG_IGB_PTP */


	dev_info(&pdev->dev, "Intel(R) Gigabit Ethernet Network Connection\n");
	dev_info(&pdev->dev, "Intel(R) Gigabit Ethernet Network Connection\n");
	/* print bus type/speed/width info */
	/* print bus type/speed/width info */
@@ -2197,9 +2193,7 @@ static void __devexit igb_remove(struct pci_dev *pdev)
	struct e1000_hw *hw = &adapter->hw;
	struct e1000_hw *hw = &adapter->hw;


	pm_runtime_get_noresume(&pdev->dev);
	pm_runtime_get_noresume(&pdev->dev);
#ifdef CONFIG_IGB_PTP
	igb_ptp_stop(adapter);
	igb_ptp_stop(adapter);
#endif /* CONFIG_IGB_PTP */


	/*
	/*
	 * The watchdog timer may be rescheduled, so explicitly
	 * The watchdog timer may be rescheduled, so explicitly
@@ -3095,10 +3089,8 @@ void igb_configure_rx_ring(struct igb_adapter *adapter,
	srrctl = IGB_RX_HDR_LEN << E1000_SRRCTL_BSIZEHDRSIZE_SHIFT;
	srrctl = IGB_RX_HDR_LEN << E1000_SRRCTL_BSIZEHDRSIZE_SHIFT;
	srrctl |= IGB_RX_BUFSZ >> E1000_SRRCTL_BSIZEPKT_SHIFT;
	srrctl |= IGB_RX_BUFSZ >> E1000_SRRCTL_BSIZEPKT_SHIFT;
	srrctl |= E1000_SRRCTL_DESCTYPE_ADV_ONEBUF;
	srrctl |= E1000_SRRCTL_DESCTYPE_ADV_ONEBUF;
#ifdef CONFIG_IGB_PTP
	if (hw->mac.type >= e1000_82580)
	if (hw->mac.type >= e1000_82580)
		srrctl |= E1000_SRRCTL_TIMESTAMP;
		srrctl |= E1000_SRRCTL_TIMESTAMP;
#endif /* CONFIG_IGB_PTP */
	/* Only set Drop Enable if we are supporting multiple queues */
	/* Only set Drop Enable if we are supporting multiple queues */
	if (adapter->vfs_allocated_count || adapter->num_rx_queues > 1)
	if (adapter->vfs_allocated_count || adapter->num_rx_queues > 1)
		srrctl |= E1000_SRRCTL_DROP_EN;
		srrctl |= E1000_SRRCTL_DROP_EN;
@@ -4134,11 +4126,9 @@ static __le32 igb_tx_cmd_type(u32 tx_flags)
	if (tx_flags & IGB_TX_FLAGS_VLAN)
	if (tx_flags & IGB_TX_FLAGS_VLAN)
		cmd_type |= cpu_to_le32(E1000_ADVTXD_DCMD_VLE);
		cmd_type |= cpu_to_le32(E1000_ADVTXD_DCMD_VLE);


#ifdef CONFIG_IGB_PTP
	/* set timestamp bit if present */
	/* set timestamp bit if present */
	if (unlikely(tx_flags & IGB_TX_FLAGS_TSTAMP))
	if (unlikely(tx_flags & IGB_TX_FLAGS_TSTAMP))
		cmd_type |= cpu_to_le32(E1000_ADVTXD_MAC_TSTAMP);
		cmd_type |= cpu_to_le32(E1000_ADVTXD_MAC_TSTAMP);
#endif /* CONFIG_IGB_PTP */


	/* set segmentation bits for TSO */
	/* set segmentation bits for TSO */
	if (tx_flags & IGB_TX_FLAGS_TSO)
	if (tx_flags & IGB_TX_FLAGS_TSO)
@@ -4347,9 +4337,7 @@ static inline int igb_maybe_stop_tx(struct igb_ring *tx_ring, const u16 size)
netdev_tx_t igb_xmit_frame_ring(struct sk_buff *skb,
netdev_tx_t igb_xmit_frame_ring(struct sk_buff *skb,
				struct igb_ring *tx_ring)
				struct igb_ring *tx_ring)
{
{
#ifdef CONFIG_IGB_PTP
	struct igb_adapter *adapter = netdev_priv(tx_ring->netdev);
	struct igb_adapter *adapter = netdev_priv(tx_ring->netdev);
#endif /* CONFIG_IGB_PTP */
	struct igb_tx_buffer *first;
	struct igb_tx_buffer *first;
	int tso;
	int tso;
	u32 tx_flags = 0;
	u32 tx_flags = 0;
@@ -4372,7 +4360,6 @@ netdev_tx_t igb_xmit_frame_ring(struct sk_buff *skb,
	first->bytecount = skb->len;
	first->bytecount = skb->len;
	first->gso_segs = 1;
	first->gso_segs = 1;


#ifdef CONFIG_IGB_PTP
	if (unlikely((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) &&
	if (unlikely((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) &&
		     !(adapter->ptp_tx_skb))) {
		     !(adapter->ptp_tx_skb))) {
		skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
		skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
@@ -4382,7 +4369,6 @@ netdev_tx_t igb_xmit_frame_ring(struct sk_buff *skb,
		if (adapter->hw.mac.type == e1000_82576)
		if (adapter->hw.mac.type == e1000_82576)
			schedule_work(&adapter->ptp_tx_work);
			schedule_work(&adapter->ptp_tx_work);
	}
	}
#endif /* CONFIG_IGB_PTP */


	if (vlan_tx_tag_present(skb)) {
	if (vlan_tx_tag_present(skb)) {
		tx_flags |= IGB_TX_FLAGS_VLAN;
		tx_flags |= IGB_TX_FLAGS_VLAN;
@@ -4776,7 +4762,6 @@ static irqreturn_t igb_msix_other(int irq, void *data)
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
	}
	}


#ifdef CONFIG_IGB_PTP
	if (icr & E1000_ICR_TS) {
	if (icr & E1000_ICR_TS) {
		u32 tsicr = rd32(E1000_TSICR);
		u32 tsicr = rd32(E1000_TSICR);


@@ -4787,7 +4772,6 @@ static irqreturn_t igb_msix_other(int irq, void *data)
			schedule_work(&adapter->ptp_tx_work);
			schedule_work(&adapter->ptp_tx_work);
		}
		}
	}
	}
#endif /* CONFIG_IGB_PTP */


	wr32(E1000_EIMS, adapter->eims_other);
	wr32(E1000_EIMS, adapter->eims_other);


@@ -5539,7 +5523,6 @@ static irqreturn_t igb_intr_msi(int irq, void *data)
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
	}
	}


#ifdef CONFIG_IGB_PTP
	if (icr & E1000_ICR_TS) {
	if (icr & E1000_ICR_TS) {
		u32 tsicr = rd32(E1000_TSICR);
		u32 tsicr = rd32(E1000_TSICR);


@@ -5550,7 +5533,6 @@ static irqreturn_t igb_intr_msi(int irq, void *data)
			schedule_work(&adapter->ptp_tx_work);
			schedule_work(&adapter->ptp_tx_work);
		}
		}
	}
	}
#endif /* CONFIG_IGB_PTP */


	napi_schedule(&q_vector->napi);
	napi_schedule(&q_vector->napi);


@@ -5593,7 +5575,6 @@ static irqreturn_t igb_intr(int irq, void *data)
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
	}
	}


#ifdef CONFIG_IGB_PTP
	if (icr & E1000_ICR_TS) {
	if (icr & E1000_ICR_TS) {
		u32 tsicr = rd32(E1000_TSICR);
		u32 tsicr = rd32(E1000_TSICR);


@@ -5604,7 +5585,6 @@ static irqreturn_t igb_intr(int irq, void *data)
			schedule_work(&adapter->ptp_tx_work);
			schedule_work(&adapter->ptp_tx_work);
		}
		}
	}
	}
#endif /* CONFIG_IGB_PTP */


	napi_schedule(&q_vector->napi);
	napi_schedule(&q_vector->napi);


@@ -5889,14 +5869,12 @@ static bool igb_add_rx_frag(struct igb_ring *rx_ring,
	if ((size <= IGB_RX_HDR_LEN) && !skb_is_nonlinear(skb)) {
	if ((size <= IGB_RX_HDR_LEN) && !skb_is_nonlinear(skb)) {
		unsigned char *va = page_address(page) + rx_buffer->page_offset;
		unsigned char *va = page_address(page) + rx_buffer->page_offset;


#ifdef CONFIG_IGB_PTP
		if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP)) {
		if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP)) {
			igb_ptp_rx_pktstamp(rx_ring->q_vector, va, skb);
			igb_ptp_rx_pktstamp(rx_ring->q_vector, va, skb);
			va += IGB_TS_HDR_LEN;
			va += IGB_TS_HDR_LEN;
			size -= IGB_TS_HDR_LEN;
			size -= IGB_TS_HDR_LEN;
		}
		}


#endif
		memcpy(__skb_put(skb, size), va, ALIGN(size, sizeof(long)));
		memcpy(__skb_put(skb, size), va, ALIGN(size, sizeof(long)));


		/* we can reuse buffer as-is, just make sure it is local */
		/* we can reuse buffer as-is, just make sure it is local */
@@ -6221,7 +6199,6 @@ static void igb_pull_tail(struct igb_ring *rx_ring,
	 */
	 */
	va = skb_frag_address(frag);
	va = skb_frag_address(frag);


#ifdef CONFIG_IGB_PTP
	if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP)) {
	if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP)) {
		/* retrieve timestamp from buffer */
		/* retrieve timestamp from buffer */
		igb_ptp_rx_pktstamp(rx_ring->q_vector, va, skb);
		igb_ptp_rx_pktstamp(rx_ring->q_vector, va, skb);
@@ -6236,7 +6213,6 @@ static void igb_pull_tail(struct igb_ring *rx_ring,
		va += IGB_TS_HDR_LEN;
		va += IGB_TS_HDR_LEN;
	}
	}


#endif
	/*
	/*
	 * we need the header to contain the greater of either ETH_HLEN or
	 * we need the header to contain the greater of either ETH_HLEN or
	 * 60 bytes if the skb->len is less than 60 for skb_pad.
	 * 60 bytes if the skb->len is less than 60 for skb_pad.
@@ -6317,9 +6293,7 @@ static void igb_process_skb_fields(struct igb_ring *rx_ring,


	igb_rx_checksum(rx_ring, rx_desc, skb);
	igb_rx_checksum(rx_ring, rx_desc, skb);


#ifdef CONFIG_IGB_PTP
	igb_ptp_rx_hwtstamp(rx_ring->q_vector, rx_desc, skb);
	igb_ptp_rx_hwtstamp(rx_ring->q_vector, rx_desc, skb);
#endif /* CONFIG_IGB_PTP */


	if ((dev->features & NETIF_F_HW_VLAN_RX) &&
	if ((dev->features & NETIF_F_HW_VLAN_RX) &&
	    igb_test_staterr(rx_desc, E1000_RXD_STAT_VP)) {
	    igb_test_staterr(rx_desc, E1000_RXD_STAT_VP)) {
@@ -6553,10 +6527,8 @@ static int igb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
	case SIOCGMIIREG:
	case SIOCGMIIREG:
	case SIOCSMIIREG:
	case SIOCSMIIREG:
		return igb_mii_ioctl(netdev, ifr, cmd);
		return igb_mii_ioctl(netdev, ifr, cmd);
#ifdef CONFIG_IGB_PTP
	case SIOCSHWTSTAMP:
	case SIOCSHWTSTAMP:
		return igb_ptp_hwtstamp_ioctl(netdev, ifr, cmd);
		return igb_ptp_hwtstamp_ioctl(netdev, ifr, cmd);
#endif /* CONFIG_IGB_PTP */
	default:
	default:
		return -EOPNOTSUPP;
		return -EOPNOTSUPP;
	}
	}
Loading