1448 netif_start_queue (dev); |
1446 netif_start_queue (dev); |
1449 } |
1447 } |
1450 |
1448 |
1451 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
1449 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
1452 |
1450 |
|
1451 //FIXME muß das hier raus ?? |
1453 if (netif_msg_ifup(tp)) |
1452 if (netif_msg_ifup(tp)) |
1454 printk(KERN_DEBUG "%s: rtl8139_open() ioaddr %#lx IRQ %d" |
1453 printk(KERN_DEBUG "%s: rtl8139_open() ioaddr %#lx IRQ %d" |
1455 " GP Pins %2.2x %s-duplex.\n", |
1454 " GP Pins %2.2x %s-duplex.\n", |
1456 dev->name, pci_resource_start (tp->pci_dev, 1), |
1455 dev->name, pci_resource_start (tp->pci_dev, 1), |
1457 dev->irq, RTL_R8 (MediaStatus), |
1456 dev->irq, RTL_R8 (MediaStatus), |
1883 if (dev != rtl_ecat_dev.dev) dev_kfree_skb(skb); |
1882 if (dev != rtl_ecat_dev.dev) dev_kfree_skb(skb); |
1884 tp->stats.tx_dropped++; |
1883 tp->stats.tx_dropped++; |
1885 return 0; |
1884 return 0; |
1886 } |
1885 } |
1887 |
1886 |
|
1887 if (dev != rtl_ecat_dev.dev) //CHANGED HM spinlock falsch |
|
1888 spin_lock_irq(&tp->lock); |
|
1889 |
1888 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
1890 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
1889 |
|
1890 spin_lock_irq(&tp->lock); |
|
1891 RTL_W32_F (TxStatus0 + (entry * sizeof (u32)), |
1891 RTL_W32_F (TxStatus0 + (entry * sizeof (u32)), |
1892 tp->tx_flag | max(len, (unsigned int)ETH_ZLEN)); |
1892 tp->tx_flag | max(len, (unsigned int)ETH_ZLEN)); |
1893 |
1893 |
1894 dev->trans_start = jiffies; |
1894 dev->trans_start = jiffies; |
1895 |
1895 |
2153 RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd)); |
2154 RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd)); |
2154 |
2155 |
2155 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
2156 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
2156 |
2157 |
2157 if (dev == rtl_ecat_dev.dev) |
2158 if (dev == rtl_ecat_dev.dev) |
2158 { |
2159 { |
2159 rtl_ecat_dev.rx_intr_cnt++; |
2160 rtl_ecat_dev.rx_intr_cnt++; |
2160 rdtscl(rtl_ecat_dev.rx_time); // Get CPU cycles |
2161 rdtscl(rtl_ecat_dev.rx_time); // Get CPU cycles |
2161 } |
2162 } |
2162 |
2163 |
2163 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
2164 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
2164 |
2165 |
2165 while (netif_running(dev) && received < budget |
2166 while ((dev == rtl_ecat_dev.dev || netif_running(dev)) //HM |
|
2167 && received < budget |
2166 && (RTL_R8 (ChipCmd) & RxBufEmpty) == 0) { |
2168 && (RTL_R8 (ChipCmd) & RxBufEmpty) == 0) { |
2167 u32 ring_offset = cur_rx % RX_BUF_LEN; |
2169 u32 ring_offset = cur_rx % RX_BUF_LEN; |
2168 u32 rx_status; |
2170 u32 rx_status; |
2169 unsigned int pkt_size; |
2171 unsigned int pkt_size; |
2170 struct sk_buff *skb; |
2172 struct sk_buff *skb; |
2177 pkt_size = rx_size - 4; |
2179 pkt_size = rx_size - 4; |
2178 |
2180 |
2179 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
2181 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
2180 |
2182 |
2181 if (dev != rtl_ecat_dev.dev && netif_msg_rx_status(tp)) |
2183 if (dev != rtl_ecat_dev.dev && netif_msg_rx_status(tp)) |
2182 printk(KERN_DEBUG "%s: rtl8139_rx() status %4.4x, size %4.4x," |
2184 printk(KERN_DEBUG "%s: rtl8139_rx() status %4.4x, size %4.4x," |
2183 " cur %4.4x.\n", dev->name, rx_status, |
2185 " cur %4.4x.\n", dev->name, rx_status, |
2184 rx_size, cur_rx); |
2186 rx_size, cur_rx); |
2185 |
2187 |
2186 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
2188 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
2187 |
2189 |
2188 #if RTL8139_DEBUG > 2 |
2190 #if RTL8139_DEBUG > 2 |
2189 { |
2191 { |
2385 if (done) { |
2387 if (done) { |
2386 /* |
2388 /* |
2387 * Order is important since data can get interrupted |
2389 * Order is important since data can get interrupted |
2388 * again when we think we are done. |
2390 * again when we think we are done. |
2389 */ |
2391 */ |
|
2392 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2393 if (dev != rtl_ecat_dev.dev) { |
|
2394 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
2390 local_irq_disable(); |
2395 local_irq_disable(); |
2391 RTL_W16_F(IntrMask, rtl8139_intr_mask); |
2396 RTL_W16_F(IntrMask, rtl8139_intr_mask); //Interrupts werden nicht enabled ?? HM |
2392 __netif_rx_complete(dev); |
2397 __netif_rx_complete(dev); |
2393 local_irq_enable(); |
2398 local_irq_enable(); |
|
2399 } |
|
2400 // else |
|
2401 |
2394 } |
2402 } |
2395 spin_unlock(&tp->rx_lock); |
2403 spin_unlock(&tp->rx_lock); |
2396 |
2404 |
2397 return !done; |
2405 return !done; |
2398 } |
2406 } |
2423 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
2432 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
2424 |
2433 |
2425 status = RTL_R16 (IntrStatus); |
2434 status = RTL_R16 (IntrStatus); |
2426 |
2435 |
2427 /* shared irq? */ |
2436 /* shared irq? */ |
2428 if (unlikely((status & rtl8139_intr_mask) == 0)) |
2437 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2438 if (dev != rtl_ecat_dev.dev) |
|
2439 if (unlikely((status & rtl8139_intr_mask) == 0)) |
2429 goto out; |
2440 goto out; |
|
2441 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
2430 |
2442 |
2431 handled = 1; |
2443 handled = 1; |
2432 |
2444 |
2433 /* h/w no longer present (hotplug?) or major error, bail */ |
2445 /* h/w no longer present (hotplug?) or major error, bail */ |
2434 if (unlikely(status == 0xFFFF)) |
2446 if (unlikely(status == 0xFFFF)) |
2435 goto out; |
2447 goto out; |
2436 |
2448 |
2437 /* close possible race's with dev_close */ |
2449 /* close possible race's with dev_close */ |
2438 if (unlikely(!netif_running(dev))) { |
2450 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2451 if (dev != rtl_ecat_dev.dev) { |
|
2452 if (unlikely(!netif_running(dev))) { |
2439 RTL_W16 (IntrMask, 0); |
2453 RTL_W16 (IntrMask, 0); |
2440 goto out; |
2454 goto out; |
2441 } |
2455 } |
2442 |
2456 } |
|
2457 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
2443 /* Acknowledge all of the current interrupt sources ASAP, but |
2458 /* Acknowledge all of the current interrupt sources ASAP, but |
2444 an first get an additional status bit from CSCR. */ |
2459 an first get an additional status bit from CSCR. */ |
2445 if (unlikely(status & RxUnderrun)) |
2460 if (unlikely(status & RxUnderrun)) |
2446 link_changed = RTL_R16 (CSCR) & CSCR_LinkChangeBit; |
2461 link_changed = RTL_R16 (CSCR) & CSCR_LinkChangeBit; |
2447 |
2462 |
2448 ackstat = status & ~(RxAckBits | TxErr); |
2463 ackstat = status & ~(RxAckBits | TxErr); |
2449 if (ackstat) |
2464 if (ackstat) { |
2450 RTL_W16 (IntrStatus, ackstat); |
2465 RTL_W16 (IntrStatus, ackstat); |
|
2466 //printk("ECAT-NIC ack\n"); //HM |
|
2467 } |
2451 |
2468 |
2452 /* Receive packets are processed by poll routine. |
2469 /* Receive packets are processed by poll routine. |
2453 If not running start it now. */ |
2470 If not running start it now. */ |
|
2471 |
|
2472 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
2454 if (status & RxAckBits){ |
2473 if (status & RxAckBits){ |
|
2474 // printk("ECAT-NIC RX-Intr Flag\n"); // HM |
|
2475 if (dev != rtl_ecat_dev.dev) { |
2455 if (netif_rx_schedule_prep(dev)) { |
2476 if (netif_rx_schedule_prep(dev)) { |
2456 RTL_W16_F (IntrMask, rtl8139_norx_intr_mask); |
2477 RTL_W16_F (IntrMask, rtl8139_norx_intr_mask); |
2457 __netif_rx_schedule (dev); |
2478 __netif_rx_schedule (dev); |
2458 } |
2479 } |
|
2480 } |
|
2481 // else |
|
2482 |
2459 } |
2483 } |
2460 |
2484 |
2461 /* Check uncommon events with one test. */ |
2485 /* Check uncommon events with one test. */ |
2462 if (unlikely(status & (PCIErr | PCSTimeout | RxUnderrun | RxErr))) |
2486 if (unlikely(status & (PCIErr | PCSTimeout | RxUnderrun | RxErr))) |
2463 rtl8139_weird_interrupt (dev, tp, ioaddr, |
2487 rtl8139_weird_interrupt (dev, tp, ioaddr, |
2506 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
2530 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
2507 |
2531 |
2508 if (dev != rtl_ecat_dev.dev) |
2532 if (dev != rtl_ecat_dev.dev) |
2509 { |
2533 { |
2510 netif_stop_queue(dev); |
2534 netif_stop_queue(dev); |
2511 } |
2535 if (tp->thr_pid >= 0) { |
2512 |
|
2513 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2514 |
|
2515 if (tp->thr_pid >= 0) { |
|
2516 tp->time_to_die = 1; |
2536 tp->time_to_die = 1; |
2517 wmb(); |
2537 wmb(); |
2518 ret = kill_proc (tp->thr_pid, SIGTERM, 1); |
2538 ret = kill_proc (tp->thr_pid, SIGTERM, 1); |
2519 if (ret) { |
2539 if (ret) { |
2520 printk (KERN_ERR "%s: unable to signal thread\n", dev->name); |
2540 printk (KERN_ERR "%s: unable to signal thread\n", dev->name); |
2521 return ret; |
2541 return ret; |
2522 } |
2542 } |
2523 wait_for_completion (&tp->thr_exited); |
2543 wait_for_completion (&tp->thr_exited); |
2524 } |
2544 } |
|
2545 } |
2525 |
2546 |
2526 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
2547 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
2527 |
2548 |
2528 if (dev != rtl_ecat_dev.dev) |
2549 if (dev != rtl_ecat_dev.dev) |
2529 { |
2550 { |
2532 dev->name, RTL_R16 (IntrStatus)); |
2553 dev->name, RTL_R16 (IntrStatus)); |
2533 } |
2554 } |
2534 |
2555 |
2535 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
2556 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
2536 |
2557 |
2537 spin_lock_irqsave (&tp->lock, flags); |
2558 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2559 if (dev != rtl_ecat_dev.dev) |
|
2560 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2561 spin_lock_irqsave (&tp->lock, flags); |
2538 |
2562 |
2539 /* Stop the chip's Tx and Rx DMA processes. */ |
2563 /* Stop the chip's Tx and Rx DMA processes. */ |
2540 RTL_W8 (ChipCmd, 0); |
2564 RTL_W8 (ChipCmd, 0); |
2541 |
2565 |
2542 /* Disable interrupts by clearing the interrupt mask. */ |
2566 /* Disable interrupts by clearing the interrupt mask. */ |
2544 |
2568 |
2545 /* Update the error counts. */ |
2569 /* Update the error counts. */ |
2546 tp->stats.rx_missed_errors += RTL_R32 (RxMissed); |
2570 tp->stats.rx_missed_errors += RTL_R32 (RxMissed); |
2547 RTL_W32 (RxMissed, 0); |
2571 RTL_W32 (RxMissed, 0); |
2548 |
2572 |
2549 spin_unlock_irqrestore (&tp->lock, flags); |
2573 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2574 if (dev != rtl_ecat_dev.dev) |
|
2575 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2576 spin_unlock_irqrestore (&tp->lock, flags); |
2550 |
2577 |
2551 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
2578 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
2552 |
2579 |
2553 if (dev != rtl_ecat_dev.dev) |
2580 if (dev != rtl_ecat_dev.dev) |
2554 { |
2581 { |