Commit e41703ac authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files
Tony Nguyen says:

====================
idpf: add initial PTP support

Milena Olech says:

This patch series introduces support for Precision Time Protocol (PTP) to
Intel(R) Infrastructure Data Path Function (IDPF) driver. PTP feature is
supported when the PTP capability is negotiated with the Control
Plane (CP). IDPF creates a PTP clock and sets a set of supported
functions.

During the PTP initialization, IDPF requests a set of PTP capabilities
and receives a writeback from the CP with the set of supported options.
These options are:
- get time of the PTP clock
- set the time of the PTP clock
- adjust the PTP clock
- Tx timestamping

Each feature is considered to have direct access, where the operations
on PCIe BAR registers are allowed, or the mailbox access, where the
virtchnl messages are used to perform any PTP action. Mailbox access
means that PTP requests are sent to the CP through dedicated secondary
mailbox and the CP reads/writes/modifies desired resource - PTP Clock
or Tx timestamp registers.

Tx timestamp capabilities are negotiated only for vports that have
UPLINK_VPORT flag set by the CP. Capabilities provide information about
the number of available Tx timestamp latches, their indexes and size of
the Tx timestamp value. IDPF requests Tx timestamp by setting the
TSYN bit and the requested timestamp index in the context descriptor for
the PTP packets. When the completion tag for that packet is received,
IDPF schedules a worker to read the Tx timestamp value.

* '200GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue:
  idpf: add support for Rx timestamping
  idpf: add Tx timestamp flows
  idpf: add Tx timestamp capabilities negotiation
  idpf: add PTP clock configuration
  idpf: add mailbox access to read PTP clock time
  idpf: negotiate PTP capabilities and get PTP clock
  idpf: move virtchnl structures to the header file
  virtchnl: add PTP virtchnl definitions
  idpf: add initial PTP support
  idpf: change the method for mailbox workqueue allocation
====================

Link: https://patch.msgid.link/20250516170645.1172700-1-anthony.l.nguyen@intel.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents c6a957d0 494565a7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
config IDPF
	tristate "Intel(R) Infrastructure Data Path Function Support"
	depends on PCI_MSI
	depends on PTP_1588_CLOCK_OPTIONAL
	select DIMLIB
	select LIBETH
	help
+3 −0
Original line number Diff line number Diff line
@@ -17,3 +17,6 @@ idpf-y := \
	idpf_vf_dev.o

idpf-$(CONFIG_IDPF_SINGLEQ)	+= idpf_singleq_txrx.o

