iPXE
Functions | Variables
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. More...
 
static void atl_close (struct net_device *netdev)
 Close network device. More...
 
int atl_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet. More...
 
void atl_check_link (struct net_device *netdev)
 
void atl_poll_tx (struct net_device *netdev)
 Poll for completed packets. More...
 
void atl_poll_rx (struct net_device *netdev)
 Poll for received packets. More...
 
static void atl_poll (struct net_device *netdev)
 Poll for completed and received packets. More...
 
static void atl_irq (struct net_device *netdev, int enable)
 Enable or disable interrupts. More...
 
static int atl_probe (struct pci_device *pci)
 Probe PCI device. More...
 
static void atl_remove (struct pci_device *pci)
 Remove PCI device. More...
 

Variables

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

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  )

◆ atl_ring_alloc()

static 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 }
unsigned int length
Definition: aqc1xx.h:234
unsigned int sw_tail
Definition: aqc1xx.h:229
#define DBGC(...)
Definition: compiler.h:505
unsigned long long uint64_t
Definition: stdint.h:13
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define ATL_RING_SIZE
Definition: aqc1xx.h:42
#define ATL_WRITE_REG(VAL, REG)
Definition: aqc1xx.h:180
struct dma_mapping map
Descriptor ring DMA mapping.
Definition: aqc1xx.h:233
unsigned int sw_head
Definition: aqc1xx.h:230
Definition: nic.h:49
unsigned int uint32_t
Definition: stdint.h:12
void * dma_alloc(struct dma_device *dma, struct dma_mapping *map, size_t len, size_t align)
Allocate and map DMA-coherent buffer.
unsigned long physaddr_t
Definition: stdint.h:20
void * ring
Definition: aqc1xx.h:231
static __always_inline physaddr_t dma(struct dma_mapping *map, void *addr)
Get DMA address from virtual address.
Definition: dma.h:436
void * memset(void *dest, int character, size_t len) __nonnull

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()

static 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 }
unsigned int length
Definition: aqc1xx.h:234
void dma_free(struct dma_mapping *map, void *addr, size_t len)
Unmap and free DMA-coherent buffer.
struct dma_mapping map
Descriptor ring DMA mapping.
Definition: aqc1xx.h:233
void * ring
Definition: aqc1xx.h:231
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

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()

static 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
#define ATL_RING_SIZE
Definition: aqc1xx.h:42

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
unsigned int sw_tail
Definition: aqc1xx.h:229
unsigned int sw_head
Definition: aqc1xx.h:230

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 }
wmb()
static void atl_ring_next_dx(unsigned int *val)
Definition: aqc1xx.c:98
uint64_t address
Base address.
Definition: ena.h:24
#define DBGC(...)
Definition: compiler.h:505
#define ATL_RX_MAX_LEN
Definition: aqc1xx.h:44
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static __always_inline physaddr_t iob_dma(struct io_buffer *iobuf)
Get I/O buffer DMA address.
Definition: iobuf.h:264
#define ATL_WRITE_REG(VAL, REG)
Definition: aqc1xx.h:180
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:181
#define ATL_RING_TAIL_PTR
Definition: aqc1xx.h:148
Definition: nic.h:49
unsigned long physaddr_t
Definition: stdint.h:20
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
Definition: wpa.h:234
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
int atl_ring_full(const struct atl_ring *ring)
Definition: aqc1xx.c:104
A persistent I/O buffer.
Definition: iobuf.h:33

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()

