• 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 #define SIOCDEVPRIVATE_RTLASF   SIOCDEVPRIVATE
36 
37 #define FUNCTION_ENABLE		1
38 #define FUNCTION_DISABLE	0
39 
40 #define ASFCONFIG	0
41 #define ASFCAPABILITY	1
42 #define ASFCOMMULEN	0
43 #define ASFHBPERIOD	0
44 #define ASFWD16RST	0
45 #define ASFCAPMASK	0
46 #define ASFALERTRESND	0
47 #define ASFLSNRPOLLCYC	0
48 #define ASFSNRPOLLCYC	0
49 #define ASFWD8RESET	0
50 #define ASFRWHEXNUM	0
51 
52 #define FMW_CAP_MASK	0x0000F867
53 #define SPC_CMD_MASK	0x1F00
54 #define SYS_CAP_MASK	0xFF
55 #define DISABLE_MASK	0x00
56 
57 #define MAX_DATA_LEN	200
58 #define MAX_STR_LEN	200
59 
60 #define COMMU_STR_MAX_LEN	23
61 
62 #define KEY_LEN		20
63 #define UUID_LEN	16
64 #define SYSID_LEN	2
65 
66 #define RW_ONE_BYTE	1
67 #define RW_TWO_BYTES	2
68 #define RW_FOUR_BYTES	4
69 
70 enum asf_registers {
71         HBPeriod	= 0x0000,
72         WD8Rst		= 0x0002,
73         WD8Timer	= 0x0003,
74         WD16Rst		= 0x0004,
75         LSnsrPollCycle	= 0x0006,
76         ASFSnsrPollPrd	= 0x0007,
77         AlertReSendCnt	= 0x0008,
78         AlertReSendItvl	= 0x0009,
79         SMBAddr		= 0x000A,
80         SMBCap		= 0x000B,
81         ASFConfigR0	= 0x000C,
82         ASFConfigR1	= 0x000D,
83         WD16Timer	= 0x000E,
84         ConsoleMA	= 0x0010,
85         ConsoleIP	= 0x0016,
86         IPAddr		= 0x001A,
87 
88         UUID		= 0x0020,
89         IANA		= 0x0030,
90         SysID		= 0x0034,
91         Community	= 0x0036,
92         StringLength	= 0x004D,
93         LC		= 0x004E,
94         EntityInst	= 0x004F,
95         FmCapMsk	= 0x0050,
96         SpCMDMsk	= 0x0054,
97         SysCapMsk	= 0x0056,
98         WDSysSt		= 0x0057,
99         RxMsgType	= 0x0058,
100         RxSpCMD		= 0x0059,
101         RxSpCMDPa	= 0x005A,
102         RxBtOpMsk	= 0x005C,
103         RmtRstAddr	= 0x005E,
104         RmtRstCmd	= 0x005F,
105         RmtRstData	= 0x0060,
106         RmtPwrOffAddr	= 0x0061,
107         RmtPwrOffCmd	= 0x0062,
108         RmtPwrOffData	= 0x0063,
109         RmtPwrOnAddr	= 0x0064,
110         RmtPwrOnCmd	= 0x0065,
111         RmtPwrOnData	= 0x0066,
112         RmtPCRAddr	= 0x0067,
113         RmtPCRCmd	= 0x0068,
114         RmtPCRData	= 0x0069,
115         RMCP_IANA	= 0x006A,
116         RMCP_OEM	= 0x006E,
117         ASFSnsr0Addr	= 0x0070,
118 
119         ASFSnsrEvSt	= 0x0073,
120         ASFSnsrEvAlert	= 0x0081,
121 
122         LSnsrNo		= 0x00AD,
123         AssrtEvntMsk	= 0x00AE,
124         DeAssrtEvntMsk	= 0x00AF,
125 
126         LSnsrAddr0	= 0x00B0,
127         LAlertCMD0	= 0x00B1,
128         LAlertDataMsk0	= 0x00B2,
129         LAlertCmp0	= 0x00B3,
130         LAlertESnsrT0	= 0x00B4,
131         LAlertET0	= 0x00B5,
132         LAlertEOffset0	= 0x00B6,
133         LAlertES0	= 0x00B7,
134         LAlertSN0	= 0x00B8,
135         LAlertEntity0	= 0x00B9,
136         LAlertEI0	= 0x00BA,
137         LSnsrState0	= 0x00BB,
138 
139         LSnsrAddr1	= 0x00BD,
140         LAlertCMD1	= 0x00BE,
141         LAlertDataMsk1	= 0x00BF,
142         LAlertCmp1	= 0x00C0,
143         LAlertESnsrT1	= 0x00C1,
144         LAlertET1	= 0x00C2,
145         LAlertEOffset1	= 0x00C3,
146         LAlertES1	= 0x00C4,
147         LAlertSN1	= 0x00C5,
148         LAlertEntity1	= 0x00C6,
149         LAlertEI1	= 0x00C7,
150         LSnsrState1	= 0x00C8,
151 
152         LSnsrAddr2	= 0x00CA,
153         LAlertCMD2	= 0x00CB,
154         LAlertDataMsk2	= 0x00CC,
155         LAlertCmp2	= 0x00CD,
156         LAlertESnsrT2	= 0x00CE,
157         LAlertET2	= 0x00CF,
158         LAlertEOffset2	= 0x00D0,
159         LAlertES2	= 0x00D1,
160         LAlertSN2	= 0x00D2,
161         LAlertEntity2	= 0x00D3,
162         LAlertEI2	= 0x00D4,
163         LSnsrState2	= 0x00D5,
164 
165         LSnsrAddr3	= 0x00D7,
166         LAlertCMD3	= 0x00D8,
167         LAlertDataMsk3	= 0x00D9,
168         LAlertCmp3	= 0x00DA,
169         LAlertESnsrT3	= 0x00DB,
170         LAlertET3	= 0x00DC,
171         LAlertEOffset3	= 0x00DD,
172         LAlertES3	= 0x00DE,
173         LAlertSN3	= 0x00DF,
174         LAlertEntity3	= 0x00E0,
175         LAlertEI3	= 0x00E1,
176         LSnsrState3	= 0x00E2,
177 
178         LSnsrAddr4	= 0x00E4,
179         LAlertCMD4	= 0x00E5,
180         LAlertDataMsk4	= 0x00E6,
181         LAlertCmp4	= 0x00E7,
182         LAlertESnsrT4	= 0x00E8,
183         LAlertET4	= 0x00E9,
184         LAlertEOffset4	= 0x00EA,
185         LAlertES4	= 0x00EB,
186         LAlertSN4	= 0x00EC,
187         LAlertEntity4	= 0x00ED,
188         LAlertEI4	= 0x00EE,
189         LSnsrState4	= 0x00EF,
190 
191         LSnsrAddr5	= 0x00F1,
192         LAlertCMD5	= 0x00F2,
193         LAlertDataMsk5	= 0x00F3,
194         LAlertCmp5	= 0x00F4,
195         LAlertESnsrT5	= 0x00F5,
196         LAlertET5	= 0x00F6,
197         LAlertEOffset5	= 0x00F7,
198         LAlertES5	= 0x00F8,
199         LAlertSN5	= 0x00F9,
200         LAlertEntity5	= 0x00FA,
201         LAlertEI5	= 0x00FB,
202         LSnsrState5	= 0x00FC,
203 
204         LSnsrAddr6	= 0x00FE,
205         LAlertCMD6	= 0x00FF,
206         LAlertDataMsk6	= 0x0100,
207         LAlertCmp6	= 0x0101,
208         LAlertESnsrT6	= 0x0102,
209         LAlertET6	= 0x0103,
210         LAlertEOffset6	= 0x0104,
211         LAlertES6	= 0x0105,
212         LAlertSN6	= 0x0106,
213         LAlertEntity6	= 0x0107,
214         LAlertEI6	= 0x0108,
215         LSnsrState6	= 0x0109,
216 
217         LSnsrAddr7	= 0x010B,
218         LAlertCMD7	= 0x010C,
219         LAlertDataMsk7	= 0x010D,
220         LAlertCmp7	= 0x010E,
221         LAlertESnsrT7	= 0x010F,
222         LAlertET7	= 0x0110,
223         LAlertEOffset7	= 0x0111,
224         LAlertES7	= 0x0112,
225         LAlertSN7	= 0x0113,
226         LAlertEntity7	= 0x0114,
227         LAlertEI7	= 0x0115,
228         LSnsrState7	= 0x0116,
229         LAssert		= 0x0117,
230         LDAssert	= 0x0118,
231         IPServiceType	= 0x0119,
232         IPIdfr		= 0x011A,
233         FlagFOffset	= 0x011C,
234         TTL		= 0x011E,
235         HbtEI		= 0x011F,
236         MgtConSID1	= 0x0120,
237         MgtConSID2	= 0x0124,
238         MgdCltSID	= 0x0128,
239         StCd		= 0x012C,
240         MgtConUR	= 0x012D,
241         MgtConUNL	= 0x012E,
242 
243         AuthPd		= 0x0130,
244         IntyPd		= 0x0138,
245         MgtConRN	= 0x0140,
246         MgdCtlRN	= 0x0150,
247         MgtConUN	= 0x0160,
248         Rakp2IntCk	= 0x0170,
249         KO		= 0x017C,
250         KA		= 0x0190,
251         KG		= 0x01A4,
252         KR		= 0x01B8,
253         CP		= 0x01CC,
254         CQ		= 0x01D0,
255         KC		= 0x01D4,
256         ConsoleSid	= 0x01E8,
257 
258         SIK1		= 0x01FC,
259         SIK2		= 0x0210,
260         Udpsrc_port	= 0x0224,
261         Udpdes_port	= 0x0226,
262         Asf_debug_mux	= 0x0228
263 };
264 
265 enum asf_cmdln_opt {
266         ASF_GET,
267         ASF_SET,
268         ASF_HELP
269 };
270 
271 struct asf_ioctl_struct {
272         unsigned int arg;
273         unsigned int offset;
274         union {
275                 unsigned int data[MAX_DATA_LEN];
276                 char string[MAX_STR_LEN];
277         } u;
278 };
279 
280 int rtl8168_asf_ioctl(struct net_device *dev, struct ifreq *ifr);
281 void rtl8168_asf_hbperiod(struct rtl8168_private *tp, int arg, unsigned int *data);
282 void rtl8168_asf_wd16rst(struct rtl8168_private *tp, int arg, unsigned int *data);
283 void rtl8168_asf_console_mac(struct rtl8168_private *, int arg, unsigned int *data);
284 void rtl8168_asf_ip_address(struct rtl8168_private *, int arg, int offset, unsigned int *data);
285 void rtl8168_asf_config_regs(struct rtl8168_private *tp, int arg, int offset, unsigned int *data);
286 void rtl8168_asf_capability_masks(struct rtl8168_private *tp, int arg, int offset, unsigned int *data);
287 void rtl8168_asf_community_string(struct rtl8168_private *tp, int arg, char *string);
288 void rtl8168_asf_community_string_len(struct rtl8168_private *tp, int arg, unsigned int *data);
289 void rtl8168_asf_alert_resend_interval(struct rtl8168_private *tp, int arg, unsigned int *data);
290 void rtl8168_asf_time_period(struct rtl8168_private *tp, int arg, int offset, unsigned int *data);
291 void rtl8168_asf_key_access(struct rtl8168_private *, int arg, int offset, unsigned int *data);
292 void rtl8168_asf_rw_hexadecimal(struct rtl8168_private *tp, int arg, int offset, int len, unsigned int *data);
293 void rtl8168_asf_rw_iana(struct rtl8168_private *tp, int arg, unsigned int *data);
294 void rtl8168_asf_rw_uuid(struct rtl8168_private *tp, int arg, unsigned int *data);
295 void rtl8168_asf_rw_systemid(struct rtl8168_private *tp, int arg, unsigned int *data);
296