master/ethernet.c
changeset 336 360e5287c888
parent 325 7833cf70c4f2
child 339 a3a4ee854bd8
equal deleted inserted replaced
335:1e37c856b74e 336:360e5287c888
    99     eoe->tx_queued_frames = 0;
    99     eoe->tx_queued_frames = 0;
   100     eoe->tx_queue_lock = SPIN_LOCK_UNLOCKED;
   100     eoe->tx_queue_lock = SPIN_LOCK_UNLOCKED;
   101     eoe->tx_frame_number = 0xFF;
   101     eoe->tx_frame_number = 0xFF;
   102     memset(&eoe->stats, 0, sizeof(struct net_device_stats));
   102     memset(&eoe->stats, 0, sizeof(struct net_device_stats));
   103 
   103 
       
   104     eoe->rx_counter = 0;
       
   105     eoe->tx_counter = 0;
       
   106     eoe->rx_rate = 0;
       
   107     eoe->tx_rate = 0;
       
   108     eoe->t_last = 0;
       
   109 
   104     if (!(eoe->dev =
   110     if (!(eoe->dev =
   105           alloc_netdev(sizeof(ec_eoe_t *), "eoe%d", ether_setup))) {
   111           alloc_netdev(sizeof(ec_eoe_t *), "eoe%d", ether_setup))) {
   106         EC_ERR("Unable to allocate net_device for EoE handler!\n");
   112         EC_ERR("Unable to allocate net_device for EoE handler!\n");
   107         goto out_return;
   113         goto out_return;
   108     }
   114     }
   270    Runs the EoE state machine.
   276    Runs the EoE state machine.
   271 */
   277 */
   272 
   278 
   273 void ec_eoe_run(ec_eoe_t *eoe /**< EoE handler */)
   279 void ec_eoe_run(ec_eoe_t *eoe /**< EoE handler */)
   274 {
   280 {
       
   281     cycles_t t_now;
       
   282 
   275     if (!eoe->opened) return;
   283     if (!eoe->opened) return;
   276 
   284 
   277     // call state function
   285     // call state function
   278     eoe->state(eoe);
   286     eoe->state(eoe);
       
   287 
       
   288     // update statistics
       
   289     t_now = get_cycles();
       
   290     if ((u32) (t_now - eoe->t_last) > cpu_khz * 1000) {
       
   291         eoe->rx_rate = eoe->rx_counter * 8;
       
   292         eoe->tx_rate = eoe->tx_counter * 8;
       
   293         eoe->rx_counter = 0;
       
   294         eoe->tx_counter = 0;
       
   295         eoe->t_last = t_now;
       
   296     }
   279 }
   297 }
   280 
   298 
   281 /*****************************************************************************/
   299 /*****************************************************************************/
   282 
   300 
   283 /**
   301 /**
   450 
   468 
   451     if (last_fragment) {
   469     if (last_fragment) {
   452         // update statistics
   470         // update statistics
   453         eoe->stats.rx_packets++;
   471         eoe->stats.rx_packets++;
   454         eoe->stats.rx_bytes += eoe->rx_skb->len;
   472         eoe->stats.rx_bytes += eoe->rx_skb->len;
       
   473         eoe->rx_counter += eoe->rx_skb->len;
   455 
   474 
   456 #if EOE_DEBUG_LEVEL > 0
   475 #if EOE_DEBUG_LEVEL > 0
   457         EC_DBG("EoE RX frame completed with %u octets.\n",
   476         EC_DBG("EoE RX frame completed with %u octets.\n",
   458                eoe->rx_skb->len);
   477                eoe->rx_skb->len);
   459 #endif
   478 #endif
   566 
   585 
   567     // frame completely sent
   586     // frame completely sent
   568     if (eoe->tx_offset >= eoe->tx_frame->skb->len) {
   587     if (eoe->tx_offset >= eoe->tx_frame->skb->len) {
   569         eoe->stats.tx_packets++;
   588         eoe->stats.tx_packets++;
   570         eoe->stats.tx_bytes += eoe->tx_frame->skb->len;
   589         eoe->stats.tx_bytes += eoe->tx_frame->skb->len;
       
   590         eoe->tx_counter += eoe->tx_frame->skb->len;
   571         dev_kfree_skb(eoe->tx_frame->skb);
   591         dev_kfree_skb(eoe->tx_frame->skb);
   572         kfree(eoe->tx_frame);
   592         kfree(eoe->tx_frame);
   573         eoe->tx_frame = NULL;
   593         eoe->tx_frame = NULL;
   574         eoe->state = ec_eoe_state_rx_start;
   594         eoe->state = ec_eoe_state_rx_start;
   575     }
   595     }