• Vladimir Oltean's avatar
    ptp: add ability to configure duty cycle for periodic output · f65b71aa
    Vladimir Oltean authored
    There are external event timestampers (PHCs with support for
    PTP_EXTTS_REQUEST) that timestamp both event edges.
    
    When those edges are very close (such as in the case of a short pulse),
    there is a chance that the collected timestamp might be of the rising,
    or of the falling edge, we never know.
    
    There are also PHCs capable of generating periodic output with a
    configurable duty cycle. This is good news, because we can space the
    rising and falling edge out enough in time, that the risks to overrun
    the 1-entry timestamp FIFO of the extts PHC are lower (example: the
    perout PHC can be configured for a period of 1 second, and an "on" time
    of 0.5 seconds, resulting in a duty cycle of 50%).
    
    A flag is introduced for signaling that an on time is present in the
    perout request structure, for preserving compatibility. Logically
    speaking, the duty cycle cannot exceed 100% and the PTP core checks for
    this.
    
    PHC drivers that don't support this flag emit a periodic output of an
    unspecified duty cycle, same as before.
    
    The duty cycle is encoded as an "on" time, similar to the "start" and
    "period" times, and reuses the reserved space while preserving overall
    binary layout.
    
    Pahole reported before:
    
    struct ptp_perout_request {
            struct ptp_clock_time start;                     /*     0    16 */
            struct ptp_clock_time period;                    /*    16    16 */
            unsigned int               index;                /*    32     4 */
            unsigned int               flags;                /*    36     4 */
            unsigned int               rsv[4];               /*    40    16 */
    
            /* size: 56, cachelines: 1, members: 5 */
            /* last cacheline: 56 bytes */
    };
    
    And now:
    
    struct ptp_perout_request {
            struct ptp_clock_time start;                     /*     0    16 */
            struct ptp_clock_time period;                    /*    16    16 */
            unsigned int               index;                /*    32     4 */
            unsigned int               flags;                /*    36     4 */
            union {
                    struct ptp_clock_time on;                /*    40    16 */
                    unsigned int       rsv[4];               /*    40    16 */
            };                                               /*    40    16 */
    
            /* size: 56, cachelines: 1, members: 5 */
            /* last cacheline: 56 bytes */
    };
    Signed-off-by: default avatarVladimir Oltean <olteanv@gmail.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    f65b71aa
ptp_chardev.c 11.9 KB