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