static 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 
245  atl_rx_ring_fill ( nic );
246 
247  nic->hw_ops->start ( nic );
248 
249  return 0;
250 
251 err_rx_alloc:
252  atl_ring_free ( &nic->tx_ring );
253 
254 err_tx_alloc:
255  return -ENOMEM;
256 }
An aQuanita network card.
Definition: aqc1xx.h:248
#define ATL_TPB0_CTRL2_HIGH_TSH
Definition: aqc1xx.h:136
#define ATL_RPF2_CTRL
Definition: aqc1xx.h:85
#define ATL_RPB0_CTRL1_SIZE
Definition: aqc1xx.h:106
#define ATL_TX_DMA_DESC_ADDR
Definition: aqc1xx.h:138
#define ATL_IRQ_CTRL_COR_EN
Definition: aqc1xx.h:54
#define ATL_TPO2_EN
Definition: aqc1xx.h:121
int flags
Definition: nic.h:51
#define ATL_IRQ_CTRL_REG_RST_DIS
Definition: aqc1xx.h:55
#define ATL_RPF_CTRL2_VLAN_PROMISC
Definition: aqc1xx.h:97
void atl_rx_ring_fill(struct atl_nic *nic)
Definition: aqc1xx.c:110
#define ATL_RING_TX_CTRL
Definition: aqc1xx.h:141
#define ATL_RX_DMA_DESC_ADDR
Definition: aqc1xx.h:117
#define ATL_IRQ_MAP_REG1
Definition: aqc1xx.h:58
static void atl_ring_free(struct atl_ring *ring)
Definition: aqc1xx.c:92
#define ATL2_RPF_NEW_EN_ADR_EN
Definition: aqc1xx.h:87
#define ATL_TX_IRQ_CTRL
Definition: aqc1xx.h:67
#define ATL_IRQ_MAP_REG1_TX0
Definition: aqc1xx.h:64
#define ATL_IRQ_MAP_REG1_TX0_EN
Definition: aqc1xx.h:63
#define ATL_RX_MAX_LEN
Definition: aqc1xx.h:44
#define ATL2_RPF_NEW_EN_ADR
Definition: aqc1xx.h:88
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define ATL_RPF_CTRL1_BRC_EN
Definition: aqc1xx.h:91
#define ATL_RING_RX_CTRL
Definition: aqc1xx.h:144
#define ATL_RPF_CTRL1_L2_PROMISC
Definition: aqc1xx.h:92
#define ATL_RPB_CTRL_FC
Definition: aqc1xx.h:102
#define ATL_TPB0_CTRL2_LOW_TSH
Definition: aqc1xx.h:134
void * priv
Driver private data.
Definition: netdevice.h:431
#define ATL_RPB_CTRL
Definition: aqc1xx.h:100
static struct net_device * netdev
Definition: gdbudp.c:52
#define ATL_WRITE_REG(VAL, REG)
Definition: aqc1xx.h:180
#define ATL_TPB_CTRL_PAD_EN
Definition: aqc1xx.h:126
#define ATL_RPF_CTRL2
Definition: aqc1xx.h:96
#define ATL_RPB_CTRL_EN
Definition: aqc1xx.h:101
#define ATL_IRQ_RX
Definition: aqc1xx.h:47
#define ATL_TPB0_CTRL1
Definition: aqc1xx.h:129
#define ATL_READ_REG(REG)
Definition: aqc1xx.h:181
#define ATL_TPB0_CTRL1_SIZE
Definition: aqc1xx.h:130
Definition: nic.h:49
unsigned int uint32_t
Definition: stdint.h:12
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
#define ATL_IRQ_MAP_REG1_RX0
Definition: aqc1xx.h:61
#define ATL_IRQ_MAP_REG1_RX0_EN
Definition: aqc1xx.h:60
#define ATL_IRQ_CTRL
Definition: aqc1xx.h:53
#define ATL_TPO2_CTRL
Definition: aqc1xx.h:120
#define ATL_RPF_CTRL1_ACTION
Definition: aqc1xx.h:93
#define ATL_RPB0_CTRL2
Definition: aqc1xx.h:108
#define ATL_RPF2_CTRL_EN
Definition: aqc1xx.h:86
#define ATL_RX_DMA_DESC_BUF_SIZE
Definition: aqc1xx.h:116
#define ATL_RING_RX_CTRL_EN
Definition: aqc1xx.h:145
#define ATL_RX_IRQ_CTRL
Definition: aqc1xx.h:71
#define ATL_TPB_CTRL_EN
Definition: aqc1xx.h:125
#define ATL_RPB0_CTRL1
Definition: aqc1xx.h:105
u8 ctrl
Definition: sky2.h:10
#define ATL_TX_IRQ_CTRL_WB_EN
Definition: aqc1xx.h:68
#define ATL_RPF_CTRL1
Definition: aqc1xx.h:90
#define ATL_RPB0_CTRL2_FC_EN
Definition: aqc1xx.h:114
#define ATL_FLAG_A2
Definition: aqc1xx.h:177
#define ATL_RING_TX_CTRL_EN
Definition: aqc1xx.h:142
#define ATL_TPB0_CTRL2
Definition: aqc1xx.h:132
#define ATL_ITR_MSKS
Definition: aqc1xx.h:152
#define ATL_RPB0_CTRL2_LOW_TSH
Definition: aqc1xx.h:111
#define ATL_TPB_CTRL
Definition: aqc1xx.h:124
#define ATL_IRQ_TX
Definition: aqc1xx.h:46
#define ATL_RPB0_CTRL2_HIGH_TSH
Definition: aqc1xx.h:113
#define ATL_RPF_CTRL1_BRC_TSH
Definition: aqc1xx.h:94
#define ATL_RX_IRQ_CTRL_WB_EN
Definition: aqc1xx.h:72

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, netdev, and net_device::priv.

