iPXE
aqc1xx.c File Reference

Marvell AQtion family network card driver. More...

#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/iobuf.h>
#include <ipxe/malloc.h>
#include <ipxe/pci.h>
#include <ipxe/profile.h>
#include "aqc1xx.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (BSD2)
static int atl_ring_alloc (const struct atl_nic *nic, struct atl_ring *ring, uint32_t desc_size, uint32_t reg_base)
static void atl_ring_free (struct atl_ring *ring)
static void atl_ring_next_dx (unsigned int *val)
int atl_ring_full (const struct atl_ring *ring)
void atl_rx_ring_fill (struct atl_nic *nic)
static int atl_open (struct net_device *netdev)
 Open network device.
static void atl_close (struct net_device *netdev)
 Close network device.
int atl_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet.
void atl_check_link (struct net_device *netdev)
void atl_poll_tx (struct net_device *netdev)
 Poll for completed packets.
void atl_poll_rx (struct net_device *netdev)
 Poll for received packets.
static void atl_poll (struct net_device *netdev)
 Poll for completed and received packets.
static void atl_irq (struct net_device *netdev, int enable)
 Enable or disable interrupts.
static int atl_probe (struct pci_device *pci)
 Probe PCI device.
static void atl_remove (struct pci_device *pci)
 Remove PCI device.

Variables

struct atl_hw_ops atl_hw
struct atl_hw_ops atl2_hw
static struct net_device_operations atl_operations
 Marvell network device operations.
static struct pci_device_id atl_nics []
 Marvell PCI device IDs.
struct pci_driver atl_driver __pci_driver
 Marvell PCI driver.

Detailed Description

Marvell AQtion family network card driver.

Marvell AQC network card driver.

Copyright(C) 2017-2024 Marvell

SPDX-License-Identifier: BSD-2-Clause

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file aqc1xx.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( BSD2 )

References atl2_hw, and atl_hw.

◆ atl_ring_alloc()

int atl_ring_alloc ( const struct atl_nic * nic,
struct atl_ring * ring,
uint32_t desc_size,
uint32_t reg_base )
static

Definition at line 58 of file aqc1xx.c.

59 {
60 physaddr_t phy_addr;
61
62 /* Allocate ring buffer.*/
63 ring->length = ATL_RING_SIZE * desc_size;
64 ring->ring = dma_alloc ( nic->dma, &ring->map, ring->length,
65 ring->length );
66
67 if ( !ring->ring )
68 return -ENOMEM;
69
70 /* Initialize the descriptor ring */
71 memset ( ring->ring, 0, ring->length );
72
73 /* Program ring address */
74 phy_addr = dma ( &ring->map, ring->ring );
75
76 /* Write ring address (hi & low parts).*/
77 ATL_WRITE_REG ( ( uint32_t )phy_addr, reg_base );
78 ATL_WRITE_REG ( ( uint32_t ) ( ( ( uint64_t )phy_addr ) >> 32 ), reg_base + 4 );
79
80 /* Write ring length.*/
81 ATL_WRITE_REG ( ATL_RING_SIZE, reg_base + 8 );
82
83 ring->sw_head = ring->sw_tail = 0;
84
85 DBGC ( nic, "AQUANTIA: %p ring is at [%08llx,%08llx), reg base %#x\n",
86 nic, ( ( unsigned long long )phy_addr ),
87 ( ( unsigned long long ) phy_addr + ring->length ), reg_base );
88
89 return 0;
90}
#define ATL_RING_SIZE
Definition aqc1xx.h:42
#define ATL_WRITE_REG(VAL, REG)
Definition aqc1xx.h:180
unsigned int uint32_t
Definition stdint.h:12
unsigned long physaddr_t
Definition stdint.h:20
unsigned long long uint64_t
Definition stdint.h:13
#define DBGC(...)
Definition compiler.h:530
#define ENOMEM
Not enough space.
Definition errno.h:578
void * memset(void *dest, int character, size_t len) __nonnull
void * dma_alloc(struct dma_device *dma, struct dma_mapping *map, size_t len, size_t align)
Allocate and map DMA-coherent buffer.
physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
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
Definition nic.h:49

References ATL_RING_SIZE, ATL_WRITE_REG, DBGC, dma(), dma_alloc(), ENOMEM, atl_ring::length, atl_ring::map, memset(), atl_ring::ring, atl_ring::sw_head, and atl_ring::sw_tail.

Referenced by atl_open().

◆ atl_ring_free()

void atl_ring_free ( struct atl_ring * ring)
static

Definition at line 92 of file aqc1xx.c.

92 {
93 dma_free ( &ring->map, ring->ring, ring->length );
94 ring->ring = NULL;
95 ring->length = 0;
96}
#define NULL
NULL pointer (VOID *).
Definition Base.h:321
void dma_free(struct dma_mapping *map, void *addr, size_t len)
Unmap and free DMA-coherent buffer.

References dma_free(), atl_ring::length, atl_ring::map, NULL, and atl_ring::ring.

Referenced by atl_close(), and atl_open().

◆ atl_ring_next_dx()

void atl_ring_next_dx ( unsigned int * val)
static

Definition at line 98 of file aqc1xx.c.

98 {
99 ++( *val );
100 if ( *val == ATL_RING_SIZE )
101 *val = 0;
102}
void __asmcall int val
Definition setjmp.h:12

References ATL_RING_SIZE, and val.

