1a4569504SAtul Gupta /*
2a4569504SAtul Gupta  * This file is part of the Chelsio T4 Ethernet driver for Linux.
3a4569504SAtul Gupta  *
4a4569504SAtul Gupta  * Copyright (c) 2003-2017 Chelsio Communications, Inc. All rights reserved.
5a4569504SAtul Gupta  *
6a4569504SAtul Gupta  * This software is available to you under a choice of one of two
7a4569504SAtul Gupta  * licenses.  You may choose to be licensed under the terms of the GNU
8a4569504SAtul Gupta  * General Public License (GPL) Version 2, available from the file
9a4569504SAtul Gupta  * COPYING in the main directory of this source tree, or the
10a4569504SAtul Gupta  * OpenIB.org BSD license below:
11a4569504SAtul Gupta  *
12a4569504SAtul Gupta  *     Redistribution and use in source and binary forms, with or
13a4569504SAtul Gupta  *     without modification, are permitted provided that the following
14a4569504SAtul Gupta  *     conditions are met:
15a4569504SAtul Gupta  *
16a4569504SAtul Gupta  *      - Redistributions of source code must retain the above
17a4569504SAtul Gupta  *        copyright notice, this list of conditions and the following
18a4569504SAtul Gupta  *        disclaimer.
19a4569504SAtul Gupta  *
20a4569504SAtul Gupta  *      - Redistributions in binary form must reproduce the above
21a4569504SAtul Gupta  *        copyright notice, this list of conditions and the following
22a4569504SAtul Gupta  *        disclaimer in the documentation and/or other materials
23a4569504SAtul Gupta  *        provided with the distribution.
24a4569504SAtul Gupta  *
25a4569504SAtul Gupta  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26a4569504SAtul Gupta  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27a4569504SAtul Gupta  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28a4569504SAtul Gupta  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29a4569504SAtul Gupta  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30a4569504SAtul Gupta  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31a4569504SAtul Gupta  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32a4569504SAtul Gupta  * SOFTWARE.
33a4569504SAtul Gupta  */
34a4569504SAtul Gupta 
35a4569504SAtul Gupta #ifndef __CXGB4_PTP_H__
36a4569504SAtul Gupta #define __CXGB4_PTP_H__
37a4569504SAtul Gupta 
38a4569504SAtul Gupta /* Maximum parts-per-billion adjustment that is acceptable */
39a4569504SAtul Gupta #define MAX_PTP_FREQ_ADJ		1000000
40a4569504SAtul Gupta #define PTP_CLOCK_MAX_ADJTIME		10000000 /* 10 ms */
41a4569504SAtul Gupta 
42a4569504SAtul Gupta #define PTP_MIN_LENGTH			63
43a4569504SAtul Gupta #define PTP_IN_TRANSMIT_PACKET_MAXNUM	240
44a4569504SAtul Gupta #define PTP_EVENT_PORT			319
45a4569504SAtul Gupta 
46a4569504SAtul Gupta enum ptp_rx_filter_mode {
47a4569504SAtul Gupta 	PTP_TS_NONE = 0,
48a4569504SAtul Gupta 	PTP_TS_L2,
49a4569504SAtul Gupta 	PTP_TS_L4,
50a4569504SAtul Gupta 	PTP_TS_L2_L4
51a4569504SAtul Gupta };
52a4569504SAtul Gupta 
53a4569504SAtul Gupta struct port_info;
54a4569504SAtul Gupta 
cxgb4_xmit_with_hwtstamp(struct sk_buff * skb)55a4569504SAtul Gupta static inline bool cxgb4_xmit_with_hwtstamp(struct sk_buff *skb)
56a4569504SAtul Gupta {
57a4569504SAtul Gupta 	return skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP;
58a4569504SAtul Gupta }
59a4569504SAtul Gupta 
cxgb4_xmit_hwtstamp_pending(struct sk_buff * skb)60a4569504SAtul Gupta static inline void cxgb4_xmit_hwtstamp_pending(struct sk_buff *skb)
61a4569504SAtul Gupta {
62a4569504SAtul Gupta 	skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
63a4569504SAtul Gupta }
64a4569504SAtul Gupta 
65a4569504SAtul Gupta void cxgb4_ptp_init(struct adapter *adap);
66a4569504SAtul Gupta void cxgb4_ptp_stop(struct adapter *adap);
67a4569504SAtul Gupta bool cxgb4_ptp_is_ptp_tx(struct sk_buff *skb);
68a4569504SAtul Gupta bool cxgb4_ptp_is_ptp_rx(struct sk_buff *skb);
69a4569504SAtul Gupta int cxgb4_ptprx_timestamping(struct port_info *pi, u8 port, u16 mode);
70a4569504SAtul Gupta int cxgb4_ptp_redirect_rx_packet(struct adapter *adap, struct port_info *pi);
71a4569504SAtul Gupta int cxgb4_ptp_txtype(struct adapter *adap, u8 port_id);
72a4569504SAtul Gupta void cxgb4_ptp_read_hwstamp(struct adapter *adap, struct port_info *pi);
73a4569504SAtul Gupta bool is_ptp_enabled(struct sk_buff *skb, struct net_device *dev);
74a4569504SAtul Gupta #endif /* __CXGB4_PTP_H__ */
75