summaryrefstree
path: root/kernel/drivers/net/ethernet/aquantia/atlantic-fwd/atl_drviface.h
blob: d79640e3ec2d26b8dd8b6e4e0eeac0730d70ec53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
/* SPDX-License-Identifier: GPL-2.0-only */
/* Atlantic Network Driver
 *
 * Copyright (C) 2017 aQuantia Corporation
 * Copyright (C) 2019-2020 Marvell International Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef _ATL_DRVIFACE_H_
#define _ATL_DRVIFACE_H_

typedef uint16_t in_port_t;
typedef uint32_t in_addr_t;

struct __attribute__((packed)) offloadKAv4 {
    uint32_t timeout;
    in_port_t local_port;
    in_port_t remote_port;
    uint8_t remote_mac_addr[6];
    uint16_t win_size;
    uint32_t seq_num;
    uint32_t ack_num;
    in_addr_t local_ip;
    in_addr_t remote_ip;
};

struct __attribute__((packed)) offloadKAv6 {
    uint32_t timeout;
    in_port_t local_port;
    in_port_t remote_port;
    uint8_t remote_mac_addr[6];
    uint16_t win_size;
    uint32_t seq_num;
    uint32_t ack_num;
    struct in6_addr local_ip;
    struct in6_addr remote_ip;
};

struct __attribute__((packed)) offloadIPInfo {
    uint8_t v4LocalAddrCount;
    uint8_t v4AddrCount;
    uint8_t v6LocalAddrCount;
    uint8_t v6AddrCount;
    // FW will add the base to the following offset fields and will treat them as pointers.
    // The offsets are relative to the start of this struct so that the struct is pretty much self-contained
    // in_addr_t *
    uint32_t v4AddrOfft;
    // uint8_t *
    uint32_t v4PrefixOfft;
    // in6_addr *
    uint32_t v6AddrOfft;
    // uint8_t *
    uint32_t v6PrefixOfft;
};

struct __attribute__((packed)) offloadPortInfo {
    uint16_t UDPPortCount;
    uint16_t TCPPortCount;
    // in_port_t *
    uint32_t UDPPortOfft;       // See the comment in the offloadIPInfo struct
                                // in_port_t *
    uint32_t TCPPortOfft;
};

struct __attribute__((packed))  offloadKAInfo {
    uint16_t v4KACount;
    uint16_t v6KACount;
    uint32_t retryCount;
    uint32_t retryInterval;
    // struct offloadKAv4 *
    uint32_t v4KAOfft;          // See the comment in the offloadIPInfo struct
                                // struct offloadKAv6 *
    uint32_t v6KAOfft;
};

struct  __attribute__((packed)) offloadRRInfo {
    uint32_t RRCount;
    uint32_t RRBufLen;
    // Offset to RR index table relative to the start of offloadRRInfo struct. The indices
    // themselves are relative to the start of RR buffer. FW will add the buffer address
    // and will treat them as pointers.
    // uint8_t **
    uint32_t RRIdxOfft;
    // Offset to the RR buffer relative to the start of offloadRRInfo struct.
    // uint8_t *
    uint32_t RRBufOfft;
};

struct __attribute__((packed)) offloadInfo {
    uint32_t version;               // = 0 till it stabilizes some
    uint32_t len;                   // The whole structure length including the variable-size buf
    uint8_t macAddr[8];
    struct offloadIPInfo ips;
    struct offloadPortInfo ports;
    struct offloadKAInfo kas;
    struct offloadRRInfo rrs;
    uint8_t buf[0];
};

#define FW_PACK_STRUCT __attribute__((packed))

#define DRV_REQUEST_SIZE 3072
#define DRV_MSG_PING            0x01
#define DRV_MSG_ARP             0x02
#define DRV_MSG_INJECT          0x03
#define DRV_MSG_WOL_ADD         0x04
#define DRV_MSG_WOL_REMOVE      0x05
#define DRV_MSG_ENABLE_WAKEUP   0x06
#define DRV_MSG_MSM             0x07
#define DRV_MSG_PROVISIONING    0x08
#define DRV_MSG_OFFLOAD_ADD     0x09
#define DRV_MSG_OFFLOAD_REMOVE 	0x0A
#define DRV_MSG_MSM_EX          0x0B
#define DRV_MSG_SMBUS_PROXY     0x0C

#define DRV_PROV_APPLY         1
#define DRV_PROV_REPLACE       2
#define DRV_PROV_ADD           3

#define FW_RPC_INJECT_PACKET_LEN 1514U

typedef enum {
    EVENT_DRIVER_ENABLE_WOL
} eDriverEvent;

//typedef enum {
//    HOST_UNINIT = 0,
//    HOST_RESET,
//    HOST_INIT,
//    HOST_RESERVED,
//    HOST_SLEEP,
//    HOST_INVALID
//} hostState_t;

struct drvMsgPing {
    uint32_t ping;
} FW_PACK_STRUCT;

union IPAddr {
    struct
    {
        uint8_t addr[16];
    } FW_PACK_STRUCT v6;
    struct
    {
        uint8_t padding[12];
        uint8_t addr[4];
    } FW_PACK_STRUCT v4;
} FW_PACK_STRUCT;

struct drvMsgArp {
    uint8_t macAddr[6];
    uint32_t uIpAddrCnt;
    struct
    {
        union IPAddr addr;
        union IPAddr mask;
    } FW_PACK_STRUCT ip[1];
} FW_PACK_STRUCT;

struct drvMsgInject {
    uint32_t len;
    uint8_t packet[FW_RPC_INJECT_PACKET_LEN];
} FW_PACK_STRUCT;

enum ndisPmWoLPacket {
    ndisPMWoLPacketUnspecified = 0,
    ndisPMWoLPacketBitmapPattern,
    ndisPMWoLPacketMagicPacket,
    ndisPMWoLPacketIPv4TcpSyn,
    ndisPMWoLPacketIPv6TcpSyn,
    ndisPMWoLPacketEapolRequestIdMessage,
    ndisPMWoLPacketMaximum
};

enum aqPmWoLPacket {
    aqPMWoLPacketUnspecified = 0x10000,
    aqPMWoLPacketArp,
    aqPMWoLPacketIPv4Ping,
    aqPMWoLPacketIpv6NsPacket,
    aqPMWoLPacketIpv6Ping,
    aqPMWoLReasonLinkUp,
    aqPMWoLReasonLinkDown,
    aqPMWoLPacketMaximum
};

enum ndisPmProtocolOffloadType {
    ndisPMProtocolOffloadIdUnspecified,
    ndisPMProtocolOffloadIdIPv4ARP,
    ndisPMProtocolOffloadIdIPv6NS,
    ndisPMProtocolOffload80211RSNRekey,
    ndisPMProtocolOffloadIdMaximum
};

struct drvMsgEnableWakeup {
    uint32_t patternMaskWindows;
    uint32_t patternMaskAquantia;
    uint32_t patternMaskOther;
    uint32_t offloadsMaskWindows;
    uint32_t offloadsMaskAquantia;
} FW_PACK_STRUCT;

struct drvMsgWoLAddIpv4TcpSynWoLPacketParameters {
    uint32_t flags;
    union {
        uint8_t v8[4];
        uint32_t v32;
    } IPv4SourceAddress;
    union {
        uint8_t v8[4];
        uint32_t v32;
    } IPv4DestAddress;
    union {
        uint8_t v8[2];
        uint16_t v16;
    } TCPSourcePortNumber;
    union {
        uint8_t v8[2];
        uint16_t v16;
    } TCPDestPortNumber;
} FW_PACK_STRUCT;

struct drvMsgWoLAddIpv6TcpSynWoLPacketParameters {
    uint32_t flags;
    union {
        uint8_t v8[16];
        uint32_t v32[4];
    } IPv6SourceAddress;
    union {
        uint8_t v8[16];
        uint32_t v32[4];
    } IPv6DestAddress;
    union {
        uint8_t v8[2];
        uint16_t v16;
    } TCPSourcePortNumber;
    union {
        uint8_t v8[2];
        uint16_t v16;
    } TCPDestPortNumber;
} FW_PACK_STRUCT;

struct drvMsgWoLAddIpv4PingWoLPacketParameters {
    uint32_t flags;
    union {
        uint8_t v8[4];
        uint32_t v32;
    } IPv4SourceAddress;
    union {
        uint8_t v8[4];
        uint32_t v32;
    } IPv4DestAddress;
} FW_PACK_STRUCT;

struct drvMsgWoLAddIpv6PingWoLPacketParameters {
    uint32_t flags;
    union {
        uint8_t v8[16];
        uint32_t v32[4];
    } IPv6SourceAddress;
    union {
        uint8_t v8[16];
        uint32_t v32[4];
    } IPv6DestAddress;
} FW_PACK_STRUCT;

struct drvMsgWoLAddEapolRequestIdMessageWoLPacketParameters {
    uint32_t flags;
    union {
        uint8_t v8[4];
        uint32_t v32;
    } IPv4SourceAddress;
    union {
        uint8_t v8[4];
        uint32_t v32;
    } IPv4DestAddress;
} FW_PACK_STRUCT;

struct drvMsgWoLAddBitmapPattern {
    uint32_t Flags;
    uint32_t MaskOffset;
    uint32_t MaskSize;
    uint32_t PatternOffset;
    uint32_t PatternSize;
} FW_PACK_STRUCT;

struct drvMsgWoLAddMagicPacketPattern {
    uint8_t macAddr[6];
} FW_PACK_STRUCT;

struct drvMsgWoLAddArpWoLPacketParameters {
    uint32_t flags;
    union {
        uint8_t v8[4];
        uint32_t v32;
    } IPv4Address;
} FW_PACK_STRUCT;

struct drvMsgWoLAddLinkUpWoLParameters {
    uint32_t timeout;
} FW_PACK_STRUCT;

struct drvMsgWoLAddLinkDownWoLParameters {
    uint32_t timeout;
} FW_PACK_STRUCT;

struct drvMsgWoLAdd {
    uint32_t priority; // Currently not used
    uint32_t packetType; // One of ndisPmWoLPacket or aqPmWoLPacket
    uint32_t patternId; // Id to save - will be used in remove message
    uint32_t nextWoLPatternOffset; // For chaining multiple additions in one request

    // Depends on `parrernId`
    union _WOL_PATTERN {
        struct drvMsgWoLAddIpv4TcpSynWoLPacketParameters wolIpv4TcpSyn;
        struct drvMsgWoLAddIpv6TcpSynWoLPacketParameters wolIpv6TcpSyn;
        struct drvMsgWoLAddEapolRequestIdMessageWoLPacketParameters wolEapolRequestIdMessage;
        struct drvMsgWoLAddBitmapPattern wolBitmap;
        struct drvMsgWoLAddMagicPacketPattern wolMagicPacket;
        struct drvMsgWoLAddIpv4PingWoLPacketParameters wolIpv4Ping;
        struct drvMsgWoLAddIpv6PingWoLPacketParameters wolIpv6Ping;
        struct drvMsgWoLAddArpWoLPacketParameters wolArp;
        struct drvMsgWoLAddLinkUpWoLParameters wolLinkUpReason;
        struct drvMsgWoLAddLinkDownWoLParameters wolLinkDownReason;
    } wolPattern;
} FW_PACK_STRUCT;

struct drvMsgWoLRemove {
    uint32_t id;
} FW_PACK_STRUCT;

struct ipv4ArpParameters {
    uint32_t flags;
    uint8_t remoteIPv4Address[4];
    uint8_t hostIPv4Address[4];
    uint8_t macAddress[6];
} FW_PACK_STRUCT;

struct ipv6NsParameters {
    uint32_t flags;
    union {
        uint8_t v8[16];
        uint32_t v32[4];
    } remoteIPv6Address;
    union {
        uint8_t v8[16];
        uint32_t v32[4];
    } solicitedNodeIPv6Address;
    union {
        uint8_t v8[16];
        uint32_t v32[4];
    } targetIPv6Addresses[2];
    uint8_t macAddress[6];
} FW_PACK_STRUCT;

struct drvMsgOffloadAdd {
    uint32_t priority;
    uint32_t protocolOffloadType;
    uint32_t protocolOffloadId;
    uint32_t nextProtocolOffloadOffset;
    union {
        struct ipv4ArpParameters ipv4Arp;
        struct ipv6NsParameters ipv6Ns;
    } wolOffload;
} FW_PACK_STRUCT;

struct drvMsgOffloadRemove {
    uint32_t id;
} FW_PACK_STRUCT;

struct drvMsmSettings {
    uint32_t msmReg054;
    uint32_t msmReg058;
    uint32_t msmReg05c;
    uint32_t msmReg060;
    uint32_t msmReg064;
    uint32_t msmReg068;
    uint32_t msmReg06c;
    uint32_t msmReg070;
    uint32_t flags;     // Valid for message DRV_MSG_MSM_EX only
} FW_PACK_STRUCT;

//struct drvMsgProvisioning {
//    uint32_t command;
//    uint32_t len;
//    provList_t list;
//} FW_PACK_STRUCT;

//struct drvMsgSmbusProxy {
//    uint32_t typeMsg;
//    union {
//        struct smbusProxyWrite smbWrite;
//        struct smbusProxyRead smbRead;
//        struct smbusProxyGetStatus smbStatus;
//        struct smbusProxyReadResp smbReadResp;
//    } FW_PACK_STRUCT;
//} FW_PACK_STRUCT;

struct drvIface {
    uint32_t msgId;

    union {
        struct drvMsgPing msgPing;
        struct drvMsgArp msgArp;
        struct drvMsgInject msgInject;
        struct drvMsgWoLAdd msgWoLAdd;
        struct drvMsgWoLRemove msgWoLRemove;
        struct drvMsgEnableWakeup msgEnableWakeup;
        struct drvMsmSettings msgMsm;
//        struct drvMsgProvisioning msgProvisioning;
        struct drvMsgOffloadAdd msgOffloadAdd;
        struct drvMsgOffloadRemove msgOffloadRemove;
//        struct drvMsgSmbusProxy msgSmbusProxy;
        struct offloadInfo fw2xOffloads;
    } FW_PACK_STRUCT;
} FW_PACK_STRUCT;

#endif