iPXE
b44.c File Reference
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
#include <byteswap.h>
#include <ipxe/io.h>
#include <mii.h>
#include <ipxe/iobuf.h>
#include <ipxe/malloc.h>
#include <ipxe/pci.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include "b44.h"

Go to the source code of this file.

Macros

#define VIRT_TO_B44(addr)
#define CTRL_MASK   (DMARX_CTRL_ENABLE | (RX_PKT_OFFSET << DMARX_CTRL_ROSHIFT))

Functions

 FILE_LICENCE (GPL2_OR_LATER)
static int ring_next (int index)
static u32 br32 (const struct b44_private *bp, u32 reg)
static void bw32 (const struct b44_private *bp, u32 reg, u32 val)
static void bflush (const struct b44_private *bp, u32 reg, u32 timeout)
static int b44_address_ok (void *address)
 Check if card can access address.
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.
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.
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.
static u32 ssb_get_core_rev (struct b44_private *bp)
static int ssb_is_core_up (struct b44_private *bp)
static u32 ssb_pci_setup (struct b44_private *bp, u32 cores)
static void ssb_core_disable (struct b44_private *bp)
static void ssb_core_reset (struct b44_private *bp)
static void b44_chip_reset (struct b44_private *bp, int reset_kind)
static void b44_halt (struct b44_private *bp)
 called by b44_poll in the error path
static void b44_init_hw (struct b44_private *bp, int reset_kind)
static void b44_populate_rx_descriptor (struct b44_private *bp, u32 idx)
static void b44_rx_refill (struct b44_private *bp, u32 pending)
static void b44_free_rx_ring (struct b44_private *bp)
static int b44_init_rx_ring (struct b44_private *bp)
static void b44_free_tx_ring (struct b44_private *bp)
static int b44_init_tx_ring (struct b44_private *bp)
static int b44_phy_read (struct b44_private *bp, int reg, u32 *val)
static int b44_phy_write (struct b44_private *bp, int reg, u32 val)
static int b44_phy_reset (struct b44_private *bp)
static void b44_cam_write (struct b44_private *bp, unsigned char *data, int index)
static void b44_set_mac_addr (struct b44_private *bp)
static void b44_read_eeprom (struct b44_private *bp, u8 *data)
static void b44_load_mac_and_phy_addr (struct b44_private *bp)
static void b44_set_rx_mode (struct net_device *netdev)
static int b44_probe (struct pci_device *pci)
 Probe device.
static void b44_remove (struct pci_device *pci)
 Remove device.
static void b44_irq (struct net_device *netdev, int enable)
 Enable or disable interrupts.
static int b44_open (struct net_device *netdev)
 Open network device.
static void b44_close (struct net_device *netdev)
 Close network device.
static int b44_transmit (struct net_device *netdev, struct io_buffer *iobuf)
 Transmit packet.
static void b44_tx_complete (struct b44_private *bp)
 Recycles sent TX descriptors and notifies network stack.
static void b44_process_rx_packets (struct b44_private *bp)
static void b44_poll (struct net_device *netdev)
 Poll for completed and received packets.

Variables

static struct net_device_operations b44_operations
static struct pci_device_id b44_nics []
struct pci_driver b44_driver __pci_driver

Macro Definition Documentation

◆ VIRT_TO_B44

#define VIRT_TO_B44 ( addr)
Value:
#define SB_PCI_DMA
Definition b44.h:389
uint32_t addr
Buffer address.
Definition dwmac.h:9
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition io.h:184

Definition at line 79 of file b44.c.

Referenced by b44_init_hw(), b44_init_rx_ring(), b44_init_tx_ring(), b44_populate_rx_descriptor(), and b44_transmit().

◆ CTRL_MASK

#define CTRL_MASK   (DMARX_CTRL_ENABLE | (RX_PKT_OFFSET << DMARX_CTRL_ROSHIFT))

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER )

◆ ring_next()

int ring_next ( int index)
inlinestatic

Definition at line 51 of file b44.c.

52{
53 /* B44_RING_SIZE is a power of 2 :) */
54 return (index + 1) & (B44_RING_SIZE - 1);
55}
long index
Definition bigint.h:65
#define B44_RING_SIZE
Definition b44.h:398

References B44_RING_SIZE, and index.

Referenced by b44_process_rx_packets(), b44_rx_refill(), b44_transmit(), and b44_tx_complete().

◆ br32()

u32 br32 ( const struct b44_private * bp,
u32 reg )
inlinestatic

Definition at line 60 of file b44.c.

61{
62 return readl(bp->regs + reg);
63}
static unsigned int unsigned int reg
Definition myson.h:162
uint16_t bp
Definition registers.h:9
#define readl
Definition w89c840.c:157

References bp, readl, reg, and u32.

