Lines Matching refs:data
173 struct tsi108_prv_data *data = netdev_priv(dev);
179 TSI_READ(TSI108_EC_INTMASK), data->phy_ok,
180 data->link_up, data->speed, data->duplex);
183 data->txhead, data->txtail, data->txfree,
190 data->rxhead, data->rxtail, data->rxfree,
193 TSI_READ(TSI108_EC_RXERR), data->rxpending);
203 static int tsi108_read_mii(struct tsi108_prv_data *data, int reg)
208 (data->phy << TSI108_MAC_MII_ADDR_PHY) |
225 static void tsi108_write_mii(struct tsi108_prv_data *data,
230 (data->phy << TSI108_MAC_MII_ADDR_PHY) |
243 struct tsi108_prv_data *data = netdev_priv(dev);
244 return tsi108_read_mii(data, reg);
249 struct tsi108_prv_data *data = netdev_priv(dev);
250 tsi108_write_mii(data, reg, val);
253 static inline void tsi108_write_tbi(struct tsi108_prv_data *data,
296 struct tsi108_prv_data *data = netdev_priv(dev);
304 if (!data->phy_ok)
307 duplex = mii_check_media(&data->mii_if, netif_msg_link(data), data->init_media);
308 data->init_media = 0;
312 speed = mii_speed(&data->mii_if);
314 if ((speed != data->speed) || duplex) {
329 data->speed = speed;
331 if (data->mii_if.full_duplex) {
334 data->duplex = 2;
338 data->duplex = 1;
345 if (data->link_up == 0) {
351 spin_lock(&data->txlock);
352 if (is_valid_ether_addr(dev->dev_addr) && data->txfree)
355 data->link_up = 1;
356 spin_unlock(&data->txlock);
359 if (data->link_up == 1) {
361 data->link_up = 0;
383 struct tsi108_prv_data *data = netdev_priv(dev);
386 spin_lock_irq(&data->misclock);
395 TSI108_STAT_RXBYTES_CARRY, &data->stats.rx_bytes);
399 &data->stats.rx_packets);
402 TSI108_STAT_RXFCS_CARRY, &data->rx_fcs);
406 &data->stats.multicast);
410 &data->stats.rx_frame_errors);
414 &data->stats.rx_length_errors);
417 TSI108_STAT_RXRUNT_CARRY, &data->rx_underruns);
420 TSI108_STAT_RXJUMBO_CARRY, &data->rx_overruns);
423 TSI108_STAT_RXFRAG_CARRY, &data->rx_short_fcs);
426 TSI108_STAT_RXJABBER_CARRY, &data->rx_long_fcs);
430 &data->stats.rx_missed_errors);
433 TSI108_STAT_TXBYTES_CARRY, &data->stats.tx_bytes);
437 &data->stats.tx_packets);
441 &data->stats.tx_aborted_errors);
444 TSI108_STAT_TXEXCOL_CARRY, &data->tx_coll_abort);
448 &data->stats.collisions);
452 &data->tx_pause_drop);
454 spin_unlock_irq(&data->misclock);
458 * data->misclock must be held.
461 tsi108_read_stat(struct tsi108_prv_data * data, int reg, int carry_bit,
493 struct tsi108_prv_data *data = netdev_priv(dev);
494 spin_lock_irq(&data->misclock);
496 data->tmpstats.rx_packets =
497 tsi108_read_stat(data, TSI108_STAT_RXPKTS,
499 TSI108_STAT_RXPKTS_CARRY, &data->stats.rx_packets);
501 data->tmpstats.tx_packets =
502 tsi108_read_stat(data, TSI108_STAT_TXPKTS,
504 TSI108_STAT_TXPKTS_CARRY, &data->stats.tx_packets);
506 data->tmpstats.rx_bytes =
507 tsi108_read_stat(data, TSI108_STAT_RXBYTES,
509 TSI108_STAT_RXBYTES_CARRY, &data->stats.rx_bytes);
511 data->tmpstats.tx_bytes =
512 tsi108_read_stat(data, TSI108_STAT_TXBYTES,
514 TSI108_STAT_TXBYTES_CARRY, &data->stats.tx_bytes);
516 data->tmpstats.multicast =
517 tsi108_read_stat(data, TSI108_STAT_RXMCAST,
519 TSI108_STAT_RXMCAST_CARRY, &data->stats.multicast);
521 excol = tsi108_read_stat(data, TSI108_STAT_TXEXCOL,
524 &data->tx_coll_abort);
526 data->tmpstats.collisions =
527 tsi108_read_stat(data, TSI108_STAT_TXTCOL,
529 TSI108_STAT_TXTCOL_CARRY, &data->stats.collisions);
531 data->tmpstats.collisions += excol;
533 data->tmpstats.rx_length_errors =
534 tsi108_read_stat(data, TSI108_STAT_RXLENGTH,
537 &data->stats.rx_length_errors);
539 data->tmpstats.rx_length_errors +=
540 tsi108_read_stat(data, TSI108_STAT_RXRUNT,
542 TSI108_STAT_RXRUNT_CARRY, &data->rx_underruns);
544 data->tmpstats.rx_length_errors +=
545 tsi108_read_stat(data, TSI108_STAT_RXJUMBO,
547 TSI108_STAT_RXJUMBO_CARRY, &data->rx_overruns);
549 data->tmpstats.rx_frame_errors =
550 tsi108_read_stat(data, TSI108_STAT_RXALIGN,
553 &data->stats.rx_frame_errors);
555 data->tmpstats.rx_frame_errors +=
556 tsi108_read_stat(data, TSI108_STAT_RXFCS,
558 &data->rx_fcs);
560 data->tmpstats.rx_frame_errors +=
561 tsi108_read_stat(data, TSI108_STAT_RXFRAG,
563 TSI108_STAT_RXFRAG_CARRY, &data->rx_short_fcs);
565 data->tmpstats.rx_missed_errors =
566 tsi108_read_stat(data, TSI108_STAT_RXDROP,
569 &data->stats.rx_missed_errors);
572 data->tmpstats.rx_fifo_errors = data->stats.rx_fifo_errors;
573 data->tmpstats.rx_crc_errors = data->stats.rx_crc_errors;
575 data->tmpstats.tx_aborted_errors =
576 tsi108_read_stat(data, TSI108_STAT_TXEXDEF,
579 &data->stats.tx_aborted_errors);
581 data->tmpstats.tx_aborted_errors +=
582 tsi108_read_stat(data, TSI108_STAT_TXPAUSEDROP,
585 &data->tx_pause_drop);
587 data->tmpstats.tx_aborted_errors += excol;
589 data->tmpstats.tx_errors = data->tmpstats.tx_aborted_errors;
590 data->tmpstats.rx_errors = data->tmpstats.rx_length_errors +
591 data->tmpstats.rx_crc_errors +
592 data->tmpstats.rx_frame_errors +
593 data->tmpstats.rx_fifo_errors + data->tmpstats.rx_missed_errors;
595 spin_unlock_irq(&data->misclock);
596 return &data->tmpstats;
599 static void tsi108_restart_rx(struct tsi108_prv_data * data, struct net_device *dev)
608 static void tsi108_restart_tx(struct tsi108_prv_data * data)
622 struct tsi108_prv_data *data = netdev_priv(dev);
627 while (!data->txfree || data->txhead != data->txtail) {
628 tx = data->txtail;
630 if (data->txring[tx].misc & TSI108_TX_OWN)
633 skb = data->txskbs[tx];
635 if (!(data->txring[tx].misc & TSI108_TX_OK))
637 dev->name, data->txring[tx].misc);
639 data->txtail = (data->txtail + 1) % TSI108_TXRING_LEN;
640 data->txfree++;
642 if (data->txring[tx].misc & TSI108_TX_EOF) {
649 if (is_valid_ether_addr(dev->dev_addr) && data->link_up)
656 struct tsi108_prv_data *data = netdev_priv(dev);
660 if (!data->phy_ok && net_ratelimit())
663 if (!data->link_up) {
670 if (data->txfree < MAX_SKB_FRAGS + 1) {
679 if (data->txfree - frags < MAX_SKB_FRAGS + 1) {
683 spin_lock_irq(&data->txlock);
687 int tx = data->txhead;
700 ((TSI108_TXRING_LEN - data->txfree) >= TSI108_TX_INT_FREQ))
703 data->txskbs[tx] = skb;
706 data->txring[tx].buf0 = dma_map_single(NULL, skb->data,
708 data->txring[tx].len = skb_headlen(skb);
713 data->txring[tx].buf0 =
716 data->txring[tx].len = frag->size;
722 if (netif_msg_pktdata(data)) {
727 printk(" %2.2x", skb->data[i]);
730 data->txring[tx].misc = misc | TSI108_TX_OWN;
732 data->txhead = (data->txhead + 1) % TSI108_TXRING_LEN;
733 data->txfree--;
743 tsi108_restart_tx(data);
745 spin_unlock_irq(&data->txlock);
751 struct tsi108_prv_data *data = netdev_priv(dev);
754 while (data->rxfree && done != budget) {
755 int rx = data->rxtail;
758 if (data->rxring[rx].misc & TSI108_RX_OWN)
761 skb = data->rxskbs[rx];
762 data->rxtail = (data->rxtail + 1) % TSI108_RXRING_LEN;
763 data->rxfree--;
766 if (data->rxring[rx].misc & TSI108_RX_BAD) {
767 spin_lock_irq(&data->misclock);
769 if (data->rxring[rx].misc & TSI108_RX_CRC)
770 data->stats.rx_crc_errors++;
771 if (data->rxring[rx].misc & TSI108_RX_OVER)
772 data->stats.rx_fifo_errors++;
774 spin_unlock_irq(&data->misclock);
779 if (netif_msg_pktdata(data)) {
782 dev->name, data->rxring[rx].len);
783 for (i = 0; i < data->rxring[rx].len; i++)
784 printk(" %2.2x", skb->data[i]);
788 skb_put(skb, data->rxring[rx].len);
798 struct tsi108_prv_data *data = netdev_priv(dev);
801 while (data->rxfree != TSI108_RXRING_LEN && done != budget) {
802 int rx = data->rxhead;
806 data->rxskbs[rx] = skb;
810 data->rxring[rx].buf0 = dma_map_single(NULL, skb->data,
819 data->rxring[rx].blen = TSI108_RX_SKB_SIZE;
820 data->rxring[rx].misc = TSI108_RX_OWN | TSI108_RX_INT;
822 data->rxhead = (data->rxhead + 1) % TSI108_RXRING_LEN;
823 data->rxfree++;
829 tsi108_restart_rx(data, dev);
836 struct tsi108_prv_data *data = container_of(napi, struct tsi108_prv_data, napi);
837 struct net_device *dev = data->dev;
848 if (data->rxpending || (estat & TSI108_EC_RXESTAT_Q0_DESCINT))
863 if (data->rxfree < TSI108_RXRING_LEN)
877 tsi108_restart_rx(data, dev);
882 spin_lock_irq(&data->misclock);
883 data->stats.rx_fifo_errors++;
884 spin_unlock_irq(&data->misclock);
888 data->rxpending = 0;
899 data->rxpending = 1;
907 struct tsi108_prv_data *data = netdev_priv(dev);
920 if (napi_schedule_prep(&data->napi)) {
931 __napi_schedule(&data->napi);
971 struct tsi108_prv_data *data = netdev_priv(dev);
978 if (netif_running(dev) && data->rxfree < TSI108_RXRING_LEN / 4)
984 struct tsi108_prv_data *data = netdev_priv(dev);
999 spin_lock(&data->txlock);
1001 spin_unlock(&data->txlock);
1009 struct tsi108_prv_data *data = netdev_priv(dev);
1041 struct tsi108_prv_data *data = netdev_priv(dev);
1062 static void tsi108_reset_ether(struct tsi108_prv_data * data)
1098 struct tsi108_prv_data *data = netdev_priv(dev);
1111 if (0x8 == data->phy)
1144 struct tsi108_prv_data *data = netdev_priv(dev);
1160 spin_lock_irq(&data->misclock);
1163 spin_lock(&data->txlock);
1165 if (data->txfree && data->link_up)
1168 spin_unlock(&data->txlock);
1169 spin_unlock_irq(&data->misclock);
1176 struct tsi108_prv_data *data = netdev_priv(dev);
1192 memset(data->mc_hash, 0, sizeof(data->mc_hash));
1199 __set_bit(hash, &data->mc_hash[0]);
1208 * back-to-back writes to the data register.
1212 data->mc_hash[i]);
1222 struct tsi108_prv_data *data = netdev_priv(dev);
1229 tsi108_write_mii(data, MII_BMCR, BMCR_RESET);
1231 if(!(tsi108_read_mii(data, MII_BMCR) & BMCR_RESET))
1238 if (data->phy_type == TSI108_PHY_BCM54XX) {
1239 tsi108_write_mii(data, 0x09, 0x0300);
1240 tsi108_write_mii(data, 0x10, 0x1020);
1241 tsi108_write_mii(data, 0x1c, 0x8c00);
1244 tsi108_write_mii(data,
1247 while (tsi108_read_mii(data, MII_BMCR) & BMCR_ANRESTART)
1255 tsi108_write_tbi(data, 0x11, 0x30);
1258 data->link_up = 0;
1260 while (!((phyval = tsi108_read_mii(data, MII_BMSR)) &
1270 data->mii_if.supports_gmii = mii_check_gmii_support(&data->mii_if);
1272 data->phy_ok = 1;
1273 data->init_media = 1;
1279 struct tsi108_prv_data *data = netdev_priv(dev);
1283 tsi108_write_mii(data, MII_BMCR, BMCR_PDOWN);
1284 data->phy_ok = 0;
1291 struct tsi108_prv_data *data = netdev_priv(dev);
1295 i = request_irq(data->irq_num, tsi108_irq, 0, dev->name, dev);
1298 data->id, data->irq_num);
1301 dev->irq = data->irq_num;
1304 data->id, dev->irq, dev->name);
1307 data->rxring = dma_alloc_coherent(NULL, rxring_size,
1308 &data->rxdma, GFP_KERNEL);
1310 if (!data->rxring) {
1315 memset(data->rxring, 0, rxring_size);
1318 data->txring = dma_alloc_coherent(NULL, txring_size,
1319 &data->txdma, GFP_KERNEL);
1321 if (!data->txring) {
1324 pci_free_consistent(0, rxring_size, data->rxring, data->rxdma);
1327 memset(data->txring, 0, txring_size);
1331 data->rxring[i].next0 = data->rxdma + (i + 1) * sizeof(rx_desc);
1332 data->rxring[i].blen = TSI108_RXBUF_SIZE;
1333 data->rxring[i].vlan = 0;
1336 data->rxring[TSI108_RXRING_LEN - 1].next0 = data->rxdma;
1338 data->rxtail = 0;
1339 data->rxhead = 0;
1353 data->rxhead = i;
1357 data->rxskbs[i] = skb;
1358 data->rxskbs[i] = skb;
1359 data->rxring[i].buf0 = virt_to_phys(data->rxskbs[i]->data);
1360 data->rxring[i].misc = TSI108_RX_OWN | TSI108_RX_INT;
1363 data->rxfree = i;
1364 TSI_WRITE(TSI108_EC_RXQ_PTRLOW, data->rxdma);
1367 data->txring[i].next0 = data->txdma + (i + 1) * sizeof(tx_desc);
1368 data->txring[i].misc = 0;
1371 data->txring[TSI108_TXRING_LEN - 1].next0 = data->txdma;
1372 data->txtail = 0;
1373 data->txhead = 0;
1374 data->txfree = TSI108_TXRING_LEN;
1375 TSI_WRITE(TSI108_EC_TXQ_PTRLOW, data->txdma);
1378 napi_enable(&data->napi);
1380 setup_timer(&data->timer, tsi108_timed_checker, (unsigned long)dev);
1381 mod_timer(&data->timer, jiffies + 1);
1383 tsi108_restart_rx(data, dev);
1401 struct tsi108_prv_data *data = netdev_priv(dev);
1404 napi_disable(&data->napi);
1406 del_timer_sync(&data->timer);
1415 while (!data->txfree || data->txhead != data->txtail) {
1416 int tx = data->txtail;
1418 skb = data->txskbs[tx];
1419 data->txtail = (data->txtail + 1) % TSI108_TXRING_LEN;
1420 data->txfree++;
1424 free_irq(data->irq_num, dev);
1428 while (data->rxfree) {
1429 int rx = data->rxtail;
1432 skb = data->rxskbs[rx];
1433 data->rxtail = (data->rxtail + 1) % TSI108_RXRING_LEN;
1434 data->rxfree--;
1440 data->rxring, data->rxdma);
1443 data->txring, data->txdma);
1450 struct tsi108_prv_data *data = netdev_priv(dev);
1511 struct tsi108_prv_data *data = netdev_priv(dev);
1515 spin_lock_irqsave(&data->txlock, flags);
1516 rc = mii_ethtool_gset(&data->mii_if, cmd);
1517 spin_unlock_irqrestore(&data->txlock, flags);
1524 struct tsi108_prv_data *data = netdev_priv(dev);
1528 spin_lock_irqsave(&data->txlock, flags);
1529 rc = mii_ethtool_sset(&data->mii_if, cmd);
1530 spin_unlock_irqrestore(&data->txlock, flags);
1537 struct tsi108_prv_data *data = netdev_priv(dev);
1540 return generic_mii_ioctl(&data->mii_if, if_mii(rq), cmd, NULL);
1565 struct tsi108_prv_data *data = NULL;
1572 printk(KERN_ERR "tsi-eth %d: Missing additional data!\n",
1586 data = netdev_priv(dev);
1587 data->dev = dev;
1593 data->regs = ioremap(einfo->regs, 0x400);
1594 if (NULL == data->regs) {
1599 data->phyregs = ioremap(einfo->phyregs, 0x400);
1600 if (NULL == data->phyregs) {
1605 data->mii_if.dev = dev;
1606 data->mii_if.mdio_read = tsi108_mdio_read;
1607 data->mii_if.mdio_write = tsi108_mdio_write;
1608 data->mii_if.phy_id = einfo->phy;
1609 data->mii_if.phy_id_mask = 0x1f;
1610 data->mii_if.reg_num_mask = 0x1f;
1612 data->phy = einfo->phy;
1613 data->phy_type = einfo->phy_type;
1614 data->irq_num = einfo->irq_num;
1615 data->id = pdev->id;
1616 netif_napi_add(dev, &data->napi, tsi108_poll, 64);
1630 spin_lock_init(&data->txlock);
1631 spin_lock_init(&data->misclock);
1633 tsi108_reset_ether(data);
1654 data->msg_enable = DEBUG;
1661 iounmap(data->regs);
1662 iounmap(data->phyregs);
1679 struct tsi108_prv_data *data = netdev_priv(dev);
1683 mod_timer(&data->timer, jiffies + CHECK_PHY_INTERVAL);