Lines Matching +full:rx +full:- +full:port +full:- +full:mapping

6 	Written/copyright 1994-2001 by Donald Becker.		    [tulip.c]
20 * Constants (module parms?) for Rx work limit
22 * Jumbo frames / dev->change_mtu
23 * Adjust Rx FIFO threshold and Max Rx DMA burst on Rx FIFO error
58 static int debug = -1;
62 /* Set the copy breakpoint for the copy-only-tiny-buffer Rx structure. */
71 MODULE_PARM_DESC (rx_copybreak, "de2104x Breakpoint at which Rx packets are copied");
93 #define NEXT_TX(N) (((N) + 1) & (DE_TX_RING_SIZE - 1))
94 #define NEXT_RX(N) (((N) + 1) & (DE_RX_RING_SIZE - 1))
96 (((CP)->tx_tail <= (CP)->tx_head) ? \
97 (CP)->tx_tail + (DE_TX_RING_SIZE - 1) - (CP)->tx_head : \
98 (CP)->tx_tail - (CP)->tx_head - 1)
100 #define PKT_BUF_SZ 1536 /* Size of each temporary Rx buffer.*/
117 #define DE_MEDIA_LAST (DE_MAX_MEDIA - 1)
131 to support a pre-NWay full-duplex signaling mechanism using short frames.
133 10base2(!) packets trigger a full-duplex-request interrupt. */
161 /* Rx/TxPoll bits */
165 /* Tx/Rx descriptor status bits */
220 /* The EEPROM commands include the alway-set leading bit. */
227 /* SROM-related bits */
288 dma_addr_t mapping; member
348 "10baseT-HD",
349 "10baseT-FD"
361 /* If on-chip autonegotiation is broken, use half-duplex (FF3F) instead */
366 #define dr32(reg) ioread32(de->regs + (reg))
367 #define dw32(reg, val) iowrite32((val), de->regs + (reg))
373 netif_dbg(de, rx_err, de->dev, in de_rx_err_acct()
374 "rx err, slot %d status 0x%x len %d\n", in de_rx_err_acct()
380 netif_warn(de, rx_err, de->dev, in de_rx_err_acct()
383 de->dev->stats.rx_length_errors++; in de_rx_err_acct()
387 de->dev->stats.rx_errors++; /* end of a packet.*/ in de_rx_err_acct()
388 if (status & 0x0890) de->dev->stats.rx_length_errors++; in de_rx_err_acct()
389 if (status & RxErrCRC) de->dev->stats.rx_crc_errors++; in de_rx_err_acct()
390 if (status & RxErrFIFO) de->dev->stats.rx_fifo_errors++; in de_rx_err_acct()
396 unsigned rx_tail = de->rx_tail; in de_rx()
401 while (--rx_work) { in de_rx()
403 dma_addr_t mapping; in de_rx() local
407 skb = de->rx_skb[rx_tail].skb; in de_rx()
410 status = le32_to_cpu(de->rx_ring[rx_tail].opts1); in de_rx()
415 * to Table 4-1 in the DE2104x spec so mask is 0x7fff in de_rx()
417 len = ((status >> 16) & 0x7fff) - 4; in de_rx()
418 mapping = de->rx_skb[rx_tail].mapping; in de_rx()
421 de->dev->stats.rx_dropped++; in de_rx()
432 netif_dbg(de, rx_status, de->dev, in de_rx()
433 "rx slot %d status 0x%x len %d copying? %d\n", in de_rx()
436 buflen = copying_skb ? (len + RX_OFFSET) : de->rx_buf_sz; in de_rx()
437 copy_skb = netdev_alloc_skb(de->dev, buflen); in de_rx()
439 de->dev->stats.rx_dropped++; in de_rx()
446 dma_unmap_single(&de->pdev->dev, mapping, buflen, in de_rx()
450 mapping = in de_rx()
451 de->rx_skb[rx_tail].mapping = in de_rx()
452 dma_map_single(&de->pdev->dev, copy_skb->data, in de_rx()
454 de->rx_skb[rx_tail].skb = copy_skb; in de_rx()
456 dma_sync_single_for_cpu(&de->pdev->dev, mapping, len, in de_rx()
461 dma_sync_single_for_device(&de->pdev->dev, mapping, in de_rx()
468 skb->protocol = eth_type_trans (skb, de->dev); in de_rx()
470 de->dev->stats.rx_packets++; in de_rx()
471 de->dev->stats.rx_bytes += skb->len; in de_rx()
477 if (rx_tail == (DE_RX_RING_SIZE - 1)) in de_rx()
478 de->rx_ring[rx_tail].opts2 = in de_rx()
479 cpu_to_le32(RingEnd | de->rx_buf_sz); in de_rx()
481 de->rx_ring[rx_tail].opts2 = cpu_to_le32(de->rx_buf_sz); in de_rx()
482 de->rx_ring[rx_tail].addr1 = cpu_to_le32(mapping); in de_rx()
484 de->rx_ring[rx_tail].opts1 = cpu_to_le32(DescOwn); in de_rx()
489 netdev_warn(de->dev, "rx work limit reached\n"); in de_rx()
491 de->rx_tail = rx_tail; in de_rx()
506 de->rx_tail, de->tx_head, de->tx_tail); in de_interrupt()
516 spin_lock(&de->lock); in de_interrupt()
524 spin_unlock(&de->lock); in de_interrupt()
529 pci_read_config_word(de->pdev, PCI_STATUS, &pci_status); in de_interrupt()
530 pci_write_config_word(de->pdev, PCI_STATUS, pci_status); in de_interrupt()
531 netdev_err(de->dev, in de_interrupt()
541 unsigned tx_head = de->tx_head; in de_tx()
542 unsigned tx_tail = de->tx_tail; in de_tx()
549 status = le32_to_cpu(de->tx_ring[tx_tail].opts1); in de_tx()
553 skb = de->tx_skb[tx_tail].skb; in de_tx()
559 dma_unmap_single(&de->pdev->dev, in de_tx()
560 de->tx_skb[tx_tail].mapping, in de_tx()
561 sizeof(de->setup_frame), in de_tx()
566 dma_unmap_single(&de->pdev->dev, de->tx_skb[tx_tail].mapping, in de_tx()
567 skb->len, DMA_TO_DEVICE); in de_tx()
571 netif_dbg(de, tx_err, de->dev, in de_tx()
574 de->dev->stats.tx_errors++; in de_tx()
576 de->dev->stats.tx_window_errors++; in de_tx()
578 de->dev->stats.tx_aborted_errors++; in de_tx()
580 de->dev->stats.tx_carrier_errors++; in de_tx()
582 de->dev->stats.tx_fifo_errors++; in de_tx()
584 de->dev->stats.tx_packets++; in de_tx()
585 de->dev->stats.tx_bytes += skb->len; in de_tx()
586 netif_dbg(de, tx_done, de->dev, in de_tx()
593 de->tx_skb[tx_tail].skb = NULL; in de_tx()
598 de->tx_tail = tx_tail; in de_tx()
600 if (netif_queue_stopped(de->dev) && (TX_BUFFS_AVAIL(de) > (DE_TX_RING_SIZE / 4))) in de_tx()
601 netif_wake_queue(de->dev); in de_tx()
609 u32 mapping, len, flags = FirstFrag | LastFrag; in de_start_xmit() local
612 spin_lock_irq(&de->lock); in de_start_xmit()
617 spin_unlock_irq(&de->lock); in de_start_xmit()
620 tx_free--; in de_start_xmit()
622 entry = de->tx_head; in de_start_xmit()
624 txd = &de->tx_ring[entry]; in de_start_xmit()
626 len = skb->len; in de_start_xmit()
627 mapping = dma_map_single(&de->pdev->dev, skb->data, len, in de_start_xmit()
629 if (entry == (DE_TX_RING_SIZE - 1)) in de_start_xmit()
634 txd->opts2 = cpu_to_le32(flags); in de_start_xmit()
635 txd->addr1 = cpu_to_le32(mapping); in de_start_xmit()
637 de->tx_skb[entry].skb = skb; in de_start_xmit()
638 de->tx_skb[entry].mapping = mapping; in de_start_xmit()
641 txd->opts1 = cpu_to_le32(DescOwn); in de_start_xmit()
644 de->tx_head = NEXT_TX(entry); in de_start_xmit()
646 entry, skb->len); in de_start_xmit()
651 spin_unlock_irq(&de->lock); in de_start_xmit()
661 new frame, not around filling de->setup_frame. This is non-deterministic
662 when re-entered but still correct. */
674 /* This should work on big-endian machines as well. */ in build_setup_frame_hash()
676 int index = ether_crc_le(ETH_ALEN, ha->addr) & 0x1ff; in build_setup_frame_hash()
685 setup_frm = &de->setup_frame[13*6]; in build_setup_frame_hash()
688 eaddrs = (const u16 *)dev->dev_addr; in build_setup_frame_hash()
703 eaddrs = (u16 *) ha->addr; in build_setup_frame_perfect()
709 memset(setup_frm, 0xff, (15 - netdev_mc_count(dev)) * 12); in build_setup_frame_perfect()
710 setup_frm = &de->setup_frame[15*6]; in build_setup_frame_perfect()
713 eaddrs = (const u16 *)dev->dev_addr; in build_setup_frame_perfect()
725 u32 mapping; in __de_set_rx_mode() local
731 if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ in __de_set_rx_mode()
736 if ((netdev_mc_count(dev) > 1000) || (dev->flags & IFF_ALLMULTI)) { in __de_set_rx_mode()
737 /* Too many to filter well -- accept all multicasts. */ in __de_set_rx_mode()
742 /* Note that only the low-address shortword of setup_frame is valid! in __de_set_rx_mode()
743 The values are doubled for big-endian architectures. */ in __de_set_rx_mode()
745 build_setup_frame_hash (de->setup_frame, dev); in __de_set_rx_mode()
747 build_setup_frame_perfect (de->setup_frame, dev); in __de_set_rx_mode()
753 entry = de->tx_head; in __de_set_rx_mode()
757 de->tx_skb[entry].skb = DE_DUMMY_SKB; in __de_set_rx_mode()
759 dummy_txd = &de->tx_ring[entry]; in __de_set_rx_mode()
760 dummy_txd->opts2 = (entry == (DE_TX_RING_SIZE - 1)) ? in __de_set_rx_mode()
762 dummy_txd->addr1 = 0; in __de_set_rx_mode()
769 de->tx_skb[entry].skb = DE_SETUP_SKB; in __de_set_rx_mode()
770 de->tx_skb[entry].mapping = mapping = in __de_set_rx_mode()
771 dma_map_single(&de->pdev->dev, de->setup_frame, in __de_set_rx_mode()
772 sizeof(de->setup_frame), DMA_TO_DEVICE); in __de_set_rx_mode()
775 txd = &de->tx_ring[entry]; in __de_set_rx_mode()
776 if (entry == (DE_TX_RING_SIZE - 1)) in __de_set_rx_mode()
777 txd->opts2 = cpu_to_le32(SetupFrame | RingEnd | sizeof (de->setup_frame)); in __de_set_rx_mode()
779 txd->opts2 = cpu_to_le32(SetupFrame | sizeof (de->setup_frame)); in __de_set_rx_mode()
780 txd->addr1 = cpu_to_le32(mapping); in __de_set_rx_mode()
783 txd->opts1 = cpu_to_le32(DescOwn); in __de_set_rx_mode()
787 dummy_txd->opts1 = cpu_to_le32(DescOwn); in __de_set_rx_mode()
791 de->tx_head = NEXT_TX(entry); in __de_set_rx_mode()
809 spin_lock_irqsave (&de->lock, flags); in de_set_rx_mode()
811 spin_unlock_irqrestore (&de->lock, flags); in de_set_rx_mode()
817 de->dev->stats.rx_missed_errors += RxMissedMask; in de_rx_missed()
819 de->dev->stats.rx_missed_errors += (rx_missed & RxMissedMask); in de_rx_missed()
824 u32 tmp = dr32(RxMissed); /* self-clearing */ in __de_get_stats()
834 spin_lock_irq(&de->lock); in de_get_stats()
837 spin_unlock_irq(&de->lock); in de_get_stats()
839 return &dev->stats; in de_get_stats()
858 /* wait until in-flight frame completes. in de_stop_rxtx()
862 while (--i) { in de_stop_rxtx()
868 netdev_warn(de->dev, "timeout expired, stopping DMA\n"); in de_stop_rxtx()
894 de->rx_tail = 0; in de_stop_hw()
895 de->tx_head = de->tx_tail = 0; in de_stop_hw()
900 if (!netif_carrier_ok(de->dev)) { in de_link_up()
901 netif_carrier_on(de->dev); in de_link_up()
902 netif_info(de, link, de->dev, "link up, media %s\n", in de_link_up()
903 media_name[de->media_type]); in de_link_up()
909 if (netif_carrier_ok(de->dev)) { in de_link_down()
910 netif_carrier_off(de->dev); in de_link_down()
911 netif_info(de, link, de->dev, "link down\n"); in de_link_down()
917 unsigned media = de->media_type; in de_set_media()
921 netdev_warn(de->dev, "chip is running while changing media!\n"); in de_set_media()
923 if (de->de21040) in de_set_media()
926 dw32(CSR14, de->media[media].csr14); in de_set_media()
927 dw32(CSR15, de->media[media].csr15); in de_set_media()
928 dw32(CSR13, de->media[media].csr13); in de_set_media()
940 netif_info(de, link, de->dev, "set link %s\n", media_name[media]); in de_set_media()
941 netif_info(de, hw, de->dev, "mode 0x%x, sia 0x%x,0x%x,0x%x,0x%x\n", in de_set_media()
944 netif_info(de, hw, de->dev, "set mode 0x%x, set sia 0x%x,0x%x,0x%x\n", in de_set_media()
945 macmode, de->media[media].csr13, in de_set_media()
946 de->media[media].csr14, de->media[media].csr15); in de_set_media()
958 de->media_type = media[i]; in de_next_media()
967 struct net_device *dev = de->dev; in de21040_media_timer()
975 if (de->media_type != DE_MEDIA_AUI && (status & LinkFailStatus)) in de21040_media_timer()
978 de->media_timer.expires = jiffies + DE_TIMER_LINK; in de21040_media_timer()
979 add_timer(&de->media_timer); in de21040_media_timer()
984 media_name[de->media_type], status); in de21040_media_timer()
990 if (de->media_lock) in de21040_media_timer()
993 if (de->media_type == DE_MEDIA_AUI) { in de21040_media_timer()
1001 spin_lock_irqsave(&de->lock, flags); in de21040_media_timer()
1003 spin_unlock_irqrestore(&de->lock, flags); in de21040_media_timer()
1008 de->media_timer.expires = jiffies + DE_TIMER_NO_LINK; in de21040_media_timer()
1009 add_timer(&de->media_timer); in de21040_media_timer()
1012 media_name[de->media_type], status); in de21040_media_timer()
1019 if (!(de->media_advertise & ADVERTISED_Autoneg)) in de_ok_to_advertise()
1021 if (!(de->media_advertise & (ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full))) in de_ok_to_advertise()
1025 if (!(de->media_advertise & ADVERTISED_BNC)) in de_ok_to_advertise()
1029 if (!(de->media_advertise & ADVERTISED_AUI)) in de_ok_to_advertise()
1033 if (!(de->media_advertise & ADVERTISED_10baseT_Half)) in de_ok_to_advertise()
1037 if (!(de->media_advertise & ADVERTISED_10baseT_Full)) in de_ok_to_advertise()
1048 struct net_device *dev = de->dev; in de21041_media_timer()
1053 /* clear port active bits */ in de21041_media_timer()
1059 if ((de->media_type == DE_MEDIA_TP_AUTO || in de21041_media_timer()
1060 de->media_type == DE_MEDIA_TP || in de21041_media_timer()
1061 de->media_type == DE_MEDIA_TP_FD) && in de21041_media_timer()
1065 de->media_timer.expires = jiffies + DE_TIMER_LINK; in de21041_media_timer()
1066 add_timer(&de->media_timer); in de21041_media_timer()
1072 media_name[de->media_type], in de21041_media_timer()
1080 if (de->media_lock) in de21041_media_timer()
1087 /* if AUI/BNC selected, then activity is on TP port */ in de21041_media_timer()
1088 if (de->media_type == DE_MEDIA_AUI || in de21041_media_timer()
1089 de->media_type == DE_MEDIA_BNC) { in de21041_media_timer()
1091 de->media_type = DE_MEDIA_TP_AUTO; in de21041_media_timer()
1097 else if (((de->media_supported & DE_AUI_BNC) == SUPPORTED_BNC) && in de21041_media_timer()
1099 de->media_type = DE_MEDIA_BNC; in de21041_media_timer()
1102 else if (((de->media_supported & DE_AUI_BNC) == SUPPORTED_AUI) && in de21041_media_timer()
1104 de->media_type = DE_MEDIA_AUI; in de21041_media_timer()
1116 * media state. If de->media_type is left unchanged, this in de21041_media_timer()
1119 if (de->media_type == DE_MEDIA_AUI) { in de21041_media_timer()
1124 } else if (de->media_type == DE_MEDIA_BNC) { in de21041_media_timer()
1137 spin_lock_irqsave(&de->lock, flags); in de21041_media_timer()
1139 spin_unlock_irqrestore(&de->lock, flags); in de21041_media_timer()
1144 de->media_timer.expires = jiffies + DE_TIMER_NO_LINK; in de21041_media_timer()
1145 add_timer(&de->media_timer); in de21041_media_timer()
1148 media_name[de->media_type], status); in de21041_media_timer()
1155 if ((de->media_type == DE_MEDIA_AUI || in de_media_interrupt()
1156 de->media_type == DE_MEDIA_BNC) && in de_media_interrupt()
1157 (de->media_lock || in de_media_interrupt()
1161 if ((de->media_type == DE_MEDIA_AUI || in de_media_interrupt()
1162 de->media_type == DE_MEDIA_BNC)) { in de_media_interrupt()
1163 de->media_type = DE_MEDIA_TP_AUTO; in de_media_interrupt()
1169 mod_timer(&de->media_timer, jiffies + DE_TIMER_LINK); in de_media_interrupt()
1175 if (netif_carrier_ok(de->dev) && de->media_type != DE_MEDIA_AUI && in de_media_interrupt()
1176 de->media_type != DE_MEDIA_BNC) { in de_media_interrupt()
1178 mod_timer(&de->media_timer, jiffies + DE_TIMER_NO_LINK); in de_media_interrupt()
1192 return -EBUSY; in de_reset_mac()
1210 return -EBUSY; in de_reset_mac()
1212 return -ENODEV; in de_reset_mac()
1220 if (de->de21040) in de_adapter_wake()
1223 pci_read_config_dword(de->pdev, PCIPM, &pmctl); in de_adapter_wake()
1226 pci_write_config_dword(de->pdev, PCIPM, pmctl); in de_adapter_wake()
1237 if (de->de21040) in de_adapter_sleep()
1241 pci_read_config_dword(de->pdev, PCIPM, &pmctl); in de_adapter_sleep()
1243 pci_write_config_dword(de->pdev, PCIPM, pmctl); in de_adapter_sleep()
1248 struct net_device *dev = de->dev; in de_init_hw()
1262 dw32(RxRingAddr, de->ring_dma); in de_init_hw()
1263 dw32(TxRingAddr, de->ring_dma + (sizeof(struct de_desc) * DE_RX_RING_SIZE)); in de_init_hw()
1267 dr32(RxMissed); /* self-clearing */ in de_init_hw()
1283 skb = netdev_alloc_skb(de->dev, de->rx_buf_sz); in de_refill_rx()
1287 de->rx_skb[i].mapping = dma_map_single(&de->pdev->dev, in de_refill_rx()
1288 skb->data, in de_refill_rx()
1289 de->rx_buf_sz, in de_refill_rx()
1291 de->rx_skb[i].skb = skb; in de_refill_rx()
1293 de->rx_ring[i].opts1 = cpu_to_le32(DescOwn); in de_refill_rx()
1294 if (i == (DE_RX_RING_SIZE - 1)) in de_refill_rx()
1295 de->rx_ring[i].opts2 = in de_refill_rx()
1296 cpu_to_le32(RingEnd | de->rx_buf_sz); in de_refill_rx()
1298 de->rx_ring[i].opts2 = cpu_to_le32(de->rx_buf_sz); in de_refill_rx()
1299 de->rx_ring[i].addr1 = cpu_to_le32(de->rx_skb[i].mapping); in de_refill_rx()
1300 de->rx_ring[i].addr2 = 0; in de_refill_rx()
1307 return -ENOMEM; in de_refill_rx()
1312 memset(de->tx_ring, 0, sizeof(struct de_desc) * DE_TX_RING_SIZE); in de_init_rings()
1313 de->tx_ring[DE_TX_RING_SIZE - 1].opts2 = cpu_to_le32(RingEnd); in de_init_rings()
1315 de->rx_tail = 0; in de_init_rings()
1316 de->tx_head = de->tx_tail = 0; in de_init_rings()
1323 de->rx_ring = dma_alloc_coherent(&de->pdev->dev, DE_RING_BYTES, in de_alloc_rings()
1324 &de->ring_dma, GFP_KERNEL); in de_alloc_rings()
1325 if (!de->rx_ring) in de_alloc_rings()
1326 return -ENOMEM; in de_alloc_rings()
1327 de->tx_ring = &de->rx_ring[DE_RX_RING_SIZE]; in de_alloc_rings()
1335 memset(de->rx_ring, 0, sizeof(struct de_desc) * DE_RX_RING_SIZE); in de_clean_rings()
1336 de->rx_ring[DE_RX_RING_SIZE - 1].opts2 = cpu_to_le32(RingEnd); in de_clean_rings()
1338 memset(de->tx_ring, 0, sizeof(struct de_desc) * DE_TX_RING_SIZE); in de_clean_rings()
1339 de->tx_ring[DE_TX_RING_SIZE - 1].opts2 = cpu_to_le32(RingEnd); in de_clean_rings()
1343 if (de->rx_skb[i].skb) { in de_clean_rings()
1344 dma_unmap_single(&de->pdev->dev, in de_clean_rings()
1345 de->rx_skb[i].mapping, de->rx_buf_sz, in de_clean_rings()
1347 dev_kfree_skb(de->rx_skb[i].skb); in de_clean_rings()
1352 struct sk_buff *skb = de->tx_skb[i].skb; in de_clean_rings()
1355 de->dev->stats.tx_dropped++; in de_clean_rings()
1356 dma_unmap_single(&de->pdev->dev, in de_clean_rings()
1357 de->tx_skb[i].mapping, in de_clean_rings()
1358 skb->len, DMA_TO_DEVICE); in de_clean_rings()
1361 dma_unmap_single(&de->pdev->dev, in de_clean_rings()
1362 de->tx_skb[i].mapping, in de_clean_rings()
1363 sizeof(de->setup_frame), in de_clean_rings()
1369 memset(&de->rx_skb, 0, sizeof(struct ring_info) * DE_RX_RING_SIZE); in de_clean_rings()
1370 memset(&de->tx_skb, 0, sizeof(struct ring_info) * DE_TX_RING_SIZE); in de_clean_rings()
1376 dma_free_coherent(&de->pdev->dev, DE_RING_BYTES, de->rx_ring, in de_free_rings()
1377 de->ring_dma); in de_free_rings()
1378 de->rx_ring = NULL; in de_free_rings()
1379 de->tx_ring = NULL; in de_free_rings()
1385 const int irq = de->pdev->irq; in de_open()
1390 de->rx_buf_sz = (dev->mtu <= 1500 ? PKT_BUF_SZ : dev->mtu + 32); in de_open()
1400 rc = request_irq(irq, de_interrupt, IRQF_SHARED, dev->name, dev); in de_open()
1413 mod_timer(&de->media_timer, jiffies + DE_TIMER_NO_LINK); in de_open()
1431 del_timer_sync(&de->media_timer); in de_close()
1433 spin_lock_irqsave(&de->lock, flags); in de_close()
1437 spin_unlock_irqrestore(&de->lock, flags); in de_close()
1439 free_irq(de->pdev->irq, dev); in de_close()
1449 const int irq = de->pdev->irq; in de_tx_timeout()
1453 de->rx_tail, de->tx_head, de->tx_tail); in de_tx_timeout()
1455 del_timer_sync(&de->media_timer); in de_tx_timeout()
1458 spin_lock_irq(&de->lock); in de_tx_timeout()
1464 spin_unlock_irq(&de->lock); in de_tx_timeout()
1489 /* handle self-clearing RxMissed counter, CSR8 */ in __de_get_regs()
1496 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, in __de_get_link_ksettings()
1497 de->media_supported); in __de_get_link_ksettings()
1498 cmd->base.phy_address = 0; in __de_get_link_ksettings()
1499 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising, in __de_get_link_ksettings()
1500 de->media_advertise); in __de_get_link_ksettings()
1502 switch (de->media_type) { in __de_get_link_ksettings()
1504 cmd->base.port = PORT_AUI; in __de_get_link_ksettings()
1507 cmd->base.port = PORT_BNC; in __de_get_link_ksettings()
1510 cmd->base.port = PORT_TP; in __de_get_link_ksettings()
1514 cmd->base.speed = 10; in __de_get_link_ksettings()
1517 cmd->base.duplex = DUPLEX_FULL; in __de_get_link_ksettings()
1519 cmd->base.duplex = DUPLEX_HALF; in __de_get_link_ksettings()
1521 if (de->media_lock) in __de_get_link_ksettings()
1522 cmd->base.autoneg = AUTONEG_DISABLE; in __de_get_link_ksettings()
1524 cmd->base.autoneg = AUTONEG_ENABLE; in __de_get_link_ksettings()
1534 u8 duplex = cmd->base.duplex; in __de_set_link_ksettings()
1535 u8 port = cmd->base.port; in __de_set_link_ksettings() local
1536 u8 autoneg = cmd->base.autoneg; in __de_set_link_ksettings()
1540 cmd->link_modes.advertising); in __de_set_link_ksettings()
1542 if (cmd->base.speed != 10) in __de_set_link_ksettings()
1543 return -EINVAL; in __de_set_link_ksettings()
1545 return -EINVAL; in __de_set_link_ksettings()
1546 if (port != PORT_TP && port != PORT_AUI && port != PORT_BNC) in __de_set_link_ksettings()
1547 return -EINVAL; in __de_set_link_ksettings()
1548 if (de->de21040 && port == PORT_BNC) in __de_set_link_ksettings()
1549 return -EINVAL; in __de_set_link_ksettings()
1551 return -EINVAL; in __de_set_link_ksettings()
1552 if (advertising & ~de->media_supported) in __de_set_link_ksettings()
1553 return -EINVAL; in __de_set_link_ksettings()
1556 return -EINVAL; in __de_set_link_ksettings()
1558 switch (port) { in __de_set_link_ksettings()
1562 return -EINVAL; in __de_set_link_ksettings()
1567 return -EINVAL; in __de_set_link_ksettings()
1577 return -EINVAL; in __de_set_link_ksettings()
1580 return -EINVAL; in __de_set_link_ksettings()
1586 if ((new_media == de->media_type) && in __de_set_link_ksettings()
1587 (media_lock == de->media_lock) && in __de_set_link_ksettings()
1588 (advertising == de->media_advertise)) in __de_set_link_ksettings()
1592 mod_timer(&de->media_timer, jiffies + DE_TIMER_NO_LINK); in __de_set_link_ksettings()
1595 de->media_type = new_media; in __de_set_link_ksettings()
1596 de->media_lock = media_lock; in __de_set_link_ksettings()
1597 de->media_advertise = advertising; in __de_set_link_ksettings()
1599 if (netif_running(de->dev)) in __de_set_link_ksettings()
1609 strscpy(info->driver, DRV_NAME, sizeof(info->driver)); in de_get_drvinfo()
1610 strscpy(info->bus_info, pci_name(de->pdev), sizeof(info->bus_info)); in de_get_drvinfo()
1623 spin_lock_irq(&de->lock); in de_get_link_ksettings()
1625 spin_unlock_irq(&de->lock); in de_get_link_ksettings()
1636 spin_lock_irq(&de->lock); in de_set_link_ksettings()
1638 spin_unlock_irq(&de->lock); in de_set_link_ksettings()
1647 return de->msg_enable; in de_get_msglevel()
1654 de->msg_enable = msglvl; in de_set_msglevel()
1662 if (!de->ee_data) in de_get_eeprom()
1663 return -EOPNOTSUPP; in de_get_eeprom()
1664 if ((eeprom->offset != 0) || (eeprom->magic != 0) || in de_get_eeprom()
1665 (eeprom->len != DE_EEPROM_SIZE)) in de_get_eeprom()
1666 return -EINVAL; in de_get_eeprom()
1667 memcpy(data, de->ee_data, eeprom->len); in de_get_eeprom()
1677 if (de->media_type != DE_MEDIA_TP_AUTO) in de_nway_reset()
1678 return -EINVAL; in de_nway_reset()
1679 if (netif_carrier_ok(de->dev)) in de_nway_reset()
1694 regs->version = (DE_REGS_VER << 2) | de->de21040; in de_get_regs()
1696 spin_lock_irq(&de->lock); in de_get_regs()
1698 spin_unlock_irq(&de->lock); in de_get_regs()
1727 } while (value < 0 && --boguscnt > 0); in de21040_get_mac_address()
1734 eth_hw_addr_set(de->dev, addr); in de21040_get_mac_address()
1741 de->media_type = DE_MEDIA_TP; in de21040_get_media_info()
1742 de->media_supported |= SUPPORTED_TP | SUPPORTED_10baseT_Full | in de21040_get_media_info()
1744 de->media_advertise = de->media_supported; in de21040_get_media_info()
1751 de->media[i].type = i; in de21040_get_media_info()
1752 de->media[i].csr13 = t21040_csr13[i]; in de21040_get_media_info()
1753 de->media[i].csr14 = t21040_csr14[i]; in de21040_get_media_info()
1754 de->media[i].csr15 = t21040_csr15[i]; in de21040_get_media_info()
1757 de->media[i].type = DE_MEDIA_INVALID; in de21040_get_media_info()
1776 for (i = 4 + addr_len; i >= 0; i--) { in tulip_read_eeprom()
1787 for (i = 16; i > 0; i--) { in tulip_read_eeprom()
1804 unsigned ee_addr_size = tulip_read_eeprom(de->regs, 0xff, 8) & 0x40000 ? 8 : 6; in de21041_get_srom_info()
1811 cpu_to_le16(tulip_read_eeprom(de->regs, i, ee_addr_size)); in de21041_get_srom_info()
1826 eth_hw_addr_set(de->dev, &ee_data[sa_offset]); in de21041_get_srom_info()
1830 …if (ofs >= (sizeof(ee_data) - sizeof(struct de_srom_info_leaf) - sizeof(struct de_srom_media_block… in de21041_get_srom_info()
1837 if (il->n_blocks == 0) in de21041_get_srom_info()
1839 if ((sizeof(ee_data) - ofs) < in de21041_get_srom_info()
1840 (sizeof(struct de_srom_info_leaf) + (sizeof(struct de_srom_media_block) * il->n_blocks))) in de21041_get_srom_info()
1844 switch (get_unaligned(&il->default_media)) { in de21041_get_srom_info()
1845 case 0x0001: de->media_type = DE_MEDIA_BNC; break; in de21041_get_srom_info()
1846 case 0x0002: de->media_type = DE_MEDIA_AUI; break; in de21041_get_srom_info()
1847 case 0x0204: de->media_type = DE_MEDIA_TP_FD; break; in de21041_get_srom_info()
1848 default: de->media_type = DE_MEDIA_TP_AUTO; break; in de21041_get_srom_info()
1853 de->board_idx, ofs, media_name[de->media_type]); in de21041_get_srom_info()
1857 de->media[i].type = DE_MEDIA_INVALID; in de21041_get_srom_info()
1858 de->media[i].csr13 = 0xffff; in de21041_get_srom_info()
1859 de->media[i].csr14 = 0xffff; in de21041_get_srom_info()
1860 de->media[i].csr15 = 0xffff; in de21041_get_srom_info()
1867 for (i = 0; i < il->n_blocks; i++) { in de21041_get_srom_info()
1872 switch(ib->opts & MediaBlockMask) { in de21041_get_srom_info()
1874 de->media_supported |= SUPPORTED_TP | SUPPORTED_10baseT_Half in de21041_get_srom_info()
1877 de->media[DE_MEDIA_TP_AUTO].type = DE_MEDIA_TP_AUTO; in de21041_get_srom_info()
1880 de->media_supported |= SUPPORTED_BNC; in de21041_get_srom_info()
1884 de->media_supported |= SUPPORTED_AUI; in de21041_get_srom_info()
1887 case 4: /* 10baseT-FD */ in de21041_get_srom_info()
1888 de->media_supported |= SUPPORTED_TP | SUPPORTED_10baseT_Full in de21041_get_srom_info()
1891 de->media[DE_MEDIA_TP_AUTO].type = DE_MEDIA_TP_AUTO; in de21041_get_srom_info()
1897 de->media[idx].type = idx; in de21041_get_srom_info()
1901 de->board_idx, i, in de21041_get_srom_info()
1902 media_name[de->media[idx].type]); in de21041_get_srom_info()
1904 bufp += sizeof (ib->opts); in de21041_get_srom_info()
1906 if (ib->opts & MediaCustomCSRs) { in de21041_get_srom_info()
1907 de->media[idx].csr13 = get_unaligned(&ib->csr13); in de21041_get_srom_info()
1908 de->media[idx].csr14 = get_unaligned(&ib->csr14); in de21041_get_srom_info()
1909 de->media[idx].csr15 = get_unaligned(&ib->csr15); in de21041_get_srom_info()
1910 bufp += sizeof(ib->csr13) + sizeof(ib->csr14) + in de21041_get_srom_info()
1911 sizeof(ib->csr15); in de21041_get_srom_info()
1915 de->media[idx].csr13, in de21041_get_srom_info()
1916 de->media[idx].csr14, in de21041_get_srom_info()
1917 de->media[idx].csr15); in de21041_get_srom_info()
1924 if (bufp > ((void *)&ee_data[DE_EEPROM_SIZE - 3])) in de21041_get_srom_info()
1928 de->media_advertise = de->media_supported; in de21041_get_srom_info()
1933 if (de->media[i].csr13 == 0xffff) in de21041_get_srom_info()
1934 de->media[i].csr13 = t21041_csr13[i]; in de21041_get_srom_info()
1935 if (de->media[i].csr14 == 0xffff) { in de21041_get_srom_info()
1937 revisions - rev. 0x21 works, 0x11 does not */ in de21041_get_srom_info()
1938 if (de->pdev->revision < 0x20) in de21041_get_srom_info()
1939 de->media[i].csr14 = t21041_csr14_brk[i]; in de21041_get_srom_info()
1941 de->media[i].csr14 = t21041_csr14[i]; in de21041_get_srom_info()
1943 if (de->media[i].csr15 == 0xffff) in de21041_get_srom_info()
1944 de->media[i].csr15 = t21041_csr15[i]; in de21041_get_srom_info()
1947 de->ee_data = kmemdup(&ee_data[0], DE_EEPROM_SIZE, GFP_KERNEL); in de21041_get_srom_info()
1954 de->media[i].type = i; in de21041_get_srom_info()
1955 de->media_supported = in de21041_get_srom_info()
1983 static int board_idx = -1; in de_init_one()
1990 return -ENOMEM; in de_init_one()
1992 dev->netdev_ops = &de_netdev_ops; in de_init_one()
1993 SET_NETDEV_DEV(dev, &pdev->dev); in de_init_one()
1994 dev->ethtool_ops = &de_ethtool_ops; in de_init_one()
1995 dev->watchdog_timeo = TX_TIMEOUT; in de_init_one()
1998 de->de21040 = ent->driver_data == 0 ? 1 : 0; in de_init_one()
1999 de->pdev = pdev; in de_init_one()
2000 de->dev = dev; in de_init_one()
2001 de->msg_enable = (debug < 0 ? DE_DEF_MSG_ENABLE : debug); in de_init_one()
2002 de->board_idx = board_idx; in de_init_one()
2003 spin_lock_init (&de->lock); in de_init_one()
2004 timer_setup(&de->media_timer, in de_init_one()
2005 de->de21040 ? de21040_media_timer : de21041_media_timer, in de_init_one()
2021 if (pdev->irq < 2) { in de_init_one()
2022 rc = -EIO; in de_init_one()
2024 pdev->irq, pci_name(pdev)); in de_init_one()
2031 rc = -EIO; in de_init_one()
2036 rc = -EIO; in de_init_one()
2046 rc = -EIO; in de_init_one()
2052 de->regs = regs; in de_init_one()
2066 if (de->de21040) { in de_init_one()
2080 de->de21040 ? "21040" : "21041", in de_init_one()
2081 regs, dev->dev_addr, pdev->irq); in de_init_one()
2094 kfree(de->ee_data); in de_init_one()
2112 kfree(de->ee_data); in de_remove_one()
2113 iounmap(de->regs); in de_remove_one()
2127 const int irq = pdev->irq; in de_suspend()
2129 del_timer_sync(&de->media_timer); in de_suspend()
2132 spin_lock_irq(&de->lock); in de_suspend()
2139 spin_unlock_irq(&de->lock); in de_suspend()