Referenced by b44_chip_reset(), b44_init_hw(), b44_phy_read(), b44_poll(), b44_set_mac_addr(), b44_set_rx_mode(), b44_wait_bit(), pending_rx_index(), pending_tx_index(), ssb_core_disable(), ssb_core_reset(), ssb_get_core_rev(), ssb_is_core_up(), and ssb_pci_setup().

◆ bw32()

void bw32 ( const struct b44_private * bp,
u32 reg,
u32 val )
inlinestatic

◆ bflush()

void bflush ( const struct b44_private * bp,
u32 reg,
u32 timeout )
inlinestatic

Definition at line 72 of file b44.c.

73{
74 readl(bp->regs + reg);
76}
void timeout(int)
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition timer.c:61

References bp, readl, reg, timeout(), u32, and udelay().

Referenced by b44_chip_reset(), b44_halt(), b44_poll(), ssb_core_disable(), and ssb_core_reset().

◆ b44_address_ok()

int b44_address_ok ( void * address)
inlinestatic

Check if card can access address.

Parameters
addressVirtual address
address_okCard can access address

Definition at line 89 of file b44.c.

89 {
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}
#define B44_30BIT_DMA_MASK
Definition b44.h:360
uint64_t address
Base address.
Definition ena.h:13

References address, B44_30BIT_DMA_MASK, and virt_to_bus().

Referenced by b44_init_rx_ring(), b44_init_tx_ring(), b44_rx_refill(), and b44_transmit().

◆ pending_tx_index()

u32 pending_tx_index ( struct b44_private * bp)
static

Ring cells waiting to be processed are between 'tx_cur' and 'pending' indexes in the ring.

Definition at line 102 of file b44.c.

103{
106
107 pending /= sizeof(struct dma_desc);
108 return pending & (B44_RING_SIZE - 1);
109}
static u32 br32(const struct b44_private *bp, u32 reg)
Definition b44.c:60
#define B44_DMATX_STAT
Definition b44.h:111
#define DMATX_STAT_CDMASK
Definition b44.h:112
uint32_t pending
Pending events.
Definition hyperv.h:1
#define u32
Definition vga.h:21

References B44_DMATX_STAT, B44_RING_SIZE, bp, br32(), DMATX_STAT_CDMASK, pending, and u32.

Referenced by b44_tx_complete().

◆ pending_rx_index()

u32 pending_rx_index ( struct b44_private * bp)
static

Ring cells waiting to be processed are between 'rx_cur' and 'pending' indexes in the ring.

Definition at line 116 of file b44.c.

117{
120
121 pending /= sizeof(struct dma_desc);
122 return pending & (B44_RING_SIZE - 1);
123}
#define DMARX_STAT_CDMASK
Definition b44.h:133
#define B44_DMARX_STAT
Definition b44.h:132

References B44_DMARX_STAT, B44_RING_SIZE, bp, br32(), DMARX_STAT_CDMASK, pending, and u32.

Referenced by b44_process_rx_packets().

◆ b44_wait_bit()

int b44_wait_bit ( struct b44_private * bp,
unsigned long reg,
u32 bit,
unsigned long timeout,
const int clear )
static

Wait until the given bit is set/cleared.

Definition at line 129 of file b44.c.

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}
#define ENODEV
No such device.
Definition errno.h:510
static unsigned int unsigned int bit
Definition bigint.h:392
struct option_descriptor clear[0]
Definition nvo_cmd.c:114

References bit, bp, br32(), clear, ENODEV, reg, timeout(), u32, udelay(), and val.

Referenced by b44_cam_write(), b44_chip_reset(), b44_phy_read(), b44_phy_write(), and ssb_core_disable().

◆ ssb_get_core_rev()

u32 ssb_get_core_rev ( struct b44_private * bp)
inlinestatic

Definition at line 164 of file b44.c.

165{
167}
#define SBIDHIGH_RC_MASK
Definition b44.h:300
#define B44_SBIDHIGH
Definition b44.h:299

References B44_SBIDHIGH, bp, br32(), SBIDHIGH_RC_MASK, and u32.

Referenced by ssb_pci_setup().

◆ ssb_is_core_up()

int ssb_is_core_up ( struct b44_private * bp)
inlinestatic

Definition at line 170 of file b44.c.

171{
173 == SBTMSLOW_CLOCK);
174}
#define SSB_CORE_DOWN
Definition b44.h:413
#define B44_SBTMSLOW
Definition b44.h:285
#define SBTMSLOW_CLOCK
Definition b44.h:288

References B44_SBTMSLOW, bp, br32(), SBTMSLOW_CLOCK, and SSB_CORE_DOWN.

Referenced by b44_chip_reset().

◆ ssb_pci_setup()

u32 ssb_pci_setup ( struct b44_private * bp,
u32 cores )
static

