Ignore:
Timestamp:
Nov 27, 2017, 1:24:02 PM (6 years ago)
Author:
coas-nagasima
Message:

Ethernetのリンク確立までの手順を修正

File:
1 edited

Legend:

Unmodified
Added
Removed
  • UsbWattMeter/trunk/lwip-1.4.1/ports/grsakura/if_rx62n.c

    r167 r327  
    306306  }
    307307
     308  /* 送受信を有効 */
     309  rx62n_set_ecmr(netif, 1);
     310
    308311  /* NIC からの割り込みを許可する。*/
    309312  ret = ena_int(INTNO_IF_RX62N_TRX);
     
    507510        struct ethernetif *ethernetif;
    508511        PHY_MODE_T mode;
     512        uint8_t phy_addr = 0;
    509513
    510514        ethernetif = netif->state;
    511515
    512516        if(ethernetif->state == PHY_STATE_NEGOTIATED){
    513                 ethernetif->link_now = phy_is_link(0);
     517                ethernetif->link_now = phy_is_link(phy_addr);
    514518                if(!ethernetif->link_now)
    515519                        ethernetif->state = PHY_STATE_RESET;
     
    518522
    519523        /* PHYの初期化 */
    520         ethernetif->state = phy_initialize(ethernetif->state, 0, &mode);
     524        ethernetif->state = phy_initialize(ethernetif->state, phy_addr, &mode);
    521525        if(ethernetif->state != PHY_STATE_NEGOTIATED){
    522526                return false;
     
    547551
    548552  if(ethernetif->link_pre != ethernetif->link_now){
    549     if(rx62n_link(netif)){
    550       bool_t cng = ethernetif->link_pre != ethernetif->link_now;
    551       ethernetif->link_pre = ethernetif->link_now;
    552       /* リンク状態に変化あり */
    553       if(cng){
    554         if (ethernetif->link_pre) {
    555           netif_set_link_up(netif);
    556         }
    557         else {
    558           netif_set_link_down(netif);
    559         }
     553    ethernetif->link_pre = ethernetif->link_now;
     554    /* リンク状態に変化あり */
     555    if (rx62n_link(netif)) {
     556      netif_set_link_up(netif);
     557    }
     558    else {
     559      netif_set_link_down(netif);
     560    }
     561
     562    if (ethernetif->state != PHY_STATE_NEGOTIATED) {
     563      ethernetif->link_pre = !ethernetif->link_now;
     564      sig_sem(ethernetif->sem_rev);
     565    }
     566
     567    return;
     568  }
     569
     570  for (;;) {
     571    /* move received packet into a new pbuf */
     572    p = low_level_input(netif);
     573    /* no packet could be read, silently ignore this */
     574    if (p == NULL) return;
     575    /* points to packet payload, which starts with an Ethernet header */
     576    ethhdr = p->payload;
     577
     578    switch (htons(ethhdr->type)) {
     579      /* IP or ARP packet? */
     580    case ETHTYPE_IP:
     581    case ETHTYPE_ARP:
     582#if PPPOE_SUPPORT
     583      /* PPPoE packet? */
     584    case ETHTYPE_PPPOEDISC:
     585    case ETHTYPE_PPPOE:
     586#endif /* PPPOE_SUPPORT */
     587      /* full packet send to tcpip_thread to process */
     588      if (netif->input(p, netif) != ERR_OK) {
     589        LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
     590        pbuf_free(p);
     591        p = NULL;
    560592      }
    561     }
    562 
    563     if (ethernetif->state != PHY_STATE_NEGOTIATED)
    564       sig_sem(ethernetif->sem_rev);
    565 
    566     return;
    567   }
    568 
    569   /* move received packet into a new pbuf */
    570   p = low_level_input(netif);
    571   /* no packet could be read, silently ignore this */
    572   if (p == NULL) return;
    573   /* points to packet payload, which starts with an Ethernet header */
    574   ethhdr = p->payload;
    575 
    576   switch (htons(ethhdr->type)) {
    577     /* IP or ARP packet? */
    578   case ETHTYPE_IP:
    579   case ETHTYPE_ARP:
    580 #if PPPOE_SUPPORT
    581     /* PPPoE packet? */
    582   case ETHTYPE_PPPOEDISC:
    583   case ETHTYPE_PPPOE:
    584 #endif /* PPPOE_SUPPORT */
    585     /* full packet send to tcpip_thread to process */
    586     if (netif->input(p, netif) != ERR_OK) {
    587       LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
     593      break;
     594
     595    default:
    588596      pbuf_free(p);
    589597      p = NULL;
    590     }
    591     break;
    592 
    593   default:
    594     pbuf_free(p);
    595     p = NULL;
    596     break;
     598      break;
     599    }
    597600  }
    598601}
Note: See TracChangeset for help on using the changeset viewer.