master/ethernet.c
changeset 344 5d8281f1aa2a
parent 340 5a5f5a14c847
child 390 685c267d80d8
equal deleted inserted replaced
343:b3858d25ba4b 344:5d8281f1aa2a
   103 
   103 
   104     eoe->rx_counter = 0;
   104     eoe->rx_counter = 0;
   105     eoe->tx_counter = 0;
   105     eoe->tx_counter = 0;
   106     eoe->rx_rate = 0;
   106     eoe->rx_rate = 0;
   107     eoe->tx_rate = 0;
   107     eoe->tx_rate = 0;
   108     eoe->t_last = 0;
   108     eoe->rate_jiffies = 0;
   109 
   109 
   110     if (!(eoe->dev =
   110     if (!(eoe->dev =
   111           alloc_netdev(sizeof(ec_eoe_t *), "eoe%d", ether_setup))) {
   111           alloc_netdev(sizeof(ec_eoe_t *), "eoe%d", ether_setup))) {
   112         EC_ERR("Unable to allocate net_device for EoE handler!\n");
   112         EC_ERR("Unable to allocate net_device for EoE handler!\n");
   113         goto out_return;
   113         goto out_return;
   276    Runs the EoE state machine.
   276    Runs the EoE state machine.
   277 */
   277 */
   278 
   278 
   279 void ec_eoe_run(ec_eoe_t *eoe /**< EoE handler */)
   279 void ec_eoe_run(ec_eoe_t *eoe /**< EoE handler */)
   280 {
   280 {
   281     cycles_t t_now;
       
   282 
       
   283     if (!eoe->opened) return;
   281     if (!eoe->opened) return;
   284 
   282 
   285     // call state function
   283     // call state function
   286     eoe->state(eoe);
   284     eoe->state(eoe);
   287 
   285 
   288     // update statistics
   286     // update statistics
   289     t_now = get_cycles();
   287     if (jiffies - eoe->rate_jiffies > HZ) {
   290     if ((u32) (t_now - eoe->t_last) > cpu_khz * 1000) {
       
   291         eoe->rx_rate = eoe->rx_counter * 8;
   288         eoe->rx_rate = eoe->rx_counter * 8;
   292         eoe->tx_rate = eoe->tx_counter * 8;
   289         eoe->tx_rate = eoe->tx_counter * 8;
   293         eoe->rx_counter = 0;
   290         eoe->rx_counter = 0;
   294         eoe->tx_counter = 0;
   291         eoe->tx_counter = 0;
   295         eoe->t_last = t_now;
   292         eoe->rate_jiffies = jiffies;
   296     }
   293     }
   297 }
   294 }
   298 
   295 
   299 /*****************************************************************************/
   296 /*****************************************************************************/
   300 
   297