Definition at line 177 of file b44.c.

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}
static void bw32(const struct b44_private *bp, u32 reg, u32 val)
Definition b44.c:66
static u32 ssb_get_core_rev(struct b44_private *bp)
Definition b44.c:164
#define SSB_PCI_TRANS_2
Definition b44.h:324
#define SSB_PCI_PREF
Definition b44.h:331
#define BCM4400_PCI_CORE_ADDR
Definition b44.h:392
#define SSB_BAR0_WIN
Definition b44.h:309
#define SSB_PCI_BURST
Definition b44.h:332
#define B44_SBINTVEC
Definition b44.h:277
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.

References B44_SBINTVEC, BCM4400_PCI_CORE_ADDR, bp, br32(), bw32(), pci_read_config_dword(), pci_write_config_dword(), SSB_BAR0_WIN, ssb_get_core_rev(), SSB_PCI_BURST, SSB_PCI_PREF, SSB_PCI_TRANS_2, u32, and val.

Referenced by b44_chip_reset().

◆ ssb_core_disable()

void ssb_core_disable ( struct b44_private * bp)
static

Definition at line 200 of file b44.c.

201{
203 return;
204
208
212
215}
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 void bflush(const struct b44_private *bp, u32 reg, u32 timeout)
Definition b44.c:72
#define SBTMSLOW_RESET
Definition b44.h:286
#define SBTMSHIGH_BUSY
Definition b44.h:295
#define B44_SBTMSHIGH
Definition b44.h:292
#define SBTMSLOW_REJECT
Definition b44.h:287
#define SBTMSLOW_FGC
Definition b44.h:289

References B44_SBTMSHIGH, B44_SBTMSLOW, b44_wait_bit(), bflush(), bp, br32(), bw32(), SBTMSHIGH_BUSY, SBTMSLOW_CLOCK, SBTMSLOW_FGC, SBTMSLOW_REJECT, SBTMSLOW_RESET, and SSB_CORE_DOWN.

Referenced by b44_remove(), and ssb_core_reset().

◆ ssb_core_reset()

void ssb_core_reset ( struct b44_private * bp)
static

Definition at line 218 of file b44.c.

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}
static void ssb_core_disable(struct b44_private *bp)
Definition b44.c:200
#define SBTMSHIGH_SERR
Definition b44.h:293
#define SBIMSTATE_BAD
Definition b44.h:276
#define B44_SBIMSTATE
Definition b44.h:267

References B44_SBIMSTATE, B44_SBTMSHIGH, B44_SBTMSLOW, bflush(), bp, br32(), bw32(), SBIMSTATE_BAD, SBTMSHIGH_SERR, SBTMSLOW_CLOCK, SBTMSLOW_FGC, SBTMSLOW_RESET, ssb_core_disable(), u32, and val.

Referenced by b44_chip_reset().

◆ b44_chip_reset()

void b44_chip_reset ( struct b44_private * bp,
int reset_kind )
static

Definition at line 258 of file b44.c.

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}
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 int ssb_is_core_up(struct b44_private *bp)
Definition b44.c:170
#define DEVCTRL_IPP
Definition b44.h:41
#define B44_CHIP_RESET_PARTIAL
Definition b44.h:411
#define B44_MDIO_CTRL
Definition b44.h:169
#define MDIO_CTRL_MAXF_MASK
Definition b44.h:170
#define MDIO_CTRL_PREAMBLE
Definition b44.h:171
#define DMARX_STAT_EMASK
Definition b44.h:139
#define DMARX_STAT_SIDLE
Definition b44.h:137
#define B44_DEVCTRL
Definition b44.h:38
#define B44_ENET_CTRL
Definition b44.h:204
#define DEVCTRL_EPR
Definition b44.h:42
#define B44_DMARX_CTRL
Definition b44.h:126
#define ENET_CTRL_EPSEL
Definition b44.h:208
#define B44_RCV_LAZY
Definition b44.h:99
#define ENET_CTRL_DISABLE
Definition b44.h:206
#define B44_DMATX_CTRL
Definition b44.h:103
#define SBINTVEC_ENET0
Definition b44.h:279

References B44_CHIP_RESET_PARTIAL, B44_DEVCTRL, B44_DMARX_CTRL, B44_DMARX_STAT, B44_DMATX_CTRL, B44_ENET_CTRL, B44_MDIO_CTRL, B44_RCV_LAZY, b44_wait_bit(), bflush(), bp, br32(), bw32(), DEVCTRL_EPR, DEVCTRL_IPP, DMARX_STAT_EMASK, DMARX_STAT_SIDLE, ENET_CTRL_DISABLE, ENET_CTRL_EPSEL, MDIO_CTRL_MAXF_MASK, MDIO_CTRL_PREAMBLE, SBINTVEC_ENET0, ssb_core_reset(), ssb_is_core_up(), ssb_pci_setup(), u32, and val.

