120 eoe->tx_frame = NULL; |
120 eoe->tx_frame = NULL; |
121 eoe->tx_queue_active = 0; |
121 eoe->tx_queue_active = 0; |
122 eoe->tx_queue_size = EC_EOE_TX_QUEUE_SIZE; |
122 eoe->tx_queue_size = EC_EOE_TX_QUEUE_SIZE; |
123 eoe->tx_queued_frames = 0; |
123 eoe->tx_queued_frames = 0; |
124 |
124 |
125 sema_init(&eoe->tx_queue_sem, 1); |
125 ec_mutex_init(&eoe->tx_queue_mutex); |
126 eoe->tx_frame_number = 0xFF; |
126 eoe->tx_frame_number = 0xFF; |
127 memset(&eoe->stats, 0, sizeof(struct net_device_stats)); |
127 memset(&eoe->stats, 0, sizeof(struct net_device_stats)); |
128 |
128 |
129 eoe->rx_counter = 0; |
129 eoe->rx_counter = 0; |
130 eoe->tx_counter = 0; |
130 eoe->tx_counter = 0; |
229 */ |
229 */ |
230 void ec_eoe_flush(ec_eoe_t *eoe /**< EoE handler */) |
230 void ec_eoe_flush(ec_eoe_t *eoe /**< EoE handler */) |
231 { |
231 { |
232 ec_eoe_frame_t *frame, *next; |
232 ec_eoe_frame_t *frame, *next; |
233 |
233 |
234 down(&eoe->tx_queue_sem); |
234 ec_mutex_lock(&eoe->tx_queue_mutex); |
235 |
235 |
236 list_for_each_entry_safe(frame, next, &eoe->tx_queue, queue) { |
236 list_for_each_entry_safe(frame, next, &eoe->tx_queue, queue) { |
237 list_del(&frame->queue); |
237 list_del(&frame->queue); |
238 dev_kfree_skb(frame->skb); |
238 dev_kfree_skb(frame->skb); |
239 kfree(frame); |
239 kfree(frame); |
240 } |
240 } |
241 eoe->tx_queued_frames = 0; |
241 eoe->tx_queued_frames = 0; |
242 |
242 |
243 up(&eoe->tx_queue_sem); |
243 ec_mutex_unlock(&eoe->tx_queue_mutex); |
244 } |
244 } |
245 |
245 |
246 /*****************************************************************************/ |
246 /*****************************************************************************/ |
247 |
247 |
248 /** Sends a frame or the next fragment. |
248 /** Sends a frame or the next fragment. |
619 eoe->rx_idle = 1; |
619 eoe->rx_idle = 1; |
620 eoe->tx_idle = 1; |
620 eoe->tx_idle = 1; |
621 return; |
621 return; |
622 } |
622 } |
623 |
623 |
624 down(&eoe->tx_queue_sem); |
624 ec_mutex_lock(&eoe->tx_queue_mutex); |
625 |
625 |
626 if (!eoe->tx_queued_frames || list_empty(&eoe->tx_queue)) { |
626 if (!eoe->tx_queued_frames || list_empty(&eoe->tx_queue)) { |
627 up(&eoe->tx_queue_sem); |
627 ec_mutex_unlock(&eoe->tx_queue_mutex); |
628 eoe->tx_idle = 1; |
628 eoe->tx_idle = 1; |
629 // no data available. |
629 // no data available. |
630 // start a new receive immediately. |
630 // start a new receive immediately. |
631 ec_eoe_state_rx_start(eoe); |
631 ec_eoe_state_rx_start(eoe); |
632 return; |
632 return; |
811 return 1; |
811 return 1; |
812 } |
812 } |
813 |
813 |
814 frame->skb = skb; |
814 frame->skb = skb; |
815 |
815 |
816 down(&eoe->tx_queue_sem); |
816 ec_mutex_lock(&eoe->tx_queue_mutex); |
817 list_add_tail(&frame->queue, &eoe->tx_queue); |
817 list_add_tail(&frame->queue, &eoe->tx_queue); |
818 eoe->tx_queued_frames++; |
818 eoe->tx_queued_frames++; |
819 if (eoe->tx_queued_frames == eoe->tx_queue_size) { |
819 if (eoe->tx_queued_frames == eoe->tx_queue_size) { |
820 netif_stop_queue(dev); |
820 netif_stop_queue(dev); |
821 eoe->tx_queue_active = 0; |
821 eoe->tx_queue_active = 0; |
822 } |
822 } |
823 up(&eoe->tx_queue_sem); |
823 ec_mutex_unlock(&eoe->tx_queue_mutex); |
824 |
824 |
825 #if EOE_DEBUG_LEVEL >= 2 |
825 #if EOE_DEBUG_LEVEL >= 2 |
826 EC_SLAVE_DBG(eoe->slave, 0, "EoE %s TX queued frame" |
826 EC_SLAVE_DBG(eoe->slave, 0, "EoE %s TX queued frame" |
827 " with %u octets (%u frames queued).\n", |
827 " with %u octets (%u frames queued).\n", |
828 eoe->dev->name, skb->len, eoe->tx_queued_frames); |
828 eoe->dev->name, skb->len, eoe->tx_queued_frames); |