Referenced by atl_poll_rx(), atl_poll_tx(), atl_ring_full(), atl_rx_ring_fill(), and atl_transmit().

◆ atl_ring_full()

int atl_ring_full ( const struct atl_ring * ring)

Definition at line 104 of file aqc1xx.c.

104 {
105 unsigned int tail = ring->sw_tail;
106 atl_ring_next_dx ( &tail );
107 return tail == ring->sw_head;
108}
static void atl_ring_next_dx(unsigned int *val)
Definition aqc1xx.c:98

References atl_ring_next_dx(), atl_ring::sw_head, and atl_ring::sw_tail.

Referenced by atl_rx_ring_fill(), and atl_transmit().

◆ atl_rx_ring_fill()

void atl_rx_ring_fill ( struct atl_nic * nic)

Definition at line 110 of file aqc1xx.c.

110 {
111 struct atl_desc_rx *rx;
112 struct io_buffer *iobuf;
114 unsigned int refilled = 0;
115
116 /* Refill ring */
117 while ( !atl_ring_full ( &nic->rx_ring ) ) {
118
119 /* Allocate I/O buffer */
120 iobuf = alloc_rx_iob ( ATL_RX_MAX_LEN, nic->dma );
121 if ( !iobuf ) {
122 /* Wait for next refill */
123 break;
124 }
125
126 /* Get next receive descriptor */
127 rx = ( struct atl_desc_rx * )nic->rx_ring.ring +
128 nic->rx_ring.sw_tail;
129
130 /* Populate receive descriptor */
131 address = iob_dma ( iobuf );
132 rx->data_addr = address;
133 rx->hdr_addr = 0;
134
135 /* Record I/O buffer */
136 assert ( nic->iobufs[nic->rx_ring.sw_tail] == NULL );
137 nic->iobufs[nic->rx_ring.sw_tail] = iobuf;
138
139 DBGC( nic, "AQUANTIA: RX[%d] is [%llx,%llx)\n",
140 nic->rx_ring.sw_tail,
141 ( ( unsigned long long )address ),
142 ( ( unsigned long long )address + ATL_RX_MAX_LEN ) );
143
144 atl_ring_next_dx ( &nic->rx_ring.sw_tail );
145 refilled++;
146 }
147
148 /* Push descriptors to card, if applicable */
149 if ( refilled ) {
150 wmb();
151 ATL_WRITE_REG ( nic->rx_ring.sw_tail, ATL_RING_TAIL_PTR );
152 }
153}
int atl_ring_full(const struct atl_ring *ring)
Definition aqc1xx.c:104
#define ATL_RX_MAX_LEN
Definition aqc1xx.h:44
#define ATL_RING_TAIL_PTR
Definition aqc1xx.h:148
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:61
uint64_t address
Base address.
Definition ena.h:13
#define wmb()
Definition io.h:546
struct io_buffer * alloc_rx_iob(size_t len, struct dma_device *dma)
Allocate and map I/O buffer for receive DMA.
Definition iobuf.c:188
static __always_inline physaddr_t iob_dma(struct io_buffer *iobuf)
Get I/O buffer DMA address.
Definition iobuf.h:328
A persistent I/O buffer.
Definition iobuf.h:98
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
Definition wpa.h:1

References address, alloc_rx_iob(), assert, atl_ring_full(), atl_ring_next_dx(), ATL_RING_TAIL_PTR, ATL_RX_MAX_LEN, ATL_WRITE_REG, DBGC, iob_dma(), NULL, rx, and wmb.

Referenced by atl_open(), and atl_poll().

◆ atl_open()

int atl_open ( struct net_device * netdev)
static

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 161 of file aqc1xx.c.