Referenced by b44_close(), b44_halt(), b44_init_hw(), and b44_probe().

◆ b44_halt()

void b44_halt ( struct b44_private * bp)
static

called by b44_poll in the error path

Definition at line 310 of file b44.c.

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}
static void b44_chip_reset(struct b44_private *bp, int reset_kind)
Definition b44.c:258
#define B44_MAC_CTRL
Definition b44.h:90
#define B44_IMASK
Definition b44.h:80
#define MAC_CTRL_PHY_PDOWN
Definition b44.h:92
#define DBG(...)
Print a debugging message.
Definition compiler.h:498

References b44_chip_reset(), B44_CHIP_RESET_PARTIAL, B44_IMASK, B44_MAC_CTRL, bflush(), bp, bw32(), DBG, and MAC_CTRL_PHY_PDOWN.

Referenced by b44_poll().

◆ b44_init_hw()

void b44_init_hw ( struct b44_private * bp,
int reset_kind )
static

Definition at line 335 of file b44.c.

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}
static int b44_phy_reset(struct b44_private *bp)
Definition b44.c:536
#define VIRT_TO_B44(addr)
Definition b44.c:79
static void b44_set_rx_mode(struct net_device *netdev)
Definition b44.c:624
#define ENET_CTRL_ENABLE
Definition b44.h:205
#define B44_DMARX_PTR
Definition b44.h:131
#define B44_CHIP_RESET_FULL
Definition b44.h:410
#define B44_MIB_CTRL
Definition b44.h:216
#define RX_HEADER_LEN
Definition b44.h:374
#define B44_RX_RING_LEN_BYTES
Definition b44.h:401
#define TX_HIWMARK_DEFLT
Definition b44.h:215
#define MIB_CTRL_CLR_ON_READ
Definition b44.h:217
#define B44_FULL_RESET
Definition b44.h:407
#define B44_DMARX_ADDR
Definition b44.h:130
#define DMATX_CTRL_ENABLE
Definition b44.h:104
#define B44_MAX_MTU
Definition b44.h:396
#define MAC_CTRL_PHY_LEDCTRL
Definition b44.h:94
#define B44_PARTIAL_RESET
Definition b44.h:409
#define B44_RXMAXLEN
Definition b44.h:167
#define B44_DMATX_ADDR
Definition b44.h:109
#define RCV_LAZY_FC_SHIFT
Definition b44.h:102
#define B44_TX_HIWMARK
Definition b44.h:214
#define B44_TXMAXLEN
Definition b44.h:168
#define MAC_CTRL_CRC32_ENAB
Definition b44.h:91
#define ETH_HLEN
Definition if_ether.h:10
#define CTRL_MASK
Control character mask.
Definition keymap.c:42

References b44_chip_reset(), B44_CHIP_RESET_FULL, B44_DMARX_ADDR, B44_DMARX_CTRL, B44_DMARX_PTR, B44_DMATX_ADDR, B44_DMATX_CTRL, B44_ENET_CTRL, B44_FULL_RESET, B44_MAC_CTRL, B44_MAX_MTU, B44_MIB_CTRL, B44_PARTIAL_RESET, b44_phy_reset(), B44_RCV_LAZY, B44_RX_RING_LEN_BYTES, B44_RXMAXLEN, b44_set_rx_mode(), B44_TX_HIWMARK, B44_TXMAXLEN, bp, br32(), bw32(), CTRL_MASK, DMATX_CTRL_ENABLE, ENET_CTRL_ENABLE, ETH_HLEN, MAC_CTRL_CRC32_ENAB, MAC_CTRL_PHY_LEDCTRL, MIB_CTRL_CLR_ON_READ, RCV_LAZY_FC_SHIFT, RX_HEADER_LEN, TX_HIWMARK_DEFLT, u32, val, and VIRT_TO_B44.

Referenced by b44_open(), and b44_poll().

◆ b44_populate_rx_descriptor()

void b44_populate_rx_descriptor ( struct b44_private * bp,
u32 idx )
static

Definition at line 379 of file b44.c.

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}
#define B44_RING_LAST
Definition b44.h:399
#define RX_PKT_BUF_SZ
Definition b44.h:405
#define DESC_CTRL_LEN
Definition b44.h:362
#define RX_PKT_OFFSET
Definition b44.h:404
#define DESC_CTRL_EOT
Definition b44.h:364
uint8_t ctrl
Ring control.
Definition dwmac.h:7
#define cpu_to_le32(value)
Definition byteswap.h:108
u16 flags
Definition b44.h:371
u16 len
Definition b44.h:370

