Add PTP support for Octeontx2
Subsystems (4)
v6 cover Add PTP support for Octeontx2
From: Subbaraya Sundeep <[email protected]>
Hi,
This patchset adds PTP support for Octeontx2 platform. PTP is an independent coprocessor block from which CGX block fetches timestamp and prepends it to the packet before sending to NIX block. Patches are as follows:
Patch 1: Patch to enable/disable packet timstamping
in CGX upon mailbox request. It also adjusts packet parser (NPC) for the 8 bytes timestamp appearing before the packet.
Patch 2: Patch adding PTP pci driver which configures
the PTP block and hooks up to RVU AF driver. It also exposes a mailbox call to adjust PTP hardware clock.
Patch 3: Patch adding PTP clock driver for PF netdev.
v6:
Resent after net-next is open
v5:
As suggested by David separated the fix (adding rtnl lock/unlock) and submitted to net.
https://www.spinics.net/lists/netdev/msg669617.html
v4:
Added rtnl_lock/unlock in otx2_reset to protect against network stack ndo_open and close calls
Added NULL check after ptp_clock_register in otx2_ptp.c
v3:
Fixed sparse error in otx2_txrx.c
Removed static inlines in otx2_txrx.c
v2:
Fixed kernel build robot reported error by
adding timecounter.h to otx2_common.h
Aleksey Makarov (2):
octeontx2-af: Add support for Marvell PTP coprocessor
octeontx2-pf: Add support for PTP clock
Zyta Szpak (1):
octeontx2-af: Support to enable/disable HW timestamping
drivers/net/ethernet/marvell/octeontx2/af/Makefile | 2 +- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 29 +++ drivers/net/ethernet/marvell/octeontx2/af/cgx.h | 4 + drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 21 ++ drivers/net/ethernet/marvell/octeontx2/af/ptp.c | 248 +++++++++++++++++++++ drivers/net/ethernet/marvell/octeontx2/af/ptp.h | 22 ++ drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 29 ++- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 5 + .../net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 54 +++++ .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 52 +++++ .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 27 +++ .../net/ethernet/marvell/octeontx2/nic/Makefile | 3 +- .../ethernet/marvell/octeontx2/nic/otx2_common.c | 7 + .../ethernet/marvell/octeontx2/nic/otx2_common.h | 19 ++ .../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 28 +++ .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 168 +++++++++++++- .../net/ethernet/marvell/octeontx2/nic/otx2_ptp.c | 209 +++++++++++++++++ .../net/ethernet/marvell/octeontx2/nic/otx2_ptp.h | 13 ++ .../net/ethernet/marvell/octeontx2/nic/otx2_txrx.c | 87 +++++++- .../net/ethernet/marvell/octeontx2/nic/otx2_txrx.h | 1 + 20 files changed, 1018 insertions(+), 10 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/ptp.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/ptp.h create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/otx2_ptp.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/otx2_ptp.h
Signature · 1 line
2.7.4
PATCH v6 1/3 octeontx2-af: Support to enable/disable HW timestamping
From: Zyta Szpak <[email protected]>
Four new mbox messages ids and handler are added in order to enable or disable timestamping procedure on tx and rx side. Additionally when PTP is enabled, the packet parser must skip over 8 bytes and start analyzing packet data there. To make NPC profiles work seemlesly PTR_ADVANCE of IKPU is set so that parsing can be done as before when all data pointers are shifted by 8 bytes automatically.
--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 29 ++++++++++++ drivers/net/ethernet/marvell/octeontx2/af/cgx.h | 4 ++ drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 4 ++ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 1 + .../net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 54 ++++++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 52 +++++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 27 +++++++++++ 7 files changed, 171 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +29 -0
@@ -468,6 +468,35 @@ static void cgx_lmac_pause_frm_config(struct cgx *cgx, int lmac_id, bool enable) } } +void cgx_lmac_ptp_config (void *cgxd,int lmac_id,bool enable) +{ +struct cgx *cgx = cgxd; +u64 cfg; + +if (!cgx) +return ; + +if (enable) { +/* Enable inbound PTP timestamping */ + cfg =cgx_read (cgx, lmac_id,CGXX_GMP_GMI_RXX_FRM_CTL ); + cfg |=CGX_GMP_GMI_RXX_FRM_CTL_PTP_MODE ; +cgx_write (cgx, lmac_id,CGXX_GMP_GMI_RXX_FRM_CTL , cfg); + + cfg =cgx_read (cgx, lmac_id,CGXX_SMUX_RX_FRM_CTL ); + cfg |=CGX_SMUX_RX_FRM_CTL_PTP_MODE ; +cgx_write (cgx, lmac_id,CGXX_SMUX_RX_FRM_CTL , cfg); + }else { +/* Disable inbound PTP stamping */ + cfg =cgx_read (cgx, lmac_id,CGXX_GMP_GMI_RXX_FRM_CTL ); + cfg &= ~CGX_GMP_GMI_RXX_FRM_CTL_PTP_MODE ; +cgx_write (cgx, lmac_id,CGXX_GMP_GMI_RXX_FRM_CTL , cfg); + + cfg =cgx_read (cgx, lmac_id,CGXX_SMUX_RX_FRM_CTL ); + cfg &= ~CGX_SMUX_RX_FRM_CTL_PTP_MODE ; +cgx_write (cgx, lmac_id,CGXX_SMUX_RX_FRM_CTL , cfg); + } +} +/* CGX Firmware interface low level support */ static int cgx_fwi_cmd_send (u64 req,u64 *resp,struct lmac *lmac) {
drivers/net/ethernet/marvell/octeontx2/af/cgx.h +4 -0
@@ -58,8 +58,10 @@#define CGXX_SMUX_RX_FRM_CTL 0x20020#define CGX_SMUX_RX_FRM_CTL_CTL_BCK BIT_ULL(3) +#define CGX_SMUX_RX_FRM_CTL_PTP_MODE BIT_ULL(12)#define CGXX_GMP_GMI_RXX_FRM_CTL 0x38028#define CGX_GMP_GMI_RXX_FRM_CTL_CTL_BCK BIT_ULL(3) +#define CGX_GMP_GMI_RXX_FRM_CTL_PTP_MODE BIT_ULL(12)#define CGXX_SMUX_TX_CTL 0x20178#define CGXX_SMUX_TX_PAUSE_PKT_TIME 0x20110#define CGXX_SMUX_TX_PAUSE_PKT_INTERVAL 0x20120
@@ -139,4 +141,6 @@ int cgx_lmac_get_pause_frm(void *cgxd, int lmac_id, u8 *tx_pause, u8 *rx_pause);int cgx_lmac_set_pause_frm (void *cgxd,int lmac_id,u8 tx_pause,u8 rx_pause); +void cgx_lmac_ptp_config (void *cgxd,int lmac_id,bool enable); +#endif /* CGX_H */
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +4 -0
@@ -143,6 +143,8 @@ M(CGX_STOP_LINKEVENTS, 0x208, cgx_stop_linkevents, msg_req, msg_rsp) \ M(CGX_GET_LINKINFO, 0x209, cgx_get_linkinfo, msg_req, cgx_link_info_msg) \ M(CGX_INTLBK_ENABLE, 0x20A, cgx_intlbk_enable, msg_req, msg_rsp) \ M(CGX_INTLBK_DISABLE, 0x20B, cgx_intlbk_disable, msg_req, msg_rsp) \ +M(CGX_PTP_RX_ENABLE, 0x20C, cgx_ptp_rx_enable, msg_req, msg_rsp) \ +M(CGX_PTP_RX_DISABLE, 0x20D, cgx_ptp_rx_disable, msg_req, msg_rsp) \M (CGX_CFG_PAUSE_FRM ,0x20E , cgx_cfg_pause_frm, cgx_pause_frm_cfg, \ cgx_pause_frm_cfg) \/* NPA mbox IDs (range 0x400 - 0x5FF) */ \
@@ -213,6 +215,8 @@ M(NIX_LSO_FORMAT_CFG, 0x8011, nix_lso_format_cfg, \ nix_lso_format_cfg, \ nix_lso_format_cfg_rsp) \ M(NIX_RXVLAN_ALLOC, 0x8012, nix_rxvlan_alloc, msg_req, msg_rsp) \ +M(NIX_LF_PTP_TX_ENABLE, 0x8013, nix_lf_ptp_tx_enable, msg_req, msg_rsp) \ +M(NIX_LF_PTP_TX_DISABLE, 0x8014, nix_lf_ptp_tx_disable, msg_req, msg_rsp) \ M(NIX_BP_ENABLE, 0x8016, nix_bp_enable, nix_bp_cfg_req, \ nix_bp_cfg_rsp) \M (NIX_BP_DISABLE ,0x8017 , nix_bp_disable, nix_bp_cfg_req, msg_rsp) \
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +1 -0
@@ -469,6 +469,7 @@ int rvu_npc_init(struct rvu *rvu);void rvu_npc_freemem (struct rvu *rvu);int rvu_npc_get_pkind (struct rvu *rvu,u16 pf);void rvu_npc_set_pkind (struct rvu *rvu,int pkind,struct rvu_pfvf *pfvf); +int npc_config_ts_kpuaction (struct rvu *rvu,int pf,u16 pcifunc,bool en);void rvu_npc_install_ucast_entry (struct rvu *rvu,u16 pcifunc,int nixlf,u64 chan,u8 *mac_addr); void rvu_npc_install_promisc_entry(struct rvu *rvu, u16 pcifunc,
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +54 -0
60 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +52 -0
58 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +27 -0
@@ -27,6 +27,7 @@#define NIXLF_PROMISC_ENTRY 2#define NPC_PARSE_RESULT_DMAC_OFFSET 8 +#define NPC_HW_TSTAMP_OFFSET 8static void npc_mcam_free_all_entries (struct rvu *rvu,struct npc_mcam *mcam,int blkaddr,u16 pcifunc);
@@ -61,6 +62,32 @@ int rvu_npc_get_pkind(struct rvu *rvu, u16 pf)return -1 ; } +int npc_config_ts_kpuaction (struct rvu *rvu,int pf,u16 pcifunc,bool en) +{ +int pkind, blkaddr; +u64 val; + + pkind =rvu_npc_get_pkind (rvu, pf); +if (pkind <0 ) { +dev_err (rvu->dev,"%s: pkind not mapped\n" , __func__); +return -EINVAL ; + } + + blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NPC , pcifunc); +if (blkaddr <0 ) { +dev_err (rvu->dev,"%s: NPC block not implemented\n" , __func__); +return -EINVAL ; + } + val =rvu_read64 (rvu, blkaddr,NPC_AF_PKINDX_ACTION0 (pkind)); + val &= ~0xff00000ULL ;/* Zero ptr advance field */ +if (en) +/* Set to timestamp offset */ + val |= (NPC_HW_TSTAMP_OFFSET <<20 ); +rvu_write64 (rvu, blkaddr,NPC_AF_PKINDX_ACTION0 (pkind), val); + +return 0 ; +} +static int npc_get_nixlf_mcam_index (struct npc_mcam *mcam,u16 pcifunc,int nixlf,int type) {
Signature · 1 line
2.7.4
Re: [PATCH v6 net-next 1/3] octeontx2-af: Support to enable/disable HW timestamping
Quoted 10 lines · [email protected] wrote:
From: Zyta Szpak <[email protected]>
Four new mbox messages ids and handler are added in order to enable or disable timestamping procedure on tx and rx side. Additionally when PTP is enabled, the packet parser must skip over 8 bytes and start analyzing packet data there. To make NPC profiles work seemlesly
PTR_ADVANCEof IKPU is set so that parsing can be done as before when all data pointers are shifted by 8 bytes automatically.
Quoted 3 lines
Signed-off-by Zyta Szpak <[email protected]>Signed-off-by Subbaraya Sundeep <[email protected]>Signed-off-by Sunil Goutham <[email protected]>
I know these patches are already acked by a couple of people in v4, but I have a few more minor concerns that I'd like you to consider listed below. Up to DaveM whether he wants to apply without the fixes I mention.
Quoted 15 lines
--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 29 ++++++++++++ drivers/net/ethernet/marvell/octeontx2/af/cgx.h | 4 ++ drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 4 ++ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 1 + .../net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 54 ++++++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 52 +++++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 27 +++++++++++ 7 files changed, 171 insertions(+)drivers/net/ethernet/marvell/octeontx2/af/cgx.c +0
-0
drivers/net/ethernet/marvell/octeontx2/af/cgx.c static void cgx_lmac_pause_frm_config(struct cgx *cgx, int lmac_id, bool enable) · line 470
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +0
-0@@ -468,6 +468,35 @@ static void cgx_lmac_pause_frm_config(struct cgx *cgx, int lmac_id, bool enable) } }
Generally what I'd like to see is that you have a comment here in kernel doc format, I suppose your driver probably doesn't have any of these, but it is particularly important to describe what each function is meant to do especially when it is a symbol callable from other files/modules. Something like:
/**
* cgx_lmac_ptp_config - enable or disable timestamping
* @cgxd: driver context
* @lmac_id: ID used to get register offset
* @enable: true if timestamping should be enabled, false if not *
* Here would be a multi-line description of what this function does
* and if it has a return value, what it's for.
*/
Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +8
-0+void cgx_lmac_ptp_config (void *cgxd,int lmac_id,bool enable) +{ +struct cgx *cgx = cgxd; +u64 cfg; + +if (!cgx) +return ; +
<snip>
Quoted 11 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +11
-0+int rvu_mbox_handler_nix_lf_ptp_tx_enable (struct rvu *rvu,struct msg_req *req, +struct msg_rsp *rsp) +{ +struct rvu_hwinfo *hw = rvu->hw; +u16 pcifunc = req->hdr.pcifunc; +struct rvu_block *block; +int blkaddr; +int nixlf; +u64 cfg; + + blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NIX , pcifunc);
drivers/net/ethernet/marvell/octeontx2/af/cgx.c
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +10
-0+if (blkaddr <0 ) +return NIX_AF_ERR_AF_LF_INVALID ; + + block = &hw->block[blkaddr]; + nixlf =rvu_get_lf (rvu, block, pcifunc,0 ); +if (nixlf <0 ) +return NIX_AF_ERR_AF_LF_INVALID ; + + cfg =rvu_read64 (rvu, blkaddr,NIX_AF_LFX_TX_CFG (nixlf)); + cfg |=BIT_ULL (32 );
I'm not super excited by the magic numbers here, without even a comment, you should make a define for bit 32, and not leave me guessing if this is the "enable" bit or is for something else.
Quoted 21 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +21
-0+rvu_write64 (rvu, blkaddr,NIX_AF_LFX_TX_CFG (nixlf), cfg); + +return 0 ; +} + +int rvu_mbox_handler_nix_lf_ptp_tx_disable (struct rvu *rvu,struct msg_req *req, +struct msg_rsp *rsp) +{ +struct rvu_hwinfo *hw = rvu->hw; +u16 pcifunc = req->hdr.pcifunc; +struct rvu_block *block; +int blkaddr; +int nixlf; +u64 cfg; + + blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NIX , pcifunc); +if (blkaddr <0 ) +return NIX_AF_ERR_AF_LF_INVALID ; + + block = &hw->block[blkaddr]; + nixlf =rvu_get_lf (rvu, block, pcifunc,0 );
drivers/net/ethernet/marvell/octeontx2/af/cgx.c
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +10
-0+if (nixlf <0 ) +return NIX_AF_ERR_AF_LF_INVALID ; + + cfg =rvu_read64 (rvu, blkaddr,NIX_AF_LFX_TX_CFG (nixlf)); + cfg &= ~BIT_ULL (32 ); +rvu_write64 (rvu, blkaddr,NIX_AF_LFX_TX_CFG (nixlf), cfg); + +return 0 ; +} +
Is this and the function above exactly the same 20+ lines of code with a one line difference? Before you passed an "enable" bool to another function, why the difference here?
Quoted 27 lines
int rvu_mbox_handler_nix_lso_format_cfg(struct rvu *rvu,
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +0
-0struct nix_lso_format_cfg *req, struct nix_lso_format_cfg_rsp *rsp)drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +9
-0@@ -27,6 +27,7 @@#define NIXLF_PROMISC_ENTRY 2#define NPC_PARSE_RESULT_DMAC_OFFSET 8 +#define NPC_HW_TSTAMP_OFFSET 8static void npc_mcam_free_all_entries (struct rvu *rvu,struct npc_mcam *mcam,int blkaddr,u16 pcifunc);@@ -61,6 +62,32 @@ int rvu_npc_get_pkind(struct rvu *rvu, u16 pf)return -1 ; } +int npc_config_ts_kpuaction (struct rvu *rvu,int pf,u16 pcifunc,bool en) +{ +int pkind, blkaddr; +u64 val; + + pkind =rvu_npc_get_pkind (rvu, pf); +if (pkind <0 ) { +dev_err (rvu->dev,"%s: pkind not mapped\n" , __func__);
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c int rvu_npc_get_pkind(struct rvu *rvu, u16 pf) · line 82
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +10
-0+return -EINVAL ; + } + + blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NPC , pcifunc); +if (blkaddr <0 ) { +dev_err (rvu->dev,"%s: NPC block not implemented\n" , __func__); +return -EINVAL ; + } + val =rvu_read64 (rvu, blkaddr,NPC_AF_PKINDX_ACTION0 (pkind)); + val &= ~0xff00000ULL ;/* Zero ptr advance field */
Please don't use trailing comments *ever* in a code section, the only place it is marginally ok, is in structure definitions.
Also, What's up with the magic number? At least you had a comment.
Re: [PATCH v6 net-next 1/3] octeontx2-af: Support to enable/disable HW timestamping
Hi,
Quoted 49 lines · Jesse Brandeburg
Quoted 10 lines · [email protected] wrote:
From: Zyta Szpak <[email protected]>
Four new mbox messages ids and handler are added in order to enable or disable timestamping procedure on tx and rx side. Additionally when PTP is enabled, the packet parser must skip over 8 bytes and start analyzing packet data there. To make NPC profiles work seemlesly
PTR_ADVANCEof IKPU is set so that parsing can be done as before when all data pointers are shifted by 8 bytes automatically.Quoted 3 lines
Signed-off-by Zyta Szpak <[email protected]>Signed-off-by Subbaraya Sundeep <[email protected]>Signed-off-by Sunil Goutham <[email protected]>I know these patches are already acked by a couple of people in v4, but I have a few more minor concerns that I'd like you to consider listed below. Up to DaveM whether he wants to apply without the fixes I mention.
Quoted 15 lines
--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 29 ++++++++++++ drivers/net/ethernet/marvell/octeontx2/af/cgx.h | 4 ++ drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 4 ++ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 1 + .../net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 54 ++++++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 52 +++++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 27 +++++++++++ 7 files changed, 171 insertions(+)drivers/net/ethernet/marvell/octeontx2/af/cgx.c +0
-0drivers/net/ethernet/marvell/octeontx2/af/cgx.c static void cgx_lmac_pause_frm_config(struct cgx *cgx, int lmac_id, bool enable) · line 470
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +0
-0@@ -468,6 +468,35 @@ static void cgx_lmac_pause_frm_config(struct cgx *cgx, int lmac_id, bool enable) } }Generally what I'd like to see is that you have a comment here in kernel doc format, I suppose your driver probably doesn't have any of these, but it is particularly important to describe what each function is meant to do especially when it is a symbol callable from other files/modules. Something like:
Quoted 10 lines
/**
*cgx_lmac_ptp_config- enable or disable timestamping
* @cgxd: driver context
* @lmac_id: ID used to get register offset
* @enable: true if timestamping should be enabled, false if not *
* Here would be a multi-line description of what this function does
* and if it has a return value, what it's for.
*/
I agree but we have lot of non static functions because of mbox handlers and adding kernel doc for all those didn't look good. We try best to use proper function names.
Quoted 27 lines
Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +8
-0+void cgx_lmac_ptp_config (void *cgxd,int lmac_id,bool enable) +{ +struct cgx *cgx = cgxd; +u64 cfg; + +if (!cgx) +return ; +<snip>
Quoted 17 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +17
-0+int rvu_mbox_handler_nix_lf_ptp_tx_enable (struct rvu *rvu,struct msg_req *req, +struct msg_rsp *rsp) +{ +struct rvu_hwinfo *hw = rvu->hw; +u16 pcifunc = req->hdr.pcifunc; +struct rvu_block *block; +int blkaddr; +int nixlf; +u64 cfg; + + blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NIX , pcifunc); +if (blkaddr <0 ) +return NIX_AF_ERR_AF_LF_INVALID ; + + block = &hw->block[blkaddr]; + nixlf =rvu_get_lf (rvu, block, pcifunc,0 ); +if (nixlf <0 )
Quoted 9 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +4
-0+return NIX_AF_ERR_AF_LF_INVALID ; + + cfg =rvu_read64 (rvu, blkaddr,NIX_AF_LFX_TX_CFG (nixlf)); + cfg |=BIT_ULL (32 );I'm not super excited by the magic numbers here, without even a comment, you should make a define for bit 32, and not leave me guessing if this is the "enable" bit or is for something else.
Because of the huge number of registers and bit definitions we are avoiding adding macros for simpler cases like the one above.
Quoted 27 lines
Quoted 27 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +27
-0+rvu_write64 (rvu, blkaddr,NIX_AF_LFX_TX_CFG (nixlf), cfg); + +return 0 ; +} + +int rvu_mbox_handler_nix_lf_ptp_tx_disable (struct rvu *rvu,struct msg_req *req, +struct msg_rsp *rsp) +{ +struct rvu_hwinfo *hw = rvu->hw; +u16 pcifunc = req->hdr.pcifunc; +struct rvu_block *block; +int blkaddr; +int nixlf; +u64 cfg; + + blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NIX , pcifunc); +if (blkaddr <0 ) +return NIX_AF_ERR_AF_LF_INVALID ; + + block = &hw->block[blkaddr]; + nixlf =rvu_get_lf (rvu, block, pcifunc,0 ); +if (nixlf <0 ) +return NIX_AF_ERR_AF_LF_INVALID ; + + cfg =rvu_read64 (rvu, blkaddr,NIX_AF_LFX_TX_CFG (nixlf)); + cfg &= ~BIT_ULL (32 ); +rvu_write64 (rvu, blkaddr,NIX_AF_LFX_TX_CFG (nixlf), cfg);
Quoted 9 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +4
-0+ +return 0 ; +} +Is this and the function above exactly the same 20+ lines of code with a one line difference? Before you passed an "enable" bool to another function, why the difference here?
Agreed. I will modify it.
Quoted 32 lines
Quoted 32 lines
int rvu_mbox_handler_nix_lso_format_cfg(struct rvu *rvu,
structnix_lso_format_cfg*req, structnix_lso_format_cfg_rsp*rsp)drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +14
-0@@ -27,6 +27,7 @@#define NIXLF_PROMISC_ENTRY 2#define NPC_PARSE_RESULT_DMAC_OFFSET 8 +#define NPC_HW_TSTAMP_OFFSET 8static void npc_mcam_free_all_entries (struct rvu *rvu,struct npc_mcam *mcam,int blkaddr,u16 pcifunc);@@ -61,6 +62,32 @@ int rvu_npc_get_pkind(struct rvu *rvu, u16 pf)return -1 ; } +int npc_config_ts_kpuaction (struct rvu *rvu,int pf,u16 pcifunc,bool en) +{ +int pkind, blkaddr; +u64 val; + + pkind =rvu_npc_get_pkind (rvu, pf); +if (pkind <0 ) { +dev_err (rvu->dev,"%s: pkind not mapped\n" , __func__); +return -EINVAL ; + } + + blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NPC , pcifunc); +if (blkaddr <0 ) {
Quoted 9 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c int rvu_npc_get_pkind(struct rvu *rvu, u16 pf) · line 82
Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +5
-0+dev_err (rvu->dev,"%s: NPC block not implemented\n" , __func__); +return -EINVAL ; + } + val =rvu_read64 (rvu, blkaddr,NPC_AF_PKINDX_ACTION0 (pkind)); + val &= ~0xff00000ULL ;/* Zero ptr advance field */ Please don't use trailing comments *ever* in a code section, the only place it is marginally ok, is in structure definitions.
Okay will fix it.
Quoted 3 lines
Also, What's up with the magic number? At least you had a comment.
Sure will fix it.
Thanks,
Sundeep
PATCH v6 2/3 octeontx2-af: Add support for Marvell PTP coprocessor
In reply to [email protected]From: Aleksey Makarov <[email protected]>
This patch adds driver for Precision Time
Protocol Clock and Timestamping block found on
Octeontx2 platform. The driver does initial
configuration and exposes a function to adjust
PTP hardware clock.
--- drivers/net/ethernet/marvell/octeontx2/af/Makefile | 2 +- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 17 ++ drivers/net/ethernet/marvell/octeontx2/af/ptp.c | 248 +++++++++++++++++++++ drivers/net/ethernet/marvell/octeontx2/af/ptp.h | 22 ++ drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 29 ++- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 4 + 6 files changed, 318 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/ptp.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/ptp.h
drivers/net/ethernet/marvell/octeontx2/af/Makefile +1 -1
@@ -8,4 +8,4 @@ obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o octeontx2_mbox-y := mbox.o octeontx2_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \ - rvu_reg.o rvu_npc.o rvu_debugfs.o + rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +17 -0
@@ -127,6 +127,7 @@ M(ATTACH_RESOURCES, 0x002, attach_resources, rsrc_attach, msg_rsp) \ M(DETACH_RESOURCES, 0x003, detach_resources, rsrc_detach, msg_rsp) \ M(MSIX_OFFSET, 0x005, msix_offset, msg_req, msix_offset_rsp) \ M(VF_FLR, 0x006, vf_flr, msg_req, msg_rsp) \ +M(PTP_OP, 0x007, ptp_op, ptp_req, ptp_rsp) \M (GET_HW_CAP ,0x008 , get_hw_cap, msg_req, get_hw_cap_rsp) \ /* CGX mbox IDs (range 0x200 - 0x3FF) */ \M (CGX_START_RXTX ,0x200 , cgx_start_rxtx, msg_req, msg_rsp) \
@@ -862,4 +863,20 @@ struct npc_get_kex_cfg_rsp { u8 mkex_pfl_name[MKEX_NAME_LEN]; }; +enum ptp_op { +PTP_OP_ADJFINE =0 , +PTP_OP_GET_CLOCK =1 , +}; + +struct ptp_req { +struct mbox_msghdr hdr; +u8 op; +s64 scaled_ppm; +}; + +struct ptp_rsp { +struct mbox_msghdr hdr; +u64 clk; +}; +#endif /* MBOX_H */
drivers/net/ethernet/marvell/octeontx2/af/ptp.c new file +248 -0
248 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/ptp.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Marvell PTP driver */ + +#ifndef PTP_H +#define PTP_H + +#include <linux/timecounter.h> +#include <linux/time64.h> +#include <linux/spinlock.h> + +struct ptp { +struct pci_dev *pdev; +void __iomem *reg_base; +u32 clock_rate; +}; + +struct ptp *ptp_get (void ); +void ptp_put (struct ptp *ptp); + +extern struct pci_driver ptp_driver; + +#endif
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +26 -3
@@ -18,6 +18,7 @@#include "cgx.h" #include "rvu.h" #include "rvu_reg.h" +#include "ptp.h" #define DRV_NAME "octeontx2-af"#define DRV_STRING "Marvell OcteonTX2 RVU Admin Function Driver"
@@ -2565,13 +2566,21 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)pci_set_master (pdev); + rvu->ptp =ptp_get (); +if (IS_ERR (rvu->ptp)) { + err =PTR_ERR (rvu->ptp); +if (err == -EPROBE_DEFER ) + goto err_release_regions; + rvu->ptp =NULL ; + } +/* Map Admin function CSRs */ rvu->afreg_base =pcim_iomap (pdev,PCI_AF_REG_BAR_NUM ,0 ); rvu->pfreg_base =pcim_iomap (pdev,PCI_PF_REG_BAR_NUM ,0 );if (!rvu->afreg_base || !rvu->pfreg_base) {dev_err (dev,"Unable to map admin function CSRs, aborting\n" ); err = -ENOMEM ; - goto err_release_regions; + goto err_put_ptp; }/* Store module params in rvu structure */
@@ -2586,7 +2595,7 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id) err =rvu_setup_hw_resources (rvu);if (err) - goto err_release_regions; + goto err_put_ptp;/* Init mailbox btw AF and PFs */ err = rvu_mbox_init(rvu, &rvu->afpf_wq_info, TYPE_AFPF,
@@ -2626,6 +2635,8 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)rvu_reset_all_blocks (rvu);rvu_free_hw_resources (rvu);rvu_clear_rvum_blk_revid (rvu); +err_put_ptp: +ptp_put (rvu->ptp); err_release_regions:pci_release_regions (pdev); err_disable_device:
@@ -2651,6 +2662,7 @@ static void rvu_remove(struct pci_dev *pdev)rvu_reset_all_blocks (rvu);rvu_free_hw_resources (rvu);rvu_clear_rvum_blk_revid (rvu); +ptp_put (rvu->ptp);pci_release_regions (pdev);pci_disable_device (pdev);pci_set_drvdata (pdev,NULL );
@@ -2676,9 +2688,19 @@ static int __init rvu_init_module(void)if (err <0 )return err; + err =pci_register_driver (&ptp_driver); +if (err <0 ) + goto ptp_err; + err =pci_register_driver (&rvu_driver);if (err <0 ) -pci_unregister_driver (&cgx_driver); + goto rvu_err; + +return 0 ; +rvu_err: +pci_unregister_driver (&ptp_driver); +ptp_err: +pci_unregister_driver (&cgx_driver);return err; }
@@ -2686,6 +2708,7 @@ static int __init rvu_init_module(void) static void __exit rvu_cleanup_module(void) {pci_unregister_driver (&rvu_driver); +pci_unregister_driver (&ptp_driver);pci_unregister_driver (&cgx_driver); }
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +4 -0
@@ -289,6 +289,8 @@ struct rvu_fwdata {u64 reserved[FWDATA_RESERVED_MEM ]; }; +struct ptp ; +struct rvu {void __iomem *afreg_base;void __iomem *pfreg_base;
@@ -337,6 +339,8 @@ struct rvu {/* Firmware data */ struct rvu_fwdata *fwdata; +struct ptp *ptp; +#ifdef CONFIG_DEBUG_FS struct rvu_debugfs rvu_dbg;#endif
Signature · 1 line
2.7.4
Re: [PATCH v6 net-next 2/3] octeontx2-af: Add support for Marvell PTP coprocessor
Quoted 7 lines · [email protected] wrote:
From: Aleksey Makarov <[email protected]>
This patch adds driver for Precision Time
Protocol Clock and Timestamping block found on
Octeontx2 platform. The driver does initial
configuration and exposes a function to adjust
PTP hardware clock.
Please explain in the commit message why you have two methods of handling the clocks PCI space, as without that it seems like some of the code is either un-necessary or not clear why it's there.
Quoted 65 lines
Co-developed-by Subbaraya Sundeep <[email protected]>Signed-off-by Subbaraya Sundeep <[email protected]>Signed-off-by Aleksey Makarov <[email protected]>Signed-off-by Sunil Goutham <[email protected]>--- drivers/net/ethernet/marvell/octeontx2/af/Makefile | 2 +- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 17 ++ drivers/net/ethernet/marvell/octeontx2/af/ptp.c | 248 +++++++++++++++++++++ drivers/net/ethernet/marvell/octeontx2/af/ptp.h | 22 ++ drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 29 ++- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 4 + 6 files changed, 318 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/ptp.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/ptp.hdrivers/net/ethernet/marvell/octeontx2/af/Makefile +1
-1@@ -8,4 +8,4 @@ obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o octeontx2_mbox-y := mbox.o octeontx2_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \ - rvu_reg.o rvu_npc.o rvu_debugfs.o + rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.odrivers/net/ethernet/marvell/octeontx2/af/mbox.h +17
-0@@ -127,6 +127,7 @@ M(ATTACH_RESOURCES, 0x002, attach_resources, rsrc_attach, msg_rsp) \ M(DETACH_RESOURCES, 0x003, detach_resources, rsrc_detach, msg_rsp) \ M(MSIX_OFFSET, 0x005, msix_offset, msg_req, msix_offset_rsp) \ M(VF_FLR, 0x006, vf_flr, msg_req, msg_rsp) \ +M(PTP_OP, 0x007, ptp_op, ptp_req, ptp_rsp) \M (GET_HW_CAP ,0x008 , get_hw_cap, msg_req, get_hw_cap_rsp) \ /* CGX mbox IDs (range 0x200 - 0x3FF) */ \M (CGX_START_RXTX ,0x200 , cgx_start_rxtx, msg_req, msg_rsp) \@@ -862,4 +863,20 @@ struct npc_get_kex_cfg_rsp { u8 mkex_pfl_name[MKEX_NAME_LEN]; }; +enum ptp_op { +PTP_OP_ADJFINE =0 , +PTP_OP_GET_CLOCK =1 , +}; + +struct ptp_req { +struct mbox_msghdr hdr; +u8 op; +s64 scaled_ppm; +}; + +struct ptp_rsp { +struct mbox_msghdr hdr; +u64 clk; +}; +#endif /* MBOX_H */ drivers/net/ethernet/marvell/octeontx2/af/ptp.c new file +0
-0
drivers/net/ethernet/marvell/octeontx2/af/ptp.c line 2
Quoted 2 lines
drivers/net/ethernet/marvell/octeontx2/af/ptp.c new file +2
-0@@ -0,0 +1,248 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Marvell PTP driver */
Your file is missing Copyrights, is that your intent?
I didn't have any comments for the rest of the patch, except that there is a lack of comments and communication of intent of the code. I can see what it does, but think of the point of view of a kernel consumer getting this code in the future and wanting to extend it or debug it, and the code being able to talk to "future you" who has no idea why the code was there or what it was trying to do.
<snip>
Re: [PATCH v6 net-next 2/3] octeontx2-af: Add support for Marvell PTP coprocessor
Hi,
Quoted 11 lines · Jesse Brandeburg
Quoted 7 lines · [email protected] wrote:
From: Aleksey Makarov <[email protected]>
This patch adds driver for Precision Time
Protocol Clock and Timestamping block found on
Octeontx2 platform. The driver does initial
configuration and exposes a function to adjust
PTP hardware clock.
Quoted 4 lines
Please explain in the commit message why you have two methods of handling the clocks PCI space, as without that it seems like some of the code is either un-necessary or not clear why it's there.
Sure will elaborate it.
Quoted 61 lines
Quoted 61 lines
Co-developed-by Subbaraya Sundeep <[email protected]>Signed-off-by Subbaraya Sundeep <[email protected]>Signed-off-by Aleksey Makarov <[email protected]>Signed-off-by Sunil Goutham <[email protected]>--- drivers/net/ethernet/marvell/octeontx2/af/Makefile | 2 +- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 17 ++ drivers/net/ethernet/marvell/octeontx2/af/ptp.c | 248 +++++++++++++++++++++ drivers/net/ethernet/marvell/octeontx2/af/ptp.h | 22 ++ drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 29 ++- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 4 + 6 files changed, 318 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/ptp.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/ptp.hdrivers/net/ethernet/marvell/octeontx2/af/Makefile +1
-1@@ -8,4 +8,4 @@ obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o octeontx2_mbox-y := mbox.o octeontx2_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \ - rvu_reg.o rvu_npc.o rvu_debugfs.o + rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.odrivers/net/ethernet/marvell/octeontx2/af/mbox.h +17
-0@@ -127,6 +127,7 @@ M(ATTACH_RESOURCES, 0x002, attach_resources, rsrc_attach, msg_rsp) \ M(DETACH_RESOURCES, 0x003, detach_resources, rsrc_detach, msg_rsp) \ M(MSIX_OFFSET, 0x005, msix_offset, msg_req, msix_offset_rsp) \ M(VF_FLR, 0x006, vf_flr, msg_req, msg_rsp) \ +M(PTP_OP, 0x007, ptp_op, ptp_req, ptp_rsp) \M (GET_HW_CAP ,0x008 , get_hw_cap, msg_req, get_hw_cap_rsp) \ /* CGX mbox IDs (range 0x200 - 0x3FF) */ \M (CGX_START_RXTX ,0x200 , cgx_start_rxtx, msg_req, msg_rsp) \@@ -862,4 +863,20 @@ struct npc_get_kex_cfg_rsp { u8 mkex_pfl_name[MKEX_NAME_LEN]; }; +enum ptp_op { +PTP_OP_ADJFINE =0 , +PTP_OP_GET_CLOCK =1 , +}; + +struct ptp_req { +struct mbox_msghdr hdr; +u8 op; +s64 scaled_ppm; +}; + +struct ptp_rsp { +struct mbox_msghdr hdr; +u64 clk; +}; +#endif /* MBOX_H */ drivers/net/ethernet/marvell/octeontx2/af/ptp.c new file +0
-0
Quoted 9 lines
drivers/net/ethernet/marvell/octeontx2/af/ptp.c line 2
Quoted 6 lines
index 0000000..e9e131d
drivers/net/ethernet/marvell/octeontx2/af/ptp.c new file +2
-0@@ -0,0 +1,248 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Marvell PTP driver */ Your file is missing Copyrights, is that your intent?
From the discussion during VF driver submission @
https://patchwork.ozlabs.org/project/netdev/patch/[email protected]/#2384778
we are putting only the two lines SPDX and short driver description
Quoted 7 lines
I didn't have any comments for the rest of the patch, except that there is a lack of comments and communication of intent of the code. I can see what it does, but think of the point of view of a kernel consumer getting this code in the future and wanting to extend it or debug it, and the code being able to talk to "future you" who has no idea why the code was there or what it was trying to do.
Okay I will add comments where seems necessary.
Thanks,
Sundeep
Quoted 1 line
<snip>
PATCH v6 3/3 octeontx2-pf: Add support for PTP clock
In reply to [email protected]From: Aleksey Makarov <[email protected]>
This patch adds PTP clock and uses it in Octeontx2 network device. PTP clock uses mailbox calls to access the hardware counter on the RVU side.
--- .../net/ethernet/marvell/octeontx2/nic/Makefile | 3 +- .../ethernet/marvell/octeontx2/nic/otx2_common.c | 7 + .../ethernet/marvell/octeontx2/nic/otx2_common.h | 19 ++ .../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 28 +++ .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 168 ++++++++++++++++- .../net/ethernet/marvell/octeontx2/nic/otx2_ptp.c | 209 +++++++++++++++++++++ .../net/ethernet/marvell/octeontx2/nic/otx2_ptp.h | 13 ++ .../net/ethernet/marvell/octeontx2/nic/otx2_txrx.c | 87 ++++++++- .../net/ethernet/marvell/octeontx2/nic/otx2_txrx.h | 1 + 9 files changed, 529 insertions(+), 6 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/otx2_ptp.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/nic/otx2_ptp.h
drivers/net/ethernet/marvell/octeontx2/nic/Makefile +2 -1
@@ -6,7 +6,8 @@ obj-$(CONFIG_OCTEONTX2_PF) += octeontx2_nicpf.o obj-$(CONFIG_OCTEONTX2_VF) += octeontx2_nicvf.o -octeontx2_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o otx2_ethtool.o +octeontx2_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o otx2_ethtool.o \ + otx2_ptp.o octeontx2_nicvf-y := otx2_vf.o ccflags-y += -I$(srctree)/drivers/net/ethernet/marvell/octeontx2/af
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +7 -0
@@ -671,6 +671,13 @@ static int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura)if (!sq->sg)return -ENOMEM ; +if (pfvf->ptp) { + err =qmem_alloc (pfvf->dev, &sq->timestamps, qset->sqe_cnt, +sizeof (*sq->timestamps)); +if (err) +return err; + } + sq->head =0 ; sq->sqe_per_sqb = (pfvf->hw.sqb_size / sq->sqe_size) -1 ; sq->num_sqbs = (qset->sqe_cnt + sq->sqe_per_sqb) / sq->sqe_per_sqb;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +19 -0
@@ -13,6 +13,9 @@#include <linux/pci.h> #include <linux/iommu.h> +#include <linux/net_tstamp.h> +#include <linux/ptp_clock_kernel.h> +#include <linux/timecounter.h> #include <mbox.h> #include "otx2_reg.h"
@@ -209,6 +212,17 @@ struct refill_work {struct otx2_nic *pf; }; +struct otx2_ptp { +struct ptp_clock_info ptp_info; +struct ptp_clock *ptp_clock; +struct otx2_nic *nic; + +struct cyclecounter cycle_counter; +struct timecounter time_counter; +}; + +#define OTX2_HW_TIMESTAMP_LEN 8 +struct otx2_nic {void __iomem *reg_base;struct net_device *netdev;
@@ -216,6 +230,8 @@ struct otx2_nic {u16 max_frs;u16 rbsize;/* Receive buffer size */ +#define OTX2_FLAG_RX_TSTAMP_ENABLED BIT_ULL(0) +#define OTX2_FLAG_TX_TSTAMP_ENABLED BIT_ULL(1)#define OTX2_FLAG_INTF_DOWN BIT_ULL(2)#define OTX2_FLAG_RX_PAUSE_ENABLED BIT_ULL(9)#define OTX2_FLAG_TX_PAUSE_ENABLED BIT_ULL(10)
@@ -251,6 +267,9 @@ struct otx2_nic {/* Block address of NIX either BLKADDR_NIX0 or BLKADDR_NIX1 */ int nix_blkaddr; + +struct otx2_ptp *ptp; +struct hwtstamp_config tstamp; };static inline bool is_otx2_lbkvf (struct pci_dev *pdev)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +28 -0
@@ -13,8 +13,10 @@#include <linux/stddef.h> #include <linux/etherdevice.h> #include <linux/log2.h> +#include <linux/net_tstamp.h> #include "otx2_common.h" +#include "otx2_ptp.h" #define DRV_NAME "octeontx2-nicpf"#define DRV_VF_NAME "octeontx2-nicvf"
@@ -663,6 +665,31 @@ static u32 otx2_get_link(struct net_device *netdev)return pfvf->linfo.link_up; } +static int otx2_get_ts_info (struct net_device *netdev, +struct ethtool_ts_info *info) +{ +struct otx2_nic *pfvf =netdev_priv (netdev); + +if (!pfvf->ptp) +return ethtool_op_get_ts_info (netdev, info); + + info->so_timestamping =SOF_TIMESTAMPING_TX_SOFTWARE | +SOF_TIMESTAMPING_RX_SOFTWARE | +SOF_TIMESTAMPING_SOFTWARE | +SOF_TIMESTAMPING_TX_HARDWARE | +SOF_TIMESTAMPING_RX_HARDWARE | +SOF_TIMESTAMPING_RAW_HARDWARE ; + + info->phc_index =otx2_ptp_clock_index (pfvf); + + info->tx_types = (1 <<HWTSTAMP_TX_OFF ) | (1 <<HWTSTAMP_TX_ON ); + + info->rx_filters = (1 <<HWTSTAMP_FILTER_NONE ) | + (1 <<HWTSTAMP_FILTER_ALL ); + +return 0 ; +} +static const struct ethtool_ops otx2_ethtool_ops = { .supported_coalesce_params =ETHTOOL_COALESCE_USECS |ETHTOOL_COALESCE_MAX_FRAMES ,
@@ -687,6 +714,7 @@ static const struct ethtool_ops otx2_ethtool_ops = { .set_msglevel = otx2_set_msglevel, .get_pauseparam = otx2_get_pauseparam, .set_pauseparam = otx2_set_pauseparam, + .get_ts_info = otx2_get_ts_info, };void otx2_set_ethtool_ops (struct net_device *netdev)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +166 -2
234 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ptp.c new file +209 -0
209 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ptp.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Marvell OcteonTx2 PTP support for ethernet driver */ + +#ifndef OTX2_PTP_H +#define OTX2_PTP_H + +int otx2_ptp_init (struct otx2_nic *pfvf); +void otx2_ptp_destroy (struct otx2_nic *pfvf); + +int otx2_ptp_clock_index (struct otx2_nic *pfvf); +int otx2_ptp_tstamp2time (struct otx2_nic *pfvf,u64 tstamp,u64 *tsns); + +#endif
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +84 -3
149 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +1 -0
@@ -91,6 +91,7 @@ struct otx2_snd_queue {struct qmem *sqe;struct qmem *tso_hdrs;struct sg_list *sg; +struct qmem *timestamps;struct queue_stats stats;u16 sqb_count;u64 *sqb_ptrs;
Signature · 1 line
2.7.4
Re: [PATCH v6 net-next 3/3] octeontx2-pf: Add support for PTP clock
Quoted 10 lines · [email protected] wrote:
From: Aleksey Makarov <[email protected]>
This patch adds PTP clock and uses it in Octeontx2 network device. PTP clock uses mailbox calls to access the hardware counter on the RVU side.
Co-developed-by Subbaraya Sundeep <[email protected]>Signed-off-by Subbaraya Sundeep <[email protected]>Signed-off-by Aleksey Makarov <[email protected]>Signed-off-by Sunil Goutham <[email protected]>
Besides that this driver doesn't have copyrights, I don't see many problems with this part of the patch. I would like to see some of the other patches have my comments addressed.
For this patch:
Re: [PATCH v6 net-next 3/3] octeontx2-pf: Add support for PTP clock
Hi,
Quoted 14 lines · Jesse Brandeburg
Quoted 10 lines · [email protected] wrote:
From: Aleksey Makarov <[email protected]>
This patch adds PTP clock and uses it in Octeontx2 network device. PTP clock uses mailbox calls to access the hardware counter on the RVU side.
Co-developed-by Subbaraya Sundeep <[email protected]>Signed-off-by Subbaraya Sundeep <[email protected]>Signed-off-by Aleksey Makarov <[email protected]>Signed-off-by Sunil Goutham <[email protected]>
Quoted 6 lines
Besides that this driver doesn't have copyrights, I don't see many problems with this part of the patch. I would like to see some of the other patches have my comments addressed.
For this patch:
Reviewed-by Jesse Brandeburg <[email protected]>
Thank you,
Sundeep