iPXE
b44.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 Stefan Hajnoczi <stefanha@gmail.com>
3 * Copyright (c) 2008 Pantelis Koukousoulas <pktoss@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
19 *
20 * This driver is a port of the b44 linux driver version 1.01
21 *
22 * Copyright (c) 2002 David S. Miller <davem@redhat.com>
23 * Copyright (c) Pekka Pietikainen <pp@ee.oulu.fi>
24 * Copyright (C) 2006 Broadcom Corporation.
25 *
26 * Some ssb bits copied from version 2.0 of the b44 driver
27 * Copyright (c) Michael Buesch
28 *
29 * Copyright (c) a lot of people too. Please respect their work.
30 */
31
32FILE_LICENCE ( GPL2_OR_LATER );
33
34#include <string.h>
35#include <errno.h>
36#include <assert.h>
37#include <stdio.h>
38#include <unistd.h>
39#include <byteswap.h>
40#include <ipxe/io.h>
41#include <mii.h>
42#include <ipxe/iobuf.h>
43#include <ipxe/malloc.h>
44#include <ipxe/pci.h>
45#include <ipxe/netdevice.h>
46#include <ipxe/ethernet.h>
47#include <ipxe/if_ether.h>
48#include "b44.h"
49
50
51static inline int ring_next(int index)
52{
53 /* B44_RING_SIZE is a power of 2 :) */
54 return (index + 1) & (B44_RING_SIZE - 1);
55}
56
57
58/* Memory-mapped I/O wrappers */
59
60static inline u32 br32(const struct b44_private *bp, u32 reg)
61{
62 return readl(bp->regs + reg);
63}
64
65
66static inline void bw32(const struct b44_private *bp, u32 reg, u32 val)
67{
68 writel(val, bp->regs + reg);
69}
70
71
72static inline void bflush(const struct b44_private *bp, u32 reg, u32 timeout)
73{
74 readl(bp->regs + reg);
76}
77
78
79#define VIRT_TO_B44(addr) ( virt_to_bus(addr) + SB_PCI_DMA )
80
81
82/**
83 * Check if card can access address
84 *
85 * @v address Virtual address
86 * @v address_ok Card can access address
87 */
88static inline __attribute__ (( always_inline )) int
90
91 /* Card can address anything with a 30-bit address */
92 if ( ( virt_to_bus ( address ) & ~B44_30BIT_DMA_MASK ) == 0 )
93 return 1;
94
95 return 0;
96}
97
98/**
99 * Ring cells waiting to be processed are between 'tx_cur' and 'pending'
100 * indexes in the ring.
101 */
103{
106
107 pending /= sizeof(struct dma_desc);
108 return pending & (B44_RING_SIZE - 1);
109}
110
111
112/**
113 * Ring cells waiting to be processed are between 'rx_cur' and 'pending'
114 * indexes in the ring.
115 */
117{
120
121 pending /= sizeof(struct dma_desc);
122 return pending & (B44_RING_SIZE - 1);
123}
124
125
126/**
127 * Wait until the given bit is set/cleared.
128 */
129static int b44_wait_bit(struct b44_private *bp, unsigned long reg, u32 bit,
130 unsigned long timeout, const int clear)
131{
132 unsigned long i;
133
134 for (i = 0; i < timeout; i++) {
135 u32 val = br32(bp, reg);
136
137 if (clear && !(val & bit))
138 break;
139
140 if (!clear && (val & bit))
141 break;
142
143 udelay(10);
144 }
145 if (i == timeout) {
146 return -ENODEV;
147 }
148 return 0;
149}
150
151
152/*
153 * Sonics Silicon Backplane support. SSB is a mini-bus interconnecting
154 * so-called IP Cores. One of those cores implements the Fast Ethernet
155 * functionality and another one the PCI engine.
156 *
157 * You need to switch to the core you want to talk to before actually
158 * sending commands.
159 *
160 * See: http://bcm-v4.sipsolutions.net/Backplane for (reverse-engineered)
161 * specs.
162 */
163
164static inline u32 ssb_get_core_rev(struct b44_private *bp)
165{
167}
168
169
170static inline int ssb_is_core_up(struct b44_private *bp)
171{
173 == SBTMSLOW_CLOCK);
174}
175
176
177static u32 ssb_pci_setup(struct b44_private *bp, u32 cores)
178{
179 u32 bar_orig, pci_rev, val;
180
181 pci_read_config_dword(bp->pci, SSB_BAR0_WIN, &bar_orig);
184 pci_rev = ssb_get_core_rev(bp);
185
187 val |= cores;
189
193
194 pci_write_config_dword(bp->pci, SSB_BAR0_WIN, bar_orig);
195
196 return pci_rev;
197}
198
199
216
217
218static void ssb_core_reset(struct b44_private *bp)
219{
220 u32 val;
222
224
225 bw32(bp, B44_SBTMSLOW, mask);
227
228 /* Clear SERR if set, this is a hw bug workaround. */
230 bw32(bp, B44_SBTMSHIGH, 0);
231
233 if (val & (SBIMSTATE_BAD)) {
235 }
236
239
242}
243
244
245/*
246 * Driver helper functions
247 */
248
249/*
250 * Chip reset provides power to the b44 MAC & PCI cores, which
251 * is necessary for MAC register access. We only do a partial
252 * reset in case of transmit/receive errors (ISTAT_ERRORS) to
253 * avoid the chip being hung for an unnecessary long time in
254 * this case.
255 *
256 * Called-by: b44_close, b44_halt, b44_inithw(b44_open), b44_probe
257 */
258static void b44_chip_reset(struct b44_private *bp, int reset_kind)
259{
260 if (ssb_is_core_up(bp)) {
261 bw32(bp, B44_RCV_LAZY, 0);
262
264
266
268
269 bp->tx_dirty = bp->tx_cur = 0;
270
273 100, 0);
274
276
277 bp->rx_cur = 0;
278 } else {
280 }
281
283
284 /* Don't enable PHY if we are only doing a partial reset. */
285 if (reset_kind == B44_CHIP_RESET_PARTIAL)
286 return;
287
288 /* Make PHY accessible. */
292
293 /* Enable internal or external PHY */
294 if (!(br32(bp, B44_DEVCTRL) & DEVCTRL_IPP)) {
297 } else {
299 if (val & DEVCTRL_EPR) {
301 bflush(bp, B44_DEVCTRL, 100);
302 }
303 }
304}
305
306
307/**
308 * called by b44_poll in the error path
309 */
310static void b44_halt(struct b44_private *bp)
311{
312 /* disable ints */
313 bw32(bp, B44_IMASK, 0);
314 bflush(bp, B44_IMASK, 1);
315
316 DBG("b44: powering down PHY\n");
318
319 /*
320 * Now reset the chip, but without enabling
321 * the MAC&PHY part of it.
322 * This has to be done _after_ we shut down the PHY
323 */
325}
326
327
328
329/*
330 * Called at device open time to get the chip ready for
331 * packet processing.
332 *
333 * Called-by: b44_open
334 */
335static void b44_init_hw(struct b44_private *bp, int reset_kind)
336{
337 u32 val;
338#define CTRL_MASK (DMARX_CTRL_ENABLE | (RX_PKT_OFFSET << DMARX_CTRL_ROSHIFT))
339
341 if (reset_kind == B44_FULL_RESET) {
343 }
344
345 /* Enable CRC32, set proper LED modes and power on PHY */
348
349 /* This sets the MAC address too. */
350 b44_set_rx_mode(bp->netdev);
351
352 /* MTU + eth header + possible VLAN tag + struct rx_header */
355
357 if (reset_kind == B44_PARTIAL_RESET) {
359 } else {
362
366
368 }
369
372#undef CTRL_MASK
373}
374
375
376/*** Management of ring descriptors ***/
377
378
380{
381 struct rx_header *rh;
382 u32 ctrl, addr;
383
384 rh = bp->rx_iobuf[idx]->data;
385 rh->len = 0;
386 rh->flags = 0;
388 if (idx == B44_RING_LAST) {
390 }
391 addr = VIRT_TO_B44(bp->rx_iobuf[idx]->data);
392
393 bp->rx[idx].ctrl = cpu_to_le32(ctrl);
394 bp->rx[idx].addr = cpu_to_le32(addr);
395 bw32(bp, B44_DMARX_PTR, idx * sizeof(struct dma_desc));
396}
397
398
399/*
400 * Refill RX ring descriptors with buffers. This is needed
401 * because during rx we are passing ownership of descriptor
402 * buffers to the network stack.
403 */
405{
406 struct io_buffer *iobuf;
407 u32 i;
408
409 // skip pending
410 for (i = pending + 1; i != bp->rx_cur; i = ring_next(i)) {
411 if (bp->rx_iobuf[i] != NULL)
412 continue;
413
414 iobuf = alloc_iob(RX_PKT_BUF_SZ);
415 if (!iobuf) {
416 DBG("Refill rx ring failed!!\n");
417 break;
418 }
419 if (!b44_address_ok(iobuf->data)) {
420 DBG("Refill rx ring bad address!!\n");
421 free_iob(iobuf);
422 break;
423 }
424 bp->rx_iobuf[i] = iobuf;
425
427 }
428}
429
430
431static void b44_free_rx_ring(struct b44_private *bp)
432{
433 u32 i;
434
435 if (bp->rx) {
436 for (i = 0; i < B44_RING_SIZE; i++) {
437 free_iob(bp->rx_iobuf[i]);
438 bp->rx_iobuf[i] = NULL;
439 }
441 bp->rx = NULL;
442 }
443}
444
445
446static int b44_init_rx_ring(struct b44_private *bp)
447{
449
451 if (!bp->rx)
452 return -ENOMEM;
453 if (!b44_address_ok(bp->rx)) {
455 return -ENOTSUP;
456 }
457
458 memset(bp->rx_iobuf, 0, sizeof(bp->rx_iobuf));
459
460 bp->rx_iobuf[0] = alloc_iob(RX_PKT_BUF_SZ);
462 b44_rx_refill(bp, 0);
463
464 DBG("Init RX rings: rx=0x%08lx\n", VIRT_TO_B44(bp->rx));
465 return 0;
466}
467
468
469static void b44_free_tx_ring(struct b44_private *bp)
470{
471 if (bp->tx) {
473 bp->tx = NULL;
474 }
475}
476
477
478static int b44_init_tx_ring(struct b44_private *bp)
479{
481
483 if (!bp->tx)
484 return -ENOMEM;
485 if (!b44_address_ok(bp->tx)) {
487 return -ENOTSUP;
488 }
489
491 memset(bp->tx_iobuf, 0, sizeof(bp->tx_iobuf));
492
493 DBG("Init TX rings: tx=0x%08lx\n", VIRT_TO_B44(bp->tx));
494 return 0;
495}
496
497
498/*** Interaction with the PHY ***/
499
500
501static int b44_phy_read(struct b44_private *bp, int reg, u32 * val)
502{
503 int err;
504
506 u32 arg2 = (bp->phy_addr << MDIO_DATA_PMD_SHIFT);
509 u32 argv = arg1 | arg2 | arg3 | arg4;
510
515
516 return err;
517}
518
519
520static int b44_phy_write(struct b44_private *bp, int reg, u32 val)
521{
523 u32 arg2 = (bp->phy_addr << MDIO_DATA_PMD_SHIFT);
527 u32 argv = arg1 | arg2 | arg3 | arg4 | arg5;
528
529
532 return b44_wait_bit(bp, B44_EMAC_ISTAT, EMAC_INT_MII, 100, 0);
533}
534
535
536static int b44_phy_reset(struct b44_private *bp)
537{
538 u32 val;
539 int err;
540
542 if (err)
543 return err;
544
545 udelay(100);
546 err = b44_phy_read(bp, MII_BMCR, &val);
547 if (!err) {
548 if (val & BMCR_RESET) {
549 return -ENODEV;
550 }
551 }
552
553 return 0;
554}
555
556
557/*
558 * The BCM44xx CAM (Content Addressable Memory) stores the MAC
559 * and PHY address.
560 */
561static void b44_cam_write(struct b44_private *bp, unsigned char *data,
562 int index)
563{
564 u32 val;
565
566 val = ((u32) data[2]) << 24;
567 val |= ((u32) data[3]) << 16;
568 val |= ((u32) data[4]) << 8;
569 val |= ((u32) data[5]) << 0;
571
572
574 (((u32) data[0]) << 8) | (((u32) data[1]) << 0));
575
577
580
582}
583
584
585static void b44_set_mac_addr(struct b44_private *bp)
586{
587 u32 val;
588 bw32(bp, B44_CAM_CTRL, 0);
589 b44_cam_write(bp, bp->netdev->ll_addr, 0);
592}
593
594
595/* Read 128-bytes of EEPROM. */
596static void b44_read_eeprom(struct b44_private *bp, u8 * data)
597{
598 long i;
599 u16 *ptr = (u16 *) data;
600
601 for (i = 0; i < 128; i += 2)
602 ptr[i / 2] = cpu_to_le16(readw(bp->regs + 4096 + i));
603}
604
605
607{
608 u8 eeprom[128];
609
610 /* Load MAC address, note byteswapping */
612 bp->netdev->hw_addr[0] = eeprom[79];
613 bp->netdev->hw_addr[1] = eeprom[78];
614 bp->netdev->hw_addr[2] = eeprom[81];
615 bp->netdev->hw_addr[3] = eeprom[80];
616 bp->netdev->hw_addr[4] = eeprom[83];
617 bp->netdev->hw_addr[5] = eeprom[82];
618
619 /* Load PHY address */
620 bp->phy_addr = eeprom[90] & 0x1f;
621}
622
623
625{
626 struct b44_private *bp = netdev->priv;
627 unsigned char zero[6] = { 0, 0, 0, 0, 0, 0 };
628 u32 val;
629 int i;
630
634
636
637 for (i = 1; i < 64; i++)
638 b44_cam_write(bp, zero, i);
639
643}
644
645
646/*** Implementation of iPXE driver callbacks ***/
647
648/**
649 * Probe device
650 *
651 * @v pci PCI device
652 * @v id Matching entry in ID table
653 * @ret rc Return status code
654 */
655static int b44_probe(struct pci_device *pci)
656{
657 struct net_device *netdev;
658 struct b44_private *bp;
659 int rc;
660
661 /* Set up netdev */
662 netdev = alloc_etherdev(sizeof(*bp));
663 if (!netdev)
664 return -ENOMEM;
665
668 netdev->dev = &pci->dev;
669
670 /* Set up private data */
671 bp = netdev->priv;
672 memset(bp, 0, sizeof(*bp));
673 bp->netdev = netdev;
674 bp->pci = pci;
675
676 /* Map device registers */
678 if (!bp->regs) {
680 return -ENOMEM;
681 }
682
683 /* Enable PCI bus mastering */
685
687
689 if (rc != 0) {
690 iounmap(bp->regs);
692 return rc;
693 }
694
695 /* Link management currently not implemented */
697
699
700 DBG("b44 %s (%04x:%04x) regs=%p MAC=%s\n", pci->id->name,
701 pci->id->vendor, pci->id->device, bp->regs,
702 eth_ntoa(netdev->ll_addr));
703
704 return 0;
705}
706
707
708/**
709 * Remove device
710 *
711 * @v pci PCI device
712 */
713static void b44_remove(struct pci_device *pci)
714{
715 struct net_device *netdev = pci_get_drvdata(pci);
716 struct b44_private *bp = netdev->priv;
717
720 iounmap(bp->regs);
723}
724
725
726/** Enable or disable interrupts
727 *
728 * @v netdev Network device
729 * @v enable Interrupts should be enabled
730 */
731static void b44_irq(struct net_device *netdev, int enable)
732{
733 struct b44_private *bp = netdev->priv;
734
735 /* Interrupt mask specifies which events generate interrupts */
737}
738
739
740/** Open network device
741 *
742 * @v netdev Network device
743 * @ret rc Return status code
744 */
745static int b44_open(struct net_device *netdev)
746{
747 struct b44_private *bp = netdev->priv;
748 int rc;
749
751 if (rc != 0)
752 return rc;
753
755 if (rc != 0)
756 return rc;
757
759
760 /* Disable interrupts */
761 b44_irq(netdev, 0);
762
763 return 0;
764}
765
766
767/** Close network device
768 *
769 * @v netdev Network device
770 */
771static void b44_close(struct net_device *netdev)
772{
773 struct b44_private *bp = netdev->priv;
774
778}
779
780
781/** Transmit packet
782 *
783 * @v netdev Network device
784 * @v iobuf I/O buffer
785 * @ret rc Return status code
786 */
787static int b44_transmit(struct net_device *netdev, struct io_buffer *iobuf)
788{
789 struct b44_private *bp = netdev->priv;
790 u32 cur = bp->tx_cur;
791 u32 ctrl;
792
793 /* Check for TX ring overflow */
794 if (bp->tx[cur].ctrl) {
795 DBG("tx overflow\n");
796 return -ENOBUFS;
797 }
798
799 /* Check for addressability */
800 if (!b44_address_ok(iobuf->data))
801 return -ENOTSUP;
802
803 /* Will call netdev_tx_complete() on the iobuf later */
804 bp->tx_iobuf[cur] = iobuf;
805
806 /* Set up TX descriptor */
807 ctrl = (iob_len(iobuf) & DESC_CTRL_LEN) |
809
810 if (cur == B44_RING_LAST)
812
813 bp->tx[cur].ctrl = cpu_to_le32(ctrl);
814 bp->tx[cur].addr = cpu_to_le32(VIRT_TO_B44(iobuf->data));
815
816 /* Update next available descriptor index */
817 cur = ring_next(cur);
818 bp->tx_cur = cur;
819 wmb();
820
821 /* Tell card that a new TX descriptor is ready */
822 bw32(bp, B44_DMATX_PTR, cur * sizeof(struct dma_desc));
823 return 0;
824}
825
826
827/** Recycles sent TX descriptors and notifies network stack
828 *
829 * @v bp Driver state
830 */
831static void b44_tx_complete(struct b44_private *bp)
832{
833 u32 cur, i;
834
835 cur = pending_tx_index(bp);
836
837 for (i = bp->tx_dirty; i != cur; i = ring_next(i)) {
838 /* Free finished frame */
839 netdev_tx_complete(bp->netdev, bp->tx_iobuf[i]);
840 bp->tx_iobuf[i] = NULL;
841
842 /* Clear TX descriptor */
843 bp->tx[i].ctrl = 0;
844 bp->tx[i].addr = 0;
845 }
846 bp->tx_dirty = cur;
847}
848
849
851{
852 struct io_buffer *iob; /* received data */
853 struct rx_header *rh;
854 u32 pending, i;
855 u16 len;
856
858
859 for (i = bp->rx_cur; i != pending; i = ring_next(i)) {
860 iob = bp->rx_iobuf[i];
861 if (iob == NULL)
862 break;
863
864 rh = iob->data;
865 len = le16_to_cpu(rh->len);
866
867 /*
868 * Guard against incompletely written RX descriptors.
869 * Without this, things can get really slow!
870 */
871 if (len == 0)
872 break;
873
874 /* Discard CRC that is generated by the card */
875 len -= 4;
876
877 /* Check for invalid packets and errors */
880 DBG("rx error len=%d flags=%04x\n", len,
881 cpu_to_le16(rh->flags));
882 rh->len = 0;
883 rh->flags = 0;
884 netdev_rx_err(bp->netdev, iob, -EINVAL);
885 continue;
886 }
887
888 /* Clear RX descriptor */
889 rh->len = 0;
890 rh->flags = 0;
891 bp->rx_iobuf[i] = NULL;
892
893 /* Hand off the IO buffer to the network stack */
895 iob_put(iob, len);
896 netdev_rx(bp->netdev, iob);
897 }
898 bp->rx_cur = i;
900}
901
902
903/** Poll for completed and received packets
904 *
905 * @v netdev Network device
906 */
907static void b44_poll(struct net_device *netdev)
908{
909 struct b44_private *bp = netdev->priv;
910 u32 istat;
911
912 /* Interrupt status */
913 istat = br32(bp, B44_ISTAT);
914 istat &= IMASK_DEF; /* only the events we care about */
915
916 if (!istat)
917 return;
918 if (istat & ISTAT_TX)
920 if (istat & ISTAT_RX)
922 if (istat & ISTAT_ERRORS) {
923 DBG("b44 error istat=0x%08x\n", istat);
924
925 /* Reset B44 core partially to avoid long waits */
926 b44_irq(bp->netdev, 0);
927 b44_halt(bp);
931 }
932
933 /* Acknowledge interrupt */
934 bw32(bp, B44_ISTAT, 0);
935 bflush(bp, B44_ISTAT, 1);
936}
937
938
940 .open = b44_open,
941 .close = b44_close,
942 .transmit = b44_transmit,
943 .poll = b44_poll,
944 .irq = b44_irq,
945};
946
947
948static struct pci_device_id b44_nics[] = {
949 PCI_ROM(0x14e4, 0x170c, "BCM4401-B0", "BCM4401-B0", 0),
950 PCI_ROM(0x14e4, 0x4401, "BCM4401", "BCM4401", 0),
951 PCI_ROM(0x14e4, 0x4402, "BCM4401-B1", "BCM4401-B1", 0),
952};
953
954
955struct pci_driver b44_driver __pci_driver = {
956 .ids = b44_nics,
957 .id_count = sizeof b44_nics / sizeof b44_nics[0],
958 .probe = b44_probe,
959 .remove = b44_remove,
960};
eeprom
Definition 3c90x.h:232
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
long index
Definition bigint.h:65
static unsigned int unsigned long unsigned long arg2
Definition xen.h:67
static unsigned int unsigned long unsigned long unsigned long unsigned long arg4
Definition xen.h:119
static unsigned int unsigned long arg1
Definition xen.h:44
static unsigned int unsigned long unsigned long unsigned long arg3
Definition xen.h:91
static unsigned int unsigned long unsigned long unsigned long unsigned long unsigned long arg5
Definition xen.h:149
Assertions.
#define MII_BMCR
Definition atl1e.h:871
static int b44_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition b44.c:787
static int ring_next(int index)
Definition b44.c:51
static void b44_free_tx_ring(struct b44_private *bp)
Definition b44.c:469
static int b44_phy_write(struct b44_private *bp, int reg, u32 val)
Definition b44.c:520
static void b44_process_rx_packets(struct b44_private *bp)
Definition b44.c:850
static int b44_init_rx_ring(struct b44_private *bp)
Definition b44.c:446
static int b44_wait_bit(struct b44_private *bp, unsigned long reg, u32 bit, unsigned long timeout, const int clear)
Wait until the given bit is set/cleared.
Definition b44.c:129
static int b44_probe(struct pci_device *pci)
Probe device.
Definition b44.c:655
static void b44_chip_reset(struct b44_private *bp, int reset_kind)
Definition b44.c:258
static u32 br32(const struct b44_private *bp, u32 reg)
Definition b44.c:60
static int b44_open(struct net_device *netdev)
Open network device.
Definition b44.c:745
static void ssb_core_disable(struct b44_private *bp)
Definition b44.c:200
static int b44_phy_reset(struct b44_private *bp)
Definition b44.c:536
static int b44_init_tx_ring(struct b44_private *bp)
Definition b44.c:478
static void bflush(const struct b44_private *bp, u32 reg, u32 timeout)
Definition b44.c:72
static void b44_remove(struct pci_device *pci)
Remove device.
Definition b44.c:713
static struct pci_device_id b44_nics[]
Definition b44.c:948
static void bw32(const struct b44_private *bp, u32 reg, u32 val)
Definition b44.c:66
#define VIRT_TO_B44(addr)
Definition b44.c:79
static int b44_address_ok(void *address)
Check if card can access address.
Definition b44.c:89
static void b44_halt(struct b44_private *bp)
called by b44_poll in the error path
Definition b44.c:310
static u32 ssb_get_core_rev(struct b44_private *bp)
Definition b44.c:164
static void b44_set_mac_addr(struct b44_private *bp)
Definition b44.c:585
static void b44_free_rx_ring(struct b44_private *bp)
Definition b44.c:431
static void b44_set_rx_mode(struct net_device *netdev)
Definition b44.c:624
static u32 pending_tx_index(struct b44_private *bp)
Ring cells waiting to be processed are between 'tx_cur' and 'pending' indexes in the ring.
Definition b44.c:102
static void b44_init_hw(struct b44_private *bp, int reset_kind)
Definition b44.c:335
static int b44_phy_read(struct b44_private *bp, int reg, u32 *val)
Definition b44.c:501
static void b44_tx_complete(struct b44_private *bp)
Recycles sent TX descriptors and notifies network stack.
Definition b44.c:831
static void b44_load_mac_and_phy_addr(struct b44_private *bp)
Definition b44.c:606
static void b44_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition b44.c:907
static void b44_close(struct net_device *netdev)
Close network device.
Definition b44.c:771
static void b44_rx_refill(struct b44_private *bp, u32 pending)
Definition b44.c:404
static void b44_populate_rx_descriptor(struct b44_private *bp, u32 idx)
Definition b44.c:379
static void b44_cam_write(struct b44_private *bp, unsigned char *data, int index)
Definition b44.c:561
static void b44_read_eeprom(struct b44_private *bp, u8 *data)
Definition b44.c:596
static struct net_device_operations b44_operations
Definition b44.c:939
static void ssb_core_reset(struct b44_private *bp)
Definition b44.c:218
static u32 ssb_pci_setup(struct b44_private *bp, u32 cores)
Definition b44.c:177
static u32 pending_rx_index(struct b44_private *bp)
Ring cells waiting to be processed are between 'rx_cur' and 'pending' indexes in the ring.
Definition b44.c:116
static void b44_irq(struct net_device *netdev, int enable)
Enable or disable interrupts.
Definition b44.c:731
static int ssb_is_core_up(struct b44_private *bp)
Definition b44.c:170
#define DMARX_STAT_CDMASK
Definition b44.h:133
#define ISTAT_RX
Definition b44.h:73
#define IMASK_DEF
Definition b44.h:81
#define CAM_CTRL_ENABLE
Definition b44.h:197
#define ENET_CTRL_ENABLE
Definition b44.h:205
#define MDIO_OP_WRITE
Definition b44.h:183
#define B44_RING_LAST
Definition b44.h:399
#define DEVCTRL_IPP
Definition b44.h:41
#define B44_DMATX_STAT
Definition b44.h:111
#define B44_CHIP_RESET_PARTIAL
Definition b44.h:411
#define B44_DMARX_STAT
Definition b44.h:132
#define RX_FLAG_ERRORS
Definition b44.h:385
#define B44_CAM_DATA_LO
Definition b44.h:193
#define RX_PKT_BUF_SZ
Definition b44.h:405
#define SSB_PCI_TRANS_2
Definition b44.h:324
#define CAM_DATA_HI_VALID
Definition b44.h:195
#define B44_RXCONFIG
Definition b44.h:158
#define SBTMSHIGH_SERR
Definition b44.h:293
#define B44_MDIO_CTRL
Definition b44.h:169
#define B44_MAC_CTRL
Definition b44.h:90
#define MDIO_CTRL_MAXF_MASK
Definition b44.h:170
#define MDIO_OP_READ
Definition b44.h:184
#define MDIO_CTRL_PREAMBLE
Definition b44.h:171
#define DMARX_STAT_EMASK
Definition b44.h:139
#define B44_DMARX_PTR
Definition b44.h:131
#define DESC_CTRL_SOF
Definition b44.h:367
#define DMARX_STAT_SIDLE
Definition b44.h:137
#define B44_EMAC_ISTAT
Definition b44.h:189
#define DESC_CTRL_LEN
Definition b44.h:362
#define SBIMSTATE_BAD
Definition b44.h:276
#define SBTMSLOW_RESET
Definition b44.h:286
#define B44_IMASK
Definition b44.h:80
#define DESC_CTRL_EOF
Definition b44.h:366
#define SSB_PCI_PREF
Definition b44.h:331
#define MDIO_DATA_SB_START
Definition b44.h:187
#define MAC_CTRL_PHY_PDOWN
Definition b44.h:92
#define CAM_CTRL_BUSY
Definition b44.h:203
#define B44_CHIP_RESET_FULL
Definition b44.h:410
#define BCM4400_PCI_CORE_ADDR
Definition b44.h:392
#define B44_MIB_CTRL
Definition b44.h:216
#define RX_HEADER_LEN
Definition b44.h:374
#define RX_PKT_OFFSET
Definition b44.h:404
#define MDIO_DATA_PMD_SHIFT
Definition b44.h:180
#define B44_ISTAT
Definition b44.h:63
#define B44_RING_SIZE
Definition b44.h:398
#define SBTMSHIGH_BUSY
Definition b44.h:295
#define B44_RX_RING_LEN_BYTES
Definition b44.h:401
#define SSB_BAR0_WIN
Definition b44.h:309
#define B44_CAM_DATA_HI
Definition b44.h:194
#define B44_SBIMSTATE
Definition b44.h:267
#define TX_HIWMARK_DEFLT
Definition b44.h:215
#define B44_DEVCTRL
Definition b44.h:38
#define B44_SBTMSHIGH
Definition b44.h:292
#define ISTAT_ERRORS
Definition b44.h:78
#define B44_DMA_ALIGNMENT
Definition b44.h:356
#define IMASK_DISABLE
Definition b44.h:82
#define MDIO_DATA_TA_SHIFT
Definition b44.h:175
#define B44_ENET_CTRL
Definition b44.h:204
#define B44_FULL_RESET_SKIP_PHY
Definition b44.h:408
#define B44_30BIT_DMA_MASK
Definition b44.h:360
#define MIB_CTRL_CLR_ON_READ
Definition b44.h:217
#define B44_FULL_RESET
Definition b44.h:407
#define RXCONFIG_PROMISC
Definition b44.h:162
#define RXCONFIG_ALLMULTI
Definition b44.h:160
#define SBIDHIGH_RC_MASK
Definition b44.h:300
#define CAM_CTRL_INDEX_SHIFT
Definition b44.h:202
#define B44_DMARX_ADDR
Definition b44.h:130
#define B44_CAM_CTRL
Definition b44.h:196
#define SSB_PCI_BURST
Definition b44.h:332
#define B44_REGS_SIZE
Definition b44.h:415
#define ISTAT_TX
Definition b44.h:74
#define DEVCTRL_EPR
Definition b44.h:42
#define DMATX_CTRL_ENABLE
Definition b44.h:104
#define MDIO_DATA_DATA
Definition b44.h:173
#define SSB_CORE_DOWN
Definition b44.h:413
#define B44_MAX_MTU
Definition b44.h:396
#define DMATX_STAT_CDMASK
Definition b44.h:112
#define SBTMSLOW_REJECT
Definition b44.h:287
#define MAC_CTRL_PHY_LEDCTRL
Definition b44.h:94
#define B44_DMARX_CTRL
Definition b44.h:126
#define B44_PARTIAL_RESET
Definition b44.h:409
#define DESC_CTRL_EOT
Definition b44.h:364
#define B44_RXMAXLEN
Definition b44.h:167
#define CAM_CTRL_WRITE
Definition b44.h:200
#define B44_DMATX_ADDR
Definition b44.h:109
#define RCV_LAZY_FC_SHIFT
Definition b44.h:102
#define ENET_CTRL_EPSEL
Definition b44.h:208
#define MDIO_DATA_RA_SHIFT
Definition b44.h:178
#define B44_RCV_LAZY
Definition b44.h:99
#define SBTMSLOW_FGC
Definition b44.h:289
#define B44_SBIDHIGH
Definition b44.h:299
#define MDIO_TA_VALID
Definition b44.h:176
#define ENET_CTRL_DISABLE
Definition b44.h:206
#define MDIO_DATA_OP_SHIFT
Definition b44.h:182
#define DESC_CTRL_IOC
Definition b44.h:365
#define B44_TX_HIWMARK
Definition b44.h:214
#define EMAC_INT_MII
Definition b44.h:190
#define B44_SBTMSLOW
Definition b44.h:285
#define B44_DMATX_PTR
Definition b44.h:110
#define B44_DMATX_CTRL
Definition b44.h:103
#define B44_SBINTVEC
Definition b44.h:277
#define B44_MDIO_DATA
Definition b44.h:172
#define SBTMSLOW_CLOCK
Definition b44.h:288
#define B44_TX_RING_LEN_BYTES
Definition b44.h:402
#define SBINTVEC_ENET0
Definition b44.h:279
#define B44_TXMAXLEN
Definition b44.h:168
#define MAC_CTRL_CRC32_ENAB
Definition b44.h:91
void timeout(int)
uint8_t ctrl
Ring control.
Definition dwmac.h:7
ring len
Length.
Definition dwmac.h:226
uint32_t addr
Buffer address.
Definition dwmac.h:9
uint8_t data[48]
Additional event data.
Definition ena.h:11
uint64_t address
Base address.
Definition ena.h:13
Error codes.
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition ethernet.c:265
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition ethernet.c:176
Ethernet protocol.
static struct net_device * netdev
Definition gdbudp.c:53
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define EINVAL
Invalid argument.
Definition errno.h:429
#define ENOMEM
Not enough space.
Definition errno.h:535
#define ENOTSUP
Operation not supported.
Definition errno.h:590
#define ENOBUFS
No buffer space available.
Definition errno.h:499
#define ENODEV
No such device.
Definition errno.h:510
#define ETH_HLEN
Definition if_ether.h:10
#define u8
Definition igbvf_osdep.h:40
#define le16_to_cpu(value)
Definition byteswap.h:113
#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
static unsigned int unsigned int bit
Definition bigint.h:392
uint32_t pending
Pending events.
Definition hyperv.h:1
iPXE I/O API
#define wmb()
Definition io.h:546
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition io.h:184
void iounmap(volatile const void *io_addr)
Unmap I/O address.
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
void __asmcall int val
Definition setjmp.h:12
String functions.
void * memset(void *dest, int character, size_t len) __nonnull
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition iobuf.c:153
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition iobuf.c:131
I/O buffers.
#define iob_put(iobuf, len)
Definition iobuf.h:125
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition iobuf.h:160
#define iob_reserve(iobuf, len)
Definition iobuf.h:72
#define CTRL_MASK
Control character mask.
Definition keymap.c:42
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition malloc.c:707
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition malloc.c:723
Dynamic memory allocation.
Media Independent Interface constants.
#define BMCR_RESET
Definition mii.h:53
static unsigned int unsigned int reg
Definition myson.h:162
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_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(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition netdevice.h:767
struct option_descriptor clear[0]
Definition nvo_cmd.c:114
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition pci.c:241
PCI bus.
#define __pci_driver
Declare a PCI driver.
Definition pci.h:278
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition pci.h:366
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition pci.h:308
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition pci.h:376
uint16_t bp
Definition registers.h:9
Driver private state.
Definition b44.h:418
struct pci_device * pci
Definition b44.h:420
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
A PCI device ID list entry.
Definition pci.h:175
uint16_t vendor
PCI vendor ID.
Definition pci.h:179
const char * name
Name.
Definition pci.h:177
uint16_t device
PCI device ID.
Definition pci.h:181
A PCI device.
Definition pci.h:211
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
A PCI driver.
Definition pci.h:252
u16 flags
Definition b44.h:371
u16 len
Definition b44.h:370
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition timer.c:61
#define u16
Definition vga.h:20
#define u32
Definition vga.h:21
#define readl
Definition w89c840.c:157
#define writel
Definition w89c840.c:160
#define readw
Definition w89c840.c:156