xref: /freebsd/sys/dev/e1000/e1000_base.h (revision 71625ec9ad2a9bc8c09784fbd23b759830e0ee5f)
1*6b9d35faSGuinan Sun /******************************************************************************
2*6b9d35faSGuinan Sun   SPDX-License-Identifier: BSD-3-Clause
3*6b9d35faSGuinan Sun 
4*6b9d35faSGuinan Sun   Copyright (c) 2001-2020, Intel Corporation
5*6b9d35faSGuinan Sun   All rights reserved.
6*6b9d35faSGuinan Sun 
7*6b9d35faSGuinan Sun   Redistribution and use in source and binary forms, with or without
8*6b9d35faSGuinan Sun   modification, are permitted provided that the following conditions are met:
9*6b9d35faSGuinan Sun 
10*6b9d35faSGuinan Sun    1. Redistributions of source code must retain the above copyright notice,
11*6b9d35faSGuinan Sun       this list of conditions and the following disclaimer.
12*6b9d35faSGuinan Sun 
13*6b9d35faSGuinan Sun    2. Redistributions in binary form must reproduce the above copyright
14*6b9d35faSGuinan Sun       notice, this list of conditions and the following disclaimer in the
15*6b9d35faSGuinan Sun       documentation and/or other materials provided with the distribution.
16*6b9d35faSGuinan Sun 
17*6b9d35faSGuinan Sun    3. Neither the name of the Intel Corporation nor the names of its
18*6b9d35faSGuinan Sun       contributors may be used to endorse or promote products derived from
19*6b9d35faSGuinan Sun       this software without specific prior written permission.
20*6b9d35faSGuinan Sun 
21*6b9d35faSGuinan Sun   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22*6b9d35faSGuinan Sun   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23*6b9d35faSGuinan Sun   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24*6b9d35faSGuinan Sun   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25*6b9d35faSGuinan Sun   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26*6b9d35faSGuinan Sun   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27*6b9d35faSGuinan Sun   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28*6b9d35faSGuinan Sun   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29*6b9d35faSGuinan Sun   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30*6b9d35faSGuinan Sun   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31*6b9d35faSGuinan Sun   POSSIBILITY OF SUCH DAMAGE.
32*6b9d35faSGuinan Sun 
33*6b9d35faSGuinan Sun ******************************************************************************/
34*6b9d35faSGuinan Sun 
35*6b9d35faSGuinan Sun #ifndef _E1000_BASE_H_
36*6b9d35faSGuinan Sun #define _E1000_BASE_H_
37*6b9d35faSGuinan Sun 
38*6b9d35faSGuinan Sun /* forward declaration */
39*6b9d35faSGuinan Sun s32 e1000_init_hw_base(struct e1000_hw *hw);
40*6b9d35faSGuinan Sun void e1000_power_down_phy_copper_base(struct e1000_hw *hw);
41*6b9d35faSGuinan Sun extern void e1000_rx_fifo_flush_base(struct e1000_hw *hw);
42*6b9d35faSGuinan Sun s32 e1000_acquire_phy_base(struct e1000_hw *hw);
43*6b9d35faSGuinan Sun void e1000_release_phy_base(struct e1000_hw *hw);
44*6b9d35faSGuinan Sun 
45*6b9d35faSGuinan Sun /* Transmit Descriptor - Advanced */
46*6b9d35faSGuinan Sun union e1000_adv_tx_desc {
47*6b9d35faSGuinan Sun 	struct {
48*6b9d35faSGuinan Sun 		__le64 buffer_addr;    /* Address of descriptor's data buf */
49*6b9d35faSGuinan Sun 		__le32 cmd_type_len;
50*6b9d35faSGuinan Sun 		__le32 olinfo_status;
51*6b9d35faSGuinan Sun 	} read;
52*6b9d35faSGuinan Sun 	struct {
53*6b9d35faSGuinan Sun 		__le64 rsvd;       /* Reserved */
54*6b9d35faSGuinan Sun 		__le32 nxtseq_seed;
55*6b9d35faSGuinan Sun 		__le32 status;
56*6b9d35faSGuinan Sun 	} wb;
57*6b9d35faSGuinan Sun };
58*6b9d35faSGuinan Sun 
59*6b9d35faSGuinan Sun /* Context descriptors */
60*6b9d35faSGuinan Sun struct e1000_adv_tx_context_desc {
61*6b9d35faSGuinan Sun 	__le32 vlan_macip_lens;
62*6b9d35faSGuinan Sun 	union {
63*6b9d35faSGuinan Sun 		__le32 launch_time;
64*6b9d35faSGuinan Sun 		__le32 seqnum_seed;
65*6b9d35faSGuinan Sun 	} u;
66*6b9d35faSGuinan Sun 	__le32 type_tucmd_mlhl;
67*6b9d35faSGuinan Sun 	__le32 mss_l4len_idx;
68*6b9d35faSGuinan Sun };
69*6b9d35faSGuinan Sun 
70*6b9d35faSGuinan Sun /* Adv Transmit Descriptor Config Masks */
71*6b9d35faSGuinan Sun #define E1000_ADVTXD_DTYP_CTXT	0x00200000 /* Advanced Context Descriptor */
72*6b9d35faSGuinan Sun #define E1000_ADVTXD_DTYP_DATA	0x00300000 /* Advanced Data Descriptor */
73*6b9d35faSGuinan Sun #define E1000_ADVTXD_DCMD_EOP	0x01000000 /* End of Packet */
74*6b9d35faSGuinan Sun #define E1000_ADVTXD_DCMD_IFCS	0x02000000 /* Insert FCS (Ethernet CRC) */
75*6b9d35faSGuinan Sun #define E1000_ADVTXD_DCMD_RS	0x08000000 /* Report Status */
76*6b9d35faSGuinan Sun #define E1000_ADVTXD_DCMD_DDTYP_ISCSI	0x10000000 /* DDP hdr type or iSCSI */
77*6b9d35faSGuinan Sun #define E1000_ADVTXD_DCMD_DEXT	0x20000000 /* Descriptor extension (1=Adv) */
78*6b9d35faSGuinan Sun #define E1000_ADVTXD_DCMD_VLE	0x40000000 /* VLAN pkt enable */
79*6b9d35faSGuinan Sun #define E1000_ADVTXD_DCMD_TSE	0x80000000 /* TCP Seg enable */
80*6b9d35faSGuinan Sun #define E1000_ADVTXD_MAC_LINKSEC	0x00040000 /* Apply LinkSec on pkt */
81*6b9d35faSGuinan Sun #define E1000_ADVTXD_MAC_TSTAMP		0x00080000 /* IEEE1588 Timestamp pkt */
82*6b9d35faSGuinan Sun #define E1000_ADVTXD_STAT_SN_CRC	0x00000002 /* NXTSEQ/SEED prsnt in WB */
83*6b9d35faSGuinan Sun #define E1000_ADVTXD_IDX_SHIFT		4  /* Adv desc Index shift */
84*6b9d35faSGuinan Sun #define E1000_ADVTXD_POPTS_ISCO_1ST	0x00000000 /* 1st TSO of iSCSI PDU */
85*6b9d35faSGuinan Sun #define E1000_ADVTXD_POPTS_ISCO_MDL	0x00000800 /* Middle TSO of iSCSI PDU */
86*6b9d35faSGuinan Sun #define E1000_ADVTXD_POPTS_ISCO_LAST	0x00001000 /* Last TSO of iSCSI PDU */
87*6b9d35faSGuinan Sun /* 1st & Last TSO-full iSCSI PDU*/
88*6b9d35faSGuinan Sun #define E1000_ADVTXD_POPTS_ISCO_FULL	0x00001800
89*6b9d35faSGuinan Sun #define E1000_ADVTXD_POPTS_IPSEC	0x00000400 /* IPSec offload request */
90*6b9d35faSGuinan Sun #define E1000_ADVTXD_PAYLEN_SHIFT	14 /* Adv desc PAYLEN shift */
91*6b9d35faSGuinan Sun 
92*6b9d35faSGuinan Sun /* Advanced Transmit Context Descriptor Config */
93*6b9d35faSGuinan Sun #define E1000_ADVTXD_MACLEN_SHIFT	9  /* Adv ctxt desc mac len shift */
94*6b9d35faSGuinan Sun #define E1000_ADVTXD_VLAN_SHIFT		16  /* Adv ctxt vlan tag shift */
95*6b9d35faSGuinan Sun #define E1000_ADVTXD_TUCMD_IPV4		0x00000400  /* IP Packet Type: 1=IPv4 */
96*6b9d35faSGuinan Sun #define E1000_ADVTXD_TUCMD_IPV6		0x00000000  /* IP Packet Type: 0=IPv6 */
97*6b9d35faSGuinan Sun #define E1000_ADVTXD_TUCMD_L4T_UDP	0x00000000  /* L4 Packet TYPE of UDP */
98*6b9d35faSGuinan Sun #define E1000_ADVTXD_TUCMD_L4T_TCP	0x00000800  /* L4 Packet TYPE of TCP */
99*6b9d35faSGuinan Sun #define E1000_ADVTXD_TUCMD_L4T_SCTP	0x00001000  /* L4 Packet TYPE of SCTP */
100*6b9d35faSGuinan Sun #define E1000_ADVTXD_TUCMD_IPSEC_TYPE_ESP	0x00002000 /* IPSec Type ESP */
101*6b9d35faSGuinan Sun /* IPSec Encrypt Enable for ESP */
102*6b9d35faSGuinan Sun #define E1000_ADVTXD_TUCMD_IPSEC_ENCRYPT_EN	0x00004000
103*6b9d35faSGuinan Sun /* Req requires Markers and CRC */
104*6b9d35faSGuinan Sun #define E1000_ADVTXD_TUCMD_MKRREQ	0x00002000
105*6b9d35faSGuinan Sun #define E1000_ADVTXD_L4LEN_SHIFT	8  /* Adv ctxt L4LEN shift */
106*6b9d35faSGuinan Sun #define E1000_ADVTXD_MSS_SHIFT		16  /* Adv ctxt MSS shift */
107*6b9d35faSGuinan Sun /* Adv ctxt IPSec SA IDX mask */
108*6b9d35faSGuinan Sun #define E1000_ADVTXD_IPSEC_SA_INDEX_MASK	0x000000FF
109*6b9d35faSGuinan Sun /* Adv ctxt IPSec ESP len mask */
110*6b9d35faSGuinan Sun #define E1000_ADVTXD_IPSEC_ESP_LEN_MASK		0x000000FF
111*6b9d35faSGuinan Sun 
112*6b9d35faSGuinan Sun #define E1000_RAR_ENTRIES_BASE		16
113*6b9d35faSGuinan Sun 
114*6b9d35faSGuinan Sun /* Receive Descriptor - Advanced */
115*6b9d35faSGuinan Sun union e1000_adv_rx_desc {
116*6b9d35faSGuinan Sun 	struct {
117*6b9d35faSGuinan Sun 		__le64 pkt_addr; /* Packet buffer address */
118*6b9d35faSGuinan Sun 		__le64 hdr_addr; /* Header buffer address */
119*6b9d35faSGuinan Sun 	} read;
120*6b9d35faSGuinan Sun 	struct {
121*6b9d35faSGuinan Sun 		struct {
122*6b9d35faSGuinan Sun 			union {
123*6b9d35faSGuinan Sun 				__le32 data;
124*6b9d35faSGuinan Sun 				struct {
125*6b9d35faSGuinan Sun 					__le16 pkt_info; /*RSS type, Pkt type*/
126*6b9d35faSGuinan Sun 					/* Split Header, header buffer len */
127*6b9d35faSGuinan Sun 					__le16 hdr_info;
128*6b9d35faSGuinan Sun 				} hs_rss;
129*6b9d35faSGuinan Sun 			} lo_dword;
130*6b9d35faSGuinan Sun 			union {
131*6b9d35faSGuinan Sun 				__le32 rss; /* RSS Hash */
132*6b9d35faSGuinan Sun 				struct {
133*6b9d35faSGuinan Sun 					__le16 ip_id; /* IP id */
134*6b9d35faSGuinan Sun 					__le16 csum; /* Packet Checksum */
135*6b9d35faSGuinan Sun 				} csum_ip;
136*6b9d35faSGuinan Sun 			} hi_dword;
137*6b9d35faSGuinan Sun 		} lower;
138*6b9d35faSGuinan Sun 		struct {
139*6b9d35faSGuinan Sun 			__le32 status_error; /* ext status/error */
140*6b9d35faSGuinan Sun 			__le16 length; /* Packet length */
141*6b9d35faSGuinan Sun 			__le16 vlan; /* VLAN tag */
142*6b9d35faSGuinan Sun 		} upper;
143*6b9d35faSGuinan Sun 	} wb;  /* writeback */
144*6b9d35faSGuinan Sun };
145*6b9d35faSGuinan Sun 
146*6b9d35faSGuinan Sun /* Additional Transmit Descriptor Control definitions */
147*6b9d35faSGuinan Sun #define E1000_TXDCTL_QUEUE_ENABLE	0x02000000 /* Ena specific Tx Queue */
148*6b9d35faSGuinan Sun 
149*6b9d35faSGuinan Sun /* Additional Receive Descriptor Control definitions */
150*6b9d35faSGuinan Sun #define E1000_RXDCTL_QUEUE_ENABLE	0x02000000 /* Ena specific Rx Queue */
151*6b9d35faSGuinan Sun 
152*6b9d35faSGuinan Sun /* SRRCTL bit definitions */
153*6b9d35faSGuinan Sun #define E1000_SRRCTL_BSIZEPKT_SHIFT		10 /* Shift _right_ */
154*6b9d35faSGuinan Sun #define E1000_SRRCTL_BSIZEHDRSIZE_SHIFT		2  /* Shift _left_ */
155*6b9d35faSGuinan Sun #define E1000_SRRCTL_DESCTYPE_ADV_ONEBUF	0x02000000
156*6b9d35faSGuinan Sun 
157*6b9d35faSGuinan Sun #endif /* _E1000_BASE_H_ */
158