161 {
162 struct atl_nic *nic = netdev->priv;
163 uint32_t ctrl = 0;
164
165 /* Tx ring */
166 if ( atl_ring_alloc ( nic, &nic->tx_ring, sizeof ( struct atl_desc_tx ),
167 ATL_TX_DMA_DESC_ADDR ) != 0 )
168 goto err_tx_alloc;
169
170 /* Rx ring */
171 if ( atl_ring_alloc ( nic, &nic->rx_ring, sizeof ( struct atl_desc_rx ),
172 ATL_RX_DMA_DESC_ADDR ) != 0 )
173 goto err_rx_alloc;
174
175 /* Allocate interrupt vectors */
177 ATL_IRQ_CTRL );
178
179 /*TX & RX Interruprt Mapping*/
183
184 /*TX interrupt ctrl reg*/
186
187 /*RX interrupt ctrl reg*/
189
190 /*RX data path*/
192 /* itr mask */
196
197 /*filter global ctrl */
201
202 /* vlan promisc */
204 /* enable rpf2 */
206
207 /* RX Packet Buffer 0 Register 1 */
209
210 /*RX Packet Buffer 0 Register 2 */
214
215 /*RPB global ctrl*/
219
220 /*TX data path*/
221 /* enable tpo2 */
223 /* tpb global ctrl *** */
225
227 /* tpb global ctrl *** */
229
232 /* tpb global ctrl */
234
235 /*Enable rings*/
240
241 if ( nic->flags == ATL_FLAG_A2 ) {
243 }
244
246
247 nic->hw_ops->start ( nic );
248
249 return 0;
250
251err_rx_alloc:
252 atl_ring_free ( &nic->tx_ring );
253
254err_tx_alloc:
255 return -ENOMEM;
256}
void atl_rx_ring_fill(struct atl_nic *nic)
Definition aqc1xx.c:110
static int atl_ring_alloc(const struct atl_nic *nic, struct atl_ring *ring, uint32_t desc_size, uint32_t reg_base)
Definition aqc1xx.c:58
static void atl_ring_free(struct atl_ring *ring)
Definition aqc1xx.c:92
#define ATL_IRQ_MAP_REG1_RX0_EN
Definition aqc1xx.h:60
#define ATL_TPB_CTRL
Definition aqc1xx.h:124
#define ATL_RING_TX_CTRL
Definition aqc1xx.h:141
#define ATL_RPB0_CTRL2_FC_EN
Definition aqc1xx.h:114
#define ATL_RPF_CTRL1_ACTION
Definition aqc1xx.h:93
#define ATL_TPB0_CTRL2_LOW_TSH
Definition aqc1xx.h:134
#define ATL_ITR_MSKS
Definition aqc1xx.h:152
#define ATL_RPB0_CTRL1_SIZE
Definition aqc1xx.h:106
#define ATL_IRQ_MAP_REG1_TX0
Definition aqc1xx.h:64
#define ATL_IRQ_TX
Definition aqc1xx.h:46
#define ATL_TPB0_CTRL2_HIGH_TSH
Definition aqc1xx.h:136
#define ATL_TX_IRQ_CTRL
Definition aqc1xx.h:67
#define ATL_TPB0_CTRL1
Definition aqc1xx.h:129
#define ATL_TPB0_CTRL2
Definition aqc1xx.h:132
#define ATL_RX_IRQ_CTRL_WB_EN
Definition aqc1xx.h:72
#define ATL_IRQ_MAP_REG1_TX0_EN
Definition aqc1xx.h:63
#define ATL_FLAG_A2
Definition aqc1xx.h:177
#define ATL_RPB0_CTRL2_LOW_TSH
Definition aqc1xx.h:111
#define ATL_IRQ_CTRL_REG_RST_DIS
Definition aqc1xx.h:55
#define ATL_RPB0_CTRL2_HIGH_TSH
Definition aqc1xx.h:113
#define ATL_TX_IRQ_CTRL_WB_EN
Definition aqc1xx.h:68
#define ATL_RPB0_CTRL1
Definition aqc1xx.h:105
#define ATL_RPF_CTRL2
Definition aqc1xx.h:96
#define ATL_TX_DMA_DESC_ADDR
Definition aqc1xx.h:138
#define ATL_RPB0_CTRL2
Definition aqc1xx.h:108
#define ATL2_RPF_NEW_EN_ADR_EN
Definition aqc1xx.h:87
#define ATL_READ_REG(REG)
Definition aqc1xx.h:181
#define ATL_TPO2_CTRL
Definition aqc1xx.h:120
#define ATL_IRQ_MAP_REG1
Definition aqc1xx.h:58
#define ATL_RPB_CTRL_FC
Definition aqc1xx.h:102
#define ATL_TPB_CTRL_PAD_EN
Definition aqc1xx.h:126
#define ATL_IRQ_CTRL_COR_EN
Definition aqc1xx.h:54
#define ATL_RPF2_CTRL_EN
Definition aqc1xx.h:86
#define ATL_RX_DMA_DESC_BUF_SIZE
Definition aqc1xx.h:116
#define ATL_IRQ_RX
Definition aqc1xx.h:47
#define ATL_RPB_CTRL
Definition aqc1xx.h:100
#define ATL_RPB_CTRL_EN
Definition aqc1xx.h:101
#define ATL2_RPF_NEW_EN_ADR
Definition aqc1xx.h:88
#define ATL_IRQ_CTRL
Definition aqc1xx.h:53
#define ATL_RING_RX_CTRL_EN
Definition aqc1xx.h:145
#define ATL_RX_DMA_DESC_ADDR
Definition aqc1xx.h:117
#define ATL_RPF2_CTRL
Definition aqc1xx.h:85
#define ATL_IRQ_MAP_REG1_RX0
Definition aqc1xx.h:61
#define ATL_RPF_CTRL2_VLAN_PROMISC
Definition aqc1xx.h:97
#define ATL_RPF_CTRL1_BRC_TSH
Definition aqc1xx.h:94
#define ATL_TPB0_CTRL1_SIZE
Definition aqc1xx.h:130
#define ATL_RPF_CTRL1_L2_PROMISC
Definition aqc1xx.h:92
#define ATL_RING_TX_CTRL_EN
Definition aqc1xx.h:142
#define ATL_TPO2_EN
Definition aqc1xx.h:121
#define ATL_RPF_CTRL1_BRC_EN
Definition aqc1xx.h:91
#define ATL_RING_RX_CTRL
Definition aqc1xx.h:144
#define ATL_TPB_CTRL_EN
Definition aqc1xx.h:125
#define ATL_RPF_CTRL1
Definition aqc1xx.h:90
#define ATL_RX_IRQ_CTRL
Definition aqc1xx.h:71
uint8_t ctrl
Ring control.
Definition dwmac.h:7
static struct net_device * netdev
Definition gdbudp.c:53
An aQuanita network card.
Definition aqc1xx.h:248
int flags
Definition nic.h:51