References addr, B44_DMARX_PTR, B44_RING_LAST, bp, bw32(), cpu_to_le32, ctrl, DESC_CTRL_EOT, DESC_CTRL_LEN, rx_header::flags, rx_header::len, RX_PKT_BUF_SZ, RX_PKT_OFFSET, u32, and VIRT_TO_B44.

Referenced by b44_init_rx_ring(), and b44_rx_refill().

◆ b44_rx_refill()

void b44_rx_refill ( struct b44_private * bp,
u32 pending )
static

Definition at line 404 of file b44.c.

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}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
static int ring_next(int index)
Definition b44.c:51
static int b44_address_ok(void *address)
Check if card can access address.
Definition b44.c:89
static void b44_populate_rx_descriptor(struct b44_private *bp, u32 idx)
Definition b44.c:379
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
A persistent I/O buffer.
Definition iobuf.h:38
void * data
Start of data.
Definition iobuf.h:53

References alloc_iob(), b44_address_ok(), b44_populate_rx_descriptor(), bp, io_buffer::data, DBG, free_iob(), NULL, pending, ring_next(), RX_PKT_BUF_SZ, and u32.

Referenced by b44_init_rx_ring(), and b44_process_rx_packets().

◆ b44_free_rx_ring()

void b44_free_rx_ring ( struct b44_private * bp)
static

Definition at line 431 of file b44.c.

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}
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition malloc.c:723

References B44_RING_SIZE, B44_RX_RING_LEN_BYTES, bp, free_iob(), free_phys(), NULL, and u32.

Referenced by b44_close(), and b44_init_rx_ring().

◆ b44_init_rx_ring()

int b44_init_rx_ring ( struct b44_private * bp)
static

Definition at line 446 of file b44.c.

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}
static void b44_free_rx_ring(struct b44_private *bp)
Definition b44.c:431
static void b44_rx_refill(struct b44_private *bp, u32 pending)
Definition b44.c:404
#define B44_DMA_ALIGNMENT
Definition b44.h:356
#define ENOMEM
Not enough space.
Definition errno.h:535
#define ENOTSUP
Operation not supported.
Definition errno.h:590
void * memset(void *dest, int character, size_t len) __nonnull
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition malloc.c:707

References alloc_iob(), b44_address_ok(), B44_DMA_ALIGNMENT, b44_free_rx_ring(), b44_populate_rx_descriptor(), b44_rx_refill(), B44_RX_RING_LEN_BYTES, bp, DBG, ENOMEM, ENOTSUP, free_phys(), malloc_phys(), memset(), RX_PKT_BUF_SZ, and VIRT_TO_B44.

Referenced by b44_open(), and b44_poll().

◆ b44_free_tx_ring()

void b44_free_tx_ring ( struct b44_private * bp)
static

Definition at line 469 of file b44.c.

470{
471 if (bp->tx) {
473 bp->tx = NULL;
474 }
475}
#define B44_TX_RING_LEN_BYTES
Definition b44.h:402

References B44_TX_RING_LEN_BYTES, bp, free_phys(), and NULL.

Referenced by b44_close(), and b44_init_tx_ring().

◆ b44_init_tx_ring()

int b44_init_tx_ring ( struct b44_private * bp)
static

Definition at line 478 of file b44.c.

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}
static void b44_free_tx_ring(struct b44_private *bp)
Definition b44.c:469

References b44_address_ok(), B44_DMA_ALIGNMENT, b44_free_tx_ring(), B44_TX_RING_LEN_BYTES, bp, DBG, ENOMEM, ENOTSUP, free_phys(), malloc_phys(), memset(), and VIRT_TO_B44.

Referenced by b44_open(), and b44_poll().

◆ b44_phy_read()

int b44_phy_read ( struct b44_private * bp,
int reg,
u32 * val )
static

Definition at line 501 of file b44.c.

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}
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
#define MDIO_OP_READ
Definition b44.h:184
#define B44_EMAC_ISTAT
Definition b44.h:189
#define MDIO_DATA_SB_START
Definition b44.h:187
#define MDIO_DATA_PMD_SHIFT
Definition b44.h:180
#define MDIO_DATA_TA_SHIFT
Definition b44.h:175
#define MDIO_DATA_DATA
Definition b44.h:173
#define MDIO_DATA_RA_SHIFT
Definition b44.h:178
#define MDIO_TA_VALID
Definition b44.h:176
#define MDIO_DATA_OP_SHIFT
Definition b44.h:182
#define EMAC_INT_MII
Definition b44.h:190
#define B44_MDIO_DATA
Definition b44.h:172

