Lines Matching refs:nic

66 #include "nic.h"
176 static int read_eeprom(struct nic *nic, int location, int addr_len);
177 static void rtl_reset(struct nic *nic);
178 static void rtl_transmit(struct nic *nic, const char *destaddr,
180 static int rtl_poll(struct nic *nic, int retrieve);
182 static void rtl_irq(struct nic *nic, irq_action_t action);
187 struct nic *nic = (struct nic *)dev;
191 unsigned short *ap = (unsigned short*)nic->node_addr;
198 nic->ioaddr = pci->ioaddr & ~3;
201 nic->irqno = pci->irq;
206 outb(0x00, nic->ioaddr + Config1);
208 addr_len = read_eeprom(nic,0,8) == 0x8129 ? 8 : 6;
210 *ap++ = read_eeprom(nic,i + 7,addr_len);
212 speed10 = inb(nic->ioaddr + MediaStatus) & MSRSpeed10;
213 fullduplex = inw(nic->ioaddr + MII_BMCR) & BMCRDuplex;
214 printf("ioaddr %#hX, irq %d, addr %! %sMbps %s-duplex\n", nic->ioaddr,
215 nic->irqno, nic->node_addr, speed10 ? "10" : "100",
218 rtl_reset(nic);
220 if (inb(nic->ioaddr + MediaStatus) & MSRLinkFail) {
226 nic->poll = rtl_poll;
227 nic->transmit = rtl_transmit;
228 nic->irq = rtl_irq;
256 static int read_eeprom(struct nic *nic, int location, int addr_len)
260 long ee_addr = nic->ioaddr + Cfg9346;
297 static void set_rx_mode(struct nic *nic) {
304 outl(rtl8139_rx_config | rx_mode, nic->ioaddr + RxConfig);
306 outl(mc_filter[0], nic->ioaddr + MAR0 + 0);
307 outl(mc_filter[1], nic->ioaddr + MAR0 + 4);
310 static void rtl_reset(struct nic* nic)
314 outb(CmdReset, nic->ioaddr + ChipCmd);
321 while ((inb(nic->ioaddr + ChipCmd) & CmdReset) != 0 &&
326 outb(nic->node_addr[i], nic->ioaddr + MAC0 + i);
329 outb(CmdRxEnb | CmdTxEnb, nic->ioaddr + ChipCmd);
331 nic->ioaddr + RxConfig); /* accept no frames yet! */
332 outl((TX_DMA_BURST<<8)|0x03000000, nic->ioaddr + TxConfig);
345 outl((unsigned long)virt_to_bus(rx_ring), nic->ioaddr + RxBuf);
353 outb(CmdRxEnb | CmdTxEnb, nic->ioaddr + ChipCmd);
355 outl(rtl8139_rx_config, nic->ioaddr + RxConfig);
358 outl(0, nic->ioaddr + RxMissed);
361 set_rx_mode(nic);
364 outw(0, nic->ioaddr + IntrMask);
367 static void rtl_transmit(struct nic *nic, const char *destaddr,
376 memcpy(tx_buffer + ETH_ALEN, nic->node_addr, ETH_ALEN);
391 outl((unsigned long)virt_to_bus(tx_buffer), nic->ioaddr + TxAddr0 + cur_tx*4);
393 nic->ioaddr + TxStatus0 + cur_tx*4);
398 status = inw(nic->ioaddr + IntrStatus);
402 outw(status & (TxOK | TxErr | PCIErr), nic->ioaddr + IntrStatus);
406 txstatus = inl(nic->ioaddr+ TxStatus0 + cur_tx*4);
419 rtl_reset(nic);
423 static int rtl_poll(struct nic *nic, int retrieve)
429 if (inb(nic->ioaddr + ChipCmd) & RxBufEmpty) {
436 status = inw(nic->ioaddr + IntrStatus);
438 outw(status & ~(RxFIFOOver | RxOverflow | RxOK), nic->ioaddr + IntrStatus);
452 rtl_reset(nic); /* this clears all interrupts still pending */
457 nic->packetlen = rx_size - 4; /* no one cares about the FCS */
461 memcpy(nic->packet, rx_ring + ring_offs + 4, semi_count);
462 memcpy(nic->packet+semi_count, rx_ring, rx_size-4-semi_count);
467 memcpy(nic->packet, rx_ring + ring_offs + 4, nic->packetlen);
475 nic->packet[12], nic->packet[13], rx_status);
478 outw(cur_rx - 16, nic->ioaddr + RxBufPtr);
482 outw(status & (RxFIFOOver | RxOverflow | RxOK), nic->ioaddr + IntrStatus);
486 static void rtl_irq(struct nic *nic, irq_action_t action)
495 mask = inw(nic->ioaddr + IntrMask);
498 outw(mask, nic->ioaddr + IntrMask);
507 outb(EROK, nic->ioaddr + RxEarlyStatus);
514 struct nic *nic = (struct nic *)dev;
516 rtl_reset(nic);
519 outb(CmdReset, nic->ioaddr + ChipCmd);
523 while ((inb(nic->ioaddr + ChipCmd) & CmdReset) != 0 && timer2_running())