References ATL2_RPF_NEW_EN_ADR, ATL2_RPF_NEW_EN_ADR_EN, ATL_FLAG_A2, ATL_IRQ_CTRL, ATL_IRQ_CTRL_COR_EN, ATL_IRQ_CTRL_REG_RST_DIS, ATL_IRQ_MAP_REG1, ATL_IRQ_MAP_REG1_RX0, ATL_IRQ_MAP_REG1_RX0_EN, ATL_IRQ_MAP_REG1_TX0, ATL_IRQ_MAP_REG1_TX0_EN, ATL_IRQ_RX, ATL_IRQ_TX, ATL_ITR_MSKS, ATL_READ_REG, atl_ring_alloc(), atl_ring_free(), ATL_RING_RX_CTRL, ATL_RING_RX_CTRL_EN, ATL_RING_TX_CTRL, ATL_RING_TX_CTRL_EN, ATL_RPB0_CTRL1, ATL_RPB0_CTRL1_SIZE, ATL_RPB0_CTRL2, ATL_RPB0_CTRL2_FC_EN, ATL_RPB0_CTRL2_HIGH_TSH, ATL_RPB0_CTRL2_LOW_TSH, ATL_RPB_CTRL, ATL_RPB_CTRL_EN, ATL_RPB_CTRL_FC, ATL_RPF2_CTRL, ATL_RPF2_CTRL_EN, ATL_RPF_CTRL1, ATL_RPF_CTRL1_ACTION, ATL_RPF_CTRL1_BRC_EN, ATL_RPF_CTRL1_BRC_TSH, ATL_RPF_CTRL1_L2_PROMISC, ATL_RPF_CTRL2, ATL_RPF_CTRL2_VLAN_PROMISC, ATL_RX_DMA_DESC_ADDR, ATL_RX_DMA_DESC_BUF_SIZE, ATL_RX_IRQ_CTRL, ATL_RX_IRQ_CTRL_WB_EN, ATL_RX_MAX_LEN, atl_rx_ring_fill(), ATL_TPB0_CTRL1, ATL_TPB0_CTRL1_SIZE, ATL_TPB0_CTRL2, ATL_TPB0_CTRL2_HIGH_TSH, ATL_TPB0_CTRL2_LOW_TSH, ATL_TPB_CTRL, ATL_TPB_CTRL_EN, ATL_TPB_CTRL_PAD_EN, ATL_TPO2_CTRL, ATL_TPO2_EN, ATL_TX_DMA_DESC_ADDR, ATL_TX_IRQ_CTRL, ATL_TX_IRQ_CTRL_WB_EN, ATL_WRITE_REG, ctrl, ENOMEM, nic::flags, and netdev.

◆ atl_close()

void atl_close ( struct net_device * netdev)
static

Close network device.

Parameters
netdevNetwork device

Definition at line 263 of file aqc1xx.c.

263 {
264 struct atl_nic *nic = netdev->priv;
265 unsigned int i;
266
267 nic->hw_ops->stop ( nic );
268 /* rpb global ctrl */
270 /* tgb global ctrl */
272
277
278 /* clear itr mask */
280
281 /* Reset the NIC */
282 nic->hw_ops->reset ( nic );
283
284 atl_ring_free ( &nic->tx_ring );
285 atl_ring_free ( &nic->rx_ring );
286
287 /* Discard any outstanding receive I/O buffers */
288 for ( i = 0 ; i < ATL_RING_SIZE ; i++ ) {
289 if ( nic->iobufs[i] )
290 free_rx_iob ( nic->iobufs[i] );
291 nic->iobufs[i] = NULL;
292 }
293}
#define ATL_ITR_MSKS_DIS
Definition aqc1xx.h:151
#define ATL_TPB_CTRL_DIS
Definition aqc1xx.h:123
#define ATL_RPB_CTRL_DIS
Definition aqc1xx.h:99
void free_rx_iob(struct io_buffer *iobuf)
Unmap and free I/O buffer for receive DMA.
Definition iobuf.c:215

References ATL_ITR_MSKS, ATL_ITR_MSKS_DIS, ATL_READ_REG, atl_ring_free(), ATL_RING_RX_CTRL, ATL_RING_RX_CTRL_EN, ATL_RING_SIZE, ATL_RING_TX_CTRL, ATL_RING_TX_CTRL_EN, ATL_RPB_CTRL, ATL_RPB_CTRL_DIS, ATL_TPB_CTRL, ATL_TPB_CTRL_DIS, ATL_WRITE_REG, free_rx_iob(), netdev, and NULL.

◆ atl_transmit()

int atl_transmit ( struct net_device * netdev,
struct io_buffer * iobuf )

Transmit packet.

Parameters
netdevNetwork device
iobufI/O buffer
Return values
rcReturn status code

Definition at line 302 of file aqc1xx.c.

