netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05
@ 2019-06-05 20:23 Jeff Kirsher
  2019-06-05 20:23 ` [net-next 01/15] ixgbe: add tracking of AF_XDP zero-copy state for each queue pair Jeff Kirsher
                   ` (15 more replies)
  0 siblings, 16 replies; 21+ messages in thread
From: Jeff Kirsher @ 2019-06-05 20:23 UTC (permalink / raw)
  To: davem; +Cc: Jeff Kirsher, netdev, nhorman, sassmann

This series contains updates to mainly ixgbe, with a few updates to
i40e, net, ice and hns2 driver.

Jan adds support for tracking each queue pair for whether or not AF_XDP
zero copy is enabled.  Also updated the ixgbe driver to use the
netdev-provided umems so that we do not need to contain these structures
in our own adapter structure.

William Tu provides two fixes for AF_XDP statistics which were causing
incorrect counts.

Jake reduces the PTP transmit timestamp timeout from 15 seconds to 1 second,
which is still well after the maximum expected delay.  Also fixes an
issues with the PTP SDP pin setup which was not properly aligning on a
full second, so updated the code to account for the cyclecounter
multiplier and simplify the code to make the intent of the calculations
more clear.  Updated the function header comments to help with the code
documentation.  Added support for SDP/PPS output for x550 devices, which
is slightly different than x540 devices that currently have this
support.

Anirudh adds a new define for Link Layer Discovery Protocol to the
networking core, so that drivers do not have to create and use their own
definitions.  In addition, update all the drivers currently defining
their own LLDP define to use the new networking core define.

The following are changes since commit 11694b03616b2a03cd7e3f0897d4d086c7fbc4b5:
  net: fec_ptp: Use dev_err() instead of pr_err()
and are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue 10GbE

Anirudh Venkataramanan (4):
  net: Add a define for LLDP ethertype
  i40e: Use LLDP ethertype define ETH_P_LLDP
  ixgbe: Use LLDP ethertype define ETH_P_LLDP
  net: hns3: Use LLDP ethertype define ETH_P_LLDP

Jacob Keller (5):
  ixgbe: reduce PTP Tx timestamp timeout to 1 second
  ixgbe: fix PTP SDP pin setup on X540 hardware
  ixgbe: use 'cc' instead of 'hw_cc' for local variable
  ixgbe: add a kernel documentation comment for ixgbe_ptp_get_ts_config
  ixgbe: implement support for SDP/PPS output on X550 hardware

Jan Sokolowski (2):
  ixgbe: add tracking of AF_XDP zero-copy state for each queue pair
  ixgbe: remove umem from adapter

Jeff Kirsher (1):
  ice: Use LLDP ethertype define ETH_P_LLDP

Kangjie Lu (1):
  net: ixgbevf: fix a missing check of ixgbevf_write_msg_read_ack

William Tu (2):
  ixgbe: fix AF_XDP tx byte count
  ixgbe: fix AF_XDP tx packet count

 .../hisilicon/hns3/hns3pf/hclge_cmd.h         |   1 -
 .../hisilicon/hns3/hns3pf/hclge_main.c        |   2 +-
 drivers/net/ethernet/intel/i40e/i40e.h        |   2 -
 .../net/ethernet/intel/i40e/i40e_debugfs.c    |   4 +-
 drivers/net/ethernet/intel/ice/ice_lib.c      |   4 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe.h      |  14 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |   6 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c  | 187 ++++++++++++++----
 .../net/ethernet/intel/ixgbe/ixgbe_sriov.c    |   2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_type.h |  14 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c  |  82 ++------
 drivers/net/ethernet/intel/ixgbevf/vf.c       |   5 +-
 include/uapi/linux/if_ether.h                 |   1 +
 13 files changed, 200 insertions(+), 124 deletions(-)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [net-next 01/15] ixgbe: add tracking of AF_XDP zero-copy state for each queue pair
  2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
@ 2019-06-05 20:23 ` Jeff Kirsher
  2019-06-05 20:23 ` [net-next 02/15] ixgbe: remove umem from adapter Jeff Kirsher
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Jeff Kirsher @ 2019-06-05 20:23 UTC (permalink / raw)
  To: davem
  Cc: Jan Sokolowski, netdev, nhorman, sassmann, Andrew Bowers, Jeff Kirsher

From: Jan Sokolowski <jan.sokolowski@intel.com>

Here, we add a bitmap to the ixgbe_adapter that tracks if a
certain queue pair has been "zero-copy enabled" via the ndo_bpf.
The bitmap is used in ixgbe_xsk_umem, and enables zero-copy if
and only if XDP is enabled, the corresponding qid in the bitmap
is set, and the umem is non-NULL;