◆ atl_close()

static 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_TPB_CTRL_DIS
Definition: aqc1xx.h:123
An aQuanita network card.
Definition: aqc1xx.h:248
#define ATL_ITR_MSKS_DIS
Definition: aqc1xx.h:151
#define ATL_RING_TX_CTRL
Definition: aqc1xx.h:141
static void atl_ring_free(struct atl_ring *ring)
Definition: aqc1xx.c:92
#define ATL_RING_RX_CTRL
Definition: aqc1xx.h:144
void * priv
Driver private data.
Definition: netdevice.h:431
#define ATL_RPB_CTRL
Definition: aqc1xx.h:100
static struct net_device * netdev
Definition: gdbudp.c:52
#define ATL_WRITE_REG(VAL, REG)
Definition: aqc1xx.h:180
#define ATL_READ_REG(REG)
Definition: aqc1xx.h:181
Definition: nic.h:49
#define ATL_RPB_CTRL_DIS
Definition: aqc1xx.h:99
#define ATL_RING_RX_CTRL_EN
Definition: aqc1xx.h:145
#define ATL_RING_TX_CTRL_EN
Definition: aqc1xx.h:142
#define ATL_ITR_MSKS
Definition: aqc1xx.h:152
#define ATL_TPB_CTRL
Definition: aqc1xx.h:124

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, netdev, and net_device::priv.