302 {
303 struct atl_nic *nic = netdev->priv;
304 struct atl_desc_tx *tx;
307
308 /* Get next transmit descriptor */
309 if ( atl_ring_full ( &nic->tx_ring ) ) {
310 DBGC ( nic, "AQUANTIA: %p out of transmit descriptors\n", nic );
311 return -ENOBUFS;
312 }
313
314 tx = ( struct atl_desc_tx * )nic->tx_ring.ring + nic->tx_ring.sw_tail;
315
316 /* Populate transmit descriptor */
317 memset ( tx, 0, sizeof ( *tx ) );
318 address = iob_dma ( iobuf );
319 tx->address = address;
320 len = iob_len ( iobuf );
321
322 tx->status = 0x1;
323 tx->status = ( (tx->status) & ~ATL_DESC_TX_BUF_LEN_MASK) |
326 tx->status = ((tx->status) & ~ATL_DESC_TX_EOP_MASK) |
329 tx->status = ( (tx->status) & ~ATL_DESC_TX_CMD_MASK) |
332 tx->flag = ( (tx->flag) & ~ATL_DESC_TX_PAY_LEN_MASK) |
335 wmb();
336
337 DBGC2 ( nic, "AQUANTIA: %p TX[%d] is [%llx, %llx]\n",
338 nic, nic->tx_ring.sw_tail,
339 ( ( unsigned long long ) address ),
340 ( ( unsigned long long ) address + len ) );
341
342 atl_ring_next_dx ( &nic->tx_ring.sw_tail );
343 ATL_WRITE_REG ( nic->tx_ring.sw_tail, ATL_RING_TAIL );
344
345 return 0;
346}
#define ATL_RING_TAIL
Definition aqc1xx.h:147
#define ATL_DESC_TX_PAY_LEN_MASK
Definition aqc1xx.h:202
#define ATL_DESC_TX_EOP_OFFSET
Definition aqc1xx.h:193
#define ATL_DESC_TX_PAY_LEN_OFFSET
Definition aqc1xx.h:203
#define ATL_DESC_TX_CMD_VALUE
Definition aqc1xx.h:197
#define ATL_DESC_TX_BUF_LEN_MASK
Definition aqc1xx.h:199
#define ATL_DESC_TX_EOP_MASK
Definition aqc1xx.h:192
#define ATL_DESC_TX_BUF_LEN_OFFSET
Definition aqc1xx.h:200
#define ATL_DESC_TX_CMD_OFFSET
Definition aqc1xx.h:196
#define ATL_DESC_TX_DX_EOP_VALUE
Definition aqc1xx.h:191
#define ATL_DESC_TX_CMD_MASK
Definition aqc1xx.h:195
ring len
Length.
Definition dwmac.h:226
#define DBGC2(...)
Definition compiler.h:547
#define ENOBUFS
No buffer space available.
Definition errno.h:542
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition iobuf.h:220
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
Definition wpa.h:4

References address, ATL_DESC_TX_BUF_LEN_MASK, ATL_DESC_TX_BUF_LEN_OFFSET, ATL_DESC_TX_CMD_MASK, ATL_DESC_TX_CMD_OFFSET, ATL_DESC_TX_CMD_VALUE, ATL_DESC_TX_DX_EOP_VALUE, ATL_DESC_TX_EOP_MASK, ATL_DESC_TX_EOP_OFFSET, ATL_DESC_TX_PAY_LEN_MASK, ATL_DESC_TX_PAY_LEN_OFFSET, atl_ring_full(), atl_ring_next_dx(), ATL_RING_TAIL, ATL_WRITE_REG, DBGC, DBGC2, ENOBUFS, iob_dma(), iob_len(), len, memset(), netdev, tx, and wmb.

◆ atl_check_link()

void atl_check_link ( struct net_device * netdev)

Definition at line 348 of file aqc1xx.c.

348 {
349 struct atl_nic *nic = netdev->priv;
351
352 /* Read link status */
353 link_state = nic->hw_ops->get_link ( nic );
354
355 DBGC ( nic, "AQUANTIA: %p link status is %08x\n", nic, link_state );
356
357 if ( link_state != nic->link_state ) {
358 if ( link_state ) {
359 DBGC ( nic, "AQUANTIA: link up\n");
361 } else {
362 DBGC ( nic, "AQUANTIA: link lost\n");
364 }
365 nic->link_state = link_state;
366 }
367}
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition netdevice.c:231
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition netdevice.h:792
uint32_t link_state
Definition aqc1xx.h:260

References DBGC, atl_nic::link_state, netdev, netdev_link_down(), and netdev_link_up().

Referenced by atl_poll().

◆ atl_poll_tx()

void atl_poll_tx ( struct net_device * netdev)

Poll for completed packets.

Parameters
netdevNetwork device

Definition at line 374 of file aqc1xx.c.

374 {
375 struct atl_nic *nic = netdev->priv;
376 struct atl_desc_tx_wb *tx;
377
378 /* Check for completed packets */
379 while ( nic->tx_ring.sw_head != nic->tx_ring.sw_tail ) {
380
381 /* Get next transmit descriptor */
382 tx = ( struct atl_desc_tx_wb * )nic->tx_ring.ring +
383 nic->tx_ring.sw_head;
384
385 /* Stop if descriptor is still in use */
386 if ( !( tx->status & cpu_to_le32 ( ATL_TX_DESC_STATUS_DD ) ) )
387 return;
388
389 DBGC2 ( nic, "AQUANTIA: %p TX[%d] complete\n",
390 nic, nic->tx_ring.sw_head );
391
392 /* Complete TX descriptor */
393 atl_ring_next_dx ( &nic->tx_ring.sw_head );
395 }
396}
#define ATL_TX_DESC_STATUS_DD
Definition aqc1xx.h:211
#define cpu_to_le32(value)
Definition byteswap.h:108
static void netdev_tx_complete_next(struct net_device *netdev)
Complete network transmission.
Definition netdevice.h:782

References atl_ring_next_dx(), ATL_TX_DESC_STATUS_DD, cpu_to_le32, DBGC2, netdev, netdev_tx_complete_next(), and tx.

Referenced by atl_poll().

◆ atl_poll_rx()

void atl_poll_rx ( struct net_device * netdev)

Poll for received packets.

Parameters
netdevNetwork device

