From: Alexander Duyck <alexander.h.duyck@intel.com>
To: Richard Cochran <richardcochran@gmail.com>
Cc: davem@davemloft.net, nhorman@redhat.com, netdev@vger.kernel.org,
john.fastabend@gmail.com, matthew.vick@intel.com,
jeffrey.t.kirsher@intel.com, sassmann@redhat.com
Subject: Re: [net-next PATCH 29/29] fm10k: Add support for PTP
Date: Fri, 19 Sep 2014 11:32:24 -0700 [thread overview]
Message-ID: <541C76B8.6040708@intel.com> (raw)
In-Reply-To: <20140919173504.GA4136@localhost.localdomain>
On 09/19/2014 10:35 AM, Richard Cochran wrote:
> On Thu, Sep 18, 2014 at 06:40:46PM -0400, Alexander Duyck wrote:
>
>> +static s32 fm10k_1588_msg_vf(struct fm10k_hw *hw, u32 **results,
>> + struct fm10k_mbx_info *mbx)
>> +{
>> + struct fm10k_intfc *interface = container_of(hw,
>> + struct fm10k_intfc,
>> + hw);
>
> This looks really funny to me here and in the other spot. Why not this?
>
> struct fm10k_intfc *interface = container_of(hw, struct fm10k_intfc, hw);
>
Because doing it that way it extends over 80 characters.
> Its only one over the 80 km/h speed limit.
>
>> + u64 timestamp;
>> + s32 err;
>> +
>> + err = fm10k_tlv_attr_get_u64(results[FM10K_1588_MSG_TIMESTAMP],
>> + ×tamp);
>> + if (err)
>> + return err;
>> +
>> + fm10k_ts_tx_hwtstamp(interface, 0, timestamp);
>> +
>> + return 0;
>> +}
>
>> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ptp.c b/drivers/net/ethernet/intel/fm10k/fm10k_ptp.c
>> new file mode 100644
>> index 0000000..41da724
>> --- /dev/null
>> +++ b/drivers/net/ethernet/intel/fm10k/fm10k_ptp.c
>
>> +/* We use a 64b counter so overflow is extremely seldom. Just
>> + * to keep things sane we should check for overflow once per day
>> + */
>
> Hm...
>
>> +void fm10k_ts_start_cc(struct fm10k_intfc *interface)
>> +{
>> + struct fm10k_hw *hw = &interface->hw;
>> +
>> + /* Initialize cycle counter */
>> + interface->cc.read = (hw->mac.type == fm10k_mac_pf) ? fm10k_cc_read_pf :
>> + fm10k_cc_read_vf;
>> + interface->cc.mask = CLOCKSOURCE_MASK(64);
>> + interface->cc.mult = 1;
>
> So shift = 0 and multi = 1. Your clock counts nanoseconds. Why not use
> it directly? Then you won't need the timecounter stuff or the overflow
> watchdog either.
Because the value cannot be adjusted directly. The timesource for the
switch is shared by all ports and host interfaces. As such we have to
maintain a software offset per host to avoid corrupting the other clocks.
>> +
>> + /* Initialize lock protecting register access */
>> + rwlock_init(&interface->tsreg_lock);
>> +
>> + /* Initialize skb queue for pending timestamp requests */
>> + skb_queue_head_init(&interface->ts_tx_skb_queue);
>> +
>> + /* Initialize the clock */
>> + fm10k_ts_reset_cc(interface);
>> +
>> + /* Initialize the overflow work */
>> + INIT_DELAYED_WORK(&interface->ts_overflow_work,
>> + fm10k_ts_overflow_check);
>> + schedule_delayed_work(&interface->ts_overflow_work,
>> + FM10K_SYSTIME_OVERFLOW_PERIOD);
>> +}
>
>> +static int fm10k_ptp_enable(struct ptp_clock_info *ptp,
>> + struct ptp_clock_request *rq, int on)
>> +{
>> + struct fm10k_intfc *interface =
>> + container_of(ptp, struct fm10k_intfc, ptp_caps);
>> + struct ptp_clock_time *t = &rq->perout.period;
>> + struct fm10k_hw *hw = &interface->hw;
>> + u64 period;
>> + u32 step;
>> +
>> + /* we can only support periodic output */
>> + if (rq->type != PTP_CLK_REQ_PEROUT)
>> + return -EINVAL;
>> +
>> + /* verify the requested channel is there */
>> + if (rq->perout.index >= ptp->n_per_out)
>> + return -EINVAL;
>> +
>> + /* we simply cannot support the operation if we don't have BAR4 */
>> + if (!hw->sw_addr)
>> + return -ENOTSUPP;
>> +
>> + /* we cannot enforce start time as there is no
>> + * mechanism for that in the hardware, we can only control
>> + * the period.
>> + */
>
> Is this because of the timecounter in the way? Another reason to use
> the 64 bit nanosecond counter directly.
The problem is we cannot modify the counter as it is in use by multiple
clocks. So if one adjusted the value it would mess up all of the others.
Also in our case the hardware design doesn't give us a register we can
plug the start time into. We can only control the frequency of the pulse.
>> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_type.h b/drivers/net/ethernet/intel/fm10k/fm10k_type.h
>> index 5055bef..dac5b79 100644
>> --- a/drivers/net/ethernet/intel/fm10k/fm10k_type.h
>> +++ b/drivers/net/ethernet/intel/fm10k/fm10k_type.h
>> @@ -225,11 +225,7 @@ struct fm10k_hw;
>> #define FM10K_STATS_NODESC_DROP 0x3807
>>
>> /* Timesync registers */
>> -#define FM10K_RRTIME_CFG 0x3808
>> -#define FM10K_RRTIME_LIMIT(_n) ((_n) + 0x380C)
>> -#define FM10K_RRTIME_COUNT(_n) ((_n) + 0x3810)
>> #define FM10K_SYSTIME 0x3814
>> -#define FM10K_SYSTIME0 0x3816
>> #define FM10K_SYSTIME_CFG 0x3818
>> #define FM10K_SYSTIME_CFG_STEP_MASK 0x0000000F
>>
>> @@ -368,9 +364,6 @@ struct fm10k_hw;
>> #define FM10K_VFITR(_n) ((_n) + 0x00060)
>>
>> /* Registers contained in BAR 4 for Switch management */
>> -#define FM10K_SW_SYSTIME_CFG 0x0224C
>> -#define FM10K_SW_SYSTIME_CFG_STEP_SHIFT 4
>> -#define FM10K_SW_SYSTIME_CFG_ADJUST_MASK 0xFF000000
>
> You added these three lines in the previous patch.
>
>> #define FM10K_SW_SYSTIME_ADJUST 0x0224D
>> #define FM10K_SW_SYSTIME_ADJUST_MASK 0x3FFFFFFF
>> #define FM10K_SW_SYSTIME_ADJUST_DIR_NEGATIVE 0x80000000
>>
Yeah, I noticed that after you asked your original question. When I had
gone through to clean up the defines that weren't used I cleaned these
up in the wrong patch.
If/when I submit a v2 I will pull them out of the previous patch in the
sequence since that is where they are added. I already have this
resolved in my local copy as of an hour or so ago.
Thanks,
Alex
next prev parent reply other threads:[~2014-09-19 18:33 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-18 22:35 [net-next PATCH 00/29] Add support for the Intel FM10000 Ethernet Switch Host Interface Alexander Duyck
2014-09-18 22:35 ` [net-next PATCH 01/29] fm10k: Add skeletal frame for Intel(R) FM10000 Ethernet Switch Host Interface Driver Alexander Duyck
2014-09-18 22:35 ` [net-next PATCH 02/29] fm10k: Add register defines and basic structures Alexander Duyck
2014-09-18 22:36 ` [net-next PATCH 03/29] fm10k: Add support for TLV message parsing and generation Alexander Duyck
2014-09-18 22:36 ` [net-next PATCH 04/29] fm10k: Add support for basic interaction with hardware Alexander Duyck
2014-09-18 22:36 ` [net-next PATCH 05/29] fm10k: Add support for mailbox Alexander Duyck
2014-09-18 22:36 ` [net-next PATCH 06/29] fm10k: Implement PF <-> SM mailbox operations Alexander Duyck
2014-09-18 22:36 ` [net-next PATCH 07/29] fm10k: Add support for PF Alexander Duyck
2014-09-18 22:36 ` [net-next PATCH 08/29] fm10k: Add support for configuring PF interface Alexander Duyck
2014-09-18 22:36 ` [net-next PATCH 09/29] fm10k: Add netdev Alexander Duyck
2014-09-18 22:37 ` [net-next PATCH 10/29] fm10k: Add support for L2 filtering Alexander Duyck
2014-09-18 22:37 ` [net-next PATCH 11/29] fm10k: Add support for ndo_open/stop Alexander Duyck
2014-09-18 22:37 ` [net-next PATCH 12/29] fm10k: Add interrupt support Alexander Duyck
2014-09-18 22:37 ` [net-next PATCH 13/29] fm10k: add support for Tx/Rx rings Alexander Duyck
2014-09-18 22:37 ` [net-next PATCH 14/29] fm10k: Add service task to handle delayed events Alexander Duyck
2014-09-18 22:37 ` [net-next PATCH 15/29] fm10k: Add Tx/Rx hardware ring bring-up/tear-down Alexander Duyck
2014-09-18 22:38 ` [net-next PATCH 16/29] fm10k: Add transmit and receive fastpath and interrupt handlers Alexander Duyck
2014-09-18 22:38 ` [net-next PATCH 17/29] fm10k: Add ethtool support Alexander Duyck
2014-09-18 22:38 ` [net-next PATCH 18/29] fm10k: Add support for PCI power management and error handling Alexander Duyck
2014-09-18 22:38 ` [net-next PATCH 19/29] fm10k: Add support for multiple queues Alexander Duyck
2014-09-18 22:38 ` [net-next PATCH 20/29] fm10k: Add support for netdev offloads Alexander Duyck
2014-09-18 22:39 ` [net-next PATCH 21/29] fm10k: Add support for MACVLAN acceleration Alexander Duyck
2014-09-18 22:39 ` [net-next PATCH 22/29] fm10k: Add support for PF <-> VF mailbox Alexander Duyck
2014-09-18 22:39 ` [net-next PATCH 23/29] fm10k: Add support for VF Alexander Duyck
2014-09-18 22:39 ` [net-next PATCH 24/29] fm10k: Add support for SR-IOV to PF core files Alexander Duyck
2014-09-18 22:39 ` [net-next PATCH 25/29] fm10k: Add support for SR-IOV to driver Alexander Duyck
2014-09-18 22:40 ` [net-next PATCH 26/29] fm10k: Add support for IEEE DCBx Alexander Duyck
2014-09-18 22:40 ` [net-next PATCH 27/29] fm10k: Add support for debugfs Alexander Duyck
2014-09-18 22:40 ` [net-next PATCH 28/29] fm10k: Add support for ptp to hw specific files Alexander Duyck
2014-09-19 7:38 ` Richard Cochran
2014-09-19 14:36 ` Alexander Duyck
2014-09-19 15:19 ` Richard Cochran
2014-09-19 15:34 ` Alexander Duyck
2014-09-18 22:40 ` [net-next PATCH 29/29] fm10k: Add support for PTP Alexander Duyck
2014-09-19 17:35 ` Richard Cochran
2014-09-19 18:32 ` Alexander Duyck [this message]
2014-09-20 21:07 ` Richard Cochran
2014-09-20 21:37 ` Joe Perches
2014-09-20 21:16 ` Richard Cochran
2014-09-20 23:36 ` Alexander Duyck
2014-09-22 11:03 ` David Laight
2014-09-22 14:21 ` Alexander Duyck
2014-09-19 7:55 ` [net-next PATCH 00/29] Add support for the Intel FM10000 Ethernet Switch Host Interface Jiri Pirko
2014-09-19 14:43 ` Alexander Duyck
2014-09-19 10:57 ` Jamal Hadi Salim
2014-09-19 14:54 ` Alexander Duyck
2014-09-19 16:58 ` Alexei Starovoitov
2014-09-19 18:22 ` Alexander Duyck
2014-09-19 23:52 ` Alexander Duyck
2014-09-20 2:03 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=541C76B8.6040708@intel.com \
--to=alexander.h.duyck@intel.com \
--cc=davem@davemloft.net \
--cc=jeffrey.t.kirsher@intel.com \
--cc=john.fastabend@gmail.com \
--cc=matthew.vick@intel.com \
--cc=netdev@vger.kernel.org \
--cc=nhorman@redhat.com \
--cc=richardcochran@gmail.com \
--cc=sassmann@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).