static int de600_start_xmit(struct sk_buff *skb, struct net_device *dev) { unsigned long flags; int transmit_from; int len; int tickssofar; u8 *buffer = skb->data; int i; if (free_tx_pages <= 0) { /* Do timeouts, to avoid hangs. */ tickssofar = jiffies - dev->trans_start; if (tickssofar < 5) return 1; /* else */ printk(KERN_WARNING "%s: transmit timed out (%d), %s?\n", dev->name, tickssofar, "network cable problem"); /* Restart the adapter. */ spin_lock_irqsave(&de600_lock, flags); if (adapter_init(dev)) { spin_unlock_irqrestore(&de600_lock, flags); return 1; } spin_unlock_irqrestore(&de600_lock, flags); } /* Start real output */ PRINTK(("de600_start_xmit:len=%d, page %d/%d\n", skb->len, tx_fifo_in, free_tx_pages)); if ((len = skb->len) < RUNT) len = RUNT; spin_lock_irqsave(&de600_lock, flags); select_nic(); tx_fifo[tx_fifo_in] = transmit_from = tx_page_adr(tx_fifo_in) - len; tx_fifo_in = (tx_fifo_in + 1) % TX_PAGES; /* Next free tx page */ if(check_lost) { /* This costs about 40 instructions per packet... */ de600_setup_address(NODE_ADDRESS, RW_ADDR); de600_read_byte(READ_DATA, dev); if (was_down || (de600_read_byte(READ_DATA, dev) != 0xde)) { if (adapter_init(dev)) { spin_unlock_irqrestore(&de600_lock, flags); return 1; } } } de600_setup_address(transmit_from, RW_ADDR); for (i = 0; i < skb->len ; ++i, ++buffer) de600_put_byte(*buffer); for (; i < len; ++i) de600_put_byte(0); if (free_tx_pages-- == TX_PAGES) { /* No transmission going on */ dev->trans_start = jiffies; netif_start_queue(dev); /* allow more packets into adapter */ /* Send page and generate a faked interrupt */ de600_setup_address(transmit_from, TX_ADDR); de600_put_command(TX_ENABLE); } else { if (free_tx_pages) netif_start_queue(dev); else netif_stop_queue(dev); select_prn(); } spin_unlock_irqrestore(&de600_lock, flags); dev_kfree_skb(skb); return 0; }
static int de600_start_xmit(struct sk_buff *skb, struct net_device *dev) { unsigned long flags; int transmit_from; int len; int tickssofar; u8 *buffer = skb->data; int i; if (free_tx_pages <= 0) { tickssofar = jiffies - dev->trans_start; if (tickssofar < 5) return NETDEV_TX_BUSY; printk(KERN_WARNING "%s: transmit timed out (%d), %s?\n", dev->name, tickssofar, "network cable problem"); spin_lock_irqsave(&de600_lock, flags); if (adapter_init(dev)) { spin_unlock_irqrestore(&de600_lock, flags); return NETDEV_TX_BUSY; } spin_unlock_irqrestore(&de600_lock, flags); } pr_debug("de600_start_xmit:len=%d, page %d/%d\n", skb->len, tx_fifo_in, free_tx_pages); if ((len = skb->len) < RUNT) len = RUNT; spin_lock_irqsave(&de600_lock, flags); select_nic(); tx_fifo[tx_fifo_in] = transmit_from = tx_page_adr(tx_fifo_in) - len; tx_fifo_in = (tx_fifo_in + 1) % TX_PAGES; if(check_lost) { de600_setup_address(NODE_ADDRESS, RW_ADDR); de600_read_byte(READ_DATA, dev); if (was_down || (de600_read_byte(READ_DATA, dev) != 0xde)) { if (adapter_init(dev)) { spin_unlock_irqrestore(&de600_lock, flags); return NETDEV_TX_BUSY; } } } de600_setup_address(transmit_from, RW_ADDR); for (i = 0; i < skb->len ; ++i, ++buffer) de600_put_byte(*buffer); for (; i < len; ++i) de600_put_byte(0); if (free_tx_pages-- == TX_PAGES) { dev->trans_start = jiffies; netif_start_queue(dev); de600_setup_address(transmit_from, TX_ADDR); de600_put_command(TX_ENABLE); } else { if (free_tx_pages) netif_start_queue(dev); else netif_stop_queue(dev); select_prn(); } spin_unlock_irqrestore(&de600_lock, flags); dev_kfree_skb(skb); return NETDEV_TX_OK; }
/* * Copy a buffer to the adapter transmit page memory. * Start sending. */ static int de600_start_xmit(struct sk_buff *skb, struct net_device *dev) { unsigned long flags; int transmit_from; int len; int tickssofar; byte *buffer = skb->data; if (free_tx_pages <= 0) { /* Do timeouts, to avoid hangs. */ tickssofar = jiffies - dev->trans_start; if (tickssofar < 5) return 1; /* else */ printk("%s: transmit timed out (%d), %s?\n", dev->name, tickssofar, "network cable problem" ); /* Restart the adapter. */ if (adapter_init(dev)) { return 1; } } /* Start real output */ PRINTK(("de600_start_xmit:len=%d, page %d/%d\n", skb->len, tx_fifo_in, free_tx_pages)); if ((len = skb->len) < RUNT) len = RUNT; save_flags(flags); cli(); select_nic(); tx_fifo[tx_fifo_in] = transmit_from = tx_page_adr(tx_fifo_in) - len; tx_fifo_in = (tx_fifo_in + 1) % TX_PAGES; /* Next free tx page */ #ifdef CHECK_LOST_DE600 /* This costs about 40 instructions per packet... */ de600_setup_address(NODE_ADDRESS, RW_ADDR); de600_read_byte(READ_DATA, dev); if (was_down || (de600_read_byte(READ_DATA, dev) != 0xde)) { if (adapter_init(dev)) { restore_flags(flags); return 1; } } #endif de600_setup_address(transmit_from, RW_ADDR); for ( ; len > 0; --len, ++buffer) de600_put_byte(*buffer); if (free_tx_pages-- == TX_PAGES) { /* No transmission going on */ dev->trans_start = jiffies; netif_start_queue(dev); /* allow more packets into adapter */ /* Send page and generate a faked interrupt */ de600_setup_address(transmit_from, TX_ADDR); de600_put_command(TX_ENABLE); } else { if (free_tx_pages) netif_start_queue(dev); else netif_stop_queue(dev); select_prn(); } restore_flags(flags); #ifdef FAKE_SMALL_MAX /* This will "patch" the socket TCP proto at an early moment */ if (skb->sk && (skb->sk->protocol == IPPROTO_TCP) && (skb->sk->prot->rspace != &de600_rspace)) skb->sk->prot->rspace = de600_rspace; /* Ugh! */ #endif dev_kfree_skb (skb); return 0; }
/* * Copy a buffer to the adapter transmit page memory. * Start sending. */ static int d_link_start_xmit(struct sk_buff *skb, struct device *dev) { int transmit_from; int len; int tickssofar; unsigned char *buffer = skb->data; /* * If some higher layer thinks we've missed a * tx-done interrupt we are passed NULL. * Caution: dev_tint() handles the cli()/sti() itself. */ if (skb == NULL) { dev_tint(dev); return 0; } /* For ethernet, fill in the header (hardware addresses) with an arp. */ if (!skb->arp) if(dev->rebuild_header(skb->data, dev)) { skb->dev = dev; arp_queue (skb); return 0; } skb->arp = 1; if (free_tx_pages <= 0) { /* Do timeouts, to avoid hangs. */ tickssofar = jiffies - dev->trans_start; if (tickssofar < 5) return 1; /* else */ printk("%s: transmit timed out (%d), %s?\n", dev->name, tickssofar, "network cable problem" ); /* Restart the adapter. */ adapter_init(dev); } /* Start real output */ PRINTK(("d_link_start_xmit:len=%d, page %d/%d\n", skb->len, tx_fifo_in, free_tx_pages)); if ((len = skb->len) < RUNT) len = RUNT; cli(); select_nic(); tx_fifo[tx_fifo_in] = transmit_from = tx_page_adr(tx_fifo_in) - len; tx_fifo_in = (tx_fifo_in + 1) % TX_PAGES; /* Next free tx page */ d_link_setup_address(transmit_from, RW_ADDR); for ( ; len > 0; --len, ++buffer) d_link_put_byte(*buffer); if (free_tx_pages-- == TX_PAGES) { /* No transmission going on */ dev->trans_start = jiffies; dev->tbusy = 0; /* allow more packets into adapter */ /* Send page and generate an interrupt */ d_link_setup_address(transmit_from, TX_ADDR); d_link_put_command(TX_ENABLE); } else { dev->tbusy = !free_tx_pages; select_prn(); } sti(); /* interrupts back on */ if (skb->free) kfree_skb (skb, FREE_WRITE); return 0; }