octeontx2-pf: Use PTP HW timestamp counter atomic update feature
Subsystems (4)
PATCH v4 1/1 octeontx2-pf: Use PTP HW timestamp counter atomic update feature
Some of the newer silicon versions in CN10K series supports a feature where in the current PTP timestamp in HW can be updated atomically without losing any cpu cycles unlike read/modify/write register. This patch uses this feature so that PTP accuracy can be improved while adjusting the master offset in HW. There is no need for SW timecounter when using this feature. So removed references to SW timecounter wherever appropriate.
---
v4:
- Addressed review comments given by Leon Romanovsky
1. Unlocked mutex in error conditions.
v3:
- Addressed review comments given by Jakub Kicinski
1. Fixed re-ordering of headers in alphabetical order
2. Refactored SoC revision identification logic
3. CN10K errata revisions can be different from atomic update supported revision devices.
4. Removed ptp device check.
v2:
- Addressed review comments given by Simon Horman, Kalesh Anakkur Purayil
1. Removed inline keyword for function in .c file
2. Modified/optimized conditions related boolean
.../net/ethernet/marvell/octeontx2/af/mbox.h | 12 ++ .../net/ethernet/marvell/octeontx2/af/ptp.c | 155 +++++++++++++-- .../net/ethernet/marvell/octeontx2/af/ptp.h | 3 +- .../net/ethernet/marvell/octeontx2/af/rvu.c | 2 +- .../net/ethernet/marvell/octeontx2/af/rvu.h | 12 ++ .../marvell/octeontx2/nic/otx2_common.h | 1 + .../ethernet/marvell/octeontx2/nic/otx2_ptp.c | 177 ++++++++++++++---- 7 files changed, 307 insertions(+), 55 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +12 -0
@@ -136,6 +136,7 @@ M(GET_HW_CAP, 0x008, get_hw_cap, msg_req, get_hw_cap_rsp) \M (LMTST_TBL_SETUP ,0x00a , lmtst_tbl_setup, lmtst_tbl_setup_req, \ msg_rsp) \ M(SET_VF_PERM, 0x00b, set_vf_perm, set_vf_perm, msg_rsp) \ +M (PTP_GET_CAP ,0x00c , ptp_get_cap, msg_req, ptp_get_cap_rsp) \ /* CGX mbox IDs (range 0x200 - 0x3FF) */ \ M(CGX_START_RXTX, 0x200, cgx_start_rxtx, msg_req, msg_rsp) \M (CGX_STOP_RXTX ,0x201 , cgx_stop_rxtx, msg_req, msg_rsp) \
@@ -1437,6 +1438,12 @@ struct npc_get_kex_cfg_rsp {u8 mkex_pfl_name[MKEX_NAME_LEN ]; }; +struct ptp_get_cap_rsp { +struct mbox_msghdr hdr; +#define PTP_CAP_HW_ATOMIC_UPDATE BIT_ULL(0) +u64 cap; +}; +struct flow_msg {unsigned char dmac[6 ];unsigned char smac[6 ];
@@ -1568,6 +1575,8 @@ enum ptp_op {PTP_OP_GET_TSTMP =2 ,PTP_OP_SET_THRESH =3 ,PTP_OP_EXTTS_ON =4 , +PTP_OP_ADJTIME =5 , + PTP_OP_SET_CLOCK = 6, }; struct ptp_req {
@@ -1576,11 +1585,14 @@ struct ptp_req {s64 scaled_ppm;u64 thresh;int extts_on; +s64 delta; +u64 clk; };struct ptp_rsp {struct mbox_msghdr hdr;u64 clk; +u64 tsc; };struct npc_get_field_status_req {
drivers/net/ethernet/marvell/octeontx2/af/ptp.c +135 -20
243 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/ptp.h +2 -1
@@ -23,9 +23,10 @@ struct ptp {u32 clock_period; }; +struct rvu ;struct ptp *ptp_get (void );void ptp_put (struct ptp *ptp); -void ptp_start (struct ptp *ptp,u64 sclk,u32 ext_clk_freq,u32 extts); +void ptp_start (struct rvu *rvu,u64 sclk,u32 ext_clk_freq,u32 extts);extern struct pci_driver ptp_driver;
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +1 -1
@@ -3322,7 +3322,7 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)mutex_init (&rvu->rswitch.switch_lock);if (rvu->fwdata) -ptp_start (rvu->ptp, rvu->fwdata->sclk, rvu->fwdata->ptp_ext_clk_rate, +ptp_start (rvu, rvu->fwdata->sclk, rvu->fwdata->ptp_ext_clk_rate, rvu->fwdata->ptp_ext_tstamp);return 0 ;
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +12 -0
@@ -17,6 +17,7 @@#include "mbox.h" #include "npc.h" #include "rvu_reg.h" +#include "ptp.h" /* PCI device IDs */ #define PCI_DEVID_OCTEONTX2_RVU_AF 0xA065
@@ -26,6 +27,7 @@#define PCI_SUBSYS_DEVID_98XX 0xB100#define PCI_SUBSYS_DEVID_96XX 0xB200#define PCI_SUBSYS_DEVID_CN10K_A 0xB900 +#define PCI_SUBSYS_DEVID_CNF10K_A 0xBA00#define PCI_SUBSYS_DEVID_CNF10K_B 0xBC00#define PCI_SUBSYS_DEVID_CN10K_B 0xBD00
@@ -634,6 +636,16 @@ static inline bool is_rvu_otx2(struct rvu *rvu) midr == PCI_REVISION_ID_95XXMM || midr == PCI_REVISION_ID_95XXO); } +static inline bool is_cnf10ka_a0 (struct rvu *rvu) +{ +struct pci_dev *pdev = rvu->pdev; + +if (pdev->subsystem_device ==PCI_SUBSYS_DEVID_CNF10K_A && + (pdev->revision &0x0F ) ==0x0 ) +return true; +return false; +} +static inline bool is_rvu_npc_hash_extract_en (struct rvu *rvu) {u64 npc_const3;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +1 -0
@@ -326,6 +326,7 @@ struct otx2_ptp {struct ptp_pin_desc extts_config;u64 (*convert_rx_ptp_tstmp)(u64 timestamp);u64 (*convert_tx_ptp_tstmp)(u64 timestamp); +u64 (*ptp_tstamp2nsec)(const struct timecounter *time_counter,u64 timestamp);struct delayed_work synctstamp_work;u64 tstamp;u32 base_ns;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ptp.c +144 -33
259 lines not on this page · raw message
Signature · 1 line
2.25.1
Quoted 12 lines · Sai Krishna
Some of the newer silicon versions in CN10K series supports a feature where in the current PTP timestamp in HW can be updated atomically without losing any cpu cycles unlike read/modify/write register. This patch uses this feature so that PTP accuracy can be improved while adjusting the master offset in HW. There is no need for SW timecounter when using this feature. So removed references to SW timecounter wherever appropriate.
Signed-off-by Sai Krishna <[email protected]>Signed-off-by Naveen Mamindlapalli <[email protected]>Signed-off-by Sunil Kovvuri Goutham <[email protected]>Reviewed-by Kalesh AP <[email protected]>
Quoted 15 lines
---
v4:
- Addressed review comments given by Leon Romanovsky
1. Unlocked mutex in error conditions.
v3:
- Addressed review comments given by Jakub Kicinski
1. Fixed re-ordering of headers in alphabetical order
2. Refactored SoC revision identification logic
3. CN10K errata revisions can be different from atomic update supported revision devices.
4. Removed ptp device check.
v2:
- Addressed review comments given by Simon Horman, Kalesh Anakkur Purayil
1. Removed inline keyword for function in .c file
2. Modified/optimized conditions related boolean
Quoted 28 lines · Sai Krishna
Some of the newer silicon versions in CN10K series supports a feature where in the current PTP timestamp in HW can be updated atomically without losing any cpu cycles unlike read/modify/write register. This patch uses this feature so that PTP accuracy can be improved while adjusting the master offset in HW. There is no need for SW timecounter when using this feature. So removed references to SW timecounter wherever appropriate.
Signed-off-by Sai Krishna <[email protected]>Signed-off-by Naveen Mamindlapalli <[email protected]>Signed-off-by Sunil Kovvuri Goutham <[email protected]>Reviewed-by Kalesh AP <[email protected]>---
v4:
- Addressed review comments given by Leon Romanovsky
1. Unlocked mutex in error conditions.
v3:
- Addressed review comments given by Jakub Kicinski
1. Fixed re-ordering of headers in alphabetical order
2. Refactored SoC revision identification logic
3. CN10K errata revisions can be different from atomic update supported revision devices.
4. Removed ptp device check.
v2:
- Addressed review comments given by Simon Horman, Kalesh Anakkur Purayil
1. Removed inline keyword for function in .c file
2. Modified/optimized conditions related boolean
Quoted 9 lines
.../net/ethernet/marvell/octeontx2/af/mbox.h | 12 ++ .../net/ethernet/marvell/octeontx2/af/ptp.c | 155 +++++++++++++-- .../net/ethernet/marvell/octeontx2/af/ptp.h | 3 +- .../net/ethernet/marvell/octeontx2/af/rvu.c | 2 +- .../net/ethernet/marvell/octeontx2/af/rvu.h | 12 ++ .../marvell/octeontx2/nic/otx2_common.h | 1 + .../ethernet/marvell/octeontx2/nic/otx2_ptp.c | 177 ++++++++++++++---- 7 files changed, 307 insertions(+), 55 deletions(-)
Thanks,
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 9 lines · On Mon, 21 Aug 2023 16:06:29 +0530 you wrote:
Some of the newer silicon versions in CN10K series supports a feature where in the current PTP timestamp in HW can be updated atomically without losing any cpu cycles unlike read/modify/write register. This patch uses this feature so that PTP accuracy can be improved while adjusting the master offset in HW. There is no need for SW timecounter when using this feature. So removed references to SW timecounter wherever appropriate.
[...]
Here is the summary with links:
- [net-next,v4] octeontx2-pf: Use PTP HW timestamp counter atomic update feature
https://git.kernel.org/netdev/net-next/c/bdf79b128685
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html