net: aquantia: PTP support for AQC devices
Subsystems (4)
v2 cover net: aquantia: PTP support for AQC devices
This patchset introduces PTP feature support in Aquantia AQC atlantic driver.
This implementation is a joined effort of aquantia developers:
Egor is the main designer and driver/firmware architect on PTP, Sergey and Dmitry are included as co-developers. Dmitry also helped me in the overall patchset preparations.
Feature was verified on AQC hardware with testptp tool, linuxptp, gptp and with Motu hardware unit.
version2 updates:
- Fixing issues from Andrew's review: replacing self with
ptp var name, making ptp_clk_offset a field in the ptp instance. devm_kzalloc advice is actually non applicable, because ptp object gets created/destroyed on each network device close/open and it should not be linked with dev lifecycle.
- Rearranging commit authorship, adding Egor as a ptp module main maintainer
- Fixing kbuild 32bit division issues
Dmitry Bezrukov (5):
net: aquantia: unify styling of bit enums
net: aquantia: styling fixes on ptp related functions
net: aquantia: rx filters for ptp
net: aquantia: add support for Phy access
net: aquantia: add support for PIN funcs
Egor Pomozov (6):
net: aquantia: PTP skeleton declarations and callbacks
net: aquantia: add basic ptp_clock callbacks
net: aquantia: add PTP rings infrastructure
net: aquantia: implement data PTP datapath
net: aquantia: add support for ptp ioctls
net: aquantia: implement get_ts_info ethtool
Igor Russkikh (1):
net: aquantia: adding atlantic ptp maintainer
MAINTAINERS | 7 + .../net/ethernet/aquantia/atlantic/Makefile | 2 + .../net/ethernet/aquantia/atlantic/aq_cfg.h | 4 +- .../ethernet/aquantia/atlantic/aq_ethtool.c | 35 +- .../ethernet/aquantia/atlantic/aq_filters.c | 17 +- .../net/ethernet/aquantia/atlantic/aq_hw.h | 48 +- .../net/ethernet/aquantia/atlantic/aq_main.c | 105 +- .../net/ethernet/aquantia/atlantic/aq_nic.c | 96 +- .../net/ethernet/aquantia/atlantic/aq_nic.h | 16 +- .../ethernet/aquantia/atlantic/aq_pci_func.c | 5 +- .../net/ethernet/aquantia/atlantic/aq_phy.c | 147 ++ .../net/ethernet/aquantia/atlantic/aq_phy.h | 32 + .../net/ethernet/aquantia/atlantic/aq_ptp.c | 1397 +++++++++++++++++ .../net/ethernet/aquantia/atlantic/aq_ptp.h | 57 + .../net/ethernet/aquantia/atlantic/aq_ring.c | 64 +- .../net/ethernet/aquantia/atlantic/aq_ring.h | 7 +- .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 328 +++- .../atlantic/hw_atl/hw_atl_b0_internal.h | 9 +- .../aquantia/atlantic/hw_atl/hw_atl_llh.c | 96 +- .../aquantia/atlantic/hw_atl/hw_atl_llh.h | 58 +- .../atlantic/hw_atl/hw_atl_llh_internal.h | 223 ++- .../aquantia/atlantic/hw_atl/hw_atl_utils.c | 7 +- .../aquantia/atlantic/hw_atl/hw_atl_utils.h | 172 +- .../atlantic/hw_atl/hw_atl_utils_fw2x.c | 97 +- 24 files changed, 2895 insertions(+), 134 deletions(-) create mode 100644 drivers/net/ethernet/aquantia/atlantic/aq_phy.c create mode 100644 drivers/net/ethernet/aquantia/atlantic/aq_phy.h create mode 100644 drivers/net/ethernet/aquantia/atlantic/aq_ptp.c create mode 100644 drivers/net/ethernet/aquantia/atlantic/aq_ptp.h
Signature · 1 line
2.17.1
PATCH v2 1/12 net: aquantia: PTP skeleton declarations and callbacks
From: Egor Pomozov <[email protected]>
Here we add basic function for PTP clock register/unregister. We also declare FW/HW capability bits used to control PTP feature on device.
PTP device is created if network card has appropriate FW that has PTP enabled in config. HW supports timestamping for PTPv2 802.AS1 and PTPv2 IPv4 UDP packets.
It also supports basic PTP callbacks for getting/setting time, adjusting frequency and time as well.
--- .../net/ethernet/aquantia/atlantic/Makefile | 1 + .../net/ethernet/aquantia/atlantic/aq_nic.c | 10 +- .../net/ethernet/aquantia/atlantic/aq_nic.h | 5 +- .../net/ethernet/aquantia/atlantic/aq_ptp.c | 93 +++++++++++++++++++ .../net/ethernet/aquantia/atlantic/aq_ptp.h | 22 +++++ .../aquantia/atlantic/hw_atl/hw_atl_utils.h | 85 ++++++++++++++++- 6 files changed, 210 insertions(+), 6 deletions(-) create mode 100644 drivers/net/ethernet/aquantia/atlantic/aq_ptp.c create mode 100644 drivers/net/ethernet/aquantia/atlantic/aq_ptp.h
drivers/net/ethernet/aquantia/atlantic/Makefile +1 -0
@@ -24,6 +24,7 @@ atlantic-objs := aq_main.o \ aq_ethtool.o \ aq_drvinfo.o \ aq_filters.o \ + aq_ptp.o \ hw_atl/hw_atl_a0.o \ hw_atl/hw_atl_b0.o \ hw_atl/hw_atl_utils.o \
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +9 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only /* * aQuantia Corporation Network Driver -* Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved +* Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved */ /* File aq_nic.c: Definition of common code for NIC. */
@@ -12,6 +12,7 @@#include "aq_hw.h" #include "aq_pci_func.h" #include "aq_main.h" +#include "aq_ptp.h" #include <linux/moduleparam.h> #include <linux/netdevice.h>
@@ -331,6 +332,10 @@ int aq_nic_init(struct aq_nic_s *self) self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i])aq_vec_init (aq_vec, self->aq_hw_ops, self->aq_hw); + err =aq_ptp_init (self, self->irqvecs -1 ); +if (err <0 ) + goto err_exit; +netif_carrier_off (self->ndev); err_exit:
@@ -970,6 +975,9 @@ void aq_nic_deinit(struct aq_nic_s *self) self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i])aq_vec_deinit (aq_vec); +aq_ptp_unregister (self); +aq_ptp_free (self); +if (likely (self->aq_fw_ops->deinit)) {mutex_lock (&self->fwreq_mutex); self->aq_fw_ops->deinit (self->aq_hw);
drivers/net/ethernet/aquantia/atlantic/aq_nic.h +4 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* * aQuantia Corporation Network Driver -* Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved +* Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved */ /* File aq_nic.h: Declaration of common code for NIC. */
@@ -17,6 +17,7 @@ struct aq_ring_s;struct aq_hw_ops ;struct aq_fw_s ;struct aq_vec_s ; +struct aq_ptp_s ;struct aq_nic_cfg_s {const struct aq_hw_caps_s *aq_hw_caps;
@@ -108,6 +109,8 @@ struct aq_nic_s {u32 irqvecs;/* mutex to serialize FW interface access operations */ struct mutex fwreq_mutex; +/* PTP support */ +struct aq_ptp_s *aq_ptp;struct aq_hw_rx_fltrs_s aq_hw_rx_fltrs; };
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c new file +93 -0
93 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/aq_ptp.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Aquantia Corporation Network Driver +* Copyright (C) 2014-2019 Aquantia Corporation. All rights reserved +*/ + +/* File aq_ptp.h: Declaration of PTP functions. +*/ +#ifndef AQ_PTP_H +#define AQ_PTP_H + +#include <linux/net_tstamp.h> +#include <linux/version.h> + +/* Common functions */ +int aq_ptp_init (struct aq_nic_s *aq_nic,unsigned int idx_vec); + +void aq_ptp_unregister (struct aq_nic_s *aq_nic); +void aq_ptp_free (struct aq_nic_s *aq_nic); + +void aq_ptp_clock_init (struct aq_nic_s *aq_nic); + +#endif /* AQ_PTP_H */
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h +81 -4
123 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v2 net-next 01/12] net: aquantia: PTP skeleton declarations and callbacks
Quoted 14 lines · Igor Russkikh
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c new file +8
-0@@ -0,0 +1,93 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Aquantia Corporation Network Driver +* Copyright (C) 2014-2019 Aquantia Corporation. All rights reserved +*/ + +/* File aq_ptp.c: +* Definition of functions for Linux PTP support. +*/
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c line 18
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c new file +10
-0+ +#include <linux/ptp_clock_kernel.h> +#include <linux/clocksource.h> + +#include "aq_nic.h" +#include "aq_ptp.h" + +struct aq_ptp_s { +struct aq_nic_s *aq_nic; +
Nit: no blank line here.
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c line 30
Quoted 12 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c new file +12
-0+struct ptp_clock *ptp_clock; +struct ptp_clock_info ptp_info; +}; + +static struct ptp_clock_info aq_ptp_clock = { + .owner =THIS_MODULE , + .name ="atlantic ptp" , + .n_ext_ts =0 , + .pps =0 , + .n_per_out =0 , + .n_pins =0 , + .pin_config =NULL ,
Nit: use tabs to align columns (here some are spaces).
Quoted 21 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c new file +21
-0+}; + +int aq_ptp_init (struct aq_nic_s *aq_nic,unsigned int idx_vec) +{ +struct hw_atl_utils_mbox mbox; +struct ptp_clock *clock; +struct aq_ptp_s *aq_ptp; +int err =0 ; + +hw_atl_utils_mpi_read_stats (aq_nic->aq_hw, &mbox); + +if (!(mbox.info.caps_ex &BIT (CAPS_EX_PHY_PTP_EN ))) { + aq_nic->aq_ptp =NULL ; +return 0 ; + } + + aq_ptp =kzalloc (sizeof (*aq_ptp),GFP_KERNEL ); +if (!aq_ptp) { + err = -ENOMEM ; + goto err_exit; + }
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c line 61
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c new file +10
-0+ + aq_ptp->aq_nic = aq_nic; + + aq_ptp->ptp_info = aq_ptp_clock; + clock =ptp_clock_register (&aq_ptp->ptp_info, &aq_nic->ndev->dev); +if (!clock) { +netdev_err (aq_nic->ndev,"ptp_clock_register failed\n" ); + err =0 ; + goto err_exit; + }
You need to test for PTR_ERR and NULL:
* ptp_clock_register() - register a PTP hardware clock driver *
* @info: Structure describing the new clock.
* @parent: Pointer to the parent device of the new clock. *
* Returns a valid pointer on success or PTR_ERR on failure. If PHC
* support is missing at the configuration level, this function
* returns NULL, and drivers are expected to gracefully handle that
* case separately.
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c line 72
Quoted 11 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c new file +11
-0+ aq_ptp->ptp_clock = clock; + + aq_nic->aq_ptp = aq_ptp; + +return 0 ; + +err_exit: +kfree (aq_ptp); + aq_nic->aq_ptp =NULL ; +return err; +}
Thanks,
Richard
Re: [PATCH v2 net-next 01/12] net: aquantia: PTP skeleton declarations and callbacks
In reply to Igor RusskikhQuoted 24 lines · Igor Russkikh
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c new file +23
-0+static struct ptp_clock_info aq_ptp_clock = { + .owner =THIS_MODULE , + .name ="atlantic ptp" , + .n_ext_ts =0 , + .pps =0 , + .n_per_out =0 , + .n_pins =0 , + .pin_config =NULL , +}; +int aq_ptp_init (struct aq_nic_s *aq_nic,unsigned int idx_vec) +{ +struct hw_atl_utils_mbox mbox; +struct ptp_clock *clock; +struct aq_ptp_s *aq_ptp; +int err =0 ; + +hw_atl_utils_mpi_read_stats (aq_nic->aq_hw, &mbox); + +if (!(mbox.info.caps_ex &BIT (CAPS_EX_PHY_PTP_EN ))) { + aq_nic->aq_ptp =NULL ; +return 0 ; + } +
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c line 56
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c new file +10
-0+ aq_ptp =kzalloc (sizeof (*aq_ptp),GFP_KERNEL ); +if (!aq_ptp) { + err = -ENOMEM ; + goto err_exit; + } + + aq_ptp->aq_nic = aq_nic; + + aq_ptp->ptp_info = aq_ptp_clock; + clock =ptp_clock_register (&aq_ptp->ptp_info, &aq_nic->ndev->dev);
You register a ptp_info with NULL pointers instead of callbacks. That means this patch will cause an Oops. Incremental patch series are nice, but be sure that every patch really works. The patch that introduces the call to ptp_clock_register() should come only when ptp_info is populated with callbacks.
Thanks,
Richard
PATCH v2 2/12 net: aquantia: unify styling of bit enums
In reply to Igor RusskikhFrom: Dmitry Bezrukov <[email protected]>
Make some other bit-enums more clear about positioning, this helps on debugging and development
--- .../aquantia/atlantic/hw_atl/hw_atl_utils.c | 2 +- .../aquantia/atlantic/hw_atl/hw_atl_utils.h | 41 +++++++++++-------- 2 files changed, 26 insertions(+), 17 deletions(-)
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only /* * aQuantia Corporation Network Driver -* Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved +* Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved */ /* File hw_atl_utils.c: Definition of common functions for Atlantic hardware
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h +25 -16
110 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v2 net-next 02/12] net: aquantia: unify styling of bit enums
Quoted 7 lines · Igor Russkikh
From: Dmitry Bezrukov <[email protected]>
Make some other bit-enums more clear about positioning, this helps on debugging and development
Signed-off-by Dmitry Bezrukov <[email protected]>Signed-off-by Igor Russkikh <[email protected]>
Andrew
PATCH v2 3/12 net: aquantia: add basic ptp_clock callbacks
In reply to Igor RusskikhFrom: Egor Pomozov <[email protected]>
Basic HW functions implemented for adjusting frequency, adjusting time, getting and setting time.
Firmware interface for PTP requests and interactions.
Enable/disable PTP counters in HW on clock register/unregister
--- .../net/ethernet/aquantia/atlantic/aq_hw.h | 21 +++- .../net/ethernet/aquantia/atlantic/aq_nic.c | 3 + .../net/ethernet/aquantia/atlantic/aq_ptp.c | 116 ++++++++++++++++++ .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 110 ++++++++++++++++- .../aquantia/atlantic/hw_atl/hw_atl_llh.c | 16 ++- .../aquantia/atlantic/hw_atl/hw_atl_llh.h | 8 +- .../atlantic/hw_atl/hw_atl_llh_internal.h | 18 ++- .../aquantia/atlantic/hw_atl/hw_atl_utils.c | 5 +- .../aquantia/atlantic/hw_atl/hw_atl_utils.h | 30 +++++ .../atlantic/hw_atl/hw_atl_utils_fw2x.c | 97 +++++++++++---- 10 files changed, 394 insertions(+), 30 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +20 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* * aQuantia Corporation Network Driver -* Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved +* Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved */ /* File aq_hw.h: Declaration of abstract interface for NIC hardware specific
@@ -15,6 +15,9 @@#include "aq_rss.h" #include "hw_atl/hw_atl_utils.h" +#define AQ_HW_MAC_COUNTER_HZ 312500000ll +#define AQ_HW_PHY_COUNTER_HZ 160000000ll +#define AQ_RX_FIRST_LOC_FVLANID 0U#define AQ_RX_LAST_LOC_FVLANID 15U#define AQ_RX_FIRST_LOC_FETHERT 16U
@@ -94,6 +97,7 @@ struct aq_stats_s {#define AQ_HW_FLAG_STOPPING 0x00000008U#define AQ_HW_FLAG_RESETTING 0x00000010U#define AQ_HW_FLAG_CLOSING 0x00000020U +#define AQ_HW_PTP_AVAILABLE 0x01000000U#define AQ_HW_LINK_DOWN 0x04000000U#define AQ_HW_FLAG_ERR_UNPLUG 0x40000000U#define AQ_HW_FLAG_ERR_HW 0x80000000U
@@ -135,6 +139,7 @@ struct aq_hw_s {u32 rpc_addr;u32 rpc_tid;struct hw_atl_utils_fw_rpc rpc; +s64 ptp_clk_offset; };struct aq_ring_s ;
@@ -235,6 +240,14 @@ struct aq_hw_ops {int (*hw_set_offload)(struct aq_hw_s *self,struct aq_nic_cfg_s *aq_nic_cfg); +void (*hw_get_ptp_ts)(struct aq_hw_s *self,u64 *stamp); + +int (*hw_adj_clock_freq)(struct aq_hw_s *self,s32 delta); + +int (*hw_adj_sys_clock)(struct aq_hw_s *self,s64 delta); + +int (*hw_set_sys_clock)(struct aq_hw_s *self,u64 time,u64 ts); +int (*hw_set_fc)(struct aq_hw_s *self,u32 fc,u32 tc); };
@@ -267,6 +280,12 @@ struct aq_fw_ops {int (*set_power)(struct aq_hw_s *self,unsigned int power_state,u8 *mac); +int (*send_fw_request)(struct aq_hw_s *self, +const struct hw_fw_request_iface *fw_req, +size_t size); + +void (*enable_ptp)(struct aq_hw_s *self,int enable); +int (*set_eee_rate)(struct aq_hw_s *self,u32 speed); int (*get_eee_rate)(struct aq_hw_s *self, u32 *rate,
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +3 -0
@@ -146,6 +146,9 @@ static int aq_nic_update_link_status(struct aq_nic_s *self) self->aq_hw->aq_link_status.mbps);aq_nic_update_interrupt_moderation_settings (self); +if (self->aq_ptp) +aq_ptp_clock_init (self); +/* Driver has to update flow control settings on RX block * on any link event. * We should query FW whether it negotiated FC.
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +116 -0
155 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +108 -2
133 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c +15 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only /* * aQuantia Corporation Network Driver -* Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved +* Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved */ /* File hw_atl_llh.c: Definitions of bitfield and register access functions for
@@ -1513,6 +1513,20 @@ void hw_atl_reg_glb_cpu_scratch_scp_set(struct aq_hw_s *aq_hw, glb_cpu_scratch_scp); } +void hw_atl_pcs_ptp_clock_read_enable (struct aq_hw_s *aq_hw, +u32 ptp_clock_read_enable) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL_PCS_PTP_CLOCK_READ_ENABLE_ADR , +HW_ATL_PCS_PTP_CLOCK_READ_ENABLE_MSK , +HW_ATL_PCS_PTP_CLOCK_READ_ENABLE_SHIFT , + ptp_clock_read_enable); +} + +u32 hw_atl_pcs_ptp_clock_get (struct aq_hw_s *aq_hw,u32 index) +{ +return aq_hw_read_reg (aq_hw,HW_ATL_PCS_PTP_TS_VAL_ADDR (index)); +} +void hw_atl_mcp_up_force_intr_set (struct aq_hw_s *aq_hw,u32 up_force_intr) { aq_hw_write_reg_bit(aq_hw, HW_ATL_MCP_UP_FORCE_INTERRUPT_ADR,
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h +7 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* * aQuantia Corporation Network Driver -* Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved +* Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved */ /* File hw_atl_llh.h: Declarations of bitfield and register access functions for
@@ -712,6 +712,12 @@ void hw_atl_msm_reg_wr_strobe_set(struct aq_hw_s *aq_hw, u32 reg_wr_strobe);/* set pci register reset disable */ void hw_atl_pci_pci_reg_res_dis_set (struct aq_hw_s *aq_hw,u32 pci_reg_res_dis); +/* pcs */ +void hw_atl_pcs_ptp_clock_read_enable (struct aq_hw_s *aq_hw, +u32 ptp_clock_read_enable); + +u32 hw_atl_pcs_ptp_clock_get (struct aq_hw_s *aq_hw,u32 index); +/* set uP Force Interrupt */ void hw_atl_mcp_up_force_intr_set (struct aq_hw_s *aq_hw,u32 up_force_intr);
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh_internal.h +17 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* * aQuantia Corporation Network Driver -* Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved +* Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved */ /* File hw_atl_llh_internal.h: Preprocessor definitions
@@ -2421,6 +2421,22 @@/* default value of bitfield register write strobe */ #define HW_ATL_MSM_REG_WR_STROBE_DEFAULT 0x0 +/* register address for bitfield PTP Digital Clock Read Enable */ +#define HW_ATL_PCS_PTP_CLOCK_READ_ENABLE_ADR 0x00004628 +/* bitmask for bitfield PTP Digital Clock Read Enable */ +#define HW_ATL_PCS_PTP_CLOCK_READ_ENABLE_MSK 0x00000010 +/* inverted bitmask for bitfield PTP Digital Clock Read Enable */ +#define HW_ATL_PCS_PTP_CLOCK_READ_ENABLE_MSKN 0xFFFFFFEF +/* lower bit position of bitfield PTP Digital Clock Read Enable */ +#define HW_ATL_PCS_PTP_CLOCK_READ_ENABLE_SHIFT 4 +/* width of bitfield PTP Digital Clock Read Enable */ +#define HW_ATL_PCS_PTP_CLOCK_READ_ENABLE_WIDTH 1 +/* default value of bitfield PTP Digital Clock Read Enable */ +#define HW_ATL_PCS_PTP_CLOCK_READ_ENABLE_DEFAULT 0x0 + +/* register address for ptp counter reading */ +#define HW_ATL_PCS_PTP_TS_VAL_ADDR (index) (0x00004900 + (index) * 0x4) +/* mif soft reset bitfield definitions * preprocessor definitions for the bitfield "soft reset". * port="pif_glb_res_i"
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c +3 -2
@@ -327,8 +327,7 @@ int hw_atl_utils_fw_downld_dwords(struct aq_hw_s *self, u32 a,return err; } -static int hw_atl_utils_fw_upload_dwords (struct aq_hw_s *self,u32 a,u32 *p, -u32 cnt) +int hw_atl_utils_fw_upload_dwords (struct aq_hw_s *self,u32 a,u32 *p,u32 cnt) {u32 val;int err =0 ;
@@ -964,4 +963,6 @@ const struct aq_fw_ops aq_fw_1x_ops = { .set_eee_rate = NULL, .get_eee_rate = NULL, .set_flow_control = NULL, + .send_fw_request = NULL, + .enable_ptp = NULL, };
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h +30 -0
@@ -279,6 +279,34 @@ struct __packed offload_info {u8 buf[0 ]; }; +/* Mailbox FW Request interface */ +struct __packed hw_fw_request_ptp_adj_freq { +u32 ns_mac; +u32 fns_mac; +u32 ns_phy; +u32 fns_phy; +u32 mac_ns_adj; +u32 mac_fns_adj; +}; + +struct __packed hw_fw_request_ptp_adj_clock { +u32 ns; +u32 sec; +int sign; +}; + +#define HW_AQ_FW_REQUEST_PTP_ADJ_FREQ 0x12 +#define HW_AQ_FW_REQUEST_PTP_ADJ_CLOCK 0x13 + +struct __packed hw_fw_request_iface { +u32 msg_id; +union { +/* PTP FW Request */ +struct hw_fw_request_ptp_adj_freq ptp_adj_freq; +struct hw_fw_request_ptp_adj_clock ptp_adj_clock; + }; +}; +enum hw_atl_rx_action_with_traffic {HW_ATL_RX_DISCARD ,HW_ATL_RX_HOST ,
@@ -561,6 +589,8 @@ struct aq_stats_s *hw_atl_utils_get_hw_stats(struct aq_hw_s *self);int hw_atl_utils_fw_downld_dwords (struct aq_hw_s *self,u32 a,u32 *p,u32 cnt); +int hw_atl_utils_fw_upload_dwords (struct aq_hw_s *self,u32 a,u32 *p,u32 cnt); +int hw_atl_utils_fw_set_wol (struct aq_hw_s *self,bool wol_enabled,u8 *mac);int hw_atl_utils_fw_rpc_call (struct aq_hw_s *self,unsigned int rpc_size);
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c +75 -22
121 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v2 net-next 03/12] net: aquantia: add basic ptp_clock callbacks
Quoted 11 lines · Igor Russkikh
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +1
-0@@ -16,15 +16,107 @@struct aq_ptp_s {struct aq_nic_s *aq_nic; +spinlock_t ptp_lock;struct ptp_clock *ptp_clock;struct ptp_clock_info ptp_info;
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c line 31
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +8
-0}; +/* aq_ptp_adjfreq +* @ptp: the ptp clock structure +* @ppb: parts per billion adjustment from base +* +* adjust the frequency of the ptp cycle counter by the +* indicated ppb from the base frequency. +*/ +static int aq_ptp_adjfreq (struct ptp_clock_info *ptp,s32 ppb)
The adjfreq() callback is deprecated. Please implement adjfine() instead.
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c line 36
Quoted 5 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +5
-0+{ + struct aq_ptp_s *aq_ptp = container_of(ptp, struct aq_ptp_s, ptp_info); +struct aq_nic_s *aq_nic = aq_ptp->aq_nic; + +mutex_lock (&aq_nic->fwreq_mutex);
Here you use a different lock than...
Quoted 9 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +9
-0+ aq_nic->aq_hw_ops->hw_adj_clock_freq (aq_nic->aq_hw, ppb); +mutex_unlock (&aq_nic->fwreq_mutex); + +return 0 ; +} + +/* aq_ptp_adjtime +* @ptp: the ptp clock structure +* @delta: offset to adjust the cycle counter by
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c line 55
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +10
-0+* +* adjust the timer by resetting the timecounter structure. +*/ +static int aq_ptp_adjtime (struct ptp_clock_info *ptp,s64 delta) +{ + struct aq_ptp_s *aq_ptp = container_of(ptp, struct aq_ptp_s, ptp_info); +struct aq_nic_s *aq_nic = aq_ptp->aq_nic; +unsigned long flags; + +spin_lock_irqsave (&aq_ptp->ptp_lock, flags);
... here. Is it safe to concurrently set the time and the frequency?
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c line 60
Quoted 5 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +5
-0+ aq_nic->aq_hw_ops->hw_adj_sys_clock (aq_nic->aq_hw, delta); +spin_unlock_irqrestore (&aq_ptp->ptp_lock, flags); + +return 0 ; +}
Thanks,
Richard
Re: [PATCH v2 net-next 03/12] net: aquantia: add basic ptp_clock callbacks
Hi Richard,
Thanks for your review, will update the patchset after the comments.
Quoted 9 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c line 36
Quoted 5 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +5
-0+{ + struct aq_ptp_s *aq_ptp = container_of(ptp, struct aq_ptp_s, ptp_info); +struct aq_nic_s *aq_nic = aq_ptp->aq_nic; + +mutex_lock (&aq_nic->fwreq_mutex);Here you use a different lock than...
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + spin_lock_irqsave(&aq_ptp->ptp_lock, flags);... here. Is it safe to concurrently set the time and the frequency?
Yes, its safe. The purpose of the locks is different, mutex secures FW accesses. They could take time and should be serialized.
Working with ptp clock however does not use FW, but spinlock is used to secure possible concurrent access and math over 64bit variable aq_ptp->ptp_clock_offset
Regards,
Igor
PATCH v2 4/12 net: aquantia: add PTP rings infrastructure
In reply to Igor RusskikhFrom: Egor Pomozov <[email protected]>
Add implementations of PTP rings alloc/free.
PTP desing on this device uses two separate rings on a separate traffic class for traffic rx/tx.
Third ring (hwts) is not a traffic ring, but is used only to receive timestamps of the transmitted packets.
--- .../net/ethernet/aquantia/atlantic/aq_hw.h | 4 + .../net/ethernet/aquantia/atlantic/aq_nic.c | 16 ++ .../net/ethernet/aquantia/atlantic/aq_ptp.c | 231 ++++++++++++++++++ .../net/ethernet/aquantia/atlantic/aq_ptp.h | 8 + .../net/ethernet/aquantia/atlantic/aq_ring.c | 33 ++- .../net/ethernet/aquantia/atlantic/aq_ring.h | 6 +- .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 45 +++- .../atlantic/hw_atl/hw_atl_b0_internal.h | 9 +- .../aquantia/atlantic/hw_atl/hw_atl_llh.c | 14 ++ .../aquantia/atlantic/hw_atl/hw_atl_llh.h | 6 + .../aquantia/atlantic/hw_atl/hw_atl_utils.h | 8 + 11 files changed, 368 insertions(+), 12 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +4 -0
@@ -240,6 +240,10 @@ struct aq_hw_ops {int (*hw_set_offload)(struct aq_hw_s *self,struct aq_nic_cfg_s *aq_nic_cfg); +int (*hw_tx_tc_mode_get)(struct aq_hw_s *self,u32 *tc_mode); + +int (*hw_rx_tc_mode_get)(struct aq_hw_s *self,u32 *tc_mode); +void (*hw_get_ptp_ts)(struct aq_hw_s *self,u64 *stamp);int (*hw_adj_clock_freq)(struct aq_hw_s *self,s32 delta);
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +16 -0
@@ -339,6 +339,14 @@ int aq_nic_init(struct aq_nic_s *self)if (err <0 ) goto err_exit; + err =aq_ptp_ring_alloc (self); +if (err <0 ) + goto err_exit; + + err =aq_ptp_ring_init (self); +if (err <0 ) + goto err_exit; +netif_carrier_off (self->ndev); err_exit:
@@ -369,6 +377,10 @@ int aq_nic_start(struct aq_nic_s *self) goto err_exit; } + err =aq_ptp_ring_start (self); +if (err <0 ) + goto err_exit; + err = self->aq_hw_ops->hw_start (self->aq_hw);if (err <0 ) goto err_exit;
@@ -963,6 +975,8 @@ int aq_nic_stop(struct aq_nic_s *self) self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i])aq_vec_stop (aq_vec); +aq_ptp_ring_stop (self); +return self->aq_hw_ops->hw_stop (self->aq_hw); }
@@ -978,7 +992,9 @@ void aq_nic_deinit(struct aq_nic_s *self) self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i])aq_vec_deinit (aq_vec); +aq_ptp_ring_deinit (self);aq_ptp_unregister (self); +aq_ptp_ring_free (self);aq_ptp_free (self);if (likely (self->aq_fw_ops->deinit)) {
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +231 -0
264 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/aq_ptp.h +8 -0
@@ -17,6 +17,14 @@ int aq_ptp_init(struct aq_nic_s *aq_nic, unsigned int idx_vec);void aq_ptp_unregister (struct aq_nic_s *aq_nic);void aq_ptp_free (struct aq_nic_s *aq_nic); +int aq_ptp_ring_alloc (struct aq_nic_s *aq_nic); +void aq_ptp_ring_free (struct aq_nic_s *aq_nic); + +int aq_ptp_ring_init (struct aq_nic_s *aq_nic); +int aq_ptp_ring_start (struct aq_nic_s *aq_nic); +void aq_ptp_ring_stop (struct aq_nic_s *aq_nic); +void aq_ptp_ring_deinit (struct aq_nic_s *aq_nic); +void aq_ptp_clock_init (struct aq_nic_s *aq_nic);#endif /* AQ_PTP_H */
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +32 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only /* * aQuantia Corporation Network Driver -* Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved +* Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved */ /* File aq_ring.c: Definition of functions for Rx/Tx rings. */
@@ -177,6 +177,37 @@ struct aq_ring_s *aq_ring_rx_alloc(struct aq_ring_s *self,return self; } +struct aq_ring_s * +aq_ring_hwts_rx_alloc (struct aq_ring_s *self,struct aq_nic_s *aq_nic, +unsigned int idx,unsigned int size,unsigned int dx_size) +{ +struct device *dev =aq_nic_get_dev (aq_nic); +int err =0 ; +size_t sz = size * dx_size +AQ_CFG_RXDS_DEF ; + +memset (self,0 ,sizeof (*self)); + + self->aq_nic = aq_nic; + self->idx = idx; + self->size = size; + self->dx_size = dx_size; + + self->dx_ring =dma_alloc_coherent (dev, sz, &self->dx_ring_pa, +GFP_KERNEL ); +if (!self->dx_ring) { + err = -ENOMEM ; + goto err_exit; + } + +err_exit: +if (err <0 ) { +aq_ring_free (self); +return NULL ; + } + +return self; +} +int aq_ring_init (struct aq_ring_s *self) { self->hw_head =0 ;
drivers/net/ethernet/aquantia/atlantic/aq_ring.h +5 -1
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* * aQuantia Corporation Network Driver -* Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved +* Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved */ /* File aq_ring.h: Declaration of functions for Rx/Tx rings. */
@@ -174,4 +174,8 @@ int aq_ring_rx_clean(struct aq_ring_s *self, int budget);int aq_ring_rx_fill (struct aq_ring_s *self); +struct aq_ring_s *aq_ring_hwts_rx_alloc (struct aq_ring_s *self, +struct aq_nic_s *aq_nic,unsigned int idx, +unsigned int size,unsigned int dx_size); +#endif /* AQ_RING_H */
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +38 -7
79 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0_internal.h +6 -3
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* * aQuantia Corporation Network Driver -* Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved +* Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved */ /* File hw_atl_b0_internal.h: Definition of Atlantic B0 chip specific
@@ -64,8 +64,11 @@#define HW_ATL_B0_MPI_SPEED_MSK 0xFFFFU#define HW_ATL_B0_MPI_SPEED_SHIFT 16U -#define HW_ATL_B0_TXBUF_MAX 160U -#define HW_ATL_B0_RXBUF_MAX 320U +#define HW_ATL_B0_TXBUF_MAX 160U +#define HW_ATL_B0_PTP_TXBUF_SIZE 8U + +#define HW_ATL_B0_RXBUF_MAX 320U +#define HW_ATL_B0_PTP_RXBUF_SIZE 16U#define HW_ATL_B0_RSS_REDIRECTION_MAX 64U#define HW_ATL_B0_RSS_REDIRECTION_BITS 3U
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c +14 -0
@@ -572,6 +572,13 @@ void hw_atl_rpb_rpf_rx_traf_class_mode_set(struct aq_hw_s *aq_hw, rx_traf_class_mode); } +u32 hw_atl_rpb_rpf_rx_traf_class_mode_get (struct aq_hw_s *aq_hw) +{ +return aq_hw_read_reg_bit (aq_hw,HW_ATL_RPB_RPF_RX_TC_MODE_ADR , +HW_ATL_RPB_RPF_RX_TC_MODE_MSK , +HW_ATL_RPB_RPF_RX_TC_MODE_SHIFT ); +} +void hw_atl_rpb_rx_buff_en_set (struct aq_hw_s *aq_hw,u32 rx_buff_en) { aq_hw_write_reg_bit(aq_hw, HW_ATL_RPB_RX_BUF_EN_ADR,
@@ -1277,6 +1284,13 @@ void hw_atl_tpb_tx_buff_en_set(struct aq_hw_s *aq_hw, u32 tx_buff_en) HW_ATL_TPB_TX_BUF_EN_SHIFT, tx_buff_en); } +u32 hw_atl_rpb_tps_tx_tc_mode_get (struct aq_hw_s *aq_hw) +{ +return aq_hw_read_reg_bit (aq_hw,HW_ATL_TPB_TX_TC_MODE_ADDR , +HW_ATL_TPB_TX_TC_MODE_MSK , +HW_ATL_TPB_TX_TC_MODE_SHIFT ); +} +void hw_atl_rpb_tps_tx_tc_mode_set (struct aq_hw_s *aq_hw,u32 tx_traf_class_mode) {
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h +6 -0
@@ -292,6 +292,9 @@ void hw_atl_rpb_dma_sys_lbk_set(struct aq_hw_s *aq_hw, u32 dma_sys_lbk);void hw_atl_rpb_rpf_rx_traf_class_mode_set (struct aq_hw_s *aq_hw,u32 rx_traf_class_mode); +/* get rx traffic class mode */ +u32 hw_atl_rpb_rpf_rx_traf_class_mode_get (struct aq_hw_s *aq_hw); +/* set rx buffer enable */ void hw_atl_rpb_rx_buff_en_set (struct aq_hw_s *aq_hw,u32 rx_buff_en);
@@ -602,6 +605,9 @@ void hw_atl_thm_lso_tcp_flag_of_middle_pkt_set(struct aq_hw_s *aq_hw,void hw_atl_rpb_tps_tx_tc_mode_set (struct aq_hw_s *aq_hw,u32 tx_traf_class_mode); +/* get TX Traffic Class Mode */ +u32 hw_atl_rpb_tps_tx_tc_mode_get (struct aq_hw_s *aq_hw); +/* set tx buffer enable */ void hw_atl_tpb_tx_buff_en_set (struct aq_hw_s *aq_hw,u32 tx_buff_en);
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h +8 -0
@@ -44,6 +44,14 @@ struct __packed hw_atl_rxd_wb_s {u16 vlan; }; +/* Hardware rx HW TIMESTAMP writeback */ +struct __packed hw_atl_rxd_hwts_wb_s { +u32 sec_hw; +u32 ns; +u32 sec_lw0; +u32 sec_lw1; +}; +struct __packed hw_atl_stats_s {u32 uprc;u32 mprc;
Signature · 1 line
2.17.1
Re: [PATCH v2 net-next 04/12] net: aquantia: add PTP rings infrastructure
drivers/net/ethernet/aquantia/atlantic/aq_nic.c void aq_nic_deinit(struct aq_nic_s *self) · line 998
Quoted 8 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +2
-0@@ -978,7 +992,9 @@ void aq_nic_deinit(struct aq_nic_s *self) self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i])aq_vec_deinit (aq_vec); +aq_ptp_ring_deinit (self);aq_ptp_unregister (self); +aq_ptp_ring_free (self);aq_ptp_free (self);
Is this order safe? Seems like you should first unregister, and then deinit?
Quoted 34 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +34
-0+int aq_ptp_ring_init (struct aq_nic_s *aq_nic) +{ +struct aq_ptp_s *aq_ptp = aq_nic->aq_ptp; +int err =0 ; + +if (!aq_ptp) +return 0 ; + + err =aq_ring_init (&aq_ptp->ptp_tx); +if (err <0 ) + goto err_exit; + err = aq_nic->aq_hw_ops->hw_ring_tx_init (aq_nic->aq_hw, + &aq_ptp->ptp_tx, + &aq_ptp->ptp_ring_param); +if (err <0 ) + goto err_exit; + + err =aq_ring_init (&aq_ptp->ptp_rx); +if (err <0 ) + goto err_exit; + err = aq_nic->aq_hw_ops->hw_ring_rx_init (aq_nic->aq_hw, + &aq_ptp->ptp_rx, + &aq_ptp->ptp_ring_param); +if (err <0 ) + goto err_exit; + + err =aq_ring_rx_fill (&aq_ptp->ptp_rx); +if (err <0 ) + goto err_exit; + err = aq_nic->aq_hw_ops->hw_ring_rx_fill (aq_nic->aq_hw, + &aq_ptp->ptp_rx, +0U ); +if (err <0 ) + goto err_exit;
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c static int aq_ptp_settime(struct ptp_clock_info *ptp, · line 194
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +10
-0+ + err =aq_ring_init (&aq_ptp->hwts_rx); +if (err <0 ) + goto err_exit; + err = aq_nic->aq_hw_ops->hw_ring_rx_init (aq_nic->aq_hw, + &aq_ptp->hwts_rx, + &aq_ptp->ptp_ring_param); + +err_exit: +return err;
Maybe there should be some undoing going on here. If you filled the rx ring, do you need to empty it on error?
Quoted 14 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +14
-0+} + +int aq_ptp_ring_start (struct aq_nic_s *aq_nic) +{ +struct aq_ptp_s *aq_ptp = aq_nic->aq_ptp; +int err =0 ; + +if (!aq_ptp) +return 0 ; + + err = aq_nic->aq_hw_ops->hw_ring_tx_start (aq_nic->aq_hw, &aq_ptp->ptp_tx); +if (err <0 ) + goto err_exit; +
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c static int aq_ptp_settime(struct ptp_clock_info *ptp, · line 218
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +10
-0+ err = aq_nic->aq_hw_ops->hw_ring_rx_start (aq_nic->aq_hw, &aq_ptp->ptp_rx); +if (err <0 ) + goto err_exit; + + err = aq_nic->aq_hw_ops->hw_ring_rx_start (aq_nic->aq_hw, + &aq_ptp->hwts_rx); +if (err <0 ) + goto err_exit; + +err_exit:
Do you need to stop the rings which started, before the error happened?
Quoted 58 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +58
-0+return err; +} + +int aq_ptp_ring_alloc (struct aq_nic_s *aq_nic) +{ +struct aq_ptp_s *aq_ptp = aq_nic->aq_ptp; +unsigned int tx_ring_idx, rx_ring_idx; +struct aq_ring_s *hwts =0 ; +u32 tx_tc_mode, rx_tc_mode; +struct aq_ring_s *ring; +int err; + +if (!aq_ptp) +return 0 ; + +/* Index must to be 8 (8 TCs) or 16 (4 TCs). +* It depends from Traffic Class mode. +*/ + aq_nic->aq_hw_ops->hw_tx_tc_mode_get (aq_nic->aq_hw, &tx_tc_mode); +if (tx_tc_mode ==0 ) + tx_ring_idx =PTP_8TC_RING_IDX ; +else + tx_ring_idx =PTP_4TC_RING_IDX ; + + ring =aq_ring_tx_alloc (&aq_ptp->ptp_tx, aq_nic, + tx_ring_idx, &aq_nic->aq_nic_cfg); +if (!ring) { + err = -ENOMEM ; + goto err_exit_1; + } + + aq_nic->aq_hw_ops->hw_rx_tc_mode_get (aq_nic->aq_hw, &rx_tc_mode); +if (rx_tc_mode ==0 ) + rx_ring_idx =PTP_8TC_RING_IDX ; +else + rx_ring_idx =PTP_4TC_RING_IDX ; + + ring =aq_ring_rx_alloc (&aq_ptp->ptp_rx, aq_nic, + rx_ring_idx, &aq_nic->aq_nic_cfg); +if (!ring) { + err = -ENOMEM ; + goto err_exit_2; + } + + hwts =aq_ring_hwts_rx_alloc (&aq_ptp->hwts_rx, aq_nic,PTP_HWST_RING_IDX , + aq_nic->aq_nic_cfg.rxds, + aq_nic->aq_nic_cfg.aq_hw_caps->rxd_size); +if (!hwts) { + err = -ENOMEM ; + goto err_exit_3; + } + + err =aq_ptp_skb_ring_init (&aq_ptp->skb_ring, aq_nic->aq_nic_cfg.rxds); +if (err !=0 ) { + err = -ENOMEM ; + goto err_exit_4; + } +
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c static int aq_ptp_settime(struct ptp_clock_info *ptp, · line 314
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +10
-0+return 0 ; + +err_exit_4: +aq_ring_free (&aq_ptp->hwts_rx); +err_exit_3: +aq_ring_free (&aq_ptp->ptp_rx); +err_exit_2: +aq_ring_free (&aq_ptp->ptp_tx); +err_exit_1: +return err;
Not very descriptive names. err_exit_hwts_rx, err_exit_ptp_rx, etc?
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +4
-0+struct aq_ring_s * +aq_ring_hwts_rx_alloc (struct aq_ring_s *self,struct aq_nic_s *aq_nic, +unsigned int idx,unsigned int size,unsigned int dx_size) +{
drivers/net/ethernet/aquantia/atlantic/aq_ring.c struct aq_ring_s *aq_ring_rx_alloc(struct aq_ring_s *self, · line 193
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +10
-0+struct device *dev =aq_nic_get_dev (aq_nic); +int err =0 ; +size_t sz = size * dx_size +AQ_CFG_RXDS_DEF ; + +memset (self,0 ,sizeof (*self)); + + self->aq_nic = aq_nic; + self->idx = idx; + self->size = size; + self->dx_size = dx_size;
More self. Why not ring? I suppose because the rest of this file is using the unhelpful self?
drivers/net/ethernet/aquantia/atlantic/aq_ring.c struct aq_ring_s *aq_ring_rx_alloc(struct aq_ring_s *self, · line 205
Quoted 12 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +12
-0+ + self->dx_ring =dma_alloc_coherent (dev, sz, &self->dx_ring_pa, +GFP_KERNEL ); +if (!self->dx_ring) { + err = -ENOMEM ; + goto err_exit; + } + +err_exit: +if (err <0 ) { +aq_ring_free (self); +return NULL ;
return ERR_PTR(err)?
drivers/net/ethernet/aquantia/atlantic/aq_ring.c struct aq_ring_s *aq_ring_rx_alloc(struct aq_ring_s *self, · line 208
Quoted 3 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +3
-0+ } + +return self;
And this code structure seem odd. Why not.
+ self->dx_ring = dma_alloc_coherent(dev, sz, &self->dx_ring_pa,
+ GFP_KERNEL);
+ if (!self->dx_ring) {
+ err = -ENOMEM;
+ goto err_exit;
+ }
+
+ return self;
+
+err_exit:
+ aq_ring_free(self);
+ return ERR_PTR(err)?
Quoted 1 line
+}
Andrew
Re: [PATCH v2 net-next 04/12] net: aquantia: add PTP rings infrastructure
Hi Andrew,
Quoted 8 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c void aq_nic_deinit(struct aq_nic_s *self) · line 998
Quoted 5 lines
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +2
-0+aq_ptp_ring_deinit (self);aq_ptp_unregister (self); +aq_ptp_ring_free (self);aq_ptp_free (self);Is this order safe? Seems like you should first unregister, and then deinit?
Will double check, probably you are right.
Quoted 4 lines
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +4
-0+ err =aq_ring_init (&aq_ptp->hwts_rx); +if (err <0 ) + goto err_exit; + err = aq_nic->aq_hw_ops->hw_ring_rx_init(aq_nic->aq_hw,
Quoted 8 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c static int aq_ptp_settime(struct ptp_clock_info *ptp, · line 194
Quoted 5 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +5
-0+ &aq_ptp->hwts_rx, + &aq_ptp->ptp_ring_param); + +err_exit: +return err;Maybe there should be some undoing going on here. If you filled the rx ring, do you need to empty it on error?
Right, ptp_rx should be cleaned here.
Quoted 9 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c static int aq_ptp_settime(struct ptp_clock_info *ptp, · line 218
Quoted 6 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +6
-0+ err = aq_nic->aq_hw_ops->hw_ring_rx_start (aq_nic->aq_hw, + &aq_ptp->hwts_rx); +if (err <0 ) + goto err_exit; + +err_exit:Do you need to stop the rings which started, before the error happened?
The failures there are only theoretical (they only do check if the device is still on PCI bus).
err result will propagate and cause overall NIC object to be failed on open, eventually aq_nic_deinit will be called and HW will endup in disabled state.
Thus, believe we only have to care not to leak memory, like in above ptp_rx case.
Quoted 9 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c struct aq_ring_s *aq_ring_rx_alloc(struct aq_ring_s *self, · line 193
Quoted 6 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +6
-0+memset (self,0 ,sizeof (*self)); + + self->aq_nic = aq_nic; + self->idx = idx; + self->size = size; + self->dx_size = dx_size;More self. Why not ring? I suppose because the rest of this file is using the unhelpful self?
Right. I think I'll make a separate patchset to fix this naming, to not to mixup things.
Quoted 7 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c struct aq_ring_s *aq_ring_rx_alloc(struct aq_ring_s *self, · line 205
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +4
-0+err_exit: +if (err <0 ) { +aq_ring_free (self); +return NULL ;return
ERR_PTR(err)?
Quoted 5 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c struct aq_ring_s *aq_ring_rx_alloc(struct aq_ring_s *self, · line 208
Quoted 3 lines
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +3
-0+ } + +return self;And this code structure seem odd. Why not.
The only cause of error on these *_alloc() functions is ENOMEM. So think I'll just simplify this, remove all err fields and leave NULL as a fail indicator.
Regards,
Igor
PATCH v2 5/12 net: aquantia: styling fixes on ptp related functions
In reply to Igor RusskikhFrom: Dmitry Bezrukov <[email protected]>
Checkpatch and styling fixes on parts of code touched by ptp
--- .../net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c | 4 ++-- .../net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c +2 -2
@@ -630,8 +630,8 @@ void hw_atl_rpb_rx_pkt_buff_size_per_tc_set(struct aq_hw_s *aq_hw, rx_pkt_buff_size_per_tc); } -void hw_atl_rpb_rx_xoff_en_per_tc_set (struct aq_hw_s *aq_hw,u32 rx_xoff_en_per_tc, -u32 buffer) +void hw_atl_rpb_rx_xoff_en_per_tc_set (struct aq_hw_s *aq_hw, +u32 rx_xoff_en_per_tc,u32 buffer) { aq_hw_write_reg_bit(aq_hw, HW_ATL_RPB_RXBXOFF_EN_ADR(buffer), HW_ATL_RPB_RXBXOFF_EN_MSK,
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h +6 -3
@@ -309,7 +309,8 @@ void hw_atl_rpb_rx_buff_lo_threshold_per_tc_set(struct aq_hw_s *aq_hw, u32 buffer);/* set rx flow control mode */ -void hw_atl_rpb_rx_flow_ctl_mode_set (struct aq_hw_s *aq_hw,u32 rx_flow_ctl_mode); +void hw_atl_rpb_rx_flow_ctl_mode_set (struct aq_hw_s *aq_hw, +u32 rx_flow_ctl_mode);/* set rx packet buffer size (per tc) */ void hw_atl_rpb_rx_pkt_buff_size_per_tc_set(struct aq_hw_s *aq_hw,
@@ -320,7 +321,8 @@ void hw_atl_rpb_rx_pkt_buff_size_per_tc_set(struct aq_hw_s *aq_hw,void hw_atl_rdm_rx_dma_desc_cache_init_set (struct aq_hw_s *aq_hw,u32 init);/* set rx xoff enable (per tc) */ -void hw_atl_rpb_rx_xoff_en_per_tc_set (struct aq_hw_s *aq_hw,u32 rx_xoff_en_per_tc, +void hw_atl_rpb_rx_xoff_en_per_tc_set (struct aq_hw_s *aq_hw, +u32 rx_xoff_en_per_tc,u32 buffer);/* rpf */
@@ -626,7 +628,8 @@ void hw_atl_tpb_tx_dma_sys_lbk_en_set(struct aq_hw_s *aq_hw, u32 tx_dma_sys_lbk_/* set tx packet buffer size (per tc) */ void hw_atl_tpb_tx_pkt_buff_size_per_tc_set (struct aq_hw_s *aq_hw, -u32 tx_pkt_buff_size_per_tc,u32 buffer); +u32 tx_pkt_buff_size_per_tc, +u32 buffer);/* set tx path pad insert enable */ void hw_atl_tpb_tx_path_scp_ins_en_set (struct aq_hw_s *aq_hw,u32 tx_path_scp_ins_en);
Signature · 1 line
2.17.1
Re: [PATCH v2 net-next 05/12] net: aquantia: styling fixes on ptp related functions
Quoted 6 lines · Igor Russkikh
From: Dmitry Bezrukov <[email protected]>
Checkpatch and styling fixes on parts of code touched by ptp
Signed-off-by Dmitry Bezrukov <[email protected]>Signed-off-by Igor Russkikh <[email protected]>
Andrew
PATCH v2 6/12 net: aquantia: implement data PTP datapath
In reply to Igor RusskikhFrom: Egor Pomozov <[email protected]>
Here we do alloc/free IRQs for PTP rings.
We also implement processing of PTP packets on TX and RX sides.
--- .../net/ethernet/aquantia/atlantic/aq_cfg.h | 4 +- .../net/ethernet/aquantia/atlantic/aq_hw.h | 12 + .../net/ethernet/aquantia/atlantic/aq_main.c | 23 +- .../net/ethernet/aquantia/atlantic/aq_nic.c | 18 +- .../net/ethernet/aquantia/atlantic/aq_nic.h | 3 + .../ethernet/aquantia/atlantic/aq_pci_func.c | 5 +- .../net/ethernet/aquantia/atlantic/aq_ptp.c | 544 +++++++++++++++++- .../net/ethernet/aquantia/atlantic/aq_ptp.h | 19 + .../net/ethernet/aquantia/atlantic/aq_ring.c | 31 +- .../net/ethernet/aquantia/atlantic/aq_ring.h | 1 + .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 100 ++++ 11 files changed, 748 insertions(+), 12 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_cfg.h +2 -2
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* * aQuantia Corporation Network Driver -* Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved +* Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved */ /* File aq_cfg.h: Definition of configuration parameters and constants. */
@@ -27,7 +27,7 @@#define AQ_CFG_INTERRUPT_MODERATION_USEC_MAX (0x1FF * 2) -#define AQ_CFG_IRQ_MASK 0x1FFU +#define AQ_CFG_IRQ_MASK 0x3FFU#define AQ_CFG_VECS_MAX 8U#define AQ_CFG_TCS_MAX 8U
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +12 -0
@@ -244,6 +244,12 @@ struct aq_hw_ops {int (*hw_rx_tc_mode_get)(struct aq_hw_s *self,u32 *tc_mode); +int (*hw_ring_hwts_rx_fill)(struct aq_hw_s *self, +struct aq_ring_s *aq_ring); + +int (*hw_ring_hwts_rx_receive)(struct aq_hw_s *self, +struct aq_ring_s *ring); +void (*hw_get_ptp_ts)(struct aq_hw_s *self,u64 *stamp);int (*hw_adj_clock_freq)(struct aq_hw_s *self,s32 delta);
@@ -252,6 +258,12 @@ struct aq_hw_ops {int (*hw_set_sys_clock)(struct aq_hw_s *self,u64 time,u64 ts); +u16 (*rx_extract_ts)(struct aq_hw_s *self,u8 *p,unsigned int len, +u64 *timestamp); + +int (*extract_hwts)(struct aq_hw_s *self,u8 *p,unsigned int len, +u64 *timestamp); +int (*hw_set_fc)(struct aq_hw_s *self,u32 fc,u32 tc); };
drivers/net/ethernet/aquantia/atlantic/aq_main.c +22 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only /* * aQuantia Corporation Network Driver -* Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved +* Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved */ /* File aq_main.c: Main file for aQuantia Linux driver. */
@@ -10,10 +10,13 @@#include "aq_nic.h" #include "aq_pci_func.h" #include "aq_ethtool.h" +#include "aq_ptp.h" #include "aq_filters.h" #include <linux/netdevice.h> #include <linux/module.h> +#include <linux/ip.h> +#include <linux/udp.h> MODULE_LICENSE ("GPL v2" );MODULE_VERSION (AQ_CFG_DRV_VERSION );
@@ -93,6 +96,24 @@ static int aq_ndev_start_xmit(struct sk_buff *skb, struct net_device *ndev) {struct aq_nic_s *aq_nic =netdev_priv (ndev); +if (unlikely (aq_utils_obj_test (&aq_nic->flags,AQ_NIC_PTP_DPATH_UP ))) { +/* Hardware adds the Timestamp for PTPv2 802.AS1 +* and PTPv2 IPv4 UDP. +* We have to push even general 320 port messages to the ptp +* queue explicitly. This is a limitation of current firmware +* and hardware PTP design of the chip. Otherwise ptp stream +* will fail to sync +*/ +if (unlikely (skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP ) || +unlikely ((ip_hdr (skb)->version ==4 ) && + (ip_hdr (skb)->protocol ==IPPROTO_UDP ) && + ((udp_hdr (skb)->dest ==htons (319 )) || + (udp_hdr (skb)->dest ==htons (320 )))) || +unlikely (eth_hdr (skb)->h_proto ==htons (ETH_P_1588 ))) +return aq_ptp_xmit (aq_nic, skb); + } + +skb_tx_timestamp (skb);return aq_nic_xmit (aq_nic, skb); }
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +14 -4
@@ -146,8 +146,11 @@ static int aq_nic_update_link_status(struct aq_nic_s *self) self->aq_hw->aq_link_status.mbps);aq_nic_update_interrupt_moderation_settings (self); -if (self->aq_ptp) +if (self->aq_ptp) {aq_ptp_clock_init (self); +aq_ptp_tm_offset_set (self, + self->aq_hw->aq_link_status.mbps); + }/* Driver has to update flow control settings on RX block * on any link event.
@@ -196,6 +199,8 @@ static void aq_nic_service_task(struct work_struct *work) service_task);int err; +aq_ptp_service_task (self); +if (aq_utils_obj_test (&self->flags,AQ_NIC_FLAGS_IS_NOT_READY ))return ;
@@ -408,6 +413,10 @@ int aq_nic_start(struct aq_nic_s *self) goto err_exit; } + err =aq_ptp_irq_alloc (self); +if (err <0 ) + goto err_exit; +if (self->aq_nic_cfg.link_irq_vec) {int irqvec =pci_irq_vector (self->pdev, self->aq_nic_cfg.link_irq_vec);
@@ -440,9 +449,8 @@ int aq_nic_start(struct aq_nic_s *self)return err; } -static unsigned int aq_nic_map_skb (struct aq_nic_s *self, -struct sk_buff *skb, -struct aq_ring_s *ring) +unsigned int aq_nic_map_skb (struct aq_nic_s *self,struct sk_buff *skb, +struct aq_ring_s *ring) {unsigned int ret =0U ;unsigned int nr_frags =skb_shinfo (skb)->nr_frags;
@@ -971,6 +979,8 @@ int aq_nic_stop(struct aq_nic_s *self)else aq_pci_func_free_irqs (self); +aq_ptp_irq_free (self); +for (i =0U , aq_vec = self->aq_vec[0 ]; self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i])aq_vec_stop (aq_vec);
drivers/net/ethernet/aquantia/atlantic/aq_nic.h +3 -0
@@ -54,6 +54,7 @@ struct aq_nic_cfg_s {#define AQ_NIC_FLAG_STOPPING 0x00000008U#define AQ_NIC_FLAG_RESETTING 0x00000010U#define AQ_NIC_FLAG_CLOSING 0x00000020U +#define AQ_NIC_PTP_DPATH_UP 0x02000000U#define AQ_NIC_LINK_DOWN 0x04000000U#define AQ_NIC_FLAG_ERR_UNPLUG 0x40000000U#define AQ_NIC_FLAG_ERR_HW 0x80000000U
@@ -129,6 +130,8 @@ void aq_nic_cfg_start(struct aq_nic_s *self);int aq_nic_ndev_register (struct aq_nic_s *self);void aq_nic_ndev_free (struct aq_nic_s *self);int aq_nic_start (struct aq_nic_s *self); +unsigned int aq_nic_map_skb (struct aq_nic_s *self,struct sk_buff *skb, +struct aq_ring_s *ring);int aq_nic_xmit (struct aq_nic_s *self,struct sk_buff *skb);int aq_nic_get_regs (struct aq_nic_s *self,struct ethtool_regs *regs,void *p);int aq_nic_get_regs_count (struct aq_nic_s *self);
drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c +4 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only /* * aQuantia Corporation Network Driver -* Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved +* Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved */ /* File aq_pci_func.c: Definition of PCI functions. */
@@ -269,6 +269,9 @@ static int aq_pci_probe(struct pci_dev *pdev, numvecs =min ((u8 )AQ_CFG_VECS_DEF ,aq_nic_get_cfg (self)->aq_hw_caps->msix_irqs); numvecs =min (numvecs,num_online_cpus ()); +/* Request IRQ vector for PTP */ + numvecs +=1 ; + numvecs +=AQ_HW_SERVICE_IRQS ;/*enable interrupts */ #if !AQ_CFG_FORCE_LEGACY_INT
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +542 -2
638 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/aq_ptp.h +19 -0
@@ -17,6 +17,9 @@ int aq_ptp_init(struct aq_nic_s *aq_nic, unsigned int idx_vec);void aq_ptp_unregister (struct aq_nic_s *aq_nic);void aq_ptp_free (struct aq_nic_s *aq_nic); +int aq_ptp_irq_alloc (struct aq_nic_s *aq_nic); +void aq_ptp_irq_free (struct aq_nic_s *aq_nic); +int aq_ptp_ring_alloc (struct aq_nic_s *aq_nic);void aq_ptp_ring_free (struct aq_nic_s *aq_nic);
@@ -25,6 +28,22 @@ int aq_ptp_ring_start(struct aq_nic_s *aq_nic);void aq_ptp_ring_stop (struct aq_nic_s *aq_nic);void aq_ptp_ring_deinit (struct aq_nic_s *aq_nic); +void aq_ptp_service_task (struct aq_nic_s *aq_nic); + +void aq_ptp_tm_offset_set (struct aq_nic_s *aq_nic,unsigned int mbps); +void aq_ptp_clock_init (struct aq_nic_s *aq_nic); +/* Traffic processing functions */ +int aq_ptp_xmit (struct aq_nic_s *aq_nic,struct sk_buff *skb); +void aq_ptp_tx_hwtstamp (struct aq_nic_s *aq_nic,u64 timestamp); + +/* Return either ring is belong to PTP or not*/ +bool aq_ptp_ring (struct aq_nic_s *aq_nic,struct aq_ring_s *ring); + +u16 aq_ptp_extract_ts (struct aq_nic_s *aq_nic,struct sk_buff *skb,u8 *p, +unsigned int len); + +struct ptp_clock *aq_ptp_get_ptp_clock (struct aq_ptp_s *aq_ptp); +#endif /* AQ_PTP_H */
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +29 -2
@@ -10,6 +10,7 @@#include "aq_nic.h" #include "aq_hw.h" #include "aq_hw_utils.h" +#include "aq_ptp.h" #include <linux/netdevice.h> #include <linux/etherdevice.h>
@@ -321,6 +322,7 @@ int aq_ring_rx_clean(struct aq_ring_s *self, self->sw_head = aq_ring_next_dx(self, self->sw_head), --budget, ++(*work_done)) {struct aq_ring_buff_s *buff = &self->buff_ring[self->sw_head]; +bool is_ptp_ring =aq_ptp_ring (self->aq_nic, self);struct aq_ring_buff_s *buff_ =NULL ;struct sk_buff *skb =NULL ;unsigned int next_ =0U ;
@@ -384,6 +386,11 @@ int aq_ring_rx_clean(struct aq_ring_s *self, err = -ENOMEM ; goto err_exit; } +if (is_ptp_ring) + buff->len -= +aq_ptp_extract_ts (self->aq_nic, skb, +aq_buf_vaddr (&buff->rxdata), + buff->len);skb_put (skb, buff->len);page_ref_inc (buff->rxdata.page); }else {
@@ -392,6 +399,11 @@ int aq_ring_rx_clean(struct aq_ring_s *self, err = -ENOMEM ; goto err_exit; } +if (is_ptp_ring) + buff->len -= +aq_ptp_extract_ts (self->aq_nic, skb, +aq_buf_vaddr (&buff->rxdata), + buff->len); hdr_len = buff->len;if (hdr_len >AQ_CFG_RX_HDR_SIZE )
@@ -451,8 +463,8 @@ int aq_ring_rx_clean(struct aq_ring_s *self,skb_set_hash (skb, buff->rss_hash, buff->is_hash_l4 ?PKT_HASH_TYPE_L4 :PKT_HASH_TYPE_NONE ); - -skb_record_rx_queue (skb, self->idx); +/* Send all PTP traffic to 0 queue */ +skb_record_rx_queue (skb, is_ptp_ring ?0 : self->idx); ++self->stats.rx.packets; self->stats.rx.bytes += skb->len;
@@ -464,6 +476,21 @@ int aq_ring_rx_clean(struct aq_ring_s *self,return err; } +void aq_ring_hwts_rx_clean (struct aq_ring_s *self,struct aq_nic_s *aq_nic) +{ +while (self->sw_head != self->hw_head) { +u64 ns; + + aq_nic->aq_hw_ops->extract_hwts (aq_nic->aq_hw, + self->dx_ring + + (self->sw_head * self->dx_size), + self->dx_size, &ns); +aq_ptp_tx_hwtstamp (aq_nic, ns); + + self->sw_head =aq_ring_next_dx (self, self->sw_head); + } +} +int aq_ring_rx_fill (struct aq_ring_s *self) {unsigned int page_order = self->page_order;
drivers/net/ethernet/aquantia/atlantic/aq_ring.h +1 -0
@@ -177,5 +177,6 @@ int aq_ring_rx_fill(struct aq_ring_s *self);struct aq_ring_s *aq_ring_hwts_rx_alloc (struct aq_ring_s *self,struct aq_nic_s *aq_nic,unsigned int idx,unsigned int size,unsigned int dx_size); +void aq_ring_hwts_rx_clean (struct aq_ring_s *self,struct aq_nic_s *aq_nic);#endif /* AQ_RING_H */
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +100 -0
123 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v2 net-next 06/12] net: aquantia: implement data PTP datapath
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +0
-0@@ -8,12 +8,24 @@*/
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c line 18
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +9
-0+static inline int aq_ptp_tm_offset_egress_get (struct aq_ptp_s *aq_ptp) +{ +return atomic_read (&aq_ptp->offset_egress); +} + +static inline int aq_ptp_tm_offset_ingress_get (struct aq_ptp_s *aq_ptp) +{ +return atomic_read (&aq_ptp->offset_ingress); +}
inline should not be used in C files. Let the compiler decide.
Quoted 12 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +12
-0+ +void aq_ptp_tm_offset_set (struct aq_nic_s *aq_nic,unsigned int mbps) +{ +struct aq_ptp_s *aq_ptp = aq_nic->aq_ptp; +int i, egress, ingress; + +if (!aq_ptp) +return ; + + egress =0 ; + ingress =0 ; +
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c struct aq_ptp_s { · line 106
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +10
-0+for (i =0 ; i <ARRAY_SIZE (ptp_offset); i++) { +if (mbps == ptp_offset[i].mbps) { + egress = ptp_offset[i].egress; + ingress = ptp_offset[i].ingress; +break ; + } + } + +atomic_set (&aq_ptp->offset_egress, egress); +atomic_set (&aq_ptp->offset_ingress, ingress);
It seems odd you have wrappers for atomic_read, but not atomic_set. Do the wrappers actually add anything?
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c struct aq_ptp_s { · line 114
Quoted 8 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +8
-0+} + +static int __aq_ptp_skb_put (struct ptp_skb_ring *ring,struct sk_buff *skb) +{ +unsigned int next_head = (ring->head +1 ) % ring->size; + +if (next_head == ring->tail) +return -1 ;
ENOMEM?
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c struct aq_ptp_s { · line 121
Quoted 7 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +7
-0+ + ring->buff[ring->head] =skb_get (skb); + ring->head = next_head; + +return 0 ; +} +
Andrew
Re: [PATCH v2 net-next 06/12] net: aquantia: implement data PTP datapath
Quoted 7 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c struct aq_ptp_s { · line 84
Quoted 5 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +4
-0+static inline int aq_ptp_tm_offset_ingress_get (struct aq_ptp_s *aq_ptp) +{ +return atomic_read (&aq_ptp->offset_ingress); +}inline should not be used in C files. Let the compiler decide.
Ok
Quoted 5 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c struct aq_ptp_s { · line 106
Quoted 2 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +2
-0+atomic_set (&aq_ptp->offset_egress, egress); +atomic_set (&aq_ptp->offset_ingress, ingress);It seems odd you have wrappers for
atomic_read, but notatomic_set. Do the wrappers actually add anything?
I think no, they are just naming sugar.
Will discuss internally and probably leave direct atomic_get|set
Quoted 4 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c struct aq_ptp_s { · line 114
Quoted 2 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +2
-0+if (next_head == ring->tail) +return -1 ;ENOMEM?
Right.
Quoted 9 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c struct aq_ptp_s { · line 121
Quoted 7 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +7
-0+ + ring->buff[ring->head] =skb_get (skb); + ring->head = next_head; + +return 0 ; +} +Andrew
Thanks for your review, Andrew!
Regards,
Igor
PATCH v2 7/12 net: aquantia: rx filters for ptp
In reply to Igor RusskikhFrom: Dmitry Bezrukov <[email protected]>
We implement HW filter reservation for PTP traffic. Special location in filters table is marked as reserved, because incoming ptp traffic should be directed only to PTP designated queue. This way HW will do PTP timestamping and proper processing.
--- .../ethernet/aquantia/atlantic/aq_filters.c | 17 ++-- .../net/ethernet/aquantia/atlantic/aq_nic.c | 44 +++++++++ .../net/ethernet/aquantia/atlantic/aq_nic.h | 8 +- .../net/ethernet/aquantia/atlantic/aq_ptp.c | 14 +++ .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 12 ++- .../atlantic/hw_atl/hw_atl_llh_internal.h | 90 ++++++++++--------- 6 files changed, 131 insertions(+), 54 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_filters.c +11 -6
@@ -1,5 +1,5 @@// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (C) 2014-2017 aQuantia Corporation. */ +/* Copyright (C) 2014-2019 aQuantia Corporation. */ /* File aq_filters.c: RX filters related functions. */
@@ -89,12 +89,14 @@ static int aq_check_approve_fl3l4(struct aq_nic_s *aq_nic,struct aq_hw_rx_fltrs_s *rx_fltrs, struct ethtool_rx_flow_spec *fsp) { + u32 last_location = AQ_RX_LAST_LOC_FL3L4 - + aq_nic->aq_hw_rx_fltrs.fl3l4.reserved_count; +if (fsp->location <AQ_RX_FIRST_LOC_FL3L4 || - fsp->location >AQ_RX_LAST_LOC_FL3L4 ) { + fsp->location > last_location) {netdev_err (aq_nic->ndev,"ethtool: location must be in range [%d, %d]" , -AQ_RX_FIRST_LOC_FL3L4 , -AQ_RX_LAST_LOC_FL3L4 ); +AQ_RX_FIRST_LOC_FL3L4 , last_location);return -EINVAL ; }if (rx_fltrs->fl3l4.is_ipv6 && rx_fltrs->fl3l4.active_ipv4) {
@@ -124,12 +126,15 @@ aq_check_approve_fl2(struct aq_nic_s *aq_nic,struct aq_hw_rx_fltrs_s *rx_fltrs, struct ethtool_rx_flow_spec *fsp) { + u32 last_location = AQ_RX_LAST_LOC_FETHERT - + aq_nic->aq_hw_rx_fltrs.fet_reserved_count; +if (fsp->location <AQ_RX_FIRST_LOC_FETHERT || - fsp->location >AQ_RX_LAST_LOC_FETHERT ) { + fsp->location > last_location) {netdev_err (aq_nic->ndev,"ethtool: location must be in range [%d, %d]" ,AQ_RX_FIRST_LOC_FETHERT , -AQ_RX_LAST_LOC_FETHERT ); + last_location);return -EINVAL ; }
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +44 -0
53 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/aq_nic.h +7 -1
@@ -18,6 +18,7 @@ struct aq_hw_ops;struct aq_fw_s ;struct aq_vec_s ;struct aq_ptp_s ; +enum aq_rx_filter_type ;struct aq_nic_cfg_s {const struct aq_hw_caps_s *aq_hw_caps;
@@ -72,6 +73,7 @@ struct aq_hw_rx_fl3l4 {u8 active_ipv4; u8 active_ipv6:2;u8 is_ipv6; +u8 reserved_count; };struct aq_hw_rx_fltrs_s {
@@ -79,6 +81,8 @@ struct aq_hw_rx_fltrs_s {u16 active_filters;struct aq_hw_rx_fl2 fl2;struct aq_hw_rx_fl3l4 fl3l4; +/*filter ether type */ +u8 fet_reserved_count; };struct aq_nic_s {
@@ -154,5 +158,7 @@ u32 aq_nic_get_fw_version(struct aq_nic_s *self);int aq_nic_change_pm_state (struct aq_nic_s *self,pm_message_t *pm_msg);int aq_nic_update_interrupt_moderation_settings (struct aq_nic_s *self);void aq_nic_shutdown (struct aq_nic_s *self); - +u8 aq_nic_reserve_filter (struct aq_nic_s *self,enum aq_rx_filter_type type); +void aq_nic_release_filter (struct aq_nic_s *self,enum aq_rx_filter_type type, +u32 location);#endif /* AQ_NIC_H */
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +14 -0
@@ -8,12 +8,14 @@*/ #include <linux/ptp_clock_kernel.h> +#include <linux/ptp_classify.h> #include <linux/interrupt.h> #include <linux/clocksource.h> #include "aq_nic.h" #include "aq_ptp.h" #include "aq_ring.h" +#include "aq_filters.h" #define AQ_PTP_TX_TIMEOUT (HZ * 10)
@@ -63,6 +65,9 @@ struct aq_ptp_s {struct aq_ring_s hwts_rx;struct ptp_skb_ring skb_ring; + +struct aq_rx_filter_l3l4 udp_filter; +struct aq_rx_filter_l2 eth_type_filter; };struct ptp_tm_offset {
@@ -939,6 +944,11 @@ int aq_ptp_init(struct aq_nic_s *aq_nic, unsigned int idx_vec)aq_ptp_clock_init (aq_nic);mutex_unlock (&aq_nic->fwreq_mutex); + aq_ptp->eth_type_filter.location = +aq_nic_reserve_filter (aq_nic, aq_rx_filter_ethertype); + aq_ptp->udp_filter.location = +aq_nic_reserve_filter (aq_nic, aq_rx_filter_l3l4); +return 0 ; err_exit:
@@ -964,6 +974,10 @@ void aq_ptp_free(struct aq_nic_s *aq_nic)if (!aq_ptp)return ; +aq_nic_release_filter (aq_nic, aq_rx_filter_ethertype, + aq_ptp->eth_type_filter.location); +aq_nic_release_filter (aq_nic, aq_rx_filter_l3l4, + aq_ptp->udp_filter.location);/* disable ptp */ mutex_lock (&aq_nic->fwreq_mutex); aq_nic->aq_fw_ops->enable_ptp (aq_nic->aq_hw,0 );
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +9 -3
@@ -1248,7 +1248,8 @@ static int hw_atl_b0_hw_fl3l4_set(struct aq_hw_s *self,hw_atl_b0_hw_fl3l4_clear (self, data); -if (data->cmd) { +if (data->cmd & (HW_ATL_RX_ENABLE_CMP_DEST_ADDR_L3 | +HW_ATL_RX_ENABLE_CMP_SRC_ADDR_L3 )) {if (!data->is_ipv6) { hw_atl_rpfl3l4_ipv4_dest_addr_set(self, location,
@@ -1265,8 +1266,13 @@ static int hw_atl_b0_hw_fl3l4_set(struct aq_hw_s *self, data->ip_src); } } -hw_atl_rpf_l4_dpd_set (self, data->p_dst, location); -hw_atl_rpf_l4_spd_set (self, data->p_src, location); + +if (data->cmd & (HW_ATL_RX_ENABLE_CMP_DEST_PORT_L4 | +HW_ATL_RX_ENABLE_CMP_SRC_PORT_L4 )) { +hw_atl_rpf_l4_dpd_set (self, data->p_dst, location); +hw_atl_rpf_l4_spd_set (self, data->p_src, location); + } +hw_atl_rpfl3l4_cmd_set (self, location, data->cmd);return aq_hw_err_from_flags (self);
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh_internal.h +46 -44
102 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 8/12 net: aquantia: add support for ptp ioctls
In reply to Igor RusskikhFrom: Egor Pomozov <[email protected]>
Here we add support for PTP specific IOCTLs of HW timestamp get/set.
These will use filters to configure flows onto the required queue ids.
--- .../net/ethernet/aquantia/atlantic/aq_main.c | 82 +++++++++++++++++++ .../net/ethernet/aquantia/atlantic/aq_ptp.c | 64 +++++++++++++++ .../net/ethernet/aquantia/atlantic/aq_ptp.h | 6 ++ 3 files changed, 152 insertions(+)
drivers/net/ethernet/aquantia/atlantic/aq_main.c +82 -0
@@ -220,6 +220,87 @@ static void aq_ndev_set_multicast_settings(struct net_device *ndev)aq_nic_set_multicast_list (aq_nic, ndev); } +static int aq_ndev_config_hwtstamp (struct aq_nic_s *aq_nic, +struct hwtstamp_config *config) +{ +if (config->flags) +return -EINVAL ; + +switch (config->tx_type) { +case HWTSTAMP_TX_OFF : +case HWTSTAMP_TX_ON : +break ; +default : +return -ERANGE ; + } + +switch (config->rx_filter) { +case HWTSTAMP_FILTER_PTP_V2_L4_EVENT : +case HWTSTAMP_FILTER_PTP_V2_L4_SYNC : +case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ : +case HWTSTAMP_FILTER_PTP_V2_L2_EVENT : +case HWTSTAMP_FILTER_PTP_V2_L2_SYNC : +case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ : +case HWTSTAMP_FILTER_PTP_V2_SYNC : +case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ : + config->rx_filter =HWTSTAMP_FILTER_PTP_V2_EVENT ; +break ; +case HWTSTAMP_FILTER_PTP_V2_EVENT : +case HWTSTAMP_FILTER_NONE : +break ; +default : +return -ERANGE ; + } + +return aq_ptp_hwtstamp_config_set (aq_nic->aq_ptp, config); +} + +static int aq_ndev_hwtstamp_set (struct aq_nic_s *aq_nic,struct ifreq *ifr) +{ +struct hwtstamp_config config; +int ret_val; + +if (!aq_nic->aq_ptp) +return -EOPNOTSUPP ; + +if (copy_from_user (&config, ifr->ifr_data,sizeof (config))) +return -EFAULT ; + + ret_val =aq_ndev_config_hwtstamp (aq_nic, &config); +if (ret_val) +return ret_val; + +return copy_to_user (ifr->ifr_data, &config,sizeof (config)) ? + -EFAULT :0 ; +} + +static int aq_ndev_hwtstamp_get (struct aq_nic_s *aq_nic,struct ifreq *ifr) +{ +struct hwtstamp_config config; + +if (!aq_nic->aq_ptp) +return -EOPNOTSUPP ; + +aq_ptp_hwtstamp_config_get (aq_nic->aq_ptp, &config); +return copy_to_user (ifr->ifr_data, &config,sizeof (config)) ? + -EFAULT :0 ; +} + +static int aq_ndev_ioctl (struct net_device *netdev,struct ifreq *ifr,int cmd) +{ +struct aq_nic_s *aq_nic =netdev_priv (netdev); + +switch (cmd) { +case SIOCSHWTSTAMP : +return aq_ndev_hwtstamp_set (aq_nic, ifr); + +case SIOCGHWTSTAMP : +return aq_ndev_hwtstamp_get (aq_nic, ifr); + } + +return -EOPNOTSUPP ; +} +static int aq_ndo_vlan_rx_add_vid (struct net_device *ndev,__be16 proto,u16 vid) {
@@ -257,6 +338,7 @@ static const struct net_device_ops aq_ndev_ops = { .ndo_change_mtu = aq_ndev_change_mtu, .ndo_set_mac_address = aq_ndev_set_mac_address, .ndo_set_features = aq_ndev_set_features, + .ndo_do_ioctl = aq_ndev_ioctl, .ndo_vlan_rx_add_vid = aq_ndo_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = aq_ndo_vlan_rx_kill_vid, };
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +64 -0
76 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/aq_ptp.h +6 -0
@@ -38,6 +38,12 @@ void aq_ptp_clock_init(struct aq_nic_s *aq_nic);int aq_ptp_xmit (struct aq_nic_s *aq_nic,struct sk_buff *skb);void aq_ptp_tx_hwtstamp (struct aq_nic_s *aq_nic,u64 timestamp); +/* Must be to check available of PTP before call */ +void aq_ptp_hwtstamp_config_get (struct aq_ptp_s *aq_ptp, +struct hwtstamp_config *config); +int aq_ptp_hwtstamp_config_set (struct aq_ptp_s *aq_ptp, +struct hwtstamp_config *config); +/* Return either ring is belong to PTP or not*/ bool aq_ptp_ring (struct aq_nic_s *aq_nic,struct aq_ring_s *ring);
Signature · 1 line
2.17.1
Re: [PATCH v2 net-next 08/12] net: aquantia: add support for ptp ioctls
Quoted 13 lines
drivers/net/ethernet/aquantia/atlantic/aq_main.c +13
-0+static int aq_ndev_config_hwtstamp (struct aq_nic_s *aq_nic, +struct hwtstamp_config *config) +{ +if (config->flags) +return -EINVAL ; + +switch (config->tx_type) { +case HWTSTAMP_TX_OFF : +case HWTSTAMP_TX_ON : +break ; +default : +return -ERANGE ; + }
drivers/net/ethernet/aquantia/atlantic/aq_main.c static void aq_ndev_set_multicast_settings(struct net_device *ndev) · line 245
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_main.c +10
-0+ +switch (config->rx_filter) { +case HWTSTAMP_FILTER_PTP_V2_L4_EVENT : +case HWTSTAMP_FILTER_PTP_V2_L4_SYNC : +case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ : +case HWTSTAMP_FILTER_PTP_V2_L2_EVENT : +case HWTSTAMP_FILTER_PTP_V2_L2_SYNC : +case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ : +case HWTSTAMP_FILTER_PTP_V2_SYNC : +case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ :
Probably a question of Richard
I think this hardware only supports IPv4. Is there some way to indicate IPv6 is not supported?
Andrew
Re: [PATCH v2 net-next 08/12] net: aquantia: add support for ptp ioctls
Quoted 14 lines
drivers/net/ethernet/aquantia/atlantic/aq_main.c static void aq_ndev_set_multicast_settings(struct net_device *ndev) · line 245
Quoted 11 lines
drivers/net/ethernet/aquantia/atlantic/aq_main.c +10
-0+ +switch (config->rx_filter) { +case HWTSTAMP_FILTER_PTP_V2_L4_EVENT : +case HWTSTAMP_FILTER_PTP_V2_L4_SYNC : +case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ : +case HWTSTAMP_FILTER_PTP_V2_L2_EVENT : +case HWTSTAMP_FILTER_PTP_V2_L2_SYNC : +case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ : +case HWTSTAMP_FILTER_PTP_V2_SYNC : +case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ :Probably a question of Richard
Quoted 2 lines
I think this hardware only supports IPv4. Is there some way to indicate IPv6 is not supported?
I don't think it exists,
but the hardware does actually supports IPv6. We now doing some verification on it and there will be a followup patch for this.
Regards,
Igor
PATCH v2 9/12 net: aquantia: implement get_ts_info ethtool
In reply to Igor RusskikhFrom: Egor Pomozov <[email protected]>
Ethtool callback with basic information on what PTP features are supported by the device.
--- .../ethernet/aquantia/atlantic/aq_ethtool.c | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +34 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only /* * aQuantia Corporation Network Driver -* Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved +* Copyright (C) 2014-2019 aQuantia Corporation. All rights reserved */ /* File aq_ethtool.c: Definition of ethertool related functions. */
@@ -9,8 +9,11 @@#include "aq_ethtool.h" #include "aq_nic.h" #include "aq_vec.h" +#include "aq_ptp.h" #include "aq_filters.h" +#include <linux/ptp_clock_kernel.h> +static void aq_ethtool_get_regs (struct net_device *ndev,struct ethtool_regs *regs,void *p) {
@@ -377,6 +380,35 @@ static int aq_ethtool_set_wol(struct net_device *ndev,return err; } +static int aq_ethtool_get_ts_info (struct net_device *ndev, +struct ethtool_ts_info *info) +{ +struct aq_nic_s *aq_nic =netdev_priv (ndev); + +ethtool_op_get_ts_info (ndev, info); + + info->so_timestamping |= +SOF_TIMESTAMPING_TX_HARDWARE | +SOF_TIMESTAMPING_RX_HARDWARE | +SOF_TIMESTAMPING_RAW_HARDWARE ; + + info->tx_types = +BIT (HWTSTAMP_TX_OFF ) | +BIT (HWTSTAMP_TX_ON ); + + info->rx_filters =BIT (HWTSTAMP_FILTER_NONE ); + +if (aq_nic->aq_ptp) + info->rx_filters |=BIT (HWTSTAMP_FILTER_PTP_V2_L4_EVENT ) | +BIT (HWTSTAMP_FILTER_PTP_V2_L2_EVENT ) | +BIT (HWTSTAMP_FILTER_PTP_V2_EVENT ); + + info->phc_index = (aq_nic->aq_ptp) ? +ptp_clock_index (aq_ptp_get_ptp_clock (aq_nic->aq_ptp)) :-1 ; + +return 0 ; +} +static enum hw_atl_fw2x_rate eee_mask_to_ethtool_mask (u32 speed) {u32 rate =0 ;
@@ -604,4 +636,5 @@ const struct ethtool_ops aq_ethtool_ops = { .set_link_ksettings = aq_ethtool_set_link_ksettings, .get_coalesce = aq_ethtool_get_coalesce, .set_coalesce = aq_ethtool_set_coalesce, + .get_ts_info = aq_ethtool_get_ts_info, };
Signature · 1 line
2.17.1
Re: [PATCH v2 net-next 09/12] net: aquantia: implement get_ts_info ethtool
Quoted 9 lines · Igor Russkikh
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +9
-0+static int aq_ethtool_get_ts_info (struct net_device *ndev, +struct ethtool_ts_info *info) +{ +struct aq_nic_s *aq_nic =netdev_priv (ndev); + +ethtool_op_get_ts_info (ndev, info); + + info->so_timestamping |= + SOF_TIMESTAMPING_TX_HARDWARE |
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c static int aq_ethtool_set_wol(struct net_device *ndev, · line 401
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +10
-0+SOF_TIMESTAMPING_RX_HARDWARE | +SOF_TIMESTAMPING_RAW_HARDWARE ; + + info->tx_types = +BIT (HWTSTAMP_TX_OFF ) | +BIT (HWTSTAMP_TX_ON ); + + info->rx_filters =BIT (HWTSTAMP_FILTER_NONE ); + +if (aq_nic->aq_ptp)
Shouldn't the test for (aq_nic->aq_ptp) also effect info->so_timestamping and info->tx_types ?
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c static int aq_ethtool_set_wol(struct net_device *ndev, · line 410
Quoted 9 lines
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +9
-0+ info->rx_filters |=BIT (HWTSTAMP_FILTER_PTP_V2_L4_EVENT ) | +BIT (HWTSTAMP_FILTER_PTP_V2_L2_EVENT ) | +BIT (HWTSTAMP_FILTER_PTP_V2_EVENT ); + + info->phc_index = (aq_nic->aq_ptp) ? +ptp_clock_index (aq_ptp_get_ptp_clock (aq_nic->aq_ptp)) :-1 ; + +return 0 ; +}
Thanks,
Richard
Re: [PATCH v2 net-next 09/12] net: aquantia: implement get_ts_info ethtool
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ + if (aq_nic->aq_ptp)Shouldn't the test for (
aq_nic->aq_ptp) also effectinfo->so_timestampingandinfo->tx_types?
You are right, it should.
It should also fallback to software ethtool_op_get_ts_info in case HW is not PTP capable.
Will fix that.
Regards,
Igor
PATCH v2 10/12 net: aquantia: add support for Phy access
In reply to Igor RusskikhFrom: Dmitry Bezrukov <[email protected]>
GPIO PIN control and access is done by direct phy manipulation. Here we add an aq_phy module which is able to access phy registers via MDIO access mailbox.
Access is controlled via HW semaphore.
--- .../net/ethernet/aquantia/atlantic/Makefile | 1 + .../net/ethernet/aquantia/atlantic/aq_hw.h | 1 + .../net/ethernet/aquantia/atlantic/aq_nic.c | 6 + .../net/ethernet/aquantia/atlantic/aq_phy.c | 147 ++++++++++++++++++ .../net/ethernet/aquantia/atlantic/aq_phy.h | 32 ++++ .../aquantia/atlantic/hw_atl/hw_atl_llh.c | 62 ++++++++ .../aquantia/atlantic/hw_atl/hw_atl_llh.h | 35 +++++ .../atlantic/hw_atl/hw_atl_llh_internal.h | 115 ++++++++++++++ 8 files changed, 399 insertions(+) create mode 100644 drivers/net/ethernet/aquantia/atlantic/aq_phy.c create mode 100644 drivers/net/ethernet/aquantia/atlantic/aq_phy.h
drivers/net/ethernet/aquantia/atlantic/Makefile +1 -0
@@ -25,6 +25,7 @@ atlantic-objs := aq_main.o \ aq_drvinfo.o \ aq_filters.o \ aq_ptp.o \ + aq_phy.o \ hw_atl/hw_atl_a0.o \ hw_atl/hw_atl_b0.o \ hw_atl/hw_atl_utils.o \
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +1 -0
@@ -140,6 +140,7 @@ struct aq_hw_s {u32 rpc_tid;struct hw_atl_utils_fw_rpc rpc;s64 ptp_clk_offset; +u16 phy_id; };struct aq_ring_s ;
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +6 -0
@@ -12,6 +12,7 @@#include "aq_hw.h" #include "aq_pci_func.h" #include "aq_main.h" +#include "aq_phy.h" #include "aq_ptp.h" #include "aq_filters.h"
@@ -337,6 +338,11 @@ int aq_nic_init(struct aq_nic_s *self)if (err <0 ) goto err_exit; +if (self->aq_nic_cfg.aq_hw_caps->media_type ==AQ_HW_MEDIA_TYPE_TP ) { + self->aq_hw->phy_id =HW_ATL_PHY_ID_MAX ; + err =aq_phy_init (self->aq_hw); + } +for (i =0U , aq_vec = self->aq_vec[0 ]; self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i])aq_vec_init (aq_vec, self->aq_hw_ops, self->aq_hw);
drivers/net/ethernet/aquantia/atlantic/aq_phy.c new file +147 -0
147 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/aq_phy.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* aQuantia Corporation Network Driver +* Copyright (C) 2018-2019 aQuantia Corporation. All rights reserved +*/ + +#ifndef AQ_PHY_H +#define AQ_PHY_H + +#include <linux/mdio.h> + +#include "hw_atl/hw_atl_llh.h" +#include "hw_atl/hw_atl_llh_internal.h" +#include "aq_hw_utils.h" +#include "aq_hw.h" + +#define HW_ATL_PHY_ID_MAX 32U + +bool aq_mdio_busy_wait (struct aq_hw_s *aq_hw); + +u16 aq_mdio_read_word (struct aq_hw_s *aq_hw,u16 mmd,u16 addr); + +void aq_mdio_write_word (struct aq_hw_s *aq_hw,u16 mmd,u16 addr,u16 data); + +u16 aq_phy_read_reg (struct aq_hw_s *aq_hw,u16 mmd,u16 address); + +void aq_phy_write_reg (struct aq_hw_s *aq_hw,u16 mmd,u16 address,u16 data); + +bool aq_phy_init_phy_id (struct aq_hw_s *aq_hw); + +bool aq_phy_init (struct aq_hw_s *aq_hw); + +#endif /* AQ_PHY_H */
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c +62 -0
71 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h +35 -0
@@ -764,9 +764,44 @@ void hw_atl_rpfl3l4_ipv6_src_addr_set(struct aq_hw_s *aq_hw, u8 location,void hw_atl_rpfl3l4_ipv6_dest_addr_set (struct aq_hw_s *aq_hw,u8 location,u32 *ipv6_dest); +/* set Global MDIO Interface 1 */ +void hw_atl_glb_mdio_iface1_set (struct aq_hw_s *hw,u32 value); + +/* get Global MDIO Interface 1 */ +u32 hw_atl_glb_mdio_iface1_get (struct aq_hw_s *hw); + +/* set Global MDIO Interface 2 */ +void hw_atl_glb_mdio_iface2_set (struct aq_hw_s *hw,u32 value); + +/* get Global MDIO Interface 2 */ +u32 hw_atl_glb_mdio_iface2_get (struct aq_hw_s *hw); + +/* set Global MDIO Interface 3 */ +void hw_atl_glb_mdio_iface3_set (struct aq_hw_s *hw,u32 value); + +/* get Global MDIO Interface 3 */ +u32 hw_atl_glb_mdio_iface3_get (struct aq_hw_s *hw); + +/* set Global MDIO Interface 4 */ +void hw_atl_glb_mdio_iface4_set (struct aq_hw_s *hw,u32 value); + +/* get Global MDIO Interface 4 */ +u32 hw_atl_glb_mdio_iface4_get (struct aq_hw_s *hw); + +/* set Global MDIO Interface 5 */ +void hw_atl_glb_mdio_iface5_set (struct aq_hw_s *hw,u32 value); + +/* get Global MDIO Interface 5 */ +u32 hw_atl_glb_mdio_iface5_get (struct aq_hw_s *hw); + +u32 hw_atl_mdio_busy_get (struct aq_hw_s *aq_hw); +/* get global microprocessor ram semaphore */ u32 hw_atl_sem_ram_get (struct aq_hw_s *self); +/* get global microprocessor mdio semaphore */ +u32 hw_atl_sem_mdio_get (struct aq_hw_s *self); +/* get global microprocessor scratch pad register */ u32 hw_atl_scrpad_get (struct aq_hw_s *aq_hw,u32 scratch_scp);
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh_internal.h +115 -0
121 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v2 net-next 10/12] net: aquantia: add support for Phy access
Quoted 6 lines · Igor Russkikh
From: Dmitry Bezrukov <[email protected]>
GPIO PIN control and access is done by direct phy manipulation. Here we add an
aq_phymodule which is able to access phy registers via MDIO access mailbox.
Quoted 6 lines
Access is controlled via HW semaphore.
Co-developed-by Nikita Danilov <[email protected]>Signed-off-by Nikita Danilov <[email protected]>Signed-off-by Dmitry Bezrukov <[email protected]>Signed-off-by Igor Russkikh <[email protected]>
Hi Igor
Is the Atlantic a combined MAC and PHY in one silicon, or are there two devices? Could the Atlantic MAC be used in combination with for example a Marvell PHY?
Quoted 103 lines
drivers/net/ethernet/aquantia/atlantic/aq_phy.c new file +97
-0@@ -0,0 +1,147 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* aQuantia Corporation Network Driver +* Copyright (C) 2018-2019 aQuantia Corporation. All rights reserved +*/ + +#include "aq_phy.h" + +bool aq_mdio_busy_wait (struct aq_hw_s *aq_hw) +{ +int err =0 ; +u32 val; + + err =readx_poll_timeout_atomic (hw_atl_mdio_busy_get, aq_hw, + val, val ==0U ,10U ,100000U ); + +if (err <0 ) +return false; + +return true; +} + +u16 aq_mdio_read_word (struct aq_hw_s *aq_hw,u16 mmd,u16 addr) +{ +u16 phy_addr = aq_hw->phy_id <<5 | mmd; + +/* Set Address register. */ +hw_atl_glb_mdio_iface4_set (aq_hw, (addr &HW_ATL_MDIO_ADDRESS_MSK ) << +HW_ATL_MDIO_ADDRESS_SHIFT ); +/* Send Address command. */ +hw_atl_glb_mdio_iface2_set (aq_hw,HW_ATL_MDIO_EXECUTE_OPERATION_MSK | + (3 <<HW_ATL_MDIO_OP_MODE_SHIFT ) | + ((phy_addr &HW_ATL_MDIO_PHY_ADDRESS_MSK ) << +HW_ATL_MDIO_PHY_ADDRESS_SHIFT )); + +aq_mdio_busy_wait (aq_hw); + +/* Send Read command. */ +hw_atl_glb_mdio_iface2_set (aq_hw,HW_ATL_MDIO_EXECUTE_OPERATION_MSK | + (1 <<HW_ATL_MDIO_OP_MODE_SHIFT ) | + ((phy_addr &HW_ATL_MDIO_PHY_ADDRESS_MSK ) << +HW_ATL_MDIO_PHY_ADDRESS_SHIFT )); +/* Read result. */ +aq_mdio_busy_wait (aq_hw); + +return (u16 )hw_atl_glb_mdio_iface5_get (aq_hw); +} + +void aq_mdio_write_word (struct aq_hw_s *aq_hw,u16 mmd,u16 addr,u16 data) +{ +u16 phy_addr = aq_hw->phy_id <<5 | mmd; + +/* Set Address register. */ +hw_atl_glb_mdio_iface4_set (aq_hw, (addr &HW_ATL_MDIO_ADDRESS_MSK ) << +HW_ATL_MDIO_ADDRESS_SHIFT ); +/* Send Address command. */ +hw_atl_glb_mdio_iface2_set (aq_hw,HW_ATL_MDIO_EXECUTE_OPERATION_MSK | + (3 <<HW_ATL_MDIO_OP_MODE_SHIFT ) | + ((phy_addr &HW_ATL_MDIO_PHY_ADDRESS_MSK ) << +HW_ATL_MDIO_PHY_ADDRESS_SHIFT )); + +aq_mdio_busy_wait (aq_hw); + +hw_atl_glb_mdio_iface3_set (aq_hw, (data &HW_ATL_MDIO_WRITE_DATA_MSK ) << +HW_ATL_MDIO_WRITE_DATA_SHIFT ); +/* Send Write command. */ +hw_atl_glb_mdio_iface2_set (aq_hw,HW_ATL_MDIO_EXECUTE_OPERATION_MSK | + (2 <<HW_ATL_MDIO_OP_MODE_SHIFT ) | + ((phy_addr &HW_ATL_MDIO_PHY_ADDRESS_MSK ) << +HW_ATL_MDIO_PHY_ADDRESS_SHIFT )); + +aq_mdio_busy_wait (aq_hw); +} + +u16 aq_phy_read_reg (struct aq_hw_s *aq_hw,u16 mmd,u16 address) +{ +int err =0 ; +u32 val; + + err =readx_poll_timeout_atomic (hw_atl_sem_mdio_get, aq_hw, + val, val ==1U ,10U ,100000U ); + +if (err <0 ) { + err =0xffff ; + goto err_exit; + } + + err =aq_mdio_read_word (aq_hw, mmd, address); + +hw_atl_reg_glb_cpu_sem_set (aq_hw,1U ,HW_ATL_FW_SM_MDIO ); + +err_exit: +return err; +} + +void aq_phy_write_reg (struct aq_hw_s *aq_hw,u16 mmd,u16 address,u16 data) +{ +int err =0 ;
drivers/net/ethernet/aquantia/atlantic/aq_phy.c line 107
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_phy.c new file +10
-0+u32 val; + + err =readx_poll_timeout_atomic (hw_atl_sem_mdio_get, aq_hw, + val, val ==1U ,10U ,100000U ); +if (err <0 ) +return ; + +aq_mdio_write_word (aq_hw, mmd, address, data); +hw_atl_reg_glb_cpu_sem_set (aq_hw,1U ,HW_ATL_FW_SM_MDIO ); +}
You have here the code needed to implement a real Linux MDIO bus driver. Are the MDIO pins exposed? Could somebody combine the chip with say a Marvell Ethernet switch? You then need access to the MDIO bus to control the switch. So by using a Linux MDIO bus driver, you make it easy for somebody to do that. You can keep with your firmware mostly driving the PHY.
Quoted 27 lines
drivers/net/ethernet/aquantia/atlantic/aq_phy.c new file +27
-0+ +bool aq_phy_init_phy_id (struct aq_hw_s *aq_hw) +{ +u16 val; + +for (aq_hw->phy_id =0 ; aq_hw->phy_id <HW_ATL_PHY_ID_MAX ; + ++aq_hw->phy_id) { +/* PMA Standard Device Identifier 2: Address 1.3 */ + val =aq_phy_read_reg (aq_hw,MDIO_MMD_PMAPMD ,3 ); + +if (val !=0xffff ) +return true; + } + +return false; +} + +bool aq_phy_init (struct aq_hw_s *aq_hw) +{ +u32 dev_id; + +if (aq_hw->phy_id ==HW_ATL_PHY_ID_MAX ) +if (!aq_phy_init_phy_id (aq_hw)) +return false; + +/* PMA Standard Device Identifier: +* Address 1.2 = MSW,
drivers/net/ethernet/aquantia/atlantic/aq_phy.c line 144
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_phy.c new file +10
-0+* Address 1.3 = LSW +*/ + dev_id =aq_phy_read_reg (aq_hw,MDIO_MMD_PMAPMD ,2 ); + dev_id <<=16 ; + dev_id |=aq_phy_read_reg (aq_hw,MDIO_MMD_PMAPMD ,3 ); + +if (dev_id ==0xffffffff ) { + aq_hw->phy_id =HW_ATL_PHY_ID_MAX ; +return false; + }
For future proofing, should you not check it is actually one of your PHYs?
Thanks
Andrew
Re: [PATCH v2 net-next 10/12] net: aquantia: add support for Phy access
Quoted 6 lines
Hi Igor
Is the Atlantic a combined MAC and PHY in one silicon, or are there two devices? Could the Atlantic MAC be used in combination with for example a Marvell PHY?
Hi Andrew,
No it can't. This is a monolitic MAC+Phy solution.
We do have MAC only NIC (AQC100 with SFP+ connector) - but even there SFP Phy is controlled by MAC firmware and this is totally transparent for driver/OS.
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_phy.c line 107
Quoted 3 lines
drivers/net/ethernet/aquantia/atlantic/aq_phy.c new file +3
-0+aq_mdio_write_word (aq_hw, mmd, address, data); +hw_atl_reg_glb_cpu_sem_set (aq_hw,1U ,HW_ATL_FW_SM_MDIO ); +}You have here the code needed to implement a real Linux MDIO bus driver. Are the MDIO pins exposed? Could somebody combine the chip with say a Marvell Ethernet switch? You then need access to the MDIO bus to control the switch. So by using a Linux MDIO bus driver, you make it easy for somebody to do that. You can keep with your firmware mostly driving the PHY.
No, these are not exposed as far as I know. Therefore it makes no sense to expose that to linux.
Quoted 6 lines
drivers/net/ethernet/aquantia/atlantic/aq_phy.c line 144
Quoted 3 lines
drivers/net/ethernet/aquantia/atlantic/aq_phy.c new file +3
-0+ aq_hw->phy_id =HW_ATL_PHY_ID_MAX ; +return false; + }For future proofing, should you not check it is actually one of your PHYs?
I don't think that makes sense, since that'll always be a hardcoded mac/phy pair.
Regards,
Igor
Re: [PATCH v2 net-next 10/12] net: aquantia: add support for Phy access
Quoted 2 lines
Hi Andrew,
No it can't. This is a monolitic MAC+Phy solution.
O.K, then not using the core infrastructure is O.K.
Thanks
Andrew
PATCH v2 11/12 net: aquantia: add support for PIN funcs
In reply to Igor RusskikhFrom: Dmitry Bezrukov <[email protected]>
Depending on FW configuration we can manage from 0 to 3 PINs for periodic output and from 0 to 1 ext ts PIN for getting TS for external event.
Ext TS PIN functionality is implemented via periodic timestamps polling directly from PHY, because right now there is now way to received PIN trigger interrupt from phy.
Poller delay is 15ms.
--- .../net/ethernet/aquantia/atlantic/aq_hw.h | 10 + .../net/ethernet/aquantia/atlantic/aq_nic.c | 1 + .../net/ethernet/aquantia/atlantic/aq_ptp.c | 339 ++++++++++++++++++ .../net/ethernet/aquantia/atlantic/aq_ptp.h | 2 + .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 63 +++- .../aquantia/atlantic/hw_atl/hw_atl_utils.h | 8 + 6 files changed, 422 insertions(+), 1 deletion(-)
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +10 -0
@@ -259,6 +259,16 @@ struct aq_hw_ops {int (*hw_set_sys_clock)(struct aq_hw_s *self,u64 time,u64 ts); +int (*hw_ts_to_sys_clock)(struct aq_hw_s *self,u64 ts,u64 *time); + +int (*hw_gpio_pulse)(struct aq_hw_s *self,u32 index,u64 start, +u32 period); + +int (*hw_extts_gpio_enable)(struct aq_hw_s *self,u32 index, +u32 enable); + +int (*hw_get_sync_ts)(struct aq_hw_s *self,u64 *ts); +u16 (*rx_extract_ts)(struct aq_hw_s *self,u8 *p,unsigned int len,u64 *timestamp);
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +1 -0
@@ -152,6 +152,7 @@ static int aq_nic_update_link_status(struct aq_nic_s *self)aq_ptp_clock_init (self);aq_ptp_tm_offset_set (self, self->aq_hw->aq_link_status.mbps); +aq_ptp_link_change (self); }/* Driver has to update flow control settings on RX block
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +339 -0
418 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/aq_ptp.h +2 -0
@@ -52,4 +52,6 @@ u16 aq_ptp_extract_ts(struct aq_nic_s *aq_nic, struct sk_buff *skb, u8 *p,struct ptp_clock *aq_ptp_get_ptp_clock (struct aq_ptp_s *aq_ptp); +int aq_ptp_link_change (struct aq_nic_s *aq_nic); +#endif /* AQ_PTP_H */
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +62 -1
88 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h +8 -0
@@ -288,6 +288,12 @@ struct __packed offload_info { };/* Mailbox FW Request interface */ +struct __packed hw_fw_request_ptp_gpio_ctrl { +u32 index; +u32 period; +u64 start; +}; +struct __packed hw_fw_request_ptp_adj_freq {u32 ns_mac;u32 fns_mac;
@@ -303,6 +309,7 @@ struct __packed hw_fw_request_ptp_adj_clock {int sign; }; +#define HW_AQ_FW_REQUEST_PTP_GPIO_CTRL 0x11#define HW_AQ_FW_REQUEST_PTP_ADJ_FREQ 0x12#define HW_AQ_FW_REQUEST_PTP_ADJ_CLOCK 0x13
@@ -310,6 +317,7 @@ struct __packed hw_fw_request_iface {u32 msg_id;union {/* PTP FW Request */ +struct hw_fw_request_ptp_gpio_ctrl ptp_gpio_ctrl;struct hw_fw_request_ptp_adj_freq ptp_adj_freq;struct hw_fw_request_ptp_adj_clock ptp_adj_clock; };
Signature · 1 line
2.17.1
Re: [PATCH v2 net-next 11/12] net: aquantia: add support for PIN funcs
Quoted 7 lines · Igor Russkikh
From: Dmitry Bezrukov <[email protected]>
Depending on FW configuration we can manage from 0 to 3 PINs for periodic output and from 0 to 1 ext ts PIN for getting TS for external event.
Ext TS PIN functionality is implemented via periodic timestamps polling directly from PHY, because right now there is now way to received
there is no way to receive the
Quoted 3 lines
PIN trigger interrupt from phy.
Poller delay is 15ms.
The polling interval is 15 milliseconds.
Thanks,
Richard
Re: [PATCH v2 net-next 11/12] net: aquantia: add support for PIN funcs
In reply to Igor RusskikhQuoted 8 lines · Igor Russkikh
From: Dmitry Bezrukov <[email protected]>
Depending on FW configuration we can manage from 0 to 3 PINs for periodic output and from 0 to 1 ext ts PIN for getting TS for external event.
Ext TS PIN functionality is implemented via periodic timestamps polling directly from PHY, because right now there is now way to received PIN trigger interrupt from phy.
Hi Igor
Is that a hardware limitation? Is the PHY interrupt not connected at all? Could future cards have the interrupt connected?
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c static void aq_ptp_convert_to_hwtstamp(struct aq_ptp_s *aq_ptp, · line 381
Quoted 11 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +11
-0+static int aq_ptp_hw_pin_conf (struct aq_nic_s *aq_nic,u32 pin_index,u64 start, +u64 period) +{ +if (period) +netdev_info (aq_nic->ndev, +"Enable GPIO %d pulsing, start time %llu, period %u\n" , + pin_index, start, (u32 )period); +else +netdev_info (aq_nic->ndev, +"Disable GPIO %d pulsing, start time %llu, period %u\n" , + pin_index, start, (u32 )period);
_info is too high a log level. _dbg would be better..
Quoted 30 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +30
-0+ +/* Notify hardware of request to being sending pulses. +* If period is ZERO then pulsen is disabled. +*/ +mutex_lock (&aq_nic->fwreq_mutex); + aq_nic->aq_hw_ops->hw_gpio_pulse (aq_nic->aq_hw, pin_index, + start, (u32 )period); +mutex_unlock (&aq_nic->fwreq_mutex); + +return 0 ; +} + +static int aq_ptp_perout_pin_configure (struct ptp_clock_info *ptp, +struct ptp_clock_request *rq,int on) +{ + struct aq_ptp_s *aq_ptp = container_of(ptp, struct aq_ptp_s, ptp_info); +struct ptp_clock_time *t = &rq->perout.period; +struct ptp_clock_time *s = &rq->perout.start; +struct aq_nic_s *aq_nic = aq_ptp->aq_nic; +u64 start, period; +u32 pin_index = rq->perout.index; + +/* verify the request channel is there */ +if (pin_index >= ptp->n_per_out) +return -EINVAL ; + +/* we cannot support periods greater +* than 4 seconds due to reg limit +*/ +if (t->sec >4 || t->sec <0 )
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c static void aq_ptp_convert_to_hwtstamp(struct aq_ptp_s *aq_ptp, · line 421
Quoted 10 lines
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +10
-0+return -ERANGE ; + +/* convert to unsigned 64b ns, +* verify we can put it in a 32b register +*/ + period = on ? t->sec *NSEC_PER_SEC + t->nsec :0 ; + +/* verify the value is in range supported by hardware */ +if (period >U32_MAX ) +return -ERANGE ;
What is U32_MAX ns? Is it greater than 4 seconds?
Andrew
PATCH v2 12/12 net: aquantia: adding atlantic ptp maintainer
In reply to Igor RusskikhPTP implementation is designed and maintained by Egor Pomozov, adding him as this module maintainer. Egor is the author of the core functionality and the architect, and is to be contacted for all Aquantia PTP/AVB functionality.
--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -1190,6 +1190,13 @@ Q: http://patchwork.ozlabs.org/project/netdev/list/ F: drivers/net/ethernet/aquantia/atlantic/ F: Documentation/networking/device_drivers/aquantia/atlantic.txt +AQUANTIA ETHERNET DRIVER PTP SUBSYSTEM +M: Egor Pomozov <[email protected]> +L: [email protected] +S: Supported +W: http://www.aquantia.com +F: drivers/net/ethernet/aquantia/atlantic/aq_ptp* + ARC FRAMEBUFFER DRIVER M: Jaya Kumar <[email protected]> S: Maintained
Signature · 1 line
2.17.1