• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 ################################################################################
4 #
5 # r8168 is the Linux device driver released for Realtek Gigabit Ethernet
6 # controllers with PCI-Express interface.
7 #
8 # Copyright(c) 2021 Realtek Semiconductor Corp. All rights reserved.
9 #
10 # This program is free software; you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License as published by the Free
12 # Software Foundation; either version 2 of the License, or (at your option)
13 # any later version.
14 #
15 # This program is distributed in the hope that it will be useful, but WITHOUT
16 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
18 # more details.
19 #
20 # You should have received a copy of the GNU General Public License along with
21 # this program; if not, see <http://www.gnu.org/licenses/>.
22 #
23 # Author:
24 # Realtek NIC software team <nicfae@realtek.com>
25 # No. 2, Innovation Road II, Hsinchu Science Park, Hsinchu 300, Taiwan
26 #
27 ################################################################################
28 */
29 
30 /************************************************************************************
31  *  This product is covered by one or more of the following patents:
32  *  US6,570,884, US6,115,776, and US6,327,625.
33  ***********************************************************************************/
34 
35 #ifndef _LINUX_R8168_REALWOW_H
36 #define _LINUX_R8168_REALWOW_H
37 
38 #define SIOCDEVPRIVATE_RTLREALWOW   SIOCDEVPRIVATE+3
39 
40 #define MAX_RealWoW_KCP_SIZE (100)
41 #define MAX_RealWoW_Payload (64)
42 
43 #define KA_TX_PACKET_SIZE (100)
44 #define KA_WAKEUP_PATTERN_SIZE (120)
45 
46 //HwSuppKeepAliveOffloadVer
47 #define HW_SUPPORT_KCP_OFFLOAD(_M)        ((_M)->HwSuppKCPOffloadVer > 0)
48 
49 enum rtl_realwow_cmd {
50 
51         RTL_REALWOW_SET_KCP_DISABLE=0,
52         RTL_REALWOW_SET_KCP_INFO,
53         RTL_REALWOW_SET_KCP_CONTENT,
54 
55         RTL_REALWOW_SET_KCP_ACKPKTINFO,
56         RTL_REALWOW_SET_KCP_WPINFO,
57         RTL_REALWOW_SET_KCPDHCP_TIMEOUT,
58 
59         RTLT_REALWOW_COMMAND_INVALID
60 };
61 
62 struct rtl_realwow_ioctl_struct {
63         __u32	cmd;
64         __u32	offset;
65         __u32	len;
66         union {
67                 __u32	data;
68                 void *data_buffer;
69         };
70 };
71 
72 typedef struct _MP_KCPInfo {
73         u8 DIPv4[4];
74         u8 MacID[6];
75         u16 UdpPort[2];
76         u8 PKTLEN[2];
77 
78         u16 ackLostCnt;
79         u8 KCP_WakePattern[MAX_RealWoW_Payload];
80         u8 KCP_AckPacket[MAX_RealWoW_Payload];
81         u32 KCP_interval;
82         u8 KCP_WakePattern_Len;
83         u8 KCP_AckPacket_Len;
84         u8 KCP_TxPacket[2][KA_TX_PACKET_SIZE];
85 } MP_KCP_INFO, *PMP_KCP_INFO;
86 
87 typedef struct _KCPInfo {
88         u32 nId; // = id
89         u8 DIPv4[4];
90         u8 MacID[6];
91         u16 UdpPort;
92         u16 PKTLEN;
93 } KCPInfo, *PKCPInfo;
94 
95 typedef struct _KCPContent {
96         u32 id; // = id
97         u32 mSec; // = msec
98         u32 size; // =size
99         u8 bPacket[MAX_RealWoW_KCP_SIZE]; // put packet here
100 } KCPContent, *PKCPContent;
101 
102 typedef struct _RealWoWAckPktInfo {
103         u16 ackLostCnt;
104         u16 patterntSize;
105         u8 pattern[MAX_RealWoW_Payload];
106 } RealWoWAckPktInfo,*PRealWoWAckPktInfo;
107 
108 typedef struct _RealWoWWPInfo {
109         u16 patterntSize;
110         u8 pattern[MAX_RealWoW_Payload];
111 } RealWoWWPInfo,*PRealWoWWPInfo;
112 
113 int rtl8168_realwow_ioctl(struct net_device *dev, struct ifreq *ifr);
114 void rtl8168_realwow_hw_init(struct net_device *dev);
115 void rtl8168_get_realwow_hw_version(struct net_device *dev);
116 void rtl8168_set_realwow_d3_para(struct net_device *dev);
117 
118 #endif /* _LINUX_R8168_REALWOW_H */
119