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:505
#define ENOMEM
Not enough space.
Definition errno.h:535
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:322
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:50
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:268
A persistent I/O buffer.
Definition iobuf.h:38
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
266 nic->hw_ops->stop ( nic );
267 /* rpb global ctrl */
269 /* tgb global ctrl */
271
276
277 /* clear itr mask */
279
280 /* Reset the NIC */
281 nic->hw_ops->reset ( nic );
282
283 atl_ring_free ( &nic->tx_ring );
284 atl_ring_free ( &nic->rx_ring );
285}
#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

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_TX_CTRL, ATL_RING_TX_CTRL_EN, ATL_RPB_CTRL, ATL_RPB_CTRL_DIS, ATL_TPB_CTRL, ATL_TPB_CTRL_DIS, ATL_WRITE_REG, and netdev.

◆ 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 294 of file aqc1xx.c.

294 {
295 struct atl_nic *nic = netdev->priv;
296 struct atl_desc_tx *tx;
299
300 /* Get next transmit descriptor */
301 if ( atl_ring_full ( &nic->tx_ring ) ) {
302 DBGC ( nic, "AQUANTIA: %p out of transmit descriptors\n", nic );
303 return -ENOBUFS;
304 }
305
306 tx = ( struct atl_desc_tx * )nic->tx_ring.ring + nic->tx_ring.sw_tail;
307
308 /* Populate transmit descriptor */
309 memset ( tx, 0, sizeof ( *tx ) );
310 address = iob_dma ( iobuf );
311 tx->address = address;
312 len = iob_len ( iobuf );
313
314 tx->status = 0x1;
315 tx->status = ( (tx->status) & ~ATL_DESC_TX_BUF_LEN_MASK) |
318 tx->status = ((tx->status) & ~ATL_DESC_TX_EOP_MASK) |
321 tx->status = ( (tx->status) & ~ATL_DESC_TX_CMD_MASK) |
324 tx->flag = ( (tx->flag) & ~ATL_DESC_TX_PAY_LEN_MASK) |
327 wmb();
328
329 DBGC2 ( nic, "AQUANTIA: %p TX[%d] is [%llx, %llx]\n",
330 nic, nic->tx_ring.sw_tail,
331 ( ( unsigned long long ) address ),
332 ( ( unsigned long long ) address + len ) );
333
334 atl_ring_next_dx ( &nic->tx_ring.sw_tail );
335 ATL_WRITE_REG ( nic->tx_ring.sw_tail, ATL_RING_TAIL );
336
337 return 0;
338}
#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:522
#define ENOBUFS
No buffer space available.
Definition errno.h:499
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition iobuf.h:160
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 340 of file aqc1xx.c.

340 {
341 struct atl_nic *nic = netdev->priv;
343
344 /* Read link status */
345 link_state = nic->hw_ops->get_link ( nic );
346
347 DBGC ( nic, "AQUANTIA: %p link status is %08x\n", nic, link_state );
348
349 if ( link_state != nic->link_state ) {
350 if ( link_state ) {
351 DBGC ( nic, "AQUANTIA: link up\n");
353 } else {
354 DBGC ( nic, "AQUANTIA: link lost\n");
356 }
357 nic->link_state = link_state;
358 }
359}
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:789
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 366 of file aqc1xx.c.

366 {
367 struct atl_nic *nic = netdev->priv;
368 struct atl_desc_tx_wb *tx;
369
370 /* Check for completed packets */
371 while ( nic->tx_ring.sw_head != nic->tx_ring.sw_tail ) {
372
373 /* Get next transmit descriptor */
374 tx = ( struct atl_desc_tx_wb * )nic->tx_ring.ring +
375 nic->tx_ring.sw_head;
376
377 /* Stop if descriptor is still in use */
378 if ( !( tx->status & cpu_to_le32 ( ATL_TX_DESC_STATUS_DD ) ) )
379 return;
380
381 DBGC2 ( nic, "AQUANTIA: %p TX[%d] complete\n",
382 nic, nic->tx_ring.sw_head );
383
384 /* Complete TX descriptor */
385 atl_ring_next_dx ( &nic->tx_ring.sw_head );
387 }
388}
#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:779

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 395 of file aqc1xx.c.

395 {
396 struct atl_nic *nic = netdev->priv;
397 struct atl_desc_rx_wb *rx;
398 struct io_buffer *iobuf;
399 size_t len;
400
401 /* Check for received packets */
402 while ( nic->rx_ring.sw_head != nic->rx_ring.sw_tail ) {
403
404 /* Get next receive descriptor */
405 rx = ( struct atl_desc_rx_wb * )nic->rx_ring.ring +
406 nic->rx_ring.sw_head;
407
408 /* Stop if descriptor is still in use */
409 if ( !( rx->status & cpu_to_le16( ATL_RX_DESC_STATUS_DD ) ) )
410 return;
411
412 /* Populate I/O buffer */
413 iobuf = nic->iobufs[nic->rx_ring.sw_head];
414 nic->iobufs[nic->rx_ring.sw_head] = NULL;
415 len = le16_to_cpu ( rx->pkt_len );
416 iob_put ( iobuf, len );
417
418 /* Hand off to network stack */
419 DBGC ( nic, "AQUANTIA: %p RX[%d] complete (length %zd)\n",
420 nic, nic->rx_ring.sw_head, len );
421
422 netdev_rx ( netdev, iobuf );
423
424 atl_ring_next_dx ( &nic->rx_ring.sw_head );
425 }
426}
#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:125
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 433 of file aqc1xx.c.