Definition at line 403 of file aqc1xx.c.

403 {
404 struct atl_nic *nic = netdev->priv;
405 struct atl_desc_rx_wb *rx;
406 struct io_buffer *iobuf;
407 size_t len;
408
409 /* Check for received packets */
410 while ( nic->rx_ring.sw_head != nic->rx_ring.sw_tail ) {
411
412 /* Get next receive descriptor */
413 rx = ( struct atl_desc_rx_wb * )nic->rx_ring.ring +
414 nic->rx_ring.sw_head;
415
416 /* Stop if descriptor is still in use */
417 if ( !( rx->status & cpu_to_le16( ATL_RX_DESC_STATUS_DD ) ) )
418 return;
419
420 /* Populate I/O buffer */
421 iobuf = nic->iobufs[nic->rx_ring.sw_head];
422 nic->iobufs[nic->rx_ring.sw_head] = NULL;
423 len = le16_to_cpu ( rx->pkt_len );
424 iob_put ( iobuf, len );
425
426 /* Hand off to network stack */
427 DBGC ( nic, "AQUANTIA: %p RX[%d] complete (length %zd)\n",
428 nic, nic->rx_ring.sw_head, len );
429
430 netdev_rx ( netdev, iobuf );
431
432 atl_ring_next_dx ( &nic->rx_ring.sw_head );
433 }
434}
#define ATL_RX_DESC_STATUS_DD
Definition aqc1xx.h:226
#define le16_to_cpu(value)
Definition byteswap.h:113
#define cpu_to_le16(value)
Definition byteswap.h:107
#define iob_put(iobuf, len)
Definition iobuf.h:185
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition netdevice.c:549

References atl_ring_next_dx(), ATL_RX_DESC_STATUS_DD, cpu_to_le16, DBGC, iob_put, le16_to_cpu, len, netdev, netdev_rx(), NULL, and rx.

Referenced by atl_poll().

◆ atl_poll()

void atl_poll ( struct net_device * netdev)
static

Poll for completed and received packets.

Parameters
netdevNetwork device

Definition at line 441 of file aqc1xx.c.

441 {
442 struct atl_nic *nic = netdev->priv;
443
444 /* Check link state */
446
447 /* Poll for TX completions */
449
450 /* Poll for RX completions */
452
453 /* Refill RX ring */
455}
void atl_poll_tx(struct net_device *netdev)
Poll for completed packets.
Definition aqc1xx.c:374
void atl_poll_rx(struct net_device *netdev)
Poll for received packets.
Definition aqc1xx.c:403
void atl_check_link(struct net_device *netdev)
Definition aqc1xx.c:348

References atl_check_link(), atl_poll_rx(), atl_poll_tx(), atl_rx_ring_fill(), and netdev.

◆ atl_irq()

void atl_irq ( struct net_device * netdev,
int enable )
static

Enable or disable interrupts.

Parameters
netdevNetwork device
enableInterrupts should be enabled

Definition at line 463 of file aqc1xx.c.

463 {
464 struct atl_nic *nic = netdev->priv;
465 uint32_t mask;
466
467 mask = ( ATL_IRQ_TX | ATL_IRQ_RX );
468 if ( enable )
469 ATL_WRITE_REG ( mask, ATL_ITR_MSKS );
470 else
471 ATL_WRITE_REG ( mask, ATL_ITR_MSKC );
472}
#define ATL_ITR_MSKC
Definition aqc1xx.h:154

References ATL_IRQ_RX, ATL_IRQ_TX, ATL_ITR_MSKC, ATL_ITR_MSKS, ATL_WRITE_REG, and netdev.

◆ atl_probe()

int atl_probe ( struct pci_device * pci)
static

Probe PCI device.

Parameters
pciPCI device
Return values
rcReturn status code

Definition at line 496 of file aqc1xx.c.