◆ 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;
298  uint32_t len;
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 }
An aQuanita network card.
Definition: aqc1xx.h:248
wmb()
static void atl_ring_next_dx(unsigned int *val)
Definition: aqc1xx.c:98
#define ATL_DESC_TX_CMD_VALUE
Definition: aqc1xx.h:197
#define ATL_DESC_TX_BUF_LEN_MASK
Definition: aqc1xx.h:199
uint64_t address
Base address.
Definition: ena.h:24
#define DBGC(...)
Definition: compiler.h:505
#define ATL_DESC_TX_DX_EOP_VALUE
Definition: aqc1xx.h:191
#define ATL_DESC_TX_EOP_MASK
Definition: aqc1xx.h:192
#define ATL_RING_TAIL
Definition: aqc1xx.h:147
#define ATL_DESC_TX_BUF_LEN_OFFSET
Definition: aqc1xx.h:200
#define ATL_DESC_TX_PAY_LEN_OFFSET
Definition: aqc1xx.h:203
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
static __always_inline physaddr_t iob_dma(struct io_buffer *iobuf)
Get I/O buffer DMA address.
Definition: iobuf.h:264
#define ATL_WRITE_REG(VAL, REG)
Definition: aqc1xx.h:180
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
Definition: nic.h:49
unsigned int uint32_t
Definition: stdint.h:12
unsigned long physaddr_t
Definition: stdint.h:20
#define ATL_DESC_TX_EOP_OFFSET
Definition: aqc1xx.h:193
#define ATL_DESC_TX_CMD_OFFSET
Definition: aqc1xx.h:196
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
#define DBGC2(...)
Definition: compiler.h:522
#define ATL_DESC_TX_PAY_LEN_MASK
Definition: aqc1xx.h:202
#define ATL_DESC_TX_CMD_MASK
Definition: aqc1xx.h:195
uint32_t len
Length.
Definition: ena.h:14
int atl_ring_full(const struct atl_ring *ring)
Definition: aqc1xx.c:104
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
Definition: wpa.h:237
void * memset(void *dest, int character, size_t len) __nonnull

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, net_device::priv, 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 }
An aQuanita network card.
Definition: aqc1xx.h:248
uint32_t link_state
Definition: aqc1xx.h:260
#define DBGC(...)
Definition: compiler.h:505
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:230
void * priv
Driver private data.
Definition: netdevice.h:431
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:774
static struct net_device * netdev
Definition: gdbudp.c:52
Definition: nic.h:49
unsigned int uint32_t
Definition: stdint.h:12

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

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 }
An aQuanita network card.
Definition: aqc1xx.h:248
static void atl_ring_next_dx(unsigned int *val)
Definition: aqc1xx.c:98
#define ATL_TX_DESC_STATUS_DD
Definition: aqc1xx.h:211
static void netdev_tx_complete_next(struct net_device *netdev)
Complete network transmission.
Definition: netdevice.h:764
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
#define cpu_to_le32(value)
Definition: byteswap.h:107
Definition: nic.h:49
#define DBGC2(...)
Definition: compiler.h:522
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
Definition: wpa.h:237
if(natsemi->flags &NATSEMI_64BIT) return 1

References atl_ring_next_dx(), ATL_TX_DESC_STATUS_DD, cpu_to_le32, DBGC2, if(), netdev, netdev_tx_complete_next(), net_device::priv, 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 }
An aQuanita network card.
Definition: aqc1xx.h:248
#define iob_put(iobuf, len)
Definition: iobuf.h:120
static void atl_ring_next_dx(unsigned int *val)
Definition: aqc1xx.c:98
#define DBGC(...)
Definition: compiler.h:505
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
#define ATL_RX_DESC_STATUS_DD
Definition: aqc1xx.h:226
#define le16_to_cpu(value)
Definition: byteswap.h:112
Definition: nic.h:49
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition: netdevice.c:548
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
Definition: wpa.h:234
#define cpu_to_le16(value)
Definition: byteswap.h:106
uint32_t len
Length.
Definition: ena.h:14
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
if(natsemi->flags &NATSEMI_64BIT) return 1
A persistent I/O buffer.
Definition: iobuf.h:33

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

Referenced by atl_poll().

◆ atl_poll()

static 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 */
440  atl_poll_tx ( netdev );
441 
442  /* Poll for RX completions */
443  atl_poll_rx ( netdev );
444 
445  /* Refill RX ring */
446  atl_rx_ring_fill ( nic );
447 }
An aQuanita network card.
Definition: aqc1xx.h:248
void atl_check_link(struct net_device *netdev)
Definition: aqc1xx.c:340
void atl_rx_ring_fill(struct atl_nic *nic)
Definition: aqc1xx.c:110
void atl_poll_rx(struct net_device *netdev)
Poll for received packets.
Definition: aqc1xx.c:395
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
Definition: nic.h:49
void atl_poll_tx(struct net_device *netdev)
Poll for completed packets.
Definition: aqc1xx.c:366

References atl_check_link(), atl_poll_rx(), atl_poll_tx(), atl_rx_ring_fill(), netdev, and net_device::priv.

◆ atl_irq()

static 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 }
An aQuanita network card.
Definition: aqc1xx.h:248
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
#define ATL_WRITE_REG(VAL, REG)
Definition: aqc1xx.h:180
#define ATL_IRQ_RX
Definition: aqc1xx.h:47
Definition: nic.h:49
unsigned int uint32_t
Definition: stdint.h:12
#define ATL_ITR_MSKS
Definition: aqc1xx.h:152
#define ATL_IRQ_TX
Definition: aqc1xx.h:46
#define ATL_ITR_MSKC
Definition: aqc1xx.h:154