433 {
434 struct atl_nic *nic = netdev->priv;
435
436 /* Check link state */
438
439 /* Poll for TX completions */
441
442 /* Poll for RX completions */
444
445 /* Refill RX ring */
447}
void atl_poll_tx(struct net_device *netdev)
Poll for completed packets.
Definition aqc1xx.c:366
void atl_poll_rx(struct net_device *netdev)
Poll for received packets.
Definition aqc1xx.c:395
void atl_check_link(struct net_device *netdev)
Definition aqc1xx.c:340

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 455 of file aqc1xx.c.

455 {
456 struct atl_nic *nic = netdev->priv;
457 uint32_t mask;
458
459 mask = ( ATL_IRQ_TX | ATL_IRQ_RX );
460 if ( enable )
461 ATL_WRITE_REG ( mask, ATL_ITR_MSKS );
462 else
463 ATL_WRITE_REG ( mask, ATL_ITR_MSKC );
464}
#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 488 of file aqc1xx.c.

488 {
489 struct net_device *netdev;
490 struct atl_nic *nic;
491 int rc = ENOERR;
492 uint32_t io_size = 0;
493
494 /* Allocate and initialise net device */
495 netdev = alloc_etherdev ( sizeof( *nic ) );
496 if ( !netdev ) {
497 rc = -ENOMEM;
498 goto err_alloc;
499 }
501 nic = netdev->priv;
502 pci_set_drvdata ( pci, netdev );
503 netdev->dev = &pci->dev;
504 memset( nic, 0, sizeof ( *nic ) );
505 nic->flags = pci->id->driver_data;
506
507 /* Fix up PCI device */
508 adjust_pci_device ( pci );
509
510 switch ( nic->flags ) {
511 case ATL_FLAG_A1:
512 nic->hw_ops = &atl_hw;
513 io_size = ATL_BAR_SIZE;
514 break;
515 case ATL_FLAG_A2:
516 nic->hw_ops = &atl2_hw;
517 io_size = ATL2_BAR_SIZE;
518 break;
519 default:
520 goto err_unsupported;
521 break;
522 }
523
524 /* Map registers */
525 nic->regs = pci_ioremap ( pci, pci->membase, io_size );
526 if ( !nic->regs ) {
527 rc = -ENODEV;
528 goto err_ioremap;
529 }
530
531 /* Configure DMA */
532 nic->dma = &pci->dma;
533
534 /* Reset the NIC */
535 if ( ( rc = nic->hw_ops->reset ( nic ) ) != 0 )
536 goto err_reset;
537
538 /* Get MAC Address */
539 if ( ( rc = nic->hw_ops->get_mac ( nic, netdev->hw_addr ) ) != 0 )
540 goto err_mac;
541
542 /* Register network device */
543 if ( ( rc = register_netdev ( netdev ) ) != 0 )
544 goto err_register_netdev;
545
546 /* Set initial link state */
548
549 return 0;
550
551err_register_netdev:
552err_mac:
553 nic->hw_ops->reset ( nic );
554err_reset:
555 iounmap ( nic->regs );
556err_ioremap:
558 netdev_put ( netdev );
559err_unsupported:
560err_alloc:
561 return rc;
562}
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:467
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:265
#define ENOERR
Operation completed successfully.
Definition errno.h:289
#define ENODEV
No such device.
Definition errno.h:510
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.
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:519
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition netdevice.h:532
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition netdevice.h:576
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition pci.c:241
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition pci.h:366
A network device.
Definition netdevice.h:353
unsigned long driver_data
Arbitrary driver data.
Definition pci.h:183
unsigned long membase
Memory base.
Definition pci.h:220
struct device dev
Generic device.
Definition pci.h:213
struct pci_device_id * id
Driver device ID.
Definition pci.h:248
struct dma_device dma
DMA device.
Definition pci.h:215

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, 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 569 of file aqc1xx.c.

569 {
570 struct net_device *netdev = pci_get_drvdata ( pci );
571 struct atl_nic *nic = netdev->priv;
572
573 /* Unregister network device */
575
576 /* Reset the NIC */
577 nic->hw_ops->reset ( nic );
578
579 /* Free network device */
580 iounmap ( nic->regs );
582 netdev_put ( netdev );
583}
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition netdevice.c:942
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition pci.h:376

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:433
int atl_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition aqc1xx.c:294
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:455
static int atl_open(struct net_device *netdev)
Open network device.
Definition aqc1xx.c:161

Marvell network device operations.

Definition at line 467 of file aqc1xx.c.

467 {
468 .open = atl_open,
469 .close = atl_close,
470 .transmit = atl_transmit,
471 .poll = atl_poll,
472 .irq = atl_irq,
473};

Referenced by atl_probe().

◆ atl_nics

struct pci_device_id atl_nics[]
static

Marvell PCI device IDs.

Definition at line 586 of file aqc1xx.c.

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

◆ __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:569
static int atl_probe(struct pci_device *pci)
Probe PCI device.
Definition aqc1xx.c:488
static struct pci_device_id atl_nics[]
Marvell PCI device IDs.
Definition aqc1xx.c:586
static struct xen_remove_from_physmap * remove
Definition xenmem.h:39

Marvell PCI driver.

Definition at line 624 of file aqc1xx.c.

624 {
625 .ids = atl_nics,
626 .id_count = ( sizeof( atl_nics ) / sizeof ( atl_nics[0] ) ),
627 .probe = atl_probe,
629};