iPXE
dwmac.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 Michael Brown <mbrown@fensystems.co.uk>.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 *
19 * You can also choose to distribute this program under the terms of
20 * the Unmodified Binary Distribution Licence (as given in the file
21 * COPYING.UBDL), provided that you have satisfied its requirements.
22 */
23
24FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25
26#include <stdint.h>
27#include <string.h>
28#include <errno.h>
29#include <byteswap.h>
30#include <ipxe/netdevice.h>
31#include <ipxe/ethernet.h>
32#include <ipxe/if_ether.h>
33#include <ipxe/iobuf.h>
34#include <ipxe/timer.h>
35#include <ipxe/devtree.h>
36#include <ipxe/fdt.h>
37#include "dwmac.h"
38
39/** @file
40 *
41 * Synopsys DesignWare MAC network driver
42 *
43 */
44
45/******************************************************************************
46 *
47 * Debug
48 *
49 ******************************************************************************
50 */
51
52/**
53 * Dump MAC registers (for debugging)
54 *
55 * @v dwmac DesignWare MAC device
56 */
57static void dwmac_dump_mac ( struct dwmac *dwmac ) {
58
59 /* Do nothing unless debugging is enabled */
60 if ( ! DBG_LOG )
61 return;
62
63 /* Dump MAC registers */
64 DBGC ( dwmac, "DWMAC %s ver %08x cfg %08x flt %08x flo %08x\n",
68 readl ( dwmac->regs + DWMAC_FLOW ) );
69 DBGC ( dwmac, "DWMAC %s isr %08x dbg %08x gmi %08x\n",
72 readl ( dwmac->regs + DWMAC_GMII ) );
73}
74
75/**
76 * Dump DMA registers (for debugging)
77 *
78 * @v dwmac DesignWare MAC device
79 */
80static void dwmac_dump_dma ( struct dwmac *dwmac ) {
82
83 /* Do nothing unless debugging is enabled */
84 if ( ! DBG_LOG )
85 return;
86
87 /* Dump DMA registers */
89 DBGC ( dwmac, "DWMAC %s bus %08x fea %08x axi %08x ahb %08x\n",
93 readl ( dwmac->regs + DWMAC_AHB ) );
94 DBGC ( dwmac, "DWMAC %s opm %08x sta %08x drp %08x\n",
97 DBGC ( dwmac, "DWMAC %s txb %08x txd %08x txb %08x\n",
100 readl ( dwmac->regs + DWMAC_TXBUF ) );
101 DBGC ( dwmac, "DWMAC %s rxb %08x rxd %08x rxb %08x\n",
104 readl ( dwmac->regs + DWMAC_RXBUF ) );
105
106 /* Clear sticky bits in status register, since nothing else will */
107 writel ( status, ( dwmac->regs + DWMAC_STATUS ) );
108}
109
110/**
111 * Dump all registers (for debugging)
112 *
113 * @v dwmac DesignWare MAC device
114 */
115static void __attribute__ (( unused )) dwmac_dump ( struct dwmac *dwmac ) {
116
117 /* Dump MAC and DMA registers */
120}
121
122/******************************************************************************
123 *
124 * Device reset
125 *
126 ******************************************************************************
127 */
128
129/**
130 * Reset hardware
131 *
132 * @v dwmac DesignWare MAC device
133 * @ret rc Return status code
134 */
135static int dwmac_reset ( struct dwmac *dwmac ) {
136 unsigned int i;
138
139 /* Trigger software reset */
141
142 /* Wait for reset to complete */
143 for ( i = 0 ; i < DWMAC_RESET_MAX_WAIT_MS ; i++ ) {
144
145 /* Delay */
146 mdelay ( 1 );
147
148 /* Check for reset completion */
149 bus = readl ( dwmac->regs + DWMAC_BUS );
150 if ( ! ( bus & DWMAC_BUS_SWR ) )
151 return 0;
152 }
153
154 DBGC ( dwmac, "DWMAC %s timed out waiting for reset\n",
155 dwmac->name );
156 return -ETIMEDOUT;
157}
158
159/******************************************************************************
160 *
161 * Link state
162 *
163 ******************************************************************************
164 */
165
166/**
167 * Check link state
168 *
169 * @v netdev Network device
170 */
171static void dwmac_check_link ( struct net_device *netdev ) {
172 struct dwmac *dwmac = netdev->priv;
173 uint32_t gmii;
174
175 /* Read SGMII/RGMII link status */
176 gmii = readl ( dwmac->regs + DWMAC_GMII );
177 DBGC ( dwmac, "DWMAC %s GMII link status %#08x\n", dwmac->name, gmii );
178
179 /* Update network device */
180 if ( gmii & DWMAC_GMII_LINK ) {
182 } else {
184 }
185}
186
187/******************************************************************************
188 *
189 * Network device interface
190 *
191 ******************************************************************************
192 */
193
194/**
195 * Create descriptor ring
196 *
197 * @v dwmac DesignWare MAC device
198 * @v ring Descriptor ring
199 * @ret rc Return status code
200 */
201static int dwmac_create_ring ( struct dwmac *dwmac, struct dwmac_ring *ring ) {
202 struct dwmac_descriptor *desc;
203 struct dwmac_descriptor *next;
205 unsigned int i;
206
207 /* Allocate descriptor ring (on its own size) */
208 ring->desc = dma_alloc ( dwmac->dma, &ring->map, ring->len, ring->len );
209 if ( ! ring->desc )
210 return -ENOMEM;
211
212 /* Initialise descriptor ring */
213 memset ( ring->desc, 0, ring->len );
214 for ( i = 0 ; i < ring->count ; i++ ) {
215 desc = &ring->desc[i];
216 desc->size = cpu_to_le16 ( DWMAC_RX_LEN |
218 desc->ctrl = ring->ctrl;
219 assert ( desc->ctrl & DWMAC_CTRL_CHAIN );
220 next = &ring->desc[ ( i + 1 ) & ( ring->count - 1 ) ];
221 desc->next = dma ( &ring->map, next );
222 }
223 wmb();
224
225 /* Program ring address */
226 base = dma ( &ring->map, ring->desc );
227 assert ( base == ( ( uint32_t ) base ) );
228 writel ( base, ( dwmac->regs + DWMAC_DMA + ring->qbase ) );
229
230 DBGC ( dwmac, "DWMAC %s ring %02x is at [%08lx,%08lx)\n",
231 dwmac->name, ring->qbase, virt_to_phys ( ring->desc ),
232 ( virt_to_phys ( ring->desc ) + ring->len ) );
233 return 0;
234}
235
236/**
237 * Destroy descriptor ring
238 *
239 * @v dwmac DesignWare MAC device
240 * @v ring Descriptor ring
241 */
242static void dwmac_destroy_ring ( struct dwmac *dwmac,
243 struct dwmac_ring *ring ) {
244
245 /* Clear ring address */
246 writel ( 0, ( dwmac->regs + DWMAC_DMA + ring->qbase ) );
247
248 /* Free descriptor ring */
249 dma_free ( &ring->map, ring->desc, ring->len );
250 ring->desc = NULL;
251 ring->prod = 0;
252 ring->cons = 0;
253}
254
255/**
256 * Refill receive descriptor ring
257 *
258 * @v dwmac DesignWare MAC device
259 */
260static void dwmac_refill_rx ( struct dwmac *dwmac ) {
261 struct dwmac_descriptor *rx;
262 struct io_buffer *iobuf;
263 unsigned int rx_idx;
264 unsigned int refilled = 0;
265
266 /* Refill ring */
267 while ( ( dwmac->rx.prod - dwmac->rx.cons ) != DWMAC_NUM_RX_DESC ) {
268
269 /* Allocate I/O buffer */
270 iobuf = alloc_rx_iob ( DWMAC_RX_LEN, dwmac->dma );
271 if ( ! iobuf ) {
272 /* Wait for next refill */
273 break;
274 }
275
276 /* Get next receive descriptor */
277 rx_idx = ( dwmac->rx.prod++ % DWMAC_NUM_RX_DESC );
278 rx = &dwmac->rx.desc[rx_idx];
279
280 /* Populate receive descriptor */
281 rx->addr = cpu_to_le32 ( iob_dma ( iobuf ) );
282 wmb();
283 rx->stat = cpu_to_le32 ( DWMAC_STAT_OWN );
284
285 /* Record I/O buffer */
286 assert ( dwmac->rx_iobuf[rx_idx] == NULL );
287 dwmac->rx_iobuf[rx_idx] = iobuf;
288
289 DBGC2 ( dwmac, "DWMAC %s RX %d is [%08lx,%08lx)\n",
290 dwmac->name, rx_idx, virt_to_phys ( iobuf->data ),
291 ( virt_to_phys ( iobuf->data ) + DWMAC_RX_LEN ) );
292 refilled++;
293 }
294
295 /* Trigger poll */
296 if ( refilled ) {
297 wmb();
298 writel ( 0, ( dwmac->regs + DWMAC_RXPOLL ) );
299 }
300}
301
302/**
303 * Open network device
304 *
305 * @v netdev Network device
306 * @ret rc Return status code
307 */
308static int dwmac_open ( struct net_device *netdev ) {
309 struct dwmac *dwmac = netdev->priv;
310 union dwmac_mac mac;
311 int rc;
312
313 /* Create transmit descriptor ring */
314 if ( ( rc = dwmac_create_ring ( dwmac, &dwmac->tx ) ) != 0 )
315 goto err_create_tx;
316
317 /* Create receive descriptor ring */
318 if ( ( rc = dwmac_create_ring ( dwmac, &dwmac->rx ) ) != 0 )
319 goto err_create_rx;
320
321 /* Set MAC address */
322 memcpy ( mac.raw, netdev->ll_addr, ETH_ALEN );
323 writel ( mac.reg.addrl, ( dwmac->regs + DWMAC_ADDRL ) );
324 writel ( mac.reg.addrh, ( dwmac->regs + DWMAC_ADDRH ) );
325
326 /* Enable promiscuous mode */
328
329 /* Enable transmit and receive */
332 ( dwmac->regs + DWMAC_OP ) );
335 ( dwmac->regs + DWMAC_CFG ) );
336
337 /* Refill receive descriptor ring */
339
340 /* Update link state */
342
343 return 0;
344
346 err_create_rx:
348 err_create_tx:
349 return rc;
350}
351
352/**
353 * Close network device
354 *
355 * @v netdev Network device
356 */
357static void dwmac_close ( struct net_device *netdev ) {
358 struct dwmac *dwmac = netdev->priv;
359 unsigned int i;
360
361 /* Reset NIC */
362 dwmac_reset ( dwmac );
363
364 /* Discard unused receive buffers */
365 for ( i = 0 ; i < DWMAC_NUM_RX_DESC ; i++ ) {
366 if ( dwmac->rx_iobuf[i] )
367 free_rx_iob ( dwmac->rx_iobuf[i] );
368 dwmac->rx_iobuf[i] = NULL;
369 }
370
371 /* Destroy receive descriptor ring */
373
374 /* Destroy transmit descriptor ring */
376}
377
378/**
379 * Transmit packet
380 *
381 * @v netdev Network device
382 * @v iobuf I/O buffer
383 * @ret rc Return status code
384 */
385static int dwmac_transmit ( struct net_device *netdev,
386 struct io_buffer *iobuf ) {
387 struct dwmac *dwmac = netdev->priv;
388 struct dwmac_descriptor *tx;
389 unsigned int tx_idx;
390
391 /* Get next transmit descriptor */
392 if ( ( dwmac->tx.prod - dwmac->tx.cons ) >= DWMAC_NUM_TX_DESC ) {
393 DBGC ( dwmac, "DWMAC %s out of transmit descriptors\n",
394 dwmac->name );
395 return -ENOBUFS;
396 }
397 tx_idx = ( dwmac->tx.prod % DWMAC_NUM_TX_DESC );
398 tx = &dwmac->tx.desc[tx_idx];
399
400 /* Update producer index */
401 dwmac->tx.prod++;
402
403 /* Populate transmit descriptor */
404 tx->size = cpu_to_le16 ( iob_len ( iobuf ) );
405 tx->addr = cpu_to_le32 ( iob_dma ( iobuf ) );
406 wmb();
409 wmb();
410
411 /* Initiate transmission */
412 writel ( 0, ( dwmac->regs + DWMAC_TXPOLL ) );
413
414 DBGC2 ( dwmac, "DWMAC %s TX %d is [%08lx,%08lx)\n",
415 dwmac->name, tx_idx, virt_to_phys ( iobuf->data ),
416 ( virt_to_phys ( iobuf->data ) + iob_len ( iobuf ) ) );
417 return 0;
418}
419
420/**
421 * Poll for completed packets
422 *
423 * @V netdev Network device
424 */
425static void dwmac_poll_tx ( struct net_device *netdev ) {
426 struct dwmac *dwmac = netdev->priv;
427 struct dwmac_descriptor *tx;
428 unsigned int tx_idx;
429
430 /* Check for completed packets */
431 while ( dwmac->tx.cons != dwmac->tx.prod ) {
432
433 /* Get next transmit descriptor */
434 tx_idx = ( dwmac->tx.cons % DWMAC_NUM_TX_DESC );
435 tx = &dwmac->tx.desc[tx_idx];
436
437 /* Stop if descriptor is still owned by hardware */
438 if ( tx->stat & cpu_to_le32 ( DWMAC_STAT_OWN ) )
439 return;
440 dwmac->tx.cons++;
441
442 /* Report completion */
443 if ( tx->stat & cpu_to_le32 ( DWMAC_STAT_ERR ) ) {
444 DBGC ( dwmac, "DWMAC %s TX %d error %#08x\n",
445 dwmac->name, tx_idx, le32_to_cpu ( tx->stat ) );
446 dwmac_dump ( dwmac );
448 } else {
449 DBGC2 ( dwmac, "DWMAC %s TX %d complete\n",
450 dwmac->name, tx_idx );
452 }
453 }
454}
455
456/**
457 * Poll for received packets
458 *
459 * @v netdev Network device
460 */
461static void dwmac_poll_rx ( struct net_device *netdev ) {
462 struct dwmac *dwmac = netdev->priv;
463 struct dwmac_descriptor *rx;
464 struct io_buffer *iobuf;
465 unsigned int rx_idx;
467 size_t len;
468
469 /* Check for received packets */
470 while ( dwmac->rx.cons != dwmac->rx.prod ) {
471
472 /* Get next receive descriptor */
473 rx_idx = ( dwmac->rx.cons % DWMAC_NUM_RX_DESC );
474 rx = &dwmac->rx.desc[rx_idx];
475
476 /* Stop if descriptor is still in use */
477 if ( rx->stat & cpu_to_le32 ( DWMAC_STAT_OWN ) )
478 return;
479 dwmac->rx.cons++;
480
481 /* Consume I/O buffer */
482 iobuf = dwmac->rx_iobuf[rx_idx];
483 assert ( iobuf != NULL );
484 dwmac->rx_iobuf[rx_idx] = NULL;
485
486 /* Hand off to network stack */
487 stat = le32_to_cpu ( rx->stat );
490 if ( stat & DWMAC_STAT_ERR ) {
491 DBGC ( dwmac, "DWMAC %s RX %d error %#08x\n",
492 dwmac->name, rx_idx, stat );
493 dwmac_dump ( dwmac );
494 netdev_rx_err ( netdev, iobuf, -EIO );
495 } else {
496 len = ( DWMAC_STAT_RX_LEN ( stat ) - 4 /* CRC */ );
497 iob_put ( iobuf, len );
498 DBGC2 ( dwmac, "DWMAC %s RX %d complete (length "
499 "%zd)\n", dwmac->name, rx_idx, len );
500 netdev_rx ( netdev, iobuf );
501 }
502 }
503}
504
505/**
506 * Poll for completed and received packets
507 *
508 * @v netdev Network device
509 */
510static void dwmac_poll ( struct net_device *netdev ) {
511 struct dwmac *dwmac = netdev->priv;
513
514 /* Check for link status changes */
518
519 /* Poll for TX competions, if applicable */
521
522 /* Poll for RX completions */
524
525 /* Refill RX ring */
527}
528
529/** DesignWare MAC network device operations */
531 .open = dwmac_open,
532 .close = dwmac_close,
533 .transmit = dwmac_transmit,
534 .poll = dwmac_poll,
535};
536
537/******************************************************************************
538 *
539 * Devicetree interface
540 *
541 ******************************************************************************
542 */
543
544/**
545 * Probe devicetree device
546 *
547 * @v dt Devicetree device
548 * @v offset Starting node offset
549 * @ret rc Return status code
550 */
551static int dwmac_probe ( struct dt_device *dt, unsigned int offset ) {
552 struct net_device *netdev;
553 struct dwmac *dwmac;
554 union dwmac_mac mac;
556 int rc;
557
558 /* Allocate and initialise net device */
559 netdev = alloc_etherdev ( sizeof ( *dwmac ) );
560 if ( ! netdev ) {
561 rc = -ENOMEM;
562 goto err_alloc;
563 }
565 dwmac = netdev->priv;
566 dt_set_drvdata ( dt, netdev );
567 netdev->dev = &dt->dev;
568 netdev->dma = &dt->dma;
569 memset ( dwmac, 0, sizeof ( *dwmac ) );
570 dwmac->dma = &dt->dma;
571 dwmac->name = netdev->dev->name;
572 dwmac_init_ring ( &dwmac->tx, DWMAC_NUM_TX_DESC, DWMAC_TXBASE,
575 dwmac_init_ring ( &dwmac->rx, DWMAC_NUM_RX_DESC, DWMAC_RXBASE,
577
578 /* Map registers */
580 if ( ! dwmac->regs ) {
581 rc = -ENODEV;
582 goto err_ioremap;
583 }
585 DBGC ( dwmac, "DWMAC %s version %x.%x (user %x.%x)\n", dwmac->name,
590
591 /* Fetch devicetree MAC address */
592 if ( ( rc = fdt_mac ( &sysfdt, offset, netdev ) ) != 0 ) {
593 DBGC ( dwmac, "DWMAC %s could not fetch MAC: %s\n",
594 dwmac->name, strerror ( rc ) );
595 goto err_mac;
596 }
597
598 /* Fetch current MAC address, if set */
599 mac.reg.addrl = readl ( dwmac->regs + DWMAC_ADDRL );
600 mac.reg.addrh = readl ( dwmac->regs + DWMAC_ADDRH );
601 memcpy ( netdev->ll_addr, mac.raw, ETH_ALEN );
602
603 /* Reset the NIC */
604 if ( ( rc = dwmac_reset ( dwmac ) ) != 0 )
605 goto err_reset;
606
607 /* Register network device */
608 if ( ( rc = register_netdev ( netdev ) ) != 0 )
609 goto err_register_netdev;
610
611 /* Update link state */
613
614 return 0;
615
617 err_register_netdev:
618 dwmac_reset ( dwmac );
619 err_reset:
620 err_mac:
621 iounmap ( dwmac->regs );
622 err_ioremap:
624 netdev_put ( netdev );
625 err_alloc:
626 return rc;
627}
628
629/**
630 * Remove devicetree device
631 *
632 * @v dt Devicetree device
633 */
634static void dwmac_remove ( struct dt_device *dt ) {
635 struct net_device *netdev = dt_get_drvdata ( dt );
636 struct dwmac *dwmac = netdev->priv;
637
638 /* Unregister network device */
640
641 /* Reset card */
642 dwmac_reset ( dwmac );
643
644 /* Free network device */
645 iounmap ( dwmac->regs );
647 netdev_put ( netdev );
648}
649
650/** DesignWare MAC compatible model identifiers */
651static const char * dwmac_ids[] = {
652 DT_ROM ( "thead,light-dwmac", "T-Head MAC" ),
653 DT_ROM ( "snps,dwmac", "DesignWare MAC" ),
654};
655
656/** DesignWare MAC devicetree driver */
657struct dt_driver dwmac_driver __dt_driver = {
658 .name = "dwmac",
659 .ids = dwmac_ids,
660 .id_count = ( sizeof ( dwmac_ids ) / sizeof ( dwmac_ids[0] ) ),
663};
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
unsigned int uint32_t
Definition stdint.h:12
unsigned long physaddr_t
Definition stdint.h:20
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
u32 version
Driver version.
Definition ath9k_hw.c:1985
uint16_t offset
Offset to command line.
Definition bzimage.h:3
void * dt_ioremap(struct dt_device *dt, unsigned int offset, unsigned int index, size_t len)
Map devicetree range.
Definition devtree.c:52
Devicetree bus.
#define DT_ROM(_name, _desc)
Definition devtree.h:34
static void * dt_get_drvdata(struct dt_device *dt)
Get devicetree driver-private data.
Definition devtree.h:82
static void dt_set_drvdata(struct dt_device *dt, void *priv)
Set devicetree driver-private data.
Definition devtree.h:72
#define __dt_driver
Declare a devicetree driver.
Definition devtree.h:64
static void dwmac_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition dwmac.c:510
static int dwmac_probe(struct dt_device *dt, unsigned int offset)
Probe devicetree device.
Definition dwmac.c:551
static void dwmac_poll_rx(struct net_device *netdev)
Poll for received packets.
Definition dwmac.c:461
static void dwmac_remove(struct dt_device *dt)
Remove devicetree device.
Definition dwmac.c:634
static void dwmac_dump_dma(struct dwmac *dwmac)
Dump DMA registers (for debugging)
Definition dwmac.c:80
static int dwmac_create_ring(struct dwmac *dwmac, struct dwmac_ring *ring)
Create descriptor ring.
Definition dwmac.c:201
static void dwmac_refill_rx(struct dwmac *dwmac)
Refill receive descriptor ring.
Definition dwmac.c:260
static int dwmac_open(struct net_device *netdev)
Open network device.
Definition dwmac.c:308
static void dwmac_dump(struct dwmac *dwmac)
Dump all registers (for debugging)
Definition dwmac.c:115
static void dwmac_poll_tx(struct net_device *netdev)
Poll for completed packets.
Definition dwmac.c:425
static void dwmac_check_link(struct net_device *netdev)
Check link state.
Definition dwmac.c:171
static void dwmac_destroy_ring(struct dwmac *dwmac, struct dwmac_ring *ring)
Destroy descriptor ring.
Definition dwmac.c:242
static struct net_device_operations dwmac_operations
DesignWare MAC network device operations.
Definition dwmac.c:530
static void dwmac_close(struct net_device *netdev)
Close network device.
Definition dwmac.c:357
static int dwmac_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition dwmac.c:385
static int dwmac_reset(struct dwmac *dwmac)
Reset hardware.
Definition dwmac.c:135
static void dwmac_dump_mac(struct dwmac *dwmac)
Dump MAC registers (for debugging)
Definition dwmac.c:57
static const char * dwmac_ids[]
DesignWare MAC compatible model identifiers.
Definition dwmac.c:651
Synopsys DesignWare MAC network driver.
uint32_t next
Next descriptor address.
Definition dwmac.h:11
#define DWMAC_ISR
Interrupt status register.
Definition dwmac.h:54
#define DWMAC_BUS_SWR
Software reset.
Definition dwmac.h:86
#define DWMAC_STAT_TX_LAST
Last segment (TX)
Definition dwmac.h:161
#define DWMAC_OP_TXEN
TX enabled.
Definition dwmac.h:111
#define DWMAC_OP_RXEN
RX enabled.
Definition dwmac.h:112
#define DWMAC_STATUS
Status register.
Definition dwmac.h:104
#define DWMAC_STAT_ERR
Error summary.
Definition dwmac.h:164
#define DWMAC_VER_USER_MAJOR(x)
User major version.
Definition dwmac.h:41
#define DWMAC_GMII_LINK
Link up.
Definition dwmac.h:73
#define DWMAC_CFG_FD
Full duplex.
Definition dwmac.h:28
#define DWMAC_TXBASE
Transmit descriptor list address register.
Definition dwmac.h:101
#define DWMAC_CFG_RXEN
RX enabled.
Definition dwmac.h:30
#define DWMAC_DROP
Packet drop counter register.
Definition dwmac.h:115
#define DWMAC_RXPOLL
Receive poll demand register.
Definition dwmac.h:95
#define DWMAC_RXBASE
Receive descriptor list address register.
Definition dwmac.h:98
#define DWMAC_STAT_TX_CHAIN
Chained descriptor (TX)
Definition dwmac.h:163
#define DWMAC_OP_RXSF
RX store and forward.
Definition dwmac.h:109
#define DWMAC_VER_CORE_MAJOR(x)
Core major version.
Definition dwmac.h:45
#define DWMAC_CFG_DO
Disable RX own frames.
Definition dwmac.h:27
#define DWMAC_NUM_TX_DESC
Number of transmit descriptors.
Definition dwmac.h:200
#define DWMAC_CFG_TXEN
TX enabled.
Definition dwmac.h:29
#define DWMAC_SIZE_RX_CHAIN
Buffer size.
Definition dwmac.h:171
#define DWMAC_AXI
AXI bus mode register.
Definition dwmac.h:118
#define DWMAC_TXPOLL
Transmit poll demand register.
Definition dwmac.h:92
#define DWMAC_REG_LEN
I/O region length.
Definition dwmac.h:19
#define DWMAC_STAT_RX_LEN(x)
Frame length (RX)
Definition dwmac.h:167
uint32_t stat
Completion status.
Definition dwmac.h:1
ring len
Length.
Definition dwmac.h:226
#define DWMAC_FILTER_PR
Promiscuous mode.
Definition dwmac.h:34
#define DWMAC_NUM_RX_DESC
Number of receive descriptors.
Definition dwmac.h:203
#define DWMAC_RESET_MAX_WAIT_MS
Time to wait for software reset to complete.
Definition dwmac.h:89
#define DWMAC_REG_IDX
I/O region index.
Definition dwmac.h:16
#define DWMAC_OP_TXSF
TX store and forward.
Definition dwmac.h:110
#define DWMAC_VER_CORE_MINOR(x)
Core minor version.
Definition dwmac.h:47
#define DWMAC_CFG
MAC configuration register.
Definition dwmac.h:26
#define DWMAC_RX_LEN
Length of receive buffers.
Definition dwmac.h:209
#define DWMAC_DEBUG
Debug register.
Definition dwmac.h:51
#define DWMAC_BUS
Bus mode register.
Definition dwmac.h:80
#define DWMAC_DMA
DMA register block.
Definition dwmac.h:76
#define DWMAC_STAT_RX_FIRST
First segment (RX)
Definition dwmac.h:165
#define DWMAC_TXBUF
Current transmit buffer address register.
Definition dwmac.h:130
#define DWMAC_TXDESC
Current transmit descriptor register.
Definition dwmac.h:124
#define DWMAC_STATUS_LINK
Link status change.
Definition dwmac.h:105
#define DWMAC_RXDESC
Current receive descriptor register.
Definition dwmac.h:127
#define DWMAC_STAT_RX_LAST
Last segment (RX)
Definition dwmac.h:166
#define DWMAC_STAT_OWN
Owned by hardware.
Definition dwmac.h:160
#define DWMAC_CTRL_CHAIN
Chained descriptor.
Definition dwmac.h:176
#define DWMAC_CTRL_TX_LAST
Last segment (TX)
Definition dwmac.h:174
#define DWMAC_VER_USER_MINOR(x)
User minor version.
Definition dwmac.h:43
#define DWMAC_ADDRL
MAC address low register.
Definition dwmac.h:60
#define DWMAC_OP
Operation mode register.
Definition dwmac.h:108
#define DWMAC_STAT_TX_FIRST
First segment (TX)
Definition dwmac.h:162
#define DWMAC_CTRL_TX_FIRST
First segment (TX)
Definition dwmac.h:175
#define DWMAC_GMII
SGMII/RGMII status register.
Definition dwmac.h:72
#define DWMAC_FEATURE
Hardware feature register.
Definition dwmac.h:136
#define DWMAC_FILTER
MAC filter register.
Definition dwmac.h:33
#define DWMAC_ADDRH
MAC address high register.
Definition dwmac.h:57
#define DWMAC_VER
Version register.
Definition dwmac.h:40
#define DWMAC_RXBUF
Current receive buffer address register.
Definition dwmac.h:133
#define DWMAC_FLOW
Flow control register.
Definition dwmac.h:37
#define DWMAC_AHB
AHB or AXI status register.
Definition dwmac.h:121
uint8_t bus
Bus.
Definition edd.h:1
uint8_t status
Status.
Definition ena.h:5
struct ena_llq_option desc
Descriptor counts.
Definition ena.h:9
uint8_t mac[ETH_ALEN]
MAC address.
Definition ena.h:13
Error codes.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition ethernet.c:265
Ethernet protocol.
int fdt_mac(struct fdt *fdt, unsigned int offset, struct net_device *netdev)
Get MAC address from property.
Definition fdt.c:867
struct fdt sysfdt
The system flattened device tree (if present)
Definition fdt.c:45
static struct net_device * netdev
Definition gdbudp.c:53
#define DBGC2(...)
Definition compiler.h:522
#define DBGC(...)
Definition compiler.h:505
#define DBG_LOG
Definition compiler.h:317
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define ETIMEDOUT
Connection timed out.
Definition errno.h:670
#define ENOMEM
Not enough space.
Definition errno.h:535
#define EIO
Input/output error.
Definition errno.h:434
#define ENOBUFS
No buffer space available.
Definition errno.h:499
#define ENODEV
No such device.
Definition errno.h:510
#define ETH_ALEN
Definition if_ether.h:9
#define le32_to_cpu(value)
Definition byteswap.h:114
#define cpu_to_le32(value)
Definition byteswap.h:108
#define cpu_to_le16(value)
Definition byteswap.h:107
#define __attribute__(x)
Definition compiler.h:10
Flattened Device Tree.
#define wmb()
Definition io.h:546
void iounmap(volatile const void *io_addr)
Unmap I/O address.
iPXE timers
String functions.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
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
void free_rx_iob(struct io_buffer *iobuf)
Unmap and free I/O buffer for receive DMA.
Definition iobuf.c:215
I/O buffers.
#define iob_put(iobuf, len)
Definition iobuf.h:125
static __always_inline physaddr_t iob_dma(struct io_buffer *iobuf)
Get I/O buffer DMA address.
Definition iobuf.h:268
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition iobuf.h:160
void dma_free(struct dma_mapping *map, void *addr, size_t len)
Unmap and free DMA-coherent buffer.
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.
uint32_t base
Base.
Definition librm.h:3
uint8_t unused
Unused.
Definition librm.h:5
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition netdevice.c:231
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition netdevice.c:549
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition netdevice.c:942
void netdev_tx_complete_next_err(struct net_device *netdev, int rc)
Complete network transmission.
Definition netdevice.c:510
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition netdevice.c:587
int register_netdev(struct net_device *netdev)
Register network device.
Definition netdevice.c:760
Network device management.
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition netdevice.h:789
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
static void netdev_tx_complete_next(struct net_device *netdev)
Complete network transmission.
Definition netdevice.h:779
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
A devicetree device.
Definition devtree.h:17
struct dma_device dma
DMA device.
Definition devtree.h:23
struct device dev
Generic device.
Definition devtree.h:21
A devicetree driver.
Definition devtree.h:37
int(* probe)(struct dt_device *dt, unsigned int offset)
Probe device.
Definition devtree.h:51
A frame descriptor.
Definition dwmac.h:144
A DesignWare descriptor ring.
Definition dwmac.h:179
unsigned int cons
Consumer index.
Definition dwmac.h:187
unsigned int prod
Producer index.
Definition dwmac.h:185
uint8_t qbase
Queue base address register (within DMA block)
Definition dwmac.h:190
uint8_t ctrl
Default control flags.
Definition dwmac.h:194
struct dma_mapping map
Descriptor ring DMA mapping.
Definition dwmac.h:183
struct dwmac_descriptor * desc
Descriptors.
Definition dwmac.h:181
size_t len
Length of descriptors.
Definition dwmac.h:196
uint8_t count
Number of descriptors.
Definition dwmac.h:192
A DesignWare MAC network card.
Definition dwmac.h:230
void * regs
Registers.
Definition dwmac.h:232
struct dwmac_ring tx
Transmit ring.
Definition dwmac.h:239
struct dma_device * dma
DMA device.
Definition dwmac.h:234
struct io_buffer * rx_iobuf[DWMAC_NUM_RX_DESC]
Receive I/O buffers.
Definition dwmac.h:243
const char * name
Device name (for debugging)
Definition dwmac.h:236
struct dwmac_ring rx
Receive ring.
Definition dwmac.h:241
A persistent I/O buffer.
Definition iobuf.h:38
void * data
Start of data.
Definition iobuf.h:53
Network device operations.
Definition netdevice.h:214
A network device.
Definition netdevice.h:353
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition timer.c:79
A DesignWare MAC address.
Definition dwmac.h:63
#define readl
Definition w89c840.c:157
#define writel
Definition w89c840.c:160
u8 tx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets to the AP.
Definition wpa.h:4
u8 rx[WPA_TKIP_MIC_KEY_LEN]
MIC key for packets from the AP.
Definition wpa.h:1
static struct xen_remove_from_physmap * remove
Definition xenmem.h:40