octeontx2: fix PTP RX enable notification on VF
Subsystems (4)
Ratheesh Kannoth
maintainerPATCH v2 1/1 octeontx2: fix PTP RX enable notification on VF
From: Sai Krishna <[email protected]>
When a VF enables PTP RX timestamping, CGX prepends an 8-byte timestamp header to each packet. The parent PF and its VFs must adjust their RX data offset before that happens, but enabling PTP RX only configured CGX and never notified the PF or VFs.
Add a CGX_PTP_RX_INFO mailbox upcall from AF to PF when RX timestamping is enabled or disabled. On receipt, the PF records the state and forwards it to active VFs. Handle the upcall on the VF mailbox path so the notification completes correctly.
Use the asynchronous upcall pattern (wait for zero, then send) on both AF-to-PF and PF-to-VF paths, and serialize PF-to-VF delivery with the mailbox lock, consistent with link-event notification.
---
v1 -> v2: Addressed sashiko comments
https://sashiko.dev/#/patchset/20260818034728.2047614-1-rkannoth%40marvell.com --- .../net/ethernet/marvell/octeontx2/af/mbox.h | 8 ++- .../ethernet/marvell/octeontx2/af/rvu_cgx.c | 20 ++++++ .../marvell/octeontx2/nic/otx2_common.h | 2 + .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 66 +++++++++++++++++++ .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 14 ++++ 5 files changed, 109 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +7 -1
@@ -427,7 +427,8 @@ M(MCS_CUSTOM_TAG_CFG_GET, 0xa021, mcs_custom_tag_cfg_get, \/* Messages initiated by AF (range 0xC00 - 0xEFF) */ #define MBOX_UP_CGX_MESSAGES \ -M(CGX_LINK_EVENT, 0xC00, cgx_link_event, cgx_link_info_msg, msg_rsp) +M(CGX_LINK_EVENT, 0xC00, cgx_link_event, cgx_link_info_msg, msg_rsp) \ +M(CGX_PTP_RX_INFO, 0xC01, cgx_ptp_rx_info, cgx_ptp_rx_info_msg, msg_rsp)#define MBOX_UP_CPT_MESSAGES \ M(CPT_INST_LMTST, 0xD00, cpt_inst_lmtst, cpt_inst_lmtst_req, msg_rsp)
@@ -647,6 +648,11 @@ struct cgx_link_info_msg {struct cgx_link_user_info link_info; }; +struct cgx_ptp_rx_info_msg { +struct mbox_msghdr hdr; +u8 ptp_en; +}; +struct cgx_pause_frm_cfg {struct mbox_msghdr hdr;u8 set;
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +20 -0
@@ -820,6 +820,24 @@ int rvu_mbox_handler_cgx_promisc_disable(struct rvu *rvu, struct msg_req *req,return 0 ; } +static void cgx_notify_up_ptp_info (struct rvu *rvu,int pf,bool enable) +{ +struct cgx_ptp_rx_info_msg *msg; + +/* Send mbox message to PF */ + msg =otx2_mbox_alloc_msg_cgx_ptp_rx_info (rvu, pf); +if (!msg) { +dev_err (rvu->dev,"failed to alloc message\n" ); +return ; + } + + msg->ptp_en = enable; + +otx2_mbox_wait_for_zero (&rvu->afpf_wq_info.mbox_up, pf); + +otx2_mbox_msg_send_up (&rvu->afpf_wq_info.mbox_up, pf); +} +static int rvu_cgx_ptp_rx_cfg (struct rvu *rvu,u16 pcifunc,bool enable) {struct rvu_pfvf *pfvf =rvu_get_pfvf (rvu, pcifunc);
@@ -837,6 +855,8 @@ static int rvu_cgx_ptp_rx_cfg(struct rvu *rvu, u16 pcifunc, bool enable)if (!is_pf_cgxmapped (rvu, pf))return -EPERM ; +cgx_notify_up_ptp_info (rvu, pf, enable); +rvu_get_cgx_lmac_id (rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); cgxd =rvu_cgx_pdata (cgx_id, rvu);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +2 -0
@@ -286,6 +286,7 @@ enum vfperm {struct otx2_vf_config {struct otx2_nic *pf;struct delayed_work link_event_work; +struct delayed_work ptp_info_work;bool intf_down;/* interface was either configured or not */ u8 mac[ETH_ALEN ];u16 vlan;
@@ -324,6 +325,7 @@ struct otx2_ptp {u64 thresh;struct ptp_pin_desc extts_config; +bool ptp_en;u64 (*convert_rx_ptp_tstmp)(u64 timestamp);u64 (*convert_tx_ptp_tstmp)(u64 timestamp);u64 (*ptp_tstamp2nsec)(const struct timecounter *time_counter,u64 timestamp);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +66 -0
96 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +14 -0
@@ -141,6 +141,20 @@ static int otx2vf_process_mbox_msg_up(struct otx2_nic *vf, err =otx2_mbox_up_handler_cgx_link_event ( vf, (struct cgx_link_info_msg *)req, rsp);return err; +case MBOX_MSG_CGX_PTP_RX_INFO : + rsp = (struct msg_rsp *)otx2_mbox_alloc_msg (&vf->mbox.mbox_up, +0 ,sizeof (struct msg_rsp )); +if (!rsp) +return -ENOMEM ; + + rsp->hdr.id =MBOX_MSG_CGX_PTP_RX_INFO ; + rsp->hdr.sig =OTX2_MBOX_RSP_SIG ; + rsp->hdr.pcifunc = req->pcifunc; + rsp->hdr.rc =0 ; + err =otx2_mbox_up_handler_cgx_ptp_rx_info (vf, + (struct cgx_ptp_rx_info_msg *)req, + rsp); +return err;default :otx2_reply_invalid_msg (&vf->mbox.mbox_up,0 ,0 , req->id);return -ENODEV ;
Signature · 1 line
2.43.0
Ratheesh Kannoth
maintainerQuoted 16 lines · Ratheesh Kannoth
From: Sai Krishna <[email protected]>
When a VF enables PTP RX timestamping, CGX prepends an 8-byte timestamp header to each packet. The parent PF and its VFs must adjust their RX data offset before that happens, but enabling PTP RX only configured CGX and never notified the PF or VFs.
Add a
CGX_PTP_RX_INFOmailbox upcall from AF to PF when RX timestamping is enabled or disabled. On receipt, the PF records the state and forwards it to active VFs. Handle the upcall on the VF mailbox path so the notification completes correctly.Use the asynchronous upcall pattern (wait for zero, then send) on both AF-to-PF and PF-to-VF paths, and serialize PF-to-VF delivery with the mailbox lock, consistent with link-event notification.
Quoted 6 lines
Fixes 421572175ba5 ("octeontx2-af: Support to enable/disable HW timestamping")Signed-off-by Sai Krishna <[email protected]>Signed-off-by Ratheesh Kannoth <[email protected]>2.43.0
Will address sashiko comments in v3
pw-bot: changes-requested