cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

aq_ptp.h (4280B)


      1/* SPDX-License-Identifier: GPL-2.0-only */
      2/* Atlantic Network Driver
      3 *
      4 * Copyright (C) 2014-2019 aQuantia Corporation
      5 * Copyright (C) 2019-2020 Marvell International Ltd.
      6 */
      7
      8/* File aq_ptp.h: Declaration of PTP functions.
      9 */
     10#ifndef AQ_PTP_H
     11#define AQ_PTP_H
     12
     13#include <linux/net_tstamp.h>
     14
     15#include "aq_ring.h"
     16
     17#define PTP_8TC_RING_IDX             8
     18#define PTP_4TC_RING_IDX            16
     19#define PTP_HWST_RING_IDX           31
     20
     21/* Index must to be 8 (8 TCs) or 16 (4 TCs).
     22 * It depends from Traffic Class mode.
     23 */
     24static inline unsigned int aq_ptp_ring_idx(const enum aq_tc_mode tc_mode)
     25{
     26	if (tc_mode == AQ_TC_MODE_8TCS)
     27		return PTP_8TC_RING_IDX;
     28
     29	return PTP_4TC_RING_IDX;
     30}
     31
     32#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
     33
     34/* Common functions */
     35int aq_ptp_init(struct aq_nic_s *aq_nic, unsigned int idx_vec);
     36
     37void aq_ptp_unregister(struct aq_nic_s *aq_nic);
     38void aq_ptp_free(struct aq_nic_s *aq_nic);
     39
     40int aq_ptp_irq_alloc(struct aq_nic_s *aq_nic);
     41void aq_ptp_irq_free(struct aq_nic_s *aq_nic);
     42
     43int aq_ptp_ring_alloc(struct aq_nic_s *aq_nic);
     44void aq_ptp_ring_free(struct aq_nic_s *aq_nic);
     45
     46int aq_ptp_ring_init(struct aq_nic_s *aq_nic);
     47int aq_ptp_ring_start(struct aq_nic_s *aq_nic);
     48void aq_ptp_ring_stop(struct aq_nic_s *aq_nic);
     49void aq_ptp_ring_deinit(struct aq_nic_s *aq_nic);
     50
     51void aq_ptp_service_task(struct aq_nic_s *aq_nic);
     52
     53void aq_ptp_tm_offset_set(struct aq_nic_s *aq_nic, unsigned int mbps);
     54
     55void aq_ptp_clock_init(struct aq_nic_s *aq_nic);
     56
     57/* Traffic processing functions */
     58int aq_ptp_xmit(struct aq_nic_s *aq_nic, struct sk_buff *skb);
     59void aq_ptp_tx_hwtstamp(struct aq_nic_s *aq_nic, u64 timestamp);
     60
     61/* Must be to check available of PTP before call */
     62void aq_ptp_hwtstamp_config_get(struct aq_ptp_s *aq_ptp,
     63				struct hwtstamp_config *config);
     64int aq_ptp_hwtstamp_config_set(struct aq_ptp_s *aq_ptp,
     65			       struct hwtstamp_config *config);
     66
     67/* Return either ring is belong to PTP or not*/
     68bool aq_ptp_ring(struct aq_nic_s *aq_nic, struct aq_ring_s *ring);
     69
     70u16 aq_ptp_extract_ts(struct aq_nic_s *aq_nic, struct sk_buff *skb, u8 *p,
     71		      unsigned int len);
     72
     73struct ptp_clock *aq_ptp_get_ptp_clock(struct aq_ptp_s *aq_ptp);
     74
     75int aq_ptp_link_change(struct aq_nic_s *aq_nic);
     76
     77/* PTP ring statistics */
     78int aq_ptp_get_ring_cnt(struct aq_nic_s *aq_nic, const enum atl_ring_type ring_type);
     79u64 *aq_ptp_get_stats(struct aq_nic_s *aq_nic, u64 *data);
     80
     81#else
     82
     83static inline int aq_ptp_init(struct aq_nic_s *aq_nic, unsigned int idx_vec)
     84{
     85	return 0;
     86}
     87
     88static inline void aq_ptp_unregister(struct aq_nic_s *aq_nic) {}
     89
     90static inline void aq_ptp_free(struct aq_nic_s *aq_nic)
     91{
     92}
     93
     94static inline int aq_ptp_irq_alloc(struct aq_nic_s *aq_nic)
     95{
     96	return 0;
     97}
     98
     99static inline void aq_ptp_irq_free(struct aq_nic_s *aq_nic)
    100{
    101}
    102
    103static inline int aq_ptp_ring_alloc(struct aq_nic_s *aq_nic)
    104{
    105	return 0;
    106}
    107
    108static inline void aq_ptp_ring_free(struct aq_nic_s *aq_nic) {}
    109
    110static inline int aq_ptp_ring_init(struct aq_nic_s *aq_nic)
    111{
    112	return 0;
    113}
    114
    115static inline int aq_ptp_ring_start(struct aq_nic_s *aq_nic)
    116{
    117	return 0;
    118}
    119
    120static inline void aq_ptp_ring_stop(struct aq_nic_s *aq_nic) {}
    121static inline void aq_ptp_ring_deinit(struct aq_nic_s *aq_nic) {}
    122static inline void aq_ptp_service_task(struct aq_nic_s *aq_nic) {}
    123static inline void aq_ptp_tm_offset_set(struct aq_nic_s *aq_nic,
    124					unsigned int mbps) {}
    125static inline void aq_ptp_clock_init(struct aq_nic_s *aq_nic) {}
    126static inline int aq_ptp_xmit(struct aq_nic_s *aq_nic, struct sk_buff *skb)
    127{
    128	return -EOPNOTSUPP;
    129}
    130
    131static inline void aq_ptp_tx_hwtstamp(struct aq_nic_s *aq_nic, u64 timestamp) {}
    132static inline void aq_ptp_hwtstamp_config_get(struct aq_ptp_s *aq_ptp,
    133					      struct hwtstamp_config *config) {}
    134static inline int aq_ptp_hwtstamp_config_set(struct aq_ptp_s *aq_ptp,
    135					     struct hwtstamp_config *config)
    136{
    137	return 0;
    138}
    139
    140static inline bool aq_ptp_ring(struct aq_nic_s *aq_nic, struct aq_ring_s *ring)
    141{
    142	return false;
    143}
    144
    145static inline u16 aq_ptp_extract_ts(struct aq_nic_s *aq_nic,
    146				    struct sk_buff *skb, u8 *p,
    147				    unsigned int len)
    148{
    149	return 0;
    150}
    151
    152static inline struct ptp_clock *aq_ptp_get_ptp_clock(struct aq_ptp_s *aq_ptp)
    153{
    154	return NULL;
    155}
    156
    157static inline int aq_ptp_link_change(struct aq_nic_s *aq_nic)
    158{
    159	return 0;
    160}
    161#endif
    162
    163#endif /* AQ_PTP_H */