References arg1, arg2, arg3, arg4, B44_EMAC_ISTAT, B44_MDIO_DATA, b44_wait_bit(), bp, br32(), bw32(), EMAC_INT_MII, MDIO_DATA_DATA, MDIO_DATA_OP_SHIFT, MDIO_DATA_PMD_SHIFT, MDIO_DATA_RA_SHIFT, MDIO_DATA_SB_START, MDIO_DATA_TA_SHIFT, MDIO_OP_READ, MDIO_TA_VALID, reg, u32, and val.

Referenced by b44_phy_reset().

◆ b44_phy_write()

int b44_phy_write ( struct b44_private * bp,
int reg,
u32 val )
static

Definition at line 520 of file b44.c.

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}
static unsigned int unsigned long unsigned long unsigned long unsigned long unsigned long arg5
Definition xen.h:149
#define MDIO_OP_WRITE
Definition b44.h:183

References arg1, arg2, arg3, arg4, arg5, B44_EMAC_ISTAT, B44_MDIO_DATA, b44_wait_bit(), bp, bw32(), EMAC_INT_MII, MDIO_DATA_DATA, MDIO_DATA_OP_SHIFT, MDIO_DATA_PMD_SHIFT, MDIO_DATA_RA_SHIFT, MDIO_DATA_SB_START, MDIO_DATA_TA_SHIFT, MDIO_OP_WRITE, MDIO_TA_VALID, reg, u32, and val.

Referenced by b44_phy_reset().

◆ b44_phy_reset()

int b44_phy_reset ( struct b44_private * bp)
static

Definition at line 536 of file b44.c.

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}
#define MII_BMCR
Definition atl1e.h:871
static int b44_phy_write(struct b44_private *bp, int reg, u32 val)
Definition b44.c:520
static int b44_phy_read(struct b44_private *bp, int reg, u32 *val)
Definition b44.c:501
#define BMCR_RESET
Definition mii.h:53

References b44_phy_read(), b44_phy_write(), BMCR_RESET, bp, ENODEV, MII_BMCR, u32, udelay(), and val.

Referenced by b44_init_hw().

◆ b44_cam_write()

void b44_cam_write ( struct b44_private * bp,
unsigned char * data,
int index )
static

Definition at line 561 of file b44.c.

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}
#define B44_CAM_DATA_LO
Definition b44.h:193
#define CAM_DATA_HI_VALID
Definition b44.h:195
#define CAM_CTRL_BUSY
Definition b44.h:203
#define B44_CAM_DATA_HI
Definition b44.h:194
#define CAM_CTRL_INDEX_SHIFT
Definition b44.h:202
#define B44_CAM_CTRL
Definition b44.h:196
#define CAM_CTRL_WRITE
Definition b44.h:200
uint8_t data[48]
Additional event data.
Definition ena.h:11

References B44_CAM_CTRL, B44_CAM_DATA_HI, B44_CAM_DATA_LO, b44_wait_bit(), bp, bw32(), CAM_CTRL_BUSY, CAM_CTRL_INDEX_SHIFT, CAM_CTRL_WRITE, CAM_DATA_HI_VALID, data, index, u32, and val.

Referenced by b44_set_mac_addr(), and b44_set_rx_mode().

◆ b44_set_mac_addr()

void b44_set_mac_addr ( struct b44_private * bp)
static

Definition at line 585 of file b44.c.

586{
587 u32 val;
588 bw32(bp, B44_CAM_CTRL, 0);
589 b44_cam_write(bp, bp->netdev->ll_addr, 0);
592}
static void b44_cam_write(struct b44_private *bp, unsigned char *data, int index)
Definition b44.c:561
#define CAM_CTRL_ENABLE
Definition b44.h:197

References B44_CAM_CTRL, b44_cam_write(), bp, br32(), bw32(), CAM_CTRL_ENABLE, u32, and val.

Referenced by b44_set_rx_mode().

◆ b44_read_eeprom()

void b44_read_eeprom ( struct b44_private * bp,
u8 * data )
static

Definition at line 596 of file b44.c.

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}
#define cpu_to_le16(value)
Definition byteswap.h:107
#define u16
Definition vga.h:20
#define readw
Definition w89c840.c:156

References bp, cpu_to_le16, data, readw, u16, and u8.

Referenced by b44_load_mac_and_phy_addr().

◆ b44_load_mac_and_phy_addr()

void b44_load_mac_and_phy_addr ( struct b44_private * bp)
static

Definition at line 606 of file b44.c.

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}
eeprom
Definition 3c90x.h:232
static void b44_read_eeprom(struct b44_private *bp, u8 *data)
Definition b44.c:596
#define u8
Definition igbvf_osdep.h:40

References b44_read_eeprom(), bp, and u8.

Referenced by b44_probe().

◆ b44_set_rx_mode()

void b44_set_rx_mode ( struct net_device * netdev)
static

