iPXE
aqc1xx.h
Go to the documentation of this file.
1/** @file
2 *
3 * Marvell AQtion family network card driver definitions.
4 *
5 * Copyright(C) 2017-2024 Marvell
6 *
7 * SPDX-License-Identifier: BSD-2-Clause
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR HOLDER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 */
31#ifndef _ATLANTIC_H
32#define _ATLANTIC_H
33
34FILE_LICENCE ( BSD2 );
35
36#include <stdint.h>
37#include <ipxe/if_ether.h>
38#include <ipxe/nvs.h>
39
40#define ATL_BAR_SIZE 0x10000
41#define ATL2_BAR_SIZE 0x40000
42#define ATL_RING_SIZE 64
43#define ATL_RING_ALIGN 128
44#define ATL_RX_MAX_LEN 2048
45
46#define ATL_IRQ_TX 0x00000001U
47#define ATL_IRQ_RX 0x00000002U
48
49/*IRQ Status Register*/
50#define ATL_IRQ_STAT_REG 0x00002000U
51
52/* Interrupt Vector Allocation Register */
53#define ATL_IRQ_CTRL 0x00002300U
54#define ATL_IRQ_CTRL_COR_EN 0x00000080U /*IRQ clear on read */
55#define ATL_IRQ_CTRL_REG_RST_DIS 0x20000000U /*Register reset disable */
56
57/*TX/RX Interruprt Mapping*/
58#define ATL_IRQ_MAP_REG1 0x00002100U /*IRQ mapping register */
59
60#define ATL_IRQ_MAP_REG1_RX0_EN 0x00008000U /*IRQ RX0 enable*/
61#define ATL_IRQ_MAP_REG1_RX0 0x00000100U /*IRQ RX0*/
62
63#define ATL_IRQ_MAP_REG1_TX0_EN 0x80000000U /*IRQ TX0 enable*/
64#define ATL_IRQ_MAP_REG1_TX0 0x00000000U /*IRQ TX0*/
65
66/*TX interrupt ctrl reg*/
67#define ATL_TX_IRQ_CTRL 0x00007B40U
68#define ATL_TX_IRQ_CTRL_WB_EN 0x00000002U
69
70/*RX interrupt ctrl reg*/
71#define ATL_RX_IRQ_CTRL 0x00005A30U
72#define ATL_RX_IRQ_CTRL_WB_EN 0x00000004U
73
74#define ATL_GLB_CTRL 0x00000000U
75
76#define ATL_PCI_CTRL 0x00001000U
77#define ATL_PCI_CTRL_RST_DIS 0x20000000U
78
79#define ATL_RX_CTRL 0x00005000U
80#define ATL_RX_CTRL_RST_DIS 0x20000000U /*RPB reset disable */
81#define ATL_TX_CTRL 0x00007000U
82#define ATL_TX_CTRL_RST_DIS 0x20000000U /*TPB reset disable */
83
84/*RX data path control registers*/
85#define ATL_RPF2_CTRL 0x00005040U
86#define ATL_RPF2_CTRL_EN 0x000F0000U /* RPF2 enable*/
87#define ATL2_RPF_NEW_EN_ADR_EN 0x00000001U /*enable*/
88#define ATL2_RPF_NEW_EN_ADR 0x5104
89
90#define ATL_RPF_CTRL1 0x00005100U
91#define ATL_RPF_CTRL1_BRC_EN 0x00000001U /*Allow broadcast receive*/
92#define ATL_RPF_CTRL1_L2_PROMISC 0x00000008U /*L2 promiscious*/
93#define ATL_RPF_CTRL1_ACTION 0x00001000U /*Action to host*/
94#define ATL_RPF_CTRL1_BRC_TSH 0x00010000U /*Brc threshold 256 units per sec*/
95
96#define ATL_RPF_CTRL2 0x00005280U
97#define ATL_RPF_CTRL2_VLAN_PROMISC 0x00000002U /*VLAN promisc*/
98
99#define ATL_RPB_CTRL_DIS 0x0
100#define ATL_RPB_CTRL 0x00005700U
101#define ATL_RPB_CTRL_EN 0x00000001U /*RPB Enable*/
102#define ATL_RPB_CTRL_FC 0x00000010U /*RPB Enable*/
103#define ATL_RPB_CTRL_TC_MODE 0x00000100U /*RPB Traffic Class Mode*/
104
105#define ATL_RPB0_CTRL1 0x00005710U
106#define ATL_RPB0_CTRL1_SIZE 0x00000140U /*RPB size (in unit 1KB) \*/
107
108#define ATL_RPB0_CTRL2 0x00005714U
109
110/*Buffer Low Threshold (70% of RPB size in unit 32B)*/
111#define ATL_RPB0_CTRL2_LOW_TSH 0x00000C00U
112/*Buffer High Threshold(30% of RPB size in unit 32B)*/
113#define ATL_RPB0_CTRL2_HIGH_TSH 0x1C000000U
114#define ATL_RPB0_CTRL2_FC_EN 0x80000000U /*Flow control Enable*/
115
116#define ATL_RX_DMA_DESC_BUF_SIZE 0x00005b18U
117#define ATL_RX_DMA_DESC_ADDR 0x00005b00U
118
119/*TX data path control registers*/
120#define ATL_TPO2_CTRL 0x00007040U
121#define ATL_TPO2_EN 0x00010000U /*TPO2 Enable*/
122
123#define ATL_TPB_CTRL_DIS 0x0
124#define ATL_TPB_CTRL 0x00007900U
125#define ATL_TPB_CTRL_EN 0x00000001U /*TPB enable*/
126#define ATL_TPB_CTRL_PAD_EN 0x00000004U /*Tx pad insert enable*/
127#define ATL_TPB_CTRL_TC_MODE 0x00000100U /*Tx traffic Class Mode*/
128
129#define ATL_TPB0_CTRL1 0x00007910U
130#define ATL_TPB0_CTRL1_SIZE 0x000000A0U /*TPB Size (in unit 1KB)*/
131
132#define ATL_TPB0_CTRL2 0x00007914U
133/*Buffer Low Threshold(30% of RPB size in unit 32B)*/
134#define ATL_TPB0_CTRL2_LOW_TSH 0x00000600U
135/*Buffer High Threshold(30% of RPB size in unit 32B)*/
136#define ATL_TPB0_CTRL2_HIGH_TSH 0x0E000000U
137
138#define ATL_TX_DMA_DESC_ADDR 0x00007c00U
139
140/*Rings control registers*/
141#define ATL_RING_TX_CTRL 0x00007c08U
142#define ATL_RING_TX_CTRL_EN 0x80000000U /*Tx descriptor Enable*/
143
144#define ATL_RING_RX_CTRL 0x00005b08U
145#define ATL_RING_RX_CTRL_EN 0x80000000U /*Rx descriptor Enable*/
146
147#define ATL_RING_TAIL 0x00007c10U
148#define ATL_RING_TAIL_PTR 0x00005b10U
149
150/*IRQ control registers*/
151#define ATL_ITR_MSKS_DIS 0x0
152#define ATL_ITR_MSKS 0x00002060U
153#define ATL_ITR_MSKS_LSW 0x0000000CU
154#define ATL_ITR_MSKC 0x00002070U
155#define ATL_ITR_MSKC_LSW 0x0000000CU
156
157/*Link advertising*/
158#define ATL_LINK_ADV 0x00000368U
159#define ATL_SHUT_LINK 0x0
160#define ATL_LINK_ADV_AUTONEG 0xF20U
161
162#define ATL_LINK_ST 0x00000370U
163
164/*Semaphores*/
165#define ATL_SEM_RAM 0x000003a8U
166#define ATL_SEM_RAM_RESET 0X1
167
168/*Mailbox*/
169#define ATL_MBOX_ADDR 0x00000360U
170#define ATL_MBOX_CTRL1 0x00000200U
171#define ATL_MBOX_CTRL1_START_MBOX_OPT 0x8000
172
173#define ATL_MBOX_CTRL3 0x00000208U
174#define ATL_MBOX_CTRL5 0x0000020cU
175
176#define ATL_FLAG_A1 0x1
177#define ATL_FLAG_A2 0x2
178
179/*write register*/
180#define ATL_WRITE_REG( VAL, REG ) writel( VAL, nic->regs + (REG) )
181#define ATL_READ_REG( REG ) readl( nic->regs + (REG) ) /*read register*/
182
188
189#define ATL_DESC_TX_DX_TYPE_VALUE 0x1
190
191#define ATL_DESC_TX_DX_EOP_VALUE 0x1
192#define ATL_DESC_TX_EOP_MASK 0x00200000
193#define ATL_DESC_TX_EOP_OFFSET 21
194
195#define ATL_DESC_TX_CMD_MASK 0x3FC00000UL
196#define ATL_DESC_TX_CMD_OFFSET 22
197#define ATL_DESC_TX_CMD_VALUE 0x22
198
199#define ATL_DESC_TX_BUF_LEN_MASK 0x000FFFF0
200#define ATL_DESC_TX_BUF_LEN_OFFSET 5
201
202#define ATL_DESC_TX_PAY_LEN_MASK 0xFFFFC000
203#define ATL_DESC_TX_PAY_LEN_OFFSET 14
204
210
211#define ATL_TX_DESC_STATUS_DD 0x00100000UL
212
218
225
226#define ATL_RX_DESC_STATUS_DD 0x0001UL
227#define ATL_RX_DESC_STATUS_EOP 0x0002UL
228struct atl_ring {
229 unsigned int sw_tail;
230 unsigned int sw_head;
231 void *ring;
232 /** Descriptor ring DMA mapping */
234 unsigned int length;
236
237struct atl_nic;
238
240 int ( *reset ) ( struct atl_nic *nic );
241 int ( *start ) ( struct atl_nic *nic );
242 int ( *stop ) ( struct atl_nic *nic );
243 int ( *get_link ) ( struct atl_nic *nic );
244 int ( *get_mac ) ( struct atl_nic *, uint8_t *mac );
245};
246
247/** An aQuanita network card */
248struct atl_nic {
249 /** Registers */
250 void *regs;
251 /** Port number (for multi-port devices) */
252 unsigned int port;
253 /** DMA device */
255 /** Flags */
256 unsigned int flags;
263};
264
269
270#endif /* _AQUANTIA_H */
#define ATL_RING_SIZE
Definition aqc1xx.h:42
unsigned short uint16_t
Definition stdint.h:11
unsigned int uint32_t
Definition stdint.h:12
unsigned long long uint64_t
Definition stdint.h:13
unsigned char uint8_t
Definition stdint.h:10
uint8_t mac[ETH_ALEN]
MAC address.
Definition ena.h:13
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
struct atl_ring __attribute__
Non-volatile storage.
uint64_t rsvd2
Definition aqc1xx.h:220
uint16_t status
Definition aqc1xx.h:221
uint16_t pkt_len
Definition aqc1xx.h:222
uint32_t rsvd4
Definition aqc1xx.h:223
uint64_t hdr_addr
Definition aqc1xx.h:215
uint64_t data_addr
Definition aqc1xx.h:214
uint64_t rsvd1
Definition aqc1xx.h:206
uint32_t status
Definition aqc1xx.h:207
uint32_t rsvd4
Definition aqc1xx.h:208
uint64_t address
Definition aqc1xx.h:184
uint32_t status
Definition aqc1xx.h:185
uint32_t flag
Definition aqc1xx.h:186
int(* start)(struct atl_nic *nic)
Definition aqc1xx.h:241
int(* reset)(struct atl_nic *nic)
Definition aqc1xx.h:240
int(* stop)(struct atl_nic *nic)
Definition aqc1xx.h:242
int(* get_mac)(struct atl_nic *, uint8_t *mac)
Definition aqc1xx.h:244
int(* get_link)(struct atl_nic *nic)
Definition aqc1xx.h:243
uint32_t tid
Definition aqc1xx.h:267
uint32_t version
Definition aqc1xx.h:266
An aQuanita network card.
Definition aqc1xx.h:248
uint32_t mbox_addr
Definition aqc1xx.h:261
struct io_buffer * iobufs[ATL_RING_SIZE]
Definition aqc1xx.h:259
unsigned int port
Port number (for multi-port devices)
Definition aqc1xx.h:252
uint32_t link_state
Definition aqc1xx.h:260
struct atl_ring rx_ring
Definition aqc1xx.h:258
struct atl_ring tx_ring
Definition aqc1xx.h:257
void * regs
Registers.
Definition aqc1xx.h:250
struct atl_hw_ops * hw_ops
Definition aqc1xx.h:262
struct dma_device * dma
DMA device.
Definition aqc1xx.h:254
unsigned int flags
Flags.
Definition aqc1xx.h:256
unsigned int sw_head
Definition aqc1xx.h:230
unsigned int sw_tail
Definition aqc1xx.h:229
unsigned int length
Definition aqc1xx.h:234
struct dma_mapping map
Descriptor ring DMA mapping.
Definition aqc1xx.h:233
void * ring
Definition aqc1xx.h:231
A DMA-capable device.
Definition dma.h:48
A DMA mapping.
Definition dma.h:33
A persistent I/O buffer.
Definition iobuf.h:38
Definition nic.h:49