Signed-off-by: Jan Sokolowski <jan.sokolowski@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe.h      | 1 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 ++++++
 drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c  | 5 ++++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index 08d85e336bd4..5f5db6eb261e 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -635,6 +635,7 @@ struct ixgbe_adapter {
 	/* XDP */
 	int num_xdp_queues;
 	struct ixgbe_ring *xdp_ring[MAX_XDP_QUEUES];
+	unsigned long *af_xdp_zc_qps; /* tracks AF_XDP ZC enabled rings */
 
 	/* TX */
 	struct ixgbe_ring *tx_ring[MAX_TX_QUEUES] ____cacheline_aligned_in_smp;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 57fd9ee6de66..b613e72c8ee4 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -6288,6 +6288,10 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter,
 	if (ixgbe_init_rss_key(adapter))
 		return -ENOMEM;
 
+	adapter->af_xdp_zc_qps = bitmap_zalloc(MAX_XDP_QUEUES, GFP_KERNEL);
+	if (!adapter->af_xdp_zc_qps)
+		return -ENOMEM;
+
 	/* Set MAC specific capability flags and exceptions */
 	switch (hw->mac.type) {
 	case ixgbe_mac_82598EB:
@@ -11161,6 +11165,7 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	kfree(adapter->jump_tables[0]);
 	kfree(adapter->mac_table);
 	kfree(adapter->rss_key);
+	bitmap_free(adapter->af_xdp_zc_qps);
 err_ioremap:
 	disable_dev = !test_and_set_bit(__IXGBE_DISABLED, &adapter->state);
 	free_netdev(netdev);
@@ -11249,6 +11254,7 @@ static void ixgbe_remove(struct pci_dev *pdev)
 
 	kfree(adapter->mac_table);
 	kfree(adapter->rss_key);
+	bitmap_free(adapter->af_xdp_zc_qps);
 	disable_dev = !test_and_set_bit(__IXGBE_DISABLED, &adapter->state);
 	free_netdev(netdev);
 
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
index bfe95ce0bd7f..b9f05fbdbf67 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
@@ -15,7 +15,8 @@ struct xdp_umem *ixgbe_xsk_umem(struct ixgbe_adapter *adapter,
 	int qid = ring->ring_idx;
 
 	if (!adapter->xsk_umems || !adapter->xsk_umems[qid] ||
-	    qid >= adapter->num_xsk_umems || !xdp_on)
+	    qid >= adapter->num_xsk_umems || !xdp_on ||
+	    !test_bit(qid, adapter->af_xdp_zc_qps))
 		return NULL;
 
 	return adapter->xsk_umems[qid];
@@ -143,6 +144,7 @@ static int ixgbe_xsk_umem_enable(struct ixgbe_adapter *adapter,
 	if (if_running)
 		ixgbe_txrx_ring_disable(adapter, qid);
 
+	set_bit(qid, adapter->af_xdp_zc_qps);
 	err = ixgbe_add_xsk_umem(adapter, umem, qid);
 	if (err)
 		return err;
@@ -173,6 +175,7 @@ static int ixgbe_xsk_umem_disable(struct ixgbe_adapter *adapter, u16 qid)
 	if (if_running)
 		ixgbe_txrx_ring_disable(adapter, qid);
 
+	clear_bit(qid, adapter->af_xdp_zc_qps);
 	ixgbe_xsk_umem_dma_unmap(adapter, adapter->xsk_umems[qid]);
 	ixgbe_remove_xsk_umem(adapter, qid);
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [net-next 02/15] ixgbe: remove umem from adapter
  2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
  2019-06-05 20:23 ` [net-next 01/15] ixgbe: add tracking of AF_XDP zero-copy state for each queue pair Jeff Kirsher
@ 2019-06-05 20:23 ` Jeff Kirsher
  2019-06-05 20:23 ` [net-next 03/15] ixgbe: fix AF_XDP tx byte count Jeff Kirsher
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Jeff Kirsher @ 2019-06-05 20:23 UTC (permalink / raw)
  To: davem
  Cc: Jan Sokolowski, netdev, nhorman, sassmann, Andrew Bowers, Jeff Kirsher

From: Jan Sokolowski <jan.sokolowski@intel.com>

As current implementation of netdev already contains and provides
umems for us, we no longer have the need to contain these
structures in ixgbe_adapter.

Refactor the code to operate on netdev-provided umems.

Signed-off-by: Jan Sokolowski <jan.sokolowski@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe.h     | 11 +--
 drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 79 ++++----------------
 2 files changed, 19 insertions(+), 71 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index 5f5db6eb261e..aa923d6d596b 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -775,11 +775,6 @@ struct ixgbe_adapter {
 #ifdef CONFIG_IXGBE_IPSEC
 	struct ixgbe_ipsec *ipsec;
 #endif /* CONFIG_IXGBE_IPSEC */
-
-	/* AF_XDP zero-copy */
-	struct xdp_umem **xsk_umems;
-	u16 num_xsk_umems_used;
-	u16 num_xsk_umems;
 };
 
 static inline u8 ixgbe_max_rss_indices(struct ixgbe_adapter *adapter)
@@ -1040,4 +1035,10 @@ static inline int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter,
 static inline int ixgbe_ipsec_vf_del_sa(struct ixgbe_adapter *adapter,
 					u32 *mbuf, u32 vf) { return -EACCES; }
 #endif /* CONFIG_IXGBE_IPSEC */
+
+static inline bool ixgbe_enabled_xdp_adapter(struct ixgbe_adapter *adapter)
+{
+	return !!adapter->xdp_prog;
+}
+
 #endif /* _IXGBE_H_ */
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
index b9f05fbdbf67..f7cc13d7eb2c 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
@@ -14,58 +14,10 @@ struct xdp_umem *ixgbe_xsk_umem(struct ixgbe_adapter *adapter,
 	bool xdp_on = READ_ONCE(adapter->xdp_prog);
 	int qid = ring->ring_idx;
 
-	if (!adapter->xsk_umems || !adapter->xsk_umems[qid] ||
-	    qid >= adapter->num_xsk_umems || !xdp_on ||
-	    !test_bit(qid, adapter->af_xdp_zc_qps))
+	if (!xdp_on || !test_bit(qid, adapter->af_xdp_zc_qps))
 		return NULL;
 
-	return adapter->xsk_umems[qid];
-}
-
-static int ixgbe_alloc_xsk_umems(struct ixgbe_adapter *adapter)
-{
-	if (adapter->xsk_umems)
-		return 0;
-
-	adapter->num_xsk_umems_used = 0;
-	adapter->num_xsk_umems = adapter->num_rx_queues;
-	adapter->xsk_umems = kcalloc(adapter->num_xsk_umems,
-				     sizeof(*adapter->xsk_umems),
-				     GFP_KERNEL);
-	if (!adapter->xsk_umems) {
-		adapter->num_xsk_umems = 0;
-		return -ENOMEM;
-	}
-
-	return 0;
-}
-
-static int ixgbe_add_xsk_umem(struct ixgbe_adapter *adapter,
-			      struct xdp_umem *umem,
-			      u16 qid)
-{
-	int err;
-
-	err = ixgbe_alloc_xsk_umems(adapter);
-	if (err)
-		return err;
-
-	adapter->xsk_umems[qid] = umem;
-	adapter->num_xsk_umems_used++;
-
-	return 0;
-}
-
-static void ixgbe_remove_xsk_umem(struct ixgbe_adapter *adapter, u16 qid)
-{
-	adapter->xsk_umems[qid] = NULL;
-	adapter->num_xsk_umems_used--;
-
-	if (adapter->num_xsk_umems == 0) {
-		kfree(adapter->xsk_umems);
-		adapter->xsk_umems = NULL;
-		adapter->num_xsk_umems = 0;
-	}
+	return xdp_get_umem_from_qid(adapter->netdev, qid);
 }
 
 static int ixgbe_xsk_umem_dma_map(struct ixgbe_adapter *adapter,
@@ -114,6 +66,7 @@ static int ixgbe_xsk_umem_enable(struct ixgbe_adapter *adapter,
 				 struct xdp_umem *umem,
 				 u16 qid)
 {
+	struct net_device *netdev = adapter->netdev;
 	struct xdp_umem_fq_reuse *reuseq;
 	bool if_running;
 	int err;
@@ -121,12 +74,9 @@ static int ixgbe_xsk_umem_enable(struct ixgbe_adapter *adapter,
 	if (qid >= adapter->num_rx_queues)
 		return -EINVAL;
 
-	if (adapter->xsk_umems) {
-		if (qid >= adapter->num_xsk_umems)
-			return -EINVAL;
-		if (adapter->xsk_umems[qid])
-			return -EBUSY;
-	}
+	if (qid >= netdev->real_num_rx_queues ||
+	    qid >= netdev->real_num_tx_queues)
+		return -EINVAL;
 
 	reuseq = xsk_reuseq_prepare(adapter->rx_ring[0]->count);
 	if (!reuseq)
@@ -139,15 +89,12 @@ static int ixgbe_xsk_umem_enable(struct ixgbe_adapter *adapter,
 		return err;
 
 	if_running = netif_running(adapter->netdev) &&
-		     READ_ONCE(adapter->xdp_prog);
+		     ixgbe_enabled_xdp_adapter(adapter);
 
 	if (if_running)
 		ixgbe_txrx_ring_disable(adapter, qid);
 
 	set_bit(qid, adapter->af_xdp_zc_qps);
-	err = ixgbe_add_xsk_umem(adapter, umem, qid);
-	if (err)
-		return err;
 
 	if (if_running) {
 		ixgbe_txrx_ring_enable(adapter, qid);
@@ -163,21 +110,21 @@ static int ixgbe_xsk_umem_enable(struct ixgbe_adapter *adapter,
 
 static int ixgbe_xsk_umem_disable(struct ixgbe_adapter *adapter, u16 qid)
 {
+	struct xdp_umem *umem;
 	bool if_running;
 
-	if (!adapter->xsk_umems || qid >= adapter->num_xsk_umems ||
-	    !adapter->xsk_umems[qid])
+	umem = xdp_get_umem_from_qid(adapter->netdev, qid);
+	if (!umem)
 		return -EINVAL;
 
 	if_running = netif_running(adapter->netdev) &&
-		     READ_ONCE(adapter->xdp_prog);
+		     ixgbe_enabled_xdp_adapter(adapter);
 
 	if (if_running)
 		ixgbe_txrx_ring_disable(adapter, qid);
 
 	clear_bit(qid, adapter->af_xdp_zc_qps);
-	ixgbe_xsk_umem_dma_unmap(adapter, adapter->xsk_umems[qid]);
-	ixgbe_remove_xsk_umem(adapter, qid);
+	ixgbe_xsk_umem_dma_unmap(adapter, umem);
 
 	if (if_running)
 		ixgbe_txrx_ring_enable(adapter, qid);
@@ -756,7 +703,7 @@ int ixgbe_xsk_async_xmit(struct net_device *dev, u32 qid)
 	if (qid >= adapter->num_xdp_queues)
 		return -ENXIO;
 
-	if (!adapter->xsk_umems || !adapter->xsk_umems[qid])
+	if (!adapter->xdp_ring[qid]->xsk_umem)
 		return -ENXIO;
 
 	ring = adapter->xdp_ring[qid];
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [net-next 03/15] ixgbe: fix AF_XDP tx byte count
  2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
  2019-06-05 20:23 ` [net-next 01/15] ixgbe: add tracking of AF_XDP zero-copy state for each queue pair Jeff Kirsher
  2019-06-05 20:23 ` [net-next 02/15] ixgbe: remove umem from adapter Jeff Kirsher
@ 2019-06-05 20:23 ` Jeff Kirsher
  2019-06-05 20:23 ` [net-next 04/15] ixgbe: fix AF_XDP tx packet count Jeff Kirsher
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Jeff Kirsher @ 2019-06-05 20:23 UTC (permalink / raw)
  To: davem; +Cc: William Tu, netdev, nhorman, sassmann, Andrew Bowers, Jeff Kirsher

From: William Tu <u9012063@gmail.com>

The tx bytecount is done twice.  When running
'./xdpsock -t -N -i eth3' and 'ip -s link show dev eth3'
The avg packet size is 120 instead of 60. So remove the
extra one.

Signed-off-by: William Tu <u9012063@gmail.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
index f7cc13d7eb2c..90aa5825f500 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
@@ -654,7 +654,6 @@ bool ixgbe_clean_xdp_tx_irq(struct ixgbe_q_vector *q_vector,
 			xsk_frames++;
 
 		tx_bi->xdpf = NULL;
-		total_bytes += tx_bi->bytecount;
 
 		tx_bi++;
 		tx_desc++;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [net-next 04/15] ixgbe: fix AF_XDP tx packet count
  2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
                   ` (2 preceding siblings ...)
  2019-06-05 20:23 ` [net-next 03/15] ixgbe: fix AF_XDP tx byte count Jeff Kirsher
@ 2019-06-05 20:23 ` Jeff Kirsher
  2019-06-05 20:23 ` [net-next 05/15] ixgbe: reduce PTP Tx timestamp timeout to 1 second Jeff Kirsher
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Jeff Kirsher @ 2019-06-05 20:23 UTC (permalink / raw)
  To: davem; +Cc: William Tu, netdev, nhorman, sassmann, Andrew Bowers, Jeff Kirsher

From: William Tu <u9012063@gmail.com>

The total_packets count at ixgbe_clean_xdp_tx_irq is
always zero when testing with xdpsock -t -N. Set the gso_segs
to 1 to make the tx packet count correct.

Signed-off-by: William Tu <u9012063@gmail.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
index 90aa5825f500..6af55bb3bef3 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
@@ -590,6 +590,7 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget)
 		tx_bi = &xdp_ring->tx_buffer_info[xdp_ring->next_to_use];
 		tx_bi->bytecount = len;
 		tx_bi->xdpf = NULL;
+		tx_bi->gso_segs = 1;
 
 		tx_desc = IXGBE_TX_DESC(xdp_ring, xdp_ring->next_to_use);
 		tx_desc->read.buffer_addr = cpu_to_le64(dma);
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [net-next 05/15] ixgbe: reduce PTP Tx timestamp timeout to 1 second
  2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
                   ` (3 preceding siblings ...)
  2019-06-05 20:23 ` [net-next 04/15] ixgbe: fix AF_XDP tx packet count Jeff Kirsher
@ 2019-06-05 20:23 ` Jeff Kirsher
  2019-06-05 20:23 ` [net-next 06/15] ixgbe: fix PTP SDP pin setup on X540 hardware Jeff Kirsher
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Jeff Kirsher @ 2019-06-05 20:23 UTC (permalink / raw)
  To: davem
  Cc: Jacob Keller, netdev, nhorman, sassmann, Andrew Bowers, Jeff Kirsher

From: Jacob Keller <jacob.e.keller@intel.com>

Previously we waited for a whole 15 seconds before we cleared the Tx
timestamp state. This is astronomically long compared to the worst case
timings expected by our devices. In addition, this is longer than the
wait in ptp4l when it detects a fault (caused by missing Tx timestamps).
Thus, reduce the timer to only 1 second, which is well after the maximum
expected delay. This should reduce user frustration when a timestamp
does get dropped for some reason.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
index d81a50dc9535..dbe84a4d2f7f 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
@@ -72,7 +72,7 @@
 #define IXGBE_INCPER_SHIFT_82599 24
 
 #define IXGBE_OVERFLOW_PERIOD    (HZ * 30)
-#define IXGBE_PTP_TX_TIMEOUT     (HZ * 15)
+#define IXGBE_PTP_TX_TIMEOUT     (HZ)
 
 /* half of a one second clock period, for use with PPS signal. We have to use
  * this instead of something pre-defined like IXGBE_PTP_PPS_HALF_SECOND, in
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [net-next 06/15] ixgbe: fix PTP SDP pin setup on X540 hardware
  2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
                   ` (4 preceding siblings ...)
  2019-06-05 20:23 ` [net-next 05/15] ixgbe: reduce PTP Tx timestamp timeout to 1 second Jeff Kirsher
@ 2019-06-05 20:23 ` Jeff Kirsher
  2019-06-06  3:20   ` Richard Cochran
  2019-06-05 20:23 ` [net-next 07/15] ixgbe: use 'cc' instead of 'hw_cc' for local variable Jeff Kirsher
                   ` (9 subsequent siblings)
  15 siblings, 1 reply; 21+ messages in thread
From: Jeff Kirsher @ 2019-06-05 20:23 UTC (permalink / raw)
  To: davem
  Cc: Jacob Keller, netdev, nhorman, sassmann, Andrew Bowers, Jeff Kirsher

From: Jacob Keller <jacob.e.keller@intel.com>

The function ixgbe_ptp_setup_sdp_X540 attempts to program a software
defined pin, in order to generate a pulse-per-second output on SDP 0.

It does work to generate the output, but does not align the output on
the full second. Additionally, it does not take into account the
cyclecounter multiplier. This leads to somewhat confusing code which is
likely to be incorrect if blindly copied to another hardware type.

Update this code to account for the cyclecounter multiplier, and to
directly use timecounter_read.

This change ensures that the SDP output will align properly on a full
second, and makes the intent of the calculations a bit more clear.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 71 ++++++++++++--------
 1 file changed, 42 insertions(+), 29 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
index dbe84a4d2f7f..047767408df0 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
@@ -74,11 +74,11 @@
 #define IXGBE_OVERFLOW_PERIOD    (HZ * 30)
 #define IXGBE_PTP_TX_TIMEOUT     (HZ)
 
-/* half of a one second clock period, for use with PPS signal. We have to use
- * this instead of something pre-defined like IXGBE_PTP_PPS_HALF_SECOND, in
- * order to force at least 64bits of precision for shifting
+/* We use our own definitions instead of NSEC_PER_SEC because we want to mark
+ * the value as a ULL to force precision when bit shifting.
  */
-#define IXGBE_PTP_PPS_HALF_SECOND 500000000ULL
+#define NS_PER_SEC      1000000000ULL
+#define NS_PER_HALF_SEC  500000000ULL
 
 /* In contrast, the X550 controller has two registers, SYSTIMEH and SYSTIMEL
  * which contain measurements of seconds and nanoseconds respectively. This
@@ -141,23 +141,26 @@
 #define MAX_TIMADJ	0x7FFFFFFF
 
 /**
- * ixgbe_ptp_setup_sdp_x540
+ * ixgbe_ptp_setup_sdp_X540
  * @adapter: private adapter structure
  *
  * this function enables or disables the clock out feature on SDP0 for
- * the X540 device. It will create a 1second periodic output that can
+ * the X540 device. It will create a 1 second periodic output that can
  * be used as the PPS (via an interrupt).
  *
- * It calculates when the systime will be on an exact second, and then
- * aligns the start of the PPS signal to that value. The shift is
- * necessary because it can change based on the link speed.
+ * It calculates when the system time will be on an exact second, and then
+ * aligns the start of the PPS signal to that value.
+ *
+ * This works by using the cycle counter shift and mult values in reverse, and
+ * assumes that the values we're shifting will not overflow.
  */
-static void ixgbe_ptp_setup_sdp_x540(struct ixgbe_adapter *adapter)
+static void ixgbe_ptp_setup_sdp_X540(struct ixgbe_adapter *adapter)
 {
+	struct cyclecounter *cc = &adapter->hw_cc;
 	struct ixgbe_hw *hw = &adapter->hw;
-	int shift = adapter->hw_cc.shift;
 	u32 esdp, tsauxc, clktiml, clktimh, trgttiml, trgttimh, rem;
-	u64 ns = 0, clock_edge = 0;
+	u64 ns = 0, clock_edge = 0, clock_period;
+	unsigned long flags;
 
 	/* disable the pin first */
 	IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, 0x0);
@@ -177,26 +180,36 @@ static void ixgbe_ptp_setup_sdp_x540(struct ixgbe_adapter *adapter)
 	/* enable the Clock Out feature on SDP0, and allow
 	 * interrupts to occur when the pin changes
 	 */
-	tsauxc = IXGBE_TSAUXC_EN_CLK |
-		 IXGBE_TSAUXC_SYNCLK |
-		 IXGBE_TSAUXC_SDP0_INT;
-
-	/* clock period (or pulse length) */
-	clktiml = (u32)(IXGBE_PTP_PPS_HALF_SECOND << shift);
-	clktimh = (u32)((IXGBE_PTP_PPS_HALF_SECOND << shift) >> 32);
+	tsauxc = (IXGBE_TSAUXC_EN_CLK |
+		  IXGBE_TSAUXC_SYNCLK |
+		  IXGBE_TSAUXC_SDP0_INT);
 
-	/* Account for the cyclecounter wrap-around value by
-	 * using the converted ns value of the current time to
-	 * check for when the next aligned second would occur.
+	/* Determine the clock time period to use. This assumes that the
+	 * cycle counter shift is small enough to avoid overflow.
 	 */
-	clock_edge |= (u64)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
-	clock_edge |= (u64)IXGBE_READ_REG(hw, IXGBE_SYSTIMH) << 32;
-	ns = timecounter_cyc2time(&adapter->hw_tc, clock_edge);
+	clock_period = div_u64((NS_PER_HALF_SEC << cc->shift), cc->mult);
+	clktiml = (u32)(clock_period);
+	clktimh = (u32)(clock_period >> 32);
 
-	div_u64_rem(ns, IXGBE_PTP_PPS_HALF_SECOND, &rem);
-	clock_edge += ((IXGBE_PTP_PPS_HALF_SECOND - (u64)rem) << shift);
+	/* Read the current clock time, and save the cycle counter value */
+	spin_lock_irqsave(&adapter->tmreg_lock, flags);
+	ns = timecounter_read(&adapter->hw_tc);
+	clock_edge = adapter->hw_tc.cycle_last;
+	spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
 
-	/* specify the initial clock start time */
+	/* Figure out how many seconds to add in order to round up */
+	div_u64_rem(ns, NS_PER_SEC, &rem);
+
+	/* Figure out how many nanoseconds to add to round the clock edge up
+	 * to the next full second
+	 */
+	rem = (NS_PER_SEC - rem);
+
+	/* Adjust the clock edge to align with the next full second. This
+	 * assumes that the cycle counter shift is small enough to avoid
+	 * overflowing when shifting the remainder.
+	 */
+	clock_edge += div_u64((rem << cc->shift), cc->mult);
 	trgttiml = (u32)clock_edge;
 	trgttimh = (u32)(clock_edge >> 32);
 
@@ -1253,7 +1266,7 @@ static long ixgbe_ptp_create_clock(struct ixgbe_adapter *adapter)
 		adapter->ptp_caps.gettimex64 = ixgbe_ptp_gettimex;
 		adapter->ptp_caps.settime64 = ixgbe_ptp_settime;
 		adapter->ptp_caps.enable = ixgbe_ptp_feature_enable;
-		adapter->ptp_setup_sdp = ixgbe_ptp_setup_sdp_x540;
+		adapter->ptp_setup_sdp = ixgbe_ptp_setup_sdp_X540;
 		break;
 	case ixgbe_mac_82599EB:
 		snprintf(adapter->ptp_caps.name,
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [net-next 07/15] ixgbe: use 'cc' instead of 'hw_cc' for local variable
  2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
                   ` (5 preceding siblings ...)
  2019-06-05 20:23 ` [net-next 06/15] ixgbe: fix PTP SDP pin setup on X540 hardware Jeff Kirsher
@ 2019-06-05 20:23 ` Jeff Kirsher
  2019-06-05 20:23 ` [net-next 08/15] ixgbe: add a kernel documentation comment for ixgbe_ptp_get_ts_config Jeff Kirsher
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Jeff Kirsher @ 2019-06-05 20:23 UTC (permalink / raw)
  To: davem
  Cc: Jacob Keller, netdev, nhorman, sassmann, Andrew Bowers, Jeff Kirsher

From: Jacob Keller <jacob.e.keller@intel.com>

The ixgbe_ptp.c file sometimes uses hw_cc as the local variable for the
cycle counter in ixgbe_ptp_read_X550. However, we use just 'cc' as
a local variable for this by convention else where in the file.

Convert this lone usage of 'hw_cc' into just the shorter 'cc' name to
match the other read functions in the file.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
index 047767408df0..20f11ea641e2 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
@@ -226,7 +226,7 @@ static void ixgbe_ptp_setup_sdp_X540(struct ixgbe_adapter *adapter)
 
 /**
  * ixgbe_ptp_read_X550 - read cycle counter value
- * @hw_cc: cyclecounter structure
+ * @cc: cyclecounter structure
  *
  * This function reads SYSTIME registers. It is called by the cyclecounter
  * structure to convert from internal representation into nanoseconds. We need
@@ -234,10 +234,10 @@ static void ixgbe_ptp_setup_sdp_X540(struct ixgbe_adapter *adapter)
  * result of SYSTIME is 32bits of "billions of cycles" and 32 bits of
  * "cycles", rather than seconds and nanoseconds.
  */
-static u64 ixgbe_ptp_read_X550(const struct cyclecounter *hw_cc)
+static u64 ixgbe_ptp_read_X550(const struct cyclecounter *cc)
 {
 	struct ixgbe_adapter *adapter =
-			container_of(hw_cc, struct ixgbe_adapter, hw_cc);
+		container_of(cc, struct ixgbe_adapter, hw_cc);
 	struct ixgbe_hw *hw = &adapter->hw;
 	struct timespec64 ts;
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [net-next 08/15] ixgbe: add a kernel documentation comment for ixgbe_ptp_get_ts_config
  2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
                   ` (6 preceding siblings ...)
  2019-06-05 20:23 ` [net-next 07/15] ixgbe: use 'cc' instead of 'hw_cc' for local variable Jeff Kirsher
@ 2019-06-05 20:23 ` Jeff Kirsher
  2019-06-05 20:23 ` [net-next 09/15] net: Add a define for LLDP ethertype Jeff Kirsher
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Jeff Kirsher @ 2019-06-05 20:23 UTC (permalink / raw)
  To: davem
  Cc: Jacob Keller, netdev, nhorman, sassmann, Andrew Bowers, Jeff Kirsher

From: Jacob Keller <jacob.e.keller@intel.com>

This function was missing a documentation comment. Add one now.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
index 20f11ea641e2..376ad91d6a8d 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
@@ -851,6 +851,15 @@ void ixgbe_ptp_rx_rgtstamp(struct ixgbe_q_vector *q_vector,
 	ixgbe_ptp_convert_to_hwtstamp(adapter, skb_hwtstamps(skb), regval);
 }
 
+/**
+ * ixgbe_ptp_get_ts_config - get current hardware timestamping configuration
+ * @adapter: pointer to adapter structure
+ * @ifr: ioctl data
+ *
+ * This function returns the current timestamping settings. Rather than
+ * attempt to deconstruct registers to fill in the values, simply keep a copy
+ * of the old settings around, and return a copy when requested.
+ */
 int ixgbe_ptp_get_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr)
 {
 	struct hwtstamp_config *config = &adapter->tstamp_config;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [net-next 09/15] net: Add a define for LLDP ethertype
  2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
                   ` (7 preceding siblings ...)
  2019-06-05 20:23 ` [net-next 08/15] ixgbe: add a kernel documentation comment for ixgbe_ptp_get_ts_config Jeff Kirsher
@ 2019-06-05 20:23 ` Jeff Kirsher
  2019-06-05 20:23 ` [net-next 10/15] i40e: Use LLDP ethertype define ETH_P_LLDP Jeff Kirsher
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Jeff Kirsher @ 2019-06-05 20:23 UTC (permalink / raw)
  To: davem
  Cc: Anirudh Venkataramanan, netdev, nhorman, sassmann, Bruce Allan,
	Andrew Bowers, Jeff Kirsher

From: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>

Add a new define ETH_P_LLDP for Link Layer Discovery Protocol (LLDP)
ethertype.

Suggested-by: Bruce Allan <bruce.w.allan@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 include/uapi/linux/if_ether.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/if_ether.h b/include/uapi/linux/if_ether.h
index 3158ba672b72..f6ceb2e63d1e 100644
--- a/include/uapi/linux/if_ether.h
+++ b/include/uapi/linux/if_ether.h
@@ -91,6 +91,7 @@
 #define ETH_P_802_EX1	0x88B5		/* 802.1 Local Experimental 1.  */
 #define ETH_P_PREAUTH	0x88C7		/* 802.11 Preauthentication */
 #define ETH_P_TIPC	0x88CA		/* TIPC 			*/
+#define ETH_P_LLDP	0x88CC		/* Link Layer Discovery Protocol */
 #define ETH_P_MACSEC	0x88E5		/* 802.1ae MACsec */
 #define ETH_P_8021AH	0x88E7          /* 802.1ah Backbone Service Tag */
 #define ETH_P_MVRP	0x88F5          /* 802.1Q MVRP                  */
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [net-next 10/15] i40e: Use LLDP ethertype define ETH_P_LLDP
  2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
                   ` (8 preceding siblings ...)
  2019-06-05 20:23 ` [net-next 09/15] net: Add a define for LLDP ethertype Jeff Kirsher
@ 2019-06-05 20:23 ` Jeff Kirsher
  2019-06-05 20:23 ` [net-next 11/15] ixgbe: " Jeff Kirsher
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Jeff Kirsher @ 2019-06-05 20:23 UTC (permalink / raw)
  To: davem
  Cc: Anirudh Venkataramanan, netdev, nhorman, sassmann, Andrew Bowers,
	Jeff Kirsher

From: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>

Remove references to I40E_ETH_P_LLDP and use ETH_P_LLDP instead.

Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e.h         | 2 --
 drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 4 ++--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
index 7ce42040b851..8dc98d1d2e86 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -295,8 +295,6 @@ struct i40e_cloud_filter {
 	u8 tunnel_type;
 };
 
-#define I40E_ETH_P_LLDP			0x88cc
-
 #define I40E_DCB_PRIO_TYPE_STRICT	0
 #define I40E_DCB_PRIO_TYPE_ETS		1
 #define I40E_DCB_STRICT_PRIO_CREDITS	127
diff --git a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
index 7ea4f09229e4..dc5b40013e61 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
@@ -1330,7 +1330,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
 			}
 			ret = i40e_aq_add_rem_control_packet_filter(&pf->hw,
 						pf->hw.mac.addr,
-						I40E_ETH_P_LLDP, 0,
+						ETH_P_LLDP, 0,
 						pf->vsi[pf->lan_vsi]->seid,
 						0, true, NULL, NULL);
 			if (ret) {
@@ -1348,7 +1348,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
 
 			ret = i40e_aq_add_rem_control_packet_filter(&pf->hw,
 						pf->hw.mac.addr,
-						I40E_ETH_P_LLDP, 0,
+						ETH_P_LLDP, 0,
 						pf->vsi[pf->lan_vsi]->seid,
 						0, false, NULL, NULL);
 			if (ret) {
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [net-next 11/15] ixgbe: Use LLDP ethertype define ETH_P_LLDP
  2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
                   ` (9 preceding siblings ...)
  2019-06-05 20:23 ` [net-next 10/15] i40e: Use LLDP ethertype define ETH_P_LLDP Jeff Kirsher
@ 2019-06-05 20:23 ` Jeff Kirsher
  2019-06-05 20:23 ` [net-next 12/15] ice: " Jeff Kirsher
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Jeff Kirsher @ 2019-06-05 20:23 UTC (permalink / raw)
  To: davem
  Cc: Anirudh Venkataramanan, netdev, nhorman, sassmann, Andrew Bowers,
	Jeff Kirsher

From: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>

Remove references to IXGBE_ETH_P_LLD and use ETH_P_LLDP instead.

Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe.h       | 2 --
 drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index aa923d6d596b..39e73ad60352 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -50,8 +50,6 @@
 #define IXGBE_MAX_RXD			   4096
 #define IXGBE_MIN_RXD			     64
 
-#define IXGBE_ETH_P_LLDP		 0x88CC
-
 /* flow control */
 #define IXGBE_MIN_FCRTL			   0x40
 #define IXGBE_MAX_FCRTL			0x7FF80
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
index 345701af7749..537dfff585e0 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
@@ -1645,7 +1645,7 @@ int ixgbe_ndo_set_vf_spoofchk(struct net_device *netdev, int vf, bool setting)
 		IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_LLDP),
 				(IXGBE_ETQF_FILTER_EN    |
 				 IXGBE_ETQF_TX_ANTISPOOF |
-				 IXGBE_ETH_P_LLDP));
+				 ETH_P_LLDP));
 
 		IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_FC),
 				(IXGBE_ETQF_FILTER_EN |
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [net-next 12/15] ice: Use LLDP ethertype define ETH_P_LLDP
  2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
                   ` (10 preceding siblings ...)
  2019-06-05 20:23 ` [net-next 11/15] ixgbe: " Jeff Kirsher
@ 2019-06-05 20:23 ` Jeff Kirsher
  2019-06-05 20:23 ` [net-next 13/15] net: hns3: " Jeff Kirsher
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Jeff Kirsher @ 2019-06-05 20:23 UTC (permalink / raw)
  To: davem; +Cc: Jeff Kirsher, netdev, nhorman, sassmann

Instead of using a local define for the LLDP ethertype, use the kernel
define ETH_P_LLDP.

Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_lib.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index 35c5ff910afa..a19f5920733b 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -2345,8 +2345,6 @@ ice_vsi_add_rem_eth_mac(struct ice_vsi *vsi, bool add_rule)
 	ice_free_fltr_list(&pf->pdev->dev, &tmp_add_list);
 }
 
-#define ICE_ETH_P_LLDP	0x88CC
-
 /**
  * ice_cfg_sw_lldp - Config switch rules for LLDP packet handling
  * @vsi: the VSI being configured
@@ -2366,7 +2364,7 @@ void ice_cfg_sw_lldp(struct ice_vsi *vsi, bool tx, bool create)
 
 	list->fltr_info.lkup_type = ICE_SW_LKUP_ETHERTYPE;
 	list->fltr_info.vsi_handle = vsi->idx;
-	list->fltr_info.l_data.ethertype_mac.ethertype = ICE_ETH_P_LLDP;
+	list->fltr_info.l_data.ethertype_mac.ethertype = ETH_P_LLDP;
 
 	if (tx) {
 		list->fltr_info.fltr_act = ICE_DROP_PACKET;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [net-next 13/15] net: hns3: Use LLDP ethertype define ETH_P_LLDP
  2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
                   ` (11 preceding siblings ...)
  2019-06-05 20:23 ` [net-next 12/15] ice: " Jeff Kirsher
@ 2019-06-05 20:23 ` Jeff Kirsher
  2019-06-05 20:23 ` [net-next 14/15] ixgbe: implement support for SDP/PPS output on X550 hardware Jeff Kirsher
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Jeff Kirsher @ 2019-06-05 20:23 UTC (permalink / raw)
  To: davem
  Cc: Anirudh Venkataramanan, netdev, nhorman, sassmann, Andrew Bowers,
	Jeff Kirsher

From: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>

Remove references to HCLGE_MAC_ETHERTYPE_LLDP and use ETH_P_LLDP instead.

Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h  | 1 -
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
index 61cb10dc2b9b..7a14d806744c 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
@@ -677,7 +677,6 @@ struct hclge_umv_spc_alc_cmd {
 #define HCLGE_MAC_MGR_MASK_VLAN_B		BIT(0)
 #define HCLGE_MAC_MGR_MASK_MAC_B		BIT(1)
 #define HCLGE_MAC_MGR_MASK_ETHERTYPE_B		BIT(2)
-#define HCLGE_MAC_ETHERTYPE_LLDP		0x88cc
 
 struct hclge_mac_mgr_tbl_entry_cmd {
 	u8      flags;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 35d2a454bf66..cda1b3d096cd 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -292,7 +292,7 @@ static const struct hclge_comm_stats_str g_mac_stats_string[] = {
 static const struct hclge_mac_mgr_tbl_entry_cmd hclge_mgr_table[] = {
 	{
 		.flags = HCLGE_MAC_MGR_MASK_VLAN_B,
-		.ethter_type = cpu_to_le16(HCLGE_MAC_ETHERTYPE_LLDP),
+		.ethter_type = cpu_to_le16(ETH_P_LLDP),
 		.mac_addr_hi32 = cpu_to_le32(htonl(0x0180C200)),
 		.mac_addr_lo16 = cpu_to_le16(htons(0x000E)),
 		.i_port_bitmap = 0x1,
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [net-next 14/15] ixgbe: implement support for SDP/PPS output on X550 hardware
  2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
                   ` (12 preceding siblings ...)
  2019-06-05 20:23 ` [net-next 13/15] net: hns3: " Jeff Kirsher
@ 2019-06-05 20:23 ` Jeff Kirsher
  2019-06-05 20:23 ` [net-next 15/15] net: ixgbevf: fix a missing check of ixgbevf_write_msg_read_ack Jeff Kirsher
  2019-06-05 23:44 ` [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 David Miller
  15 siblings, 0 replies; 21+ messages in thread
From: Jeff Kirsher @ 2019-06-05 20:23 UTC (permalink / raw)
  To: davem
  Cc: Jacob Keller, netdev, nhorman, sassmann, Andrew Bowers, Jeff Kirsher

From: Jacob Keller <jacob.e.keller@intel.com>

Similar to the X540 hardware, enable support for generating a 1pps
output signal on SDP0.

This support is slightly different to the X540 hardware, because of the
register layout changes. First, the system time register is now
represented in 'cycles' and 'billions of cycles'. Second, we need to
also program the TSSDP register, as well as the ESDP register. Third,
the clock output uses only FREQOUT, instead of a full 64bit value for
the output clock period. Finally, we have to use the ST0 bit instead of
the SYNCLK bit in the TSAUXC register.

This support should work even for the hardware with a higher frequency
clock, as it carefully takes into account the multiply and shift of the
cycle counter used.

We also set the pps configuration to 1, since we now support generating
a pulse per second output.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c  | 99 ++++++++++++++++++-
 drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 14 ++-
 2 files changed, 108 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
index 376ad91d6a8d..2c4d327fcc2e 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
@@ -224,6 +224,101 @@ static void ixgbe_ptp_setup_sdp_X540(struct ixgbe_adapter *adapter)
 	IXGBE_WRITE_FLUSH(hw);
 }
 
+/**
+ * ixgbe_ptp_setup_sdp_X550
+ * @adapter: private adapter structure
+ *
+ * Enable or disable a clock output signal on SDP 0 for X550 hardware.
+ *
+ * Use the target time feature to align the output signal on the next full
+ * second.
+ *
+ * This works by using the cycle counter shift and mult values in reverse, and
+ * assumes that the values we're shifting will not overflow.
+ */
+static void ixgbe_ptp_setup_sdp_X550(struct ixgbe_adapter *adapter)
+{
+	u32 esdp, tsauxc, freqout, trgttiml, trgttimh, rem, tssdp;
+	struct cyclecounter *cc = &adapter->hw_cc;
+	struct ixgbe_hw *hw = &adapter->hw;
+	u64 ns = 0, clock_edge = 0;
+	struct timespec64 ts;
+	unsigned long flags;
+
+	/* disable the pin first */
+	IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, 0x0);
+	IXGBE_WRITE_FLUSH(hw);
+
+	if (!(adapter->flags2 & IXGBE_FLAG2_PTP_PPS_ENABLED))
+		return;
+
+	esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
+
+	/* enable the SDP0 pin as output, and connected to the
+	 * native function for Timesync (ClockOut)
+	 */
+	esdp |= IXGBE_ESDP_SDP0_DIR |
+		IXGBE_ESDP_SDP0_NATIVE;
+
+	/* enable the Clock Out feature on SDP0, and use Target Time 0 to
+	 * enable generation of interrupts on the clock change.
+	 */
+#define IXGBE_TSAUXC_DIS_TS_CLEAR 0x40000000
+	tsauxc = (IXGBE_TSAUXC_EN_CLK | IXGBE_TSAUXC_ST0 |
+		  IXGBE_TSAUXC_EN_TT0 | IXGBE_TSAUXC_SDP0_INT |
+		  IXGBE_TSAUXC_DIS_TS_CLEAR);
+
+	tssdp = (IXGBE_TSSDP_TS_SDP0_EN |
+		 IXGBE_TSSDP_TS_SDP0_CLK0);
+
+	/* Determine the clock time period to use. This assumes that the
+	 * cycle counter shift is small enough to avoid overflowing a 32bit
+	 * value.
+	 */
+	freqout = div_u64(NS_PER_HALF_SEC << cc->shift,  cc->mult);
+
+	/* Read the current clock time, and save the cycle counter value */
+	spin_lock_irqsave(&adapter->tmreg_lock, flags);
+	ns = timecounter_read(&adapter->hw_tc);
+	clock_edge = adapter->hw_tc.cycle_last;
+	spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
+
+	/* Figure out how far past the next second we are */
+	div_u64_rem(ns, NS_PER_SEC, &rem);
+
+	/* Figure out how many nanoseconds to add to round the clock edge up
+	 * to the next full second
+	 */
+	rem = (NS_PER_SEC - rem);
+
+	/* Adjust the clock edge to align with the next full second. This
+	 * assumes that the cycle counter shift is small enough to avoid
+	 * overflowing when shifting the remainder.
+	 */
+	clock_edge += div_u64((rem << cc->shift), cc->mult);
+
+	/* X550 hardware stores the time in 32bits of 'billions of cycles' and
+	 * 32bits of 'cycles'. There's no guarantee that cycles represents
+	 * nanoseconds. However, we can use the math from a timespec64 to
+	 * convert into the hardware representation.
+	 *
+	 * See ixgbe_ptp_read_X550() for more details.
+	 */
+	ts = ns_to_timespec64(clock_edge);
+	trgttiml = (u32)ts.tv_nsec;
+	trgttimh = (u32)ts.tv_sec;
+
+	IXGBE_WRITE_REG(hw, IXGBE_FREQOUT0, freqout);
+	IXGBE_WRITE_REG(hw, IXGBE_TRGTTIML0, trgttiml);
+	IXGBE_WRITE_REG(hw, IXGBE_TRGTTIMH0, trgttimh);
+
+	IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
+	IXGBE_WRITE_REG(hw, IXGBE_TSSDP, tssdp);
+	IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, tsauxc);
+
+	IXGBE_WRITE_FLUSH(hw);
+}
+
 /**
  * ixgbe_ptp_read_X550 - read cycle counter value
  * @cc: cyclecounter structure
@@ -1302,13 +1397,13 @@ static long ixgbe_ptp_create_clock(struct ixgbe_adapter *adapter)
 		adapter->ptp_caps.n_alarm = 0;
 		adapter->ptp_caps.n_ext_ts = 0;
 		adapter->ptp_caps.n_per_out = 0;
-		adapter->ptp_caps.pps = 0;
+		adapter->ptp_caps.pps = 1;
 		adapter->ptp_caps.adjfreq = ixgbe_ptp_adjfreq_X550;
 		adapter->ptp_caps.adjtime = ixgbe_ptp_adjtime;
 		adapter->ptp_caps.gettimex64 = ixgbe_ptp_gettimex;
 		adapter->ptp_caps.settime64 = ixgbe_ptp_settime;
 		adapter->ptp_caps.enable = ixgbe_ptp_feature_enable;
-		adapter->ptp_setup_sdp = NULL;
+		adapter->ptp_setup_sdp = ixgbe_ptp_setup_sdp_X550;
 		break;
 	default:
 		adapter->ptp_clock = NULL;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index 84f2dba39e36..2be1c4c72435 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -1067,6 +1067,7 @@ struct ixgbe_nvm_version {
 #define IXGBE_AUXSTMPL1  0x08C44 /* Auxiliary Time Stamp 1 register Low - RO */
 #define IXGBE_AUXSTMPH1  0x08C48 /* Auxiliary Time Stamp 1 register High - RO */
 #define IXGBE_TSIM       0x08C68 /* TimeSync Interrupt Mask Register - RW */
+#define IXGBE_TSSDP      0x0003C /* TimeSync SDP Configuration Register - RW */
 
 /* Diagnostic Registers */
 #define IXGBE_RDSTATCTL   0x02C20
@@ -2240,11 +2241,18 @@ enum {
 #define IXGBE_RXDCTL_RLPML_EN   0x00008000
 #define IXGBE_RXDCTL_VME        0x40000000  /* VLAN mode enable */
 
-#define IXGBE_TSAUXC_EN_CLK   0x00000004
-#define IXGBE_TSAUXC_SYNCLK   0x00000008
-#define IXGBE_TSAUXC_SDP0_INT 0x00000040
+#define IXGBE_TSAUXC_EN_CLK		0x00000004
+#define IXGBE_TSAUXC_SYNCLK		0x00000008
+#define IXGBE_TSAUXC_SDP0_INT		0x00000040
+#define IXGBE_TSAUXC_EN_TT0		0x00000001
+#define IXGBE_TSAUXC_EN_TT1		0x00000002
+#define IXGBE_TSAUXC_ST0		0x00000010
 #define IXGBE_TSAUXC_DISABLE_SYSTIME	0x80000000
 
+#define IXGBE_TSSDP_TS_SDP0_SEL_MASK	0x000000C0
+#define IXGBE_TSSDP_TS_SDP0_CLK0	0x00000080
+#define IXGBE_TSSDP_TS_SDP0_EN		0x00000100
+
 #define IXGBE_TSYNCTXCTL_VALID		0x00000001 /* Tx timestamp valid */
 #define IXGBE_TSYNCTXCTL_ENABLED	0x00000010 /* Tx timestamping enabled */
 
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [net-next 15/15] net: ixgbevf: fix a missing check of ixgbevf_write_msg_read_ack
  2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
                   ` (13 preceding siblings ...)
  2019-06-05 20:23 ` [net-next 14/15] ixgbe: implement support for SDP/PPS output on X550 hardware Jeff Kirsher
@ 2019-06-05 20:23 ` Jeff Kirsher
  2019-06-05 23:44 ` [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 David Miller
  15 siblings, 0 replies; 21+ messages in thread
From: Jeff Kirsher @ 2019-06-05 20:23 UTC (permalink / raw)
  To: davem
  Cc: Kangjie Lu, netdev, nhorman, sassmann, Andrew Bowers,
	Mukesh Ojha, Jeff Kirsher

From: Kangjie Lu <kjlu@umn.edu>

If ixgbevf_write_msg_read_ack fails, return its error code upstream

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbevf/vf.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbevf/vf.c b/drivers/net/ethernet/intel/ixgbevf/vf.c
index cd3b81300cc7..d5ce49636548 100644
--- a/drivers/net/ethernet/intel/ixgbevf/vf.c
+++ b/drivers/net/ethernet/intel/ixgbevf/vf.c
@@ -508,9 +508,8 @@ static s32 ixgbevf_update_mc_addr_list_vf(struct ixgbe_hw *hw,
 		vector_list[i++] = ixgbevf_mta_vector(hw, ha->addr);
 	}
 
-	ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf, IXGBE_VFMAILBOX_SIZE);
-
-	return 0;
+	return ixgbevf_write_msg_read_ack(hw, msgbuf, msgbuf,
+			IXGBE_VFMAILBOX_SIZE);
 }
 
 /**
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05
  2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
                   ` (14 preceding siblings ...)
  2019-06-05 20:23 ` [net-next 15/15] net: ixgbevf: fix a missing check of ixgbevf_write_msg_read_ack Jeff Kirsher
@ 2019-06-05 23:44 ` David Miller
  15 siblings, 0 replies; 21+ messages in thread
From: David Miller @ 2019-06-05 23:44 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: netdev, nhorman, sassmann

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Wed,  5 Jun 2019 13:23:43 -0700

> This series contains updates to mainly ixgbe, with a few updates to
> i40e, net, ice and hns2 driver.

Pulled, thanks for the ETH_P_LLDP consolidation.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [net-next 06/15] ixgbe: fix PTP SDP pin setup on X540 hardware
  2019-06-05 20:23 ` [net-next 06/15] ixgbe: fix PTP SDP pin setup on X540 hardware Jeff Kirsher
@ 2019-06-06  3:20   ` Richard Cochran
  2019-06-06 20:37     ` Keller, Jacob E
  0 siblings, 1 reply; 21+ messages in thread
From: Richard Cochran @ 2019-06-06  3:20 UTC (permalink / raw)
  To: Jeff Kirsher
  Cc: davem, Jacob Keller, netdev, nhorman, sassmann, Andrew Bowers

On Wed, Jun 05, 2019 at 01:23:49PM -0700, Jeff Kirsher wrote:
> + * It calculates when the system time will be on an exact second, and then
> + * aligns the start of the PPS signal to that value.
> + *
> + * This works by using the cycle counter shift and mult values in reverse, and
> + * assumes that the values we're shifting will not overflow.

So I guess that this device can't adjust the frequency in hardware,
and that is why the driver uses a timecounter.

BUT your PPS will not be correct.  You use the 'mult' to calculate the
future counter time of the PPS, but as soon as the PTP stack adjusts
the frequency (and changes 'mult') the PPS will occur at the wrong
time.

Sorry to say it,
Richard

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [net-next 06/15] ixgbe: fix PTP SDP pin setup on X540 hardware
  2019-06-06  3:20   ` Richard Cochran
@ 2019-06-06 20:37     ` Keller, Jacob E
  2019-06-07  3:34       ` Richard Cochran
  0 siblings, 1 reply; 21+ messages in thread
From: Keller, Jacob E @ 2019-06-06 20:37 UTC (permalink / raw)
  To: Richard Cochran, Kirsher, Jeffrey T
  Cc: davem, netdev, nhorman, sassmann, Bowers, AndrewX

> -----Original Message-----
> From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org] On
> Behalf Of Richard Cochran
> Sent: Wednesday, June 05, 2019 8:21 PM
> To: Kirsher, Jeffrey T <jeffrey.t.kirsher@intel.com>
> Cc: davem@davemloft.net; Keller, Jacob E <jacob.e.keller@intel.com>;
> netdev@vger.kernel.org; nhorman@redhat.com; sassmann@redhat.com; Bowers,
> AndrewX <andrewx.bowers@intel.com>
> Subject: Re: [net-next 06/15] ixgbe: fix PTP SDP pin setup on X540 hardware
> 
> On Wed, Jun 05, 2019 at 01:23:49PM -0700, Jeff Kirsher wrote:
> > + * It calculates when the system time will be on an exact second, and then
> > + * aligns the start of the PPS signal to that value.
> > + *
> > + * This works by using the cycle counter shift and mult values in reverse, and
> > + * assumes that the values we're shifting will not overflow.
> 
> So I guess that this device can't adjust the frequency in hardware,
> and that is why the driver uses a timecounter.
> 

No. We use the timecounter to track the time offset, not the frequency. That is, our hardware can't represent 64bits of time, but it can adjust frequency. The time counter is used to track the adjustments from adjtime and set time, but not adjfreq.

The timecounter is used to provide two features: (a) storing a full 64bits of time for passing back to the PTP stack and (b) atomic adjustments in adjtime. When programming the SDP we need to reverse the calculations done so that they're in terms of the SYSTIME values. But the frequency changes are all done directly to the SYSTIME increment values, and should be reflected properly in the pin output.

> BUT your PPS will not be correct.  You use the 'mult' to calculate the
> future counter time of the PPS, but as soon as the PTP stack adjusts
> the frequency (and changes 'mult') the PPS will occur at the wrong
> time.

Every path which changes mult (which is only link speed changes as far as I remember offhand) re-programs the PPS. We also re-program the pin at adjtime and settime.

There should be no caller outside of our driver who adjusts the multiplier.

Thanks,
Jake

> 
> Sorry to say it,
> Richard

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [net-next 06/15] ixgbe: fix PTP SDP pin setup on X540 hardware
  2019-06-06 20:37     ` Keller, Jacob E
@ 2019-06-07  3:34       ` Richard Cochran
  2019-06-07 17:27         ` Keller, Jacob E
  0 siblings, 1 reply; 21+ messages in thread
From: Richard Cochran @ 2019-06-07  3:34 UTC (permalink / raw)
  To: Keller, Jacob E
  Cc: Kirsher, Jeffrey T, davem, netdev, nhorman, sassmann, Bowers, AndrewX

On Thu, Jun 06, 2019 at 08:37:59PM +0000, Keller, Jacob E wrote:
> No. We use the timecounter to track the time offset, not the
> frequency. That is, our hardware can't represent 64bits of time, but
> it can adjust frequency. The time counter is used to track the
> adjustments from adjtime and set time, but not adjfreq.

Ah, okay.  Never mind then... carry on!

Thanks,
Richard

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [net-next 06/15] ixgbe: fix PTP SDP pin setup on X540 hardware
  2019-06-07  3:34       ` Richard Cochran
@ 2019-06-07 17:27         ` Keller, Jacob E
  0 siblings, 0 replies; 21+ messages in thread
From: Keller, Jacob E @ 2019-06-07 17:27 UTC (permalink / raw)
  To: Richard Cochran
  Cc: Kirsher, Jeffrey T, davem, netdev, nhorman, sassmann, Bowers, AndrewX

> -----Original Message-----
> From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org] On
> Behalf Of Richard Cochran
> Sent: Thursday, June 06, 2019 8:35 PM
> To: Keller, Jacob E <jacob.e.keller@intel.com>
> Cc: Kirsher, Jeffrey T <jeffrey.t.kirsher@intel.com>; davem@davemloft.net;
> netdev@vger.kernel.org; nhorman@redhat.com; sassmann@redhat.com; Bowers,
> AndrewX <andrewx.bowers@intel.com>
> Subject: Re: [net-next 06/15] ixgbe: fix PTP SDP pin setup on X540 hardware
> 
> On Thu, Jun 06, 2019 at 08:37:59PM +0000, Keller, Jacob E wrote:
> > No. We use the timecounter to track the time offset, not the
> > frequency. That is, our hardware can't represent 64bits of time, but
> > it can adjust frequency. The time counter is used to track the
> > adjustments from adjtime and set time, but not adjfreq.
> 
> Ah, okay.  Never mind then... carry on!
> 
> Thanks,
> Richard

Thanks for the review!

Regards,
Jake

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2019-06-07 17:27 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-05 20:23 [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 Jeff Kirsher
2019-06-05 20:23 ` [net-next 01/15] ixgbe: add tracking of AF_XDP zero-copy state for each queue pair Jeff Kirsher
2019-06-05 20:23 ` [net-next 02/15] ixgbe: remove umem from adapter Jeff Kirsher
2019-06-05 20:23 ` [net-next 03/15] ixgbe: fix AF_XDP tx byte count Jeff Kirsher
2019-06-05 20:23 ` [net-next 04/15] ixgbe: fix AF_XDP tx packet count Jeff Kirsher
2019-06-05 20:23 ` [net-next 05/15] ixgbe: reduce PTP Tx timestamp timeout to 1 second Jeff Kirsher
2019-06-05 20:23 ` [net-next 06/15] ixgbe: fix PTP SDP pin setup on X540 hardware Jeff Kirsher
2019-06-06  3:20   ` Richard Cochran
2019-06-06 20:37     ` Keller, Jacob E
2019-06-07  3:34       ` Richard Cochran
2019-06-07 17:27         ` Keller, Jacob E
2019-06-05 20:23 ` [net-next 07/15] ixgbe: use 'cc' instead of 'hw_cc' for local variable Jeff Kirsher
2019-06-05 20:23 ` [net-next 08/15] ixgbe: add a kernel documentation comment for ixgbe_ptp_get_ts_config Jeff Kirsher
2019-06-05 20:23 ` [net-next 09/15] net: Add a define for LLDP ethertype Jeff Kirsher
2019-06-05 20:23 ` [net-next 10/15] i40e: Use LLDP ethertype define ETH_P_LLDP Jeff Kirsher
2019-06-05 20:23 ` [net-next 11/15] ixgbe: " Jeff Kirsher
2019-06-05 20:23 ` [net-next 12/15] ice: " Jeff Kirsher
2019-06-05 20:23 ` [net-next 13/15] net: hns3: " Jeff Kirsher
2019-06-05 20:23 ` [net-next 14/15] ixgbe: implement support for SDP/PPS output on X550 hardware Jeff Kirsher
2019-06-05 20:23 ` [net-next 15/15] net: ixgbevf: fix a missing check of ixgbevf_write_msg_read_ack Jeff Kirsher
2019-06-05 23:44 ` [net-next 00/15][pull request] 10GbE Intel Wired LAN Driver Updates 2019-06-05 David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).