496 {
497 struct net_device *netdev;
498 struct atl_nic *nic;
499 int rc = ENOERR;
500 uint32_t io_size = 0;
501
502 /* Allocate and initialise net device */
503 netdev = alloc_etherdev ( sizeof( *nic ) );
504 if ( !netdev ) {
505 rc = -ENOMEM;
506 goto err_alloc;
507 }
509 nic = netdev->priv;
510 pci_set_drvdata ( pci, netdev );
511 netdev->dev = &pci->dev;
512 memset( nic, 0, sizeof ( *nic ) );
513 nic->flags = pci->id->driver_data;
514
515 /* Fix up PCI device */
516 adjust_pci_device ( pci );
517
518 switch ( nic->flags ) {
519 case ATL_FLAG_A1:
520 nic->hw_ops = &atl_hw;
521 io_size = ATL_BAR_SIZE;
522 break;
523 case ATL_FLAG_A2:
524 nic->hw_ops = &atl2_hw;
525 io_size = ATL2_BAR_SIZE;
526 break;
527 default:
528 goto err_unsupported;
529 break;
530 }
531
532 /* Map registers */
533 nic->regs = pci_ioremap ( pci, pci->membase, io_size );
534 if ( !nic->regs ) {
535 rc = -ENODEV;
536 goto err_ioremap;
537 }
538
539 /* Configure DMA */
540 nic->dma = &pci->dma;
541 dma_set_mask_64bit ( nic->dma );
542 netdev->dma = nic->dma;
543
544 /* Reset the NIC */
545 if ( ( rc = nic->hw_ops->reset ( nic ) ) != 0 )
546 goto err_reset;
547
548 /* Get MAC Address */
549 if ( ( rc = nic->hw_ops->get_mac ( nic, netdev->hw_addr ) ) != 0 )
550 goto err_mac;
551
552 /* Register network device */
553 if ( ( rc = register_netdev ( netdev ) ) != 0 )
554 goto err_register_netdev;
555
556 /* Set initial link state */
558
559 return 0;
560
561err_register_netdev:
562err_mac:
563 nic->hw_ops->reset ( nic );
564err_reset:
565 iounmap ( nic->regs );
566err_ioremap:
568 netdev_put ( netdev );
569err_unsupported:
570err_alloc:
571 return rc;
572}
struct atl_hw_ops atl2_hw
Definition atl2_hw.c:220
static struct net_device_operations atl_operations
Marvell network device operations.
Definition aqc1xx.c:475
struct atl_hw_ops atl_hw
Definition atl_hw.c:308
#define ATL_BAR_SIZE
Definition aqc1xx.h:40
#define ATL_FLAG_A1
Definition aqc1xx.h:176
#define ATL2_BAR_SIZE
Definition aqc1xx.h:41
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition ethernet.c:266
#define ENOERR
Operation completed successfully.
Definition errno.h:332
#define ENODEV
No such device.
Definition errno.h:553
void iounmap(volatile const void *io_addr)
Unmap I/O address.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
static __always_inline void dma_set_mask_64bit(struct dma_device *dma)
Set 64-bit addressable space mask.
Definition dma.h:467
int register_netdev(struct net_device *netdev)
Register network device.
Definition netdevice.c:760
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition netdevice.h:522
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition netdevice.h:535
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition netdevice.h:579
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition pci.c:255
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition pci.h:370
A network device.
Definition netdevice.h:353
unsigned long driver_data
Arbitrary driver data.
Definition pci.h:186
unsigned long membase
Memory base.
Definition pci.h:223
struct device dev
Generic device.
Definition pci.h:216
struct pci_device_id * id
Driver device ID.
Definition pci.h:251
struct dma_device dma
DMA device.
Definition pci.h:218

References adjust_pci_device(), alloc_etherdev(), ATL2_BAR_SIZE, atl2_hw, ATL_BAR_SIZE, ATL_FLAG_A1, ATL_FLAG_A2, atl_hw, atl_operations, pci_device::dev, pci_device::dma, dma_set_mask_64bit(), pci_device_id::driver_data, ENODEV, ENOERR, ENOMEM, nic::flags, pci_device::id, iounmap(), pci_device::membase, memset(), netdev, netdev_init(), netdev_link_down(), netdev_nullify(), netdev_put(), pci_ioremap(), pci_set_drvdata(), rc, and register_netdev().

◆ atl_remove()

void atl_remove ( struct pci_device * pci)
static

Remove PCI device.

Parameters
pciPCI device

Definition at line 579 of file aqc1xx.c.

579 {
580 struct net_device *netdev = pci_get_drvdata ( pci );
581 struct atl_nic *nic = netdev->priv;
582
583 /* Unregister network device */
585
586 /* Reset the NIC */
587 nic->hw_ops->reset ( nic );
588
589 /* Free network device */
590 iounmap ( nic->regs );
592 netdev_put ( netdev );
593}
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition netdevice.c:946
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition pci.h:380

References iounmap(), netdev, netdev_nullify(), netdev_put(), pci_get_drvdata(), and unregister_netdev().

Variable Documentation

◆ atl_hw

struct atl_hw_ops atl_hw
extern

Definition at line 308 of file atl_hw.c.

308 {
309 .reset = atl_hw_reset,
310 .start = atl_hw_start,
311 .stop = atl_hw_stop,
312 .get_link = atl_hw_get_link,
313 .get_mac = atl_hw_get_mac,
314};
int atl_hw_get_mac(struct atl_nic *nic, uint8_t *mac)
Definition atl_hw.c:289
int atl_hw_stop(struct atl_nic *nic)
Definition atl_hw.c:242
int atl_hw_reset(struct atl_nic *nic)
Definition atl_hw.c:188
int atl_hw_start(struct atl_nic *nic)
Definition atl_hw.c:237
int atl_hw_get_link(struct atl_nic *nic)
Definition atl_hw.c:247

Referenced by atl_probe(), and FILE_LICENCE().

◆ atl2_hw

struct atl_hw_ops atl2_hw
extern

Definition at line 220 of file atl2_hw.c.

220 {
221 .reset = atl2_hw_reset,
222 .start = atl2_hw_start,
223 .stop = atl2_hw_stop,
224 .get_link = atl2_hw_get_link,
225 .get_mac = atl2_hw_get_mac,
226};
int atl2_hw_reset(struct atl_nic *nic)
Definition atl2_hw.c:112
int atl2_hw_start(struct atl_nic *nic)
Definition atl2_hw.c:182
int atl2_hw_get_mac(struct atl_nic *nic, uint8_t *mac)
Definition atl2_hw.c:210
int atl2_hw_stop(struct atl_nic *nic)
Definition atl2_hw.c:192
int atl2_hw_get_link(struct atl_nic *nic)
Definition atl2_hw.c:202

Referenced by atl_probe(), and FILE_LICENCE().

◆ atl_operations

