On Wed, Aug 16, 2017 at 09:32:09PM +0800, Hangbin Liu wrote:
> +     /* ts_label changed */
> +     if (if_indextoname(ts_index, ts_label) && strcmp(p->iface->ts_label, 
> ts_label)) {
> +             strncpy(p->iface->ts_label, ts_label, MAX_IFNAME_SIZE);
> +             sk_get_ts_info(p->iface->ts_label, &p->iface->ts_info);
> +
> +             p->link_status |= TS_LABEL_CHANGED;
> +             pr_notice("port %hu: ts label changed to %s", portnum(p), 
> ts_label);
> +     }
> +
> +     /* We set the link status to down by force if its timestamp not
> +      * support required mode. But the link's status is actually up.
> +      *
> +      * So the next time we receive this link's rtnl message, we need
> +      * to check the required_modes again. If still not support
> +      * required_modes, then keep the link status down.
> +      */
> +     if (p->iface->ts_info.valid) {
> +             required_modes = clock_required_modes(p->clock);
> +             if ((p->iface->ts_info.so_timestamping & required_modes) != 
> required_modes) {
> +                     pr_err("interface '%s' does not support requested "
> +                            "timestamping mode, set link status down by 
> force.",
> +                            p->iface->ts_label);
> +                     p->link_status = LINK_DOWN | LINK_STATE_CHANGED;
> +             } else if (p->link_status & TS_LABEL_CHANGED) {
> +                     p->phc_index = p->iface->ts_info.phc_index;
> +                     clock_switch_phc(p->clock, p->phc_index);
> +             }
> +     }

One more issue found. When we set link down and up, the phc index may changed.

# ethtool -T p7p1
Time stamping parameters for p7p1:
Capabilities:
        hardware-transmit     (SOF_TIMESTAMPING_TX_HARDWARE)
        software-transmit     (SOF_TIMESTAMPING_TX_SOFTWARE)
        hardware-receive      (SOF_TIMESTAMPING_RX_HARDWARE)
        software-receive      (SOF_TIMESTAMPING_RX_SOFTWARE)
        software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
        hardware-raw-clock    (SOF_TIMESTAMPING_RAW_HARDWARE)
PTP Hardware Clock: 5
Hardware Transmit Timestamp Modes:
        off                   (HWTSTAMP_TX_OFF)
        on                    (HWTSTAMP_TX_ON)
Hardware Receive Filter Modes:
        none                  (HWTSTAMP_FILTER_NONE)
        ptpv1-l4-sync         (HWTSTAMP_FILTER_PTP_V1_L4_SYNC)
        ptpv1-l4-delay-req    (HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ)
        ptpv2-event           (HWTSTAMP_FILTER_PTP_V2_EVENT)

# ip link set p7p1 down && sleep 10 && ip link set p7p1 up

# ethtool -T p7p1
Time stamping parameters for p7p1:
Capabilities:
        hardware-transmit     (SOF_TIMESTAMPING_TX_HARDWARE)
        software-transmit     (SOF_TIMESTAMPING_TX_SOFTWARE)
        hardware-receive      (SOF_TIMESTAMPING_RX_HARDWARE)
        software-receive      (SOF_TIMESTAMPING_RX_SOFTWARE)
        software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
        hardware-raw-clock    (SOF_TIMESTAMPING_RAW_HARDWARE)
PTP Hardware Clock: 6
Hardware Transmit Timestamp Modes:
        off                   (HWTSTAMP_TX_OFF)
        on                    (HWTSTAMP_TX_ON)
Hardware Receive Filter Modes:
        none                  (HWTSTAMP_FILTER_NONE)
        ptpv1-l4-sync         (HWTSTAMP_FILTER_PTP_V1_L4_SYNC)
        ptpv1-l4-delay-req    (HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ)
        ptpv2-event           (HWTSTAMP_FILTER_PTP_V2_EVENT)

This will cause errors like

ptp4l[90454.937]: failed to adjust the clock: No such device
ptp4l[90454.937]: failed to step clock: No such device

after link down/up. So we need to get_ts_info every time link up.

I will fix it in the new version of this patch.

Thanks
Hangbin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to