xref: /wlan-driver/fw-api/fw/enet.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2012-2014, 2017, 2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  *
4*5113495bSYour Name  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5*5113495bSYour Name  *
6*5113495bSYour Name  *
7*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
8*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
9*5113495bSYour Name  * above copyright notice and this permission notice appear in all
10*5113495bSYour Name  * copies.
11*5113495bSYour Name  *
12*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
20*5113495bSYour Name  */
21*5113495bSYour Name 
22*5113495bSYour Name /*
23*5113495bSYour Name  * This file was originally distributed by Qualcomm Atheros, Inc.
24*5113495bSYour Name  * under proprietary terms before Copyright ownership was assigned
25*5113495bSYour Name  * to the Linux Foundation.
26*5113495bSYour Name  */
27*5113495bSYour Name 
28*5113495bSYour Name #ifndef _ENET__H_
29*5113495bSYour Name #define _ENET__H_
30*5113495bSYour Name 
31*5113495bSYour Name #if defined(ATH_TARGET)
32*5113495bSYour Name #include <osapi.h>   /* A_UINT8 */
33*5113495bSYour Name #else
34*5113495bSYour Name #include <a_types.h> /* A_UINT8 */
35*5113495bSYour Name #endif
36*5113495bSYour Name 
37*5113495bSYour Name 
38*5113495bSYour Name #define ETHERNET_ADDR_LEN 6 /* bytes */
39*5113495bSYour Name #define ETHERNET_TYPE_LEN 2 /* bytes - length of the Ethernet type field */
40*5113495bSYour Name 
41*5113495bSYour Name struct ethernet_hdr_t {
42*5113495bSYour Name     A_UINT8 dest_addr[ETHERNET_ADDR_LEN];
43*5113495bSYour Name     A_UINT8 src_addr[ETHERNET_ADDR_LEN];
44*5113495bSYour Name     A_UINT8 ethertype[ETHERNET_TYPE_LEN];
45*5113495bSYour Name };
46*5113495bSYour Name 
47*5113495bSYour Name #define ETHERNET_HDR_LEN (sizeof(struct ethernet_hdr_t))
48*5113495bSYour Name 
49*5113495bSYour Name #define ETHERNET_CRC_LEN  4     /* bytes - length of the Ethernet CRC */
50*5113495bSYour Name #define ETHERNET_MAX_LEN  1518  /* bytes */
51*5113495bSYour Name 
52*5113495bSYour Name #define ETHERNET_MTU (ETHERNET_MAX_LEN - (ETHERNET_HDR_LEN + ETHERNET_CRC_LEN))
53*5113495bSYour Name 
54*5113495bSYour Name 
55*5113495bSYour Name typedef struct llc_snap_hdr_t {
56*5113495bSYour Name     A_UINT8 dsap;
57*5113495bSYour Name     A_UINT8 ssap;
58*5113495bSYour Name     A_UINT8 cntl;
59*5113495bSYour Name     A_UINT8 org_code[3];
60*5113495bSYour Name     A_UINT8 ethertype[2];
61*5113495bSYour Name } LLC_SNAP_HDR;
62*5113495bSYour Name 
63*5113495bSYour Name #define LLC_SNAP_HDR_LEN (sizeof(struct llc_snap_hdr_t))
64*5113495bSYour Name #define LLC_SNAP_HDR_OFFSET_ETHERTYPE \
65*5113495bSYour Name     (offsetof(struct llc_snap_hdr_t, ethertype[0]))
66*5113495bSYour Name 
67*5113495bSYour Name #define ETHERTYPE_VLAN_LEN  4
68*5113495bSYour Name 
69*5113495bSYour Name struct ethernet_vlan_hdr_t {
70*5113495bSYour Name     A_UINT8 dest_addr[ETHERNET_ADDR_LEN];
71*5113495bSYour Name     A_UINT8 src_addr[ETHERNET_ADDR_LEN];
72*5113495bSYour Name     A_UINT8 vlan_tpid[2];
73*5113495bSYour Name     A_UINT8 vlan_tci[2];
74*5113495bSYour Name     A_UINT8 ethertype[2];
75*5113495bSYour Name };
76*5113495bSYour Name 
77*5113495bSYour Name typedef PREPACK struct _wai_hdr {
78*5113495bSYour Name     A_UINT8 version[2];
79*5113495bSYour Name     A_UINT8 type;
80*5113495bSYour Name     A_UINT8 stype;
81*5113495bSYour Name     A_UINT8 reserve[2];
82*5113495bSYour Name     A_UINT8 length[2];
83*5113495bSYour Name     A_UINT8 rxseq[2];
84*5113495bSYour Name     A_UINT8 frag_sc;
85*5113495bSYour Name     A_UINT8 more_frag;
86*5113495bSYour Name     /* followed octets of data */
87*5113495bSYour Name } POSTPACK wai_hdr;
88*5113495bSYour Name 
89*5113495bSYour Name typedef PREPACK struct {
90*5113495bSYour Name     A_UINT16 vlan_tci;
91*5113495bSYour Name     A_UINT16 vlan_encap_p;
92*5113495bSYour Name } POSTPACK vlan_hdr_t;
93*5113495bSYour Name 
94*5113495bSYour Name #define ETHERTYPE_IS_EAPOL_WAPI(typeorlen)           \
95*5113495bSYour Name 			((typeorlen) == ETHERTYPE_PAE ||  \
96*5113495bSYour Name 			(typeorlen) == ETHERTYPE_WAI)
97*5113495bSYour Name 
98*5113495bSYour Name #define IS_ETHERTYPE(_typeOrLen) ((_typeOrLen) >= 0x0600)
99*5113495bSYour Name 
100*5113495bSYour Name #ifndef ETHERTYPE_IPV4
101*5113495bSYour Name #define ETHERTYPE_IPV4  0x0800 /* Internet Protocol, Version 4 (IPv4) */
102*5113495bSYour Name #endif
103*5113495bSYour Name 
104*5113495bSYour Name #ifndef ETHERTYPE_AARP
105*5113495bSYour Name #define	ETHERTYPE_AARP	0x80f3		/* Internal QCA AARP protocol */
106*5113495bSYour Name #endif
107*5113495bSYour Name 
108*5113495bSYour Name #ifndef ETHERTYPE_IPX
109*5113495bSYour Name #define ETHERTYPE_IPX    0x8137    /* IPX over DIX protocol */
110*5113495bSYour Name #endif
111*5113495bSYour Name 
112*5113495bSYour Name #ifndef ETHERTYPE_ARP
113*5113495bSYour Name #define ETHERTYPE_ARP   0x0806 /* Address Resolution Protocol (ARP) */
114*5113495bSYour Name #endif
115*5113495bSYour Name 
116*5113495bSYour Name #ifndef ETHERTYPE_RARP
117*5113495bSYour Name #define ETHERTYPE_RARP  0x8035 /* Reverse Address Resolution Protocol (RARP) */
118*5113495bSYour Name #endif
119*5113495bSYour Name 
120*5113495bSYour Name #ifndef ETHERTYPE_VLAN
121*5113495bSYour Name #define ETHERTYPE_VLAN  0x8100 /* VLAN TAG protocol */
122*5113495bSYour Name #endif
123*5113495bSYour Name 
124*5113495bSYour Name #ifndef ETHERTYPE_SNMP
125*5113495bSYour Name #define ETHERTYPE_SNMP  0x814C /* Simple Network Management Protocol (SNMP) */
126*5113495bSYour Name #endif
127*5113495bSYour Name 
128*5113495bSYour Name #ifndef ETHERTYPE_IPV6
129*5113495bSYour Name #define ETHERTYPE_IPV6  0x86DD /* Internet Protocol, Version 6 (IPv6) */
130*5113495bSYour Name #endif
131*5113495bSYour Name 
132*5113495bSYour Name #ifndef ETHERTYPE_PAE
133*5113495bSYour Name #define ETHERTYPE_PAE   0x888E /* EAP over LAN (EAPOL) */
134*5113495bSYour Name #endif
135*5113495bSYour Name 
136*5113495bSYour Name #ifndef ETHERTYPE_WAI
137*5113495bSYour Name #define ETHERTYPE_WAI   0x88B4 /* WAPI */
138*5113495bSYour Name #endif
139*5113495bSYour Name 
140*5113495bSYour Name #ifndef ETHERTYPE_TDLS
141*5113495bSYour Name #define ETHERTYPE_TDLS  0x890D /* TDLS */
142*5113495bSYour Name #endif
143*5113495bSYour Name 
144*5113495bSYour Name #define LLC_SNAP_LSAP 0xaa
145*5113495bSYour Name #define LLC_UI 0x3
146*5113495bSYour Name 
147*5113495bSYour Name #define RFC1042_SNAP_ORGCODE_0 0x00
148*5113495bSYour Name #define RFC1042_SNAP_ORGCODE_1 0x00
149*5113495bSYour Name #define RFC1042_SNAP_ORGCODE_2 0x00
150*5113495bSYour Name 
151*5113495bSYour Name #define BTEP_SNAP_ORGCODE_0 0x00
152*5113495bSYour Name #define BTEP_SNAP_ORGCODE_1 0x00
153*5113495bSYour Name #define BTEP_SNAP_ORGCODE_2 0xf8
154*5113495bSYour Name 
155*5113495bSYour Name 
156*5113495bSYour Name #define WAI_FRAME_TYPE 0X01
157*5113495bSYour Name #define WAPI_M4_TYPE 0x0c
158*5113495bSYour Name #define WAPI_M2_TYPE 0x09
159*5113495bSYour Name 
160*5113495bSYour Name 
161*5113495bSYour Name #define ICMP_PROTOCOL   1
162*5113495bSYour Name #define TCP_PROTOCOL    6
163*5113495bSYour Name #define UDP_PROTOCOL    17
164*5113495bSYour Name #define IGMP_PROTOCOL   2
165*5113495bSYour Name #define ICMPV6_PROTOCOL 58
166*5113495bSYour Name #define BOOTP_SERVER_PORT 67
167*5113495bSYour Name #define BOOTP_CLIENT_PORT 68
168*5113495bSYour Name #define MLD_QUERY 130
169*5113495bSYour Name #define MLD_DONE  132
170*5113495bSYour Name 
171*5113495bSYour Name 
172*5113495bSYour Name #define IS_EAPOL(typeorlen) \
173*5113495bSYour Name     ((typeorlen) == ETHERTYPE_PAE || \
174*5113495bSYour Name      (typeorlen) == ETHERTYPE_WAI)
175*5113495bSYour Name 
176*5113495bSYour Name #define IS_SNAP(_llc) \
177*5113495bSYour Name     ((_llc)->dsap == LLC_SNAP_LSAP && \
178*5113495bSYour Name      (_llc)->ssap == LLC_SNAP_LSAP && \
179*5113495bSYour Name      (_llc)->cntl == LLC_UI)
180*5113495bSYour Name 
181*5113495bSYour Name #define IS_RFC1042(_llc) \
182*5113495bSYour Name     ((_llc)->org_code[0] == RFC1042_SNAP_ORGCODE_0 && \
183*5113495bSYour Name      (_llc)->org_code[1] == RFC1042_SNAP_ORGCODE_1 && \
184*5113495bSYour Name      (_llc)->org_code[2] == RFC1042_SNAP_ORGCODE_2)
185*5113495bSYour Name 
186*5113495bSYour Name #define IS_BTEP(_llc) \
187*5113495bSYour Name     ((_llc)->org_code[0] == BTEP_SNAP_ORGCODE_0 && \
188*5113495bSYour Name      (_llc)->org_code[1] == BTEP_SNAP_ORGCODE_1 && \
189*5113495bSYour Name      (_llc)->org_code[2] == BTEP_SNAP_ORGCODE_2)
190*5113495bSYour Name 
191*5113495bSYour Name #define IS_MULTICAST(_hdr) (*(A_UINT8 *)(_hdr) & 0x1)
192*5113495bSYour Name #define IS_BROADCAST(_hdr) \
193*5113495bSYour Name     ((*((A_UINT8 *)(_hdr) + 0) == 0xff) && \
194*5113495bSYour Name      (*((A_UINT8 *)(_hdr) + 1) == 0xff) && \
195*5113495bSYour Name      (*((A_UINT8 *)(_hdr) + 2) == 0xff) && \
196*5113495bSYour Name      (*((A_UINT8 *)(_hdr) + 3) == 0xff) && \
197*5113495bSYour Name      (*((A_UINT8 *)(_hdr) + 4) == 0xff) && \
198*5113495bSYour Name      (*((A_UINT8 *)(_hdr) + 5) == 0xff))
199*5113495bSYour Name 
200*5113495bSYour Name 
201*5113495bSYour Name #endif /* _ENET__H_ */
202