Definition at line 624 of file b44.c.

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}
static void b44_set_mac_addr(struct b44_private *bp)
Definition b44.c:585
#define B44_RXCONFIG
Definition b44.h:158
#define RXCONFIG_PROMISC
Definition b44.h:162
#define RXCONFIG_ALLMULTI
Definition b44.h:160
static struct net_device * netdev
Definition gdbudp.c:53
Driver private state.
Definition b44.h:418

References B44_CAM_CTRL, b44_cam_write(), B44_RXCONFIG, b44_set_mac_addr(), bp, br32(), bw32(), CAM_CTRL_ENABLE, netdev, RXCONFIG_ALLMULTI, RXCONFIG_PROMISC, u32, and val.

Referenced by b44_init_hw().

◆ b44_probe()

int b44_probe ( struct pci_device * pci)
static

Probe device.

Parameters
pciPCI device
idMatching entry in ID table
Return values
rcReturn status code

Definition at line 655 of file b44.c.

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}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
static void b44_load_mac_and_phy_addr(struct b44_private *bp)
Definition b44.c:606
static struct net_device_operations b44_operations
Definition b44.c:939
#define B44_REGS_SIZE
Definition b44.h:415
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
void iounmap(volatile const void *io_addr)
Unmap I/O address.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
int register_netdev(struct net_device *netdev)
Register network device.
Definition netdevice.c:760
static void netdev_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_put(struct net_device *netdev)
Drop reference to network device.
Definition netdevice.h:576
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition pci.c:241
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition pci.h:366
struct pci_device * pci
Definition b44.h:420
A network device.
Definition netdevice.h:353
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
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

References adjust_pci_device(), alloc_etherdev(), b44_chip_reset(), B44_CHIP_RESET_FULL, b44_load_mac_and_phy_addr(), b44_operations, B44_REGS_SIZE, bp, DBG, pci_device::dev, pci_device_id::device, ENOMEM, eth_ntoa(), pci_device::id, iounmap(), pci_device::membase, memset(), pci_device_id::name, netdev, netdev_init(), netdev_link_up(), netdev_put(), b44_private::pci, pci_ioremap(), pci_set_drvdata(), rc, register_netdev(), and pci_device_id::vendor.

◆ b44_remove()

void b44_remove ( struct pci_device * pci)
static

Remove device.

Parameters
pciPCI device

Definition at line 713 of file b44.c.

714{
715 struct net_device *netdev = pci_get_drvdata(pci);
716 struct b44_private *bp = netdev->priv;
717
720 iounmap(bp->regs);
723}
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition netdevice.c:942
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition netdevice.h:532
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition pci.h:376

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

◆ b44_irq()

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

Enable or disable interrupts.

Parameters
netdevNetwork device
enableInterrupts should be enabled

Definition at line 731 of file b44.c.

732{
733 struct b44_private *bp = netdev->priv;
734
735 /* Interrupt mask specifies which events generate interrupts */
737}
#define IMASK_DEF
Definition b44.h:81
#define IMASK_DISABLE
Definition b44.h:82

References B44_IMASK, bp, bw32(), IMASK_DEF, IMASK_DISABLE, and netdev.

Referenced by b44_open(), and b44_poll().

◆ b44_open()

int b44_open ( struct net_device * netdev)
static

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 745 of file b44.c.

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}
static int b44_init_rx_ring(struct b44_private *bp)
Definition b44.c:446
static int b44_init_tx_ring(struct b44_private *bp)
Definition b44.c:478
static void b44_init_hw(struct b44_private *bp, int reset_kind)
Definition b44.c:335
static void b44_irq(struct net_device *netdev, int enable)
Enable or disable interrupts.
Definition b44.c:731

References B44_FULL_RESET, b44_init_hw(), b44_init_rx_ring(), b44_init_tx_ring(), b44_irq(), bp, netdev, and rc.

◆ b44_close()

void b44_close ( struct net_device * netdev)
static

Close network device.

Parameters
netdevNetwork device

Definition at line 771 of file b44.c.

772{
773 struct b44_private *bp = netdev->priv;
774
778}

References b44_chip_reset(), b44_free_rx_ring(), b44_free_tx_ring(), B44_FULL_RESET, bp, and netdev.

◆ b44_transmit()

int b44_transmit ( struct net_device * netdev,
struct io_buffer * iobuf )
static

Transmit packet.

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

Definition at line 787 of file b44.c.

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}
#define DESC_CTRL_SOF
Definition b44.h:367
#define DESC_CTRL_EOF
Definition b44.h:366
#define DESC_CTRL_IOC
Definition b44.h:365
#define B44_DMATX_PTR
Definition b44.h:110
#define ENOBUFS
No buffer space available.
Definition errno.h:499
#define wmb()
Definition io.h:546
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition iobuf.h:160