References ATL_IRQ_RX, ATL_IRQ_TX, ATL_ITR_MSKC, ATL_ITR_MSKS, ATL_WRITE_REG, netdev, and net_device::priv.

◆ atl_probe()

static 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 
551 err_register_netdev:
552 err_mac:
553  nic->hw_ops->reset ( nic );
554 err_reset:
555  iounmap ( nic->regs );
556 err_ioremap:
558  netdev_put ( netdev );
559 err_unsupported:
560 err_alloc:
561  return rc;
562 }
An aQuanita network card.
Definition: aqc1xx.h:248
unsigned long membase
Memory base.
Definition: pci.h:215
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct dma_device dma
DMA device.
Definition: pci.h:210
int flags
Definition: nic.h:51
unsigned long driver_data
Arbitrary driver data.
Definition: pci.h:178
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:230
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:154
struct device dev
Generic device.
Definition: pci.h:208
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:515
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:359
#define ENOMEM
Not enough space.
Definition: errno.h:534
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
#define ATL_FLAG_A1
Definition: aqc1xx.h:176
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:759
struct atl_hw_ops atl_hw
Definition: atl_hw.c:307
A network device.
Definition: netdevice.h:352
#define ENODEV
No such device.
Definition: errno.h:509
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:528
Definition: nic.h:49
unsigned int uint32_t
Definition: stdint.h:12
struct atl_hw_ops atl2_hw
Definition: atl2_hw.c:219
struct device * dev
Underlying hardware device.
Definition: netdevice.h:364
#define ATL2_BAR_SIZE
Definition: aqc1xx.h:41
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
struct pci_device_id * id
Driver device ID.
Definition: pci.h:243
void iounmap(volatile const void *io_addr)
Unmap I/O address.
#define ENOERR
Operation completed successfully.
Definition: errno.h:288
#define ATL_FLAG_A2
Definition: aqc1xx.h:177
static struct net_device_operations atl_operations
Marvell network device operations.
Definition: aqc1xx.c:467
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
struct nic nic
Definition: legacy.c:22
#define ATL_BAR_SIZE
Definition: aqc1xx.h:40
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:381
void * memset(void *dest, int character, size_t len) __nonnull

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, net_device::dev, pci_device::dma, pci_device_id::driver_data, ENODEV, ENOERR, ENOMEM, nic::flags, net_device::hw_addr, pci_device::id, iounmap(), pci_device::membase, memset(), netdev, netdev_init(), netdev_link_down(), netdev_nullify(), netdev_put(), nic, pci_ioremap(), pci_set_drvdata(), net_device::priv, rc, and register_netdev().

◆ atl_remove()

static 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 }
An aQuanita network card.
Definition: aqc1xx.h:248
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:572
void * priv
Driver private data.
Definition: netdevice.h:431
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:941
A network device.
Definition: netdevice.h:352
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:528
Definition: nic.h:49
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:369
void iounmap(volatile const void *io_addr)
Unmap I/O address.

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

Variable Documentation

◆ atl_hw

struct atl_hw_ops atl_hw

Definition at line 307 of file atl_hw.c.

Referenced by atl_probe().

◆ atl2_hw

struct atl_hw_ops atl2_hw

Definition at line 219 of file atl2_hw.c.

Referenced by atl_probe().

◆ 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_close(struct net_device *netdev)
Close network device.
Definition: aqc1xx.c:263
static int atl_open(struct net_device *netdev)
Open network device.
Definition: aqc1xx.c:161
int atl_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: aqc1xx.c:294
static void atl_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition: aqc1xx.c:433
static void atl_irq(struct net_device *netdev, int enable)
Enable or disable interrupts.
Definition: aqc1xx.c:455

Marvell network device operations.

Definition at line 467 of file aqc1xx.c.

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.

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

Marvell PCI driver.

Definition at line 624 of file aqc1xx.c.