idpf-$(CONFIG_PTP_1588_CLOCK)	+= idpf_ptp.o
idpf-$(CONFIG_PTP_1588_CLOCK)	+= idpf_virtchnl_ptp.o
+19 −0
Original line number Diff line number Diff line
@@ -189,6 +189,7 @@ struct idpf_vport_max_q {
 * @mb_intr_reg_init: Mailbox interrupt register initialization
 * @reset_reg_init: Reset register initialization
 * @trigger_reset: Trigger a reset to occur
 * @ptp_reg_init: PTP register initialization
 */
struct idpf_reg_ops {
	void (*ctlq_reg_init)(struct idpf_ctlq_create_info *cq);
@@ -197,6 +198,7 @@ struct idpf_reg_ops {
	void (*reset_reg_init)(struct idpf_adapter *adapter);
	void (*trigger_reset)(struct idpf_adapter *adapter,
			      enum idpf_flags trig_cause);
	void (*ptp_reg_init)(const struct idpf_adapter *adapter);
};

/**
@@ -290,6 +292,9 @@ struct idpf_port_stats {
 * @port_stats: per port csum, header split, and other offload stats
 * @link_up: True if link is up
 * @sw_marker_wq: workqueue for marker packets
 * @tx_tstamp_caps: Capabilities negotiated for Tx timestamping
 * @tstamp_config: The Tx tstamp config
 * @tstamp_task: Tx timestamping task
 */
struct idpf_vport {
	u16 num_txq;
@@ -334,6 +339,10 @@ struct idpf_vport {
	bool link_up;

	wait_queue_head_t sw_marker_wq;

	struct idpf_ptp_vport_tx_tstamp_caps *tx_tstamp_caps;
	struct kernel_hwtstamp_config tstamp_config;
	struct work_struct tstamp_task;
};

/**
@@ -478,6 +487,13 @@ struct idpf_vport_config {

struct idpf_vc_xn_manager;

#define idpf_for_each_vport(adapter, iter) \
	for (struct idpf_vport **__##iter = &(adapter)->vports[0], \
	     *iter = (adapter)->max_vports ? *__##iter : NULL; \
	     iter; \
	     iter = (++__##iter) < &(adapter)->vports[(adapter)->max_vports] ? \
	     *__##iter : NULL)

/**
 * struct idpf_adapter - Device data struct generated on probe
 * @pdev: PCI device struct given on probe
@@ -530,6 +546,7 @@ struct idpf_vc_xn_manager;
 * @vector_lock: Lock to protect vector distribution
 * @queue_lock: Lock to protect queue distribution
 * @vc_buf_lock: Lock to protect virtchnl buffer
 * @ptp: Storage for PTP-related data
 */
struct idpf_adapter {
	struct pci_dev *pdev;
@@ -587,6 +604,8 @@ struct idpf_adapter {
	struct mutex vector_lock;
	struct mutex queue_lock;
	struct mutex vc_buf_lock;

	struct idpf_ptp *ptp;
};

/**
+3 −0
Original line number Diff line number Diff line
@@ -123,9 +123,12 @@ struct idpf_ctlq_info {
/**
 * enum idpf_mbx_opc - PF/VF mailbox commands
 * @idpf_mbq_opc_send_msg_to_cp: used by PF or VF to send a message to its CP
 * @idpf_mbq_opc_send_msg_to_peer_drv: used by PF or VF to send a message to
 *				       any peer driver
 */
enum idpf_mbx_opc {
	idpf_mbq_opc_send_msg_to_cp		= 0x0801,
	idpf_mbq_opc_send_msg_to_peer_drv	= 0x0804,
};

/* API supported for control queue management */
+14 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
#include "idpf.h"
#include "idpf_lan_pf_regs.h"
#include "idpf_virtchnl.h"
#include "idpf_ptp.h"

#define IDPF_PF_ITR_IDX_SPACING		0x4

@@ -148,6 +149,18 @@ static void idpf_trigger_reset(struct idpf_adapter *adapter,
	       idpf_get_reg_addr(adapter, PFGEN_CTRL));
}

/**
 * idpf_ptp_reg_init - Initialize required registers
 * @adapter: Driver specific private structure
 *
 * Set the bits required for enabling shtime and cmd execution
 */
static void idpf_ptp_reg_init(const struct idpf_adapter *adapter)
{
	adapter->ptp->cmd.shtime_enable_mask = PF_GLTSYN_CMD_SYNC_SHTIME_EN_M;
	adapter->ptp->cmd.exec_cmd_mask = PF_GLTSYN_CMD_SYNC_EXEC_CMD_M;
}

/**
 * idpf_reg_ops_init - Initialize register API function pointers
 * @adapter: Driver specific private structure
@@ -159,6 +172,7 @@ static void idpf_reg_ops_init(struct idpf_adapter *adapter)
	adapter->dev_ops.reg_ops.mb_intr_reg_init = idpf_mb_intr_reg_init;
	adapter->dev_ops.reg_ops.reset_reg_init = idpf_reset_reg_init;
	adapter->dev_ops.reg_ops.trigger_reset = idpf_trigger_reset;
	adapter->dev_ops.reg_ops.ptp_reg_init = idpf_ptp_reg_init;
}

/**
Loading