struct net_device_operations atl_operations
static
Initial value:
= {
.open = atl_open,
.close = atl_close,
.transmit = atl_transmit,
.poll = atl_poll,
.irq = atl_irq,
}
static void atl_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition aqc1xx.c:441
int atl_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition aqc1xx.c:302
static void atl_close(struct net_device *netdev)
Close network device.
Definition aqc1xx.c:263
static void atl_irq(struct net_device *netdev, int enable)
Enable or disable interrupts.
Definition aqc1xx.c:463
static int atl_open(struct net_device *netdev)
Open network device.
Definition aqc1xx.c:161

Marvell network device operations.

Definition at line 475 of file aqc1xx.c.

475 {
476 .open = atl_open,
477 .close = atl_close,
478 .transmit = atl_transmit,
479 .poll = atl_poll,
480 .irq = atl_irq,
481};

Referenced by atl_probe().

◆ atl_nics

struct pci_device_id atl_nics[]
static

Marvell PCI device IDs.

Definition at line 596 of file aqc1xx.c.

596 {
597 /* Atlantic 1 */
598 /* 10G */
599 PCI_ROM ( 0x1D6A, 0x0001, "AQC07", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A1 ),
600 PCI_ROM ( 0x1D6A, 0xD107, "AQC07", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A1 ),
601 PCI_ROM ( 0x1D6A, 0x07B1, "AQC07", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A1 ),
602 PCI_ROM ( 0x1D6A, 0x87B1, "AQC07", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A1 ),
603
604 /* SFP */
605 PCI_ROM ( 0x1D6A, 0xD100, "AQC00", "Felicity Network Adapter", ATL_FLAG_A1 ),
606 PCI_ROM ( 0x1D6A, 0x00B1, "AQC00", "Felicity Network Adapter", ATL_FLAG_A1 ),
607 PCI_ROM ( 0x1D6A, 0x80B1, "AQC00", "Felicity Network Adapter", ATL_FLAG_A1 ),
608
609 /* 5G */
610 PCI_ROM ( 0x1D6A, 0xD108, "AQC08", "Marvell AQtion 5Gbit Network Adapter", ATL_FLAG_A1 ),
611 PCI_ROM ( 0x1D6A, 0x08B1, "AQC08", "Marvell AQtion 5Gbit Network Adapter", ATL_FLAG_A1 ),
612 PCI_ROM ( 0x1D6A, 0x88B1, "AQC08", "Marvell AQtion 5Gbit Network Adapter", ATL_FLAG_A1 ),
613 PCI_ROM ( 0x1D6A, 0x11B1, "AQC11", "Marvell AQtion 5Gbit Network Adapter", ATL_FLAG_A1 ),
614 PCI_ROM ( 0x1D6A, 0x91B1, "AQC11", "Marvell AQtion 5Gbit Network Adapter", ATL_FLAG_A1 ),
615
616 /* 2.5G */
617 PCI_ROM ( 0x1D6A, 0xD109, "AQC09", "Marvell AQtion 2.5Gbit Network Adapter", ATL_FLAG_A1 ),
618 PCI_ROM ( 0x1D6A, 0x09B1, "AQC09", "Marvell AQtion 2.5Gbit Network Adapter", ATL_FLAG_A1 ),
619 PCI_ROM ( 0x1D6A, 0x89B1, "AQC09", "Marvell AQtion 2.5Gbit Network Adapter", ATL_FLAG_A1 ),
620 PCI_ROM ( 0x1D6A, 0x12B1, "AQC12", "Marvell AQtion 2.5Gbit Network Adapter", ATL_FLAG_A1 ),
621 PCI_ROM ( 0x1D6A, 0x92B1, "AQC12", "Marvell AQtion 2.5Gbit Network Adapter", ATL_FLAG_A1 ),
622
623 /* Atlantic 2 */
624 PCI_ROM ( 0x1D6A, 0x00C0, "AQC13", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A2 ),
625 PCI_ROM ( 0x1D6A, 0x94C0, "AQC13", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A2 ),
626 PCI_ROM ( 0x1D6A, 0x93C0, "AQC13", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A2 ),
627 PCI_ROM ( 0x1D6A, 0x04C0, "AQC13", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A2 ),
628 PCI_ROM ( 0x1D6A, 0x14C0, "AQC13", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A2 ),
629 PCI_ROM ( 0x1D6A, 0x12C0, "AQC13", "Marvell AQtion 10Gbit Network Adapter", ATL_FLAG_A2 ),
630 PCI_ROM ( 0x1D6A, 0x03C0, "AQC14", "Marvell AQtion 5Gbit Network Adapter", ATL_FLAG_A2 ),
631};
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition pci.h:311

◆ __pci_driver

struct pci_driver atl_driver __pci_driver
Initial value:
= {
.ids = atl_nics,
.id_count = ( sizeof( atl_nics ) / sizeof ( atl_nics[0] ) ),
.probe = atl_probe,
}
static void atl_remove(struct pci_device *pci)
Remove PCI device.
Definition aqc1xx.c:579
static int atl_probe(struct pci_device *pci)
Probe PCI device.
Definition aqc1xx.c:496
static struct pci_device_id atl_nics[]
Marvell PCI device IDs.
Definition aqc1xx.c:596
static struct xen_remove_from_physmap * remove
Definition xenmem.h:40

Marvell PCI driver.

Definition at line 634 of file aqc1xx.c.

634 {
635 .ids = atl_nics,
636 .id_count = ( sizeof( atl_nics ) / sizeof ( atl_nics[0] ) ),
637 .probe = atl_probe,
639};