References b44_address_ok(), B44_DMATX_PTR, B44_RING_LAST, bp, bw32(), cpu_to_le32, ctrl, io_buffer::data, DBG, DESC_CTRL_EOF, DESC_CTRL_EOT, DESC_CTRL_IOC, DESC_CTRL_LEN, DESC_CTRL_SOF, ENOBUFS, ENOTSUP, iob_len(), netdev, ring_next(), u32, VIRT_TO_B44, and wmb.

◆ b44_tx_complete()

void b44_tx_complete ( struct b44_private * bp)
static

Recycles sent TX descriptors and notifies network stack.

Parameters
bpDriver state

Definition at line 831 of file b44.c.

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}
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 netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition netdevice.h:767

References bp, netdev_tx_complete(), NULL, pending_tx_index(), ring_next(), and u32.

Referenced by b44_poll().

◆ b44_process_rx_packets()

void b44_process_rx_packets ( struct b44_private * bp)
static

Definition at line 850 of file b44.c.

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}
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
#define RX_FLAG_ERRORS
Definition b44.h:385
ring len
Length.
Definition dwmac.h:226
#define EINVAL
Invalid argument.
Definition errno.h:429
#define le16_to_cpu(value)
Definition byteswap.h:113
#define iob_put(iobuf, len)
Definition iobuf.h:125
#define iob_reserve(iobuf, len)
Definition iobuf.h:72
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition netdevice.c:549
void netdev_rx_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Discard received packet.
Definition netdevice.c:587

References b44_rx_refill(), bp, cpu_to_le16, io_buffer::data, DBG, EINVAL, rx_header::flags, iob_put, iob_reserve, le16_to_cpu, len, rx_header::len, netdev_rx(), netdev_rx_err(), NULL, pending, pending_rx_index(), ring_next(), RX_FLAG_ERRORS, RX_PKT_BUF_SZ, RX_PKT_OFFSET, u16, and u32.

Referenced by b44_poll().

◆ b44_poll()

void b44_poll ( struct net_device * netdev)
static

Poll for completed and received packets.

Parameters
netdevNetwork device

Definition at line 907 of file b44.c.

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}
static void b44_process_rx_packets(struct b44_private *bp)
Definition b44.c:850
static void b44_halt(struct b44_private *bp)
called by b44_poll in the error path
Definition b44.c:310
static void b44_tx_complete(struct b44_private *bp)
Recycles sent TX descriptors and notifies network stack.
Definition b44.c:831
#define ISTAT_RX
Definition b44.h:73
#define B44_ISTAT
Definition b44.h:63
#define ISTAT_ERRORS
Definition b44.h:78
#define B44_FULL_RESET_SKIP_PHY
Definition b44.h:408
#define ISTAT_TX
Definition b44.h:74

References B44_FULL_RESET_SKIP_PHY, b44_halt(), b44_init_hw(), b44_init_rx_ring(), b44_init_tx_ring(), b44_irq(), B44_ISTAT, b44_process_rx_packets(), b44_tx_complete(), bflush(), bp, br32(), bw32(), DBG, IMASK_DEF, ISTAT_ERRORS, ISTAT_RX, ISTAT_TX, netdev, and u32.

Variable Documentation

◆ b44_operations

struct net_device_operations b44_operations
static
Initial value:
= {
.open = b44_open,
.close = b44_close,
.transmit = b44_transmit,
.poll = b44_poll,
.irq = b44_irq,
}
static int b44_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition b44.c:787
static int b44_open(struct net_device *netdev)
Open network device.
Definition b44.c:745
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

Definition at line 939 of file b44.c.

939 {
940 .open = b44_open,
941 .close = b44_close,
942 .transmit = b44_transmit,
943 .poll = b44_poll,
944 .irq = b44_irq,
945};

Referenced by b44_probe().

◆ b44_nics

struct pci_device_id b44_nics[]
static
Initial value:
= {
PCI_ROM(0x14e4, 0x170c, "BCM4401-B0", "BCM4401-B0", 0),
PCI_ROM(0x14e4, 0x4401, "BCM4401", "BCM4401", 0),
PCI_ROM(0x14e4, 0x4402, "BCM4401-B1", "BCM4401-B1", 0),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition pci.h:308

Definition at line 948 of file b44.c.

948 {
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};

◆ __pci_driver

struct pci_driver b44_driver __pci_driver
Initial value:
= {
.ids = b44_nics,
.id_count = sizeof b44_nics / sizeof b44_nics[0],
.probe = b44_probe,
.remove = b44_remove,
}
static int b44_probe(struct pci_device *pci)
Probe device.
Definition b44.c:655
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

Definition at line 955 of file b44.c.

955 {
956 .ids = b44_nics,
957 .id_count = sizeof b44_nics / sizeof b44_nics[0],
958 .probe = b44_probe,
959 .remove = b44_remove,
960};