master/ethernet.c
changeset 2626 713058b68b43
parent 2625 e25af8bd3957
child 2641 535465bf176d
equal deleted inserted replaced
2625:e25af8bd3957 2626:713058b68b43
   191     eoe->dev->stop = ec_eoedev_stop;
   191     eoe->dev->stop = ec_eoedev_stop;
   192     eoe->dev->hard_start_xmit = ec_eoedev_tx;
   192     eoe->dev->hard_start_xmit = ec_eoedev_tx;
   193     eoe->dev->get_stats = ec_eoedev_stats;
   193     eoe->dev->get_stats = ec_eoedev_stats;
   194 #endif
   194 #endif
   195 
   195 
   196     // First check if the MAC address assigned to the master is globally unique
   196     // First check if the MAC address assigned to the master is globally
   197     if ((slave->master->devices[EC_DEVICE_MAIN].dev->dev_addr[0] & 0x02) != 0x02) {
   197     // unique
   198         // The master MAC is unique and the NIC part can be used for the EoE interface MAC
   198     if ((slave->master->devices[EC_DEVICE_MAIN].dev->dev_addr[0] & 0x02) !=
       
   199             0x02) {
       
   200         // The master MAC is unique and the NIC part can be used for the EoE
       
   201         // interface MAC
   199         use_master_mac = 1;
   202         use_master_mac = 1;
   200     }
   203     }
   201     else {
   204     else {
   202         // The master MAC is not unique, so we check for unique MAC in other interfaces
   205         // The master MAC is not unique, so we check for unique MAC in other
       
   206         // interfaces
   203         dev = first_net_device(&init_net);
   207         dev = first_net_device(&init_net);
   204         while (dev) {
   208         while (dev) {
   205             // Check if globally unique MAC address
   209             // Check if globally unique MAC address
   206             if (dev->addr_len == ETH_ALEN) {
   210             if (dev->addr_len == ETH_ALEN) {
   207                 if (memcmp(dev->dev_addr, lo_mac, ETH_ALEN) != 0) {
   211                 if (memcmp(dev->dev_addr, lo_mac, ETH_ALEN) != 0) {
   208                     if ((dev->dev_addr[0] & 0x02) != 0x02) {
   212                     if ((dev->dev_addr[0] & 0x02) != 0x02) {
   209                         // The first globally unique MAC address has been identified
   213                         // The first globally unique MAC address has been
       
   214                         // identified
   210                         break;
   215                         break;
   211                     }
   216                     }
   212                 }
   217                 }
   213             }
   218             }
   214             dev = next_net_device(dev);
   219             dev = next_net_device(dev);
   215         }
   220         }
   216         if (eoe->dev->addr_len == ETH_ALEN) {
   221         if (eoe->dev->addr_len == ETH_ALEN) {
   217             if (dev) {
   222             if (dev) {
   218                 // A unique MAC were identified in one of the other network interfaces
   223                 // A unique MAC were identified in one of the other network
   219                 // and the NIC part can be used for the EoE interface MAC.
   224                 // interfaces and the NIC part can be used for the EoE
   220                 EC_SLAVE_INFO(slave, "%s MAC address derived from NIC part of %s MAC address",
   225                 // interface MAC.
       
   226                 EC_SLAVE_INFO(slave, "%s MAC address derived from"
       
   227                         " NIC part of %s MAC address",
   221                     eoe->dev->name, dev->name);
   228                     eoe->dev->name, dev->name);
   222                 eoe->dev->dev_addr[1] = dev->dev_addr[3];
   229                 eoe->dev->dev_addr[1] = dev->dev_addr[3];
   223                 eoe->dev->dev_addr[2] = dev->dev_addr[4];
   230                 eoe->dev->dev_addr[2] = dev->dev_addr[4];
   224                 eoe->dev->dev_addr[3] = dev->dev_addr[5];
   231                 eoe->dev->dev_addr[3] = dev->dev_addr[5];
   225             }
   232             }
   228             }
   235             }
   229         }
   236         }
   230     }
   237     }
   231     if (eoe->dev->addr_len == ETH_ALEN) {
   238     if (eoe->dev->addr_len == ETH_ALEN) {
   232         if (use_master_mac) {
   239         if (use_master_mac) {
   233             EC_SLAVE_INFO(slave, "%s MAC address derived from NIC part of %s MAC address",
   240             EC_SLAVE_INFO(slave, "%s MAC address derived"
   234                 eoe->dev->name, slave->master->devices[EC_DEVICE_MAIN].dev->name);
   241                     " from NIC part of %s MAC address",
   235             eoe->dev->dev_addr[1] = slave->master->devices[EC_DEVICE_MAIN].dev->dev_addr[3];
   242                 eoe->dev->name,
   236             eoe->dev->dev_addr[2] = slave->master->devices[EC_DEVICE_MAIN].dev->dev_addr[4];
   243                 slave->master->devices[EC_DEVICE_MAIN].dev->name);
   237             eoe->dev->dev_addr[3] = slave->master->devices[EC_DEVICE_MAIN].dev->dev_addr[5];
   244             eoe->dev->dev_addr[1] =
       
   245                 slave->master->devices[EC_DEVICE_MAIN].dev->dev_addr[3];
       
   246             eoe->dev->dev_addr[2] =
       
   247                 slave->master->devices[EC_DEVICE_MAIN].dev->dev_addr[4];
       
   248             eoe->dev->dev_addr[3] =
       
   249                 slave->master->devices[EC_DEVICE_MAIN].dev->dev_addr[5];
   238         }
   250         }
   239         eoe->dev->dev_addr[0] = 0x02;
   251         eoe->dev->dev_addr[0] = 0x02;
   240         eoe->dev->dev_addr[4] = (uint8_t)(slave->ring_position >> 8);
   252         eoe->dev->dev_addr[4] = (uint8_t)(slave->ring_position >> 8);
   241         eoe->dev->dev_addr[5] = (uint8_t)(slave->ring_position);
   253         eoe->dev->dev_addr[5] = (uint8_t)(slave->ring_position);
   242     }
   254     }
   335 
   347 
   336     if (remaining_size <= eoe->slave->configured_tx_mailbox_size - 10) {
   348     if (remaining_size <= eoe->slave->configured_tx_mailbox_size - 10) {
   337         current_size = remaining_size;
   349         current_size = remaining_size;
   338         last_fragment = 1;
   350         last_fragment = 1;
   339     } else {
   351     } else {
   340         current_size = ((eoe->slave->configured_tx_mailbox_size - 10) / 32) * 32;
   352         current_size =
       
   353             ((eoe->slave->configured_tx_mailbox_size - 10) / 32) * 32;
   341         last_fragment = 0;
   354         last_fragment = 0;
   342     }
   355     }
   343 
   356 
   344     if (eoe->tx_fragment_number) {
   357     if (eoe->tx_fragment_number) {
   345         complete_offset = eoe->tx_offset / 32;
   358         complete_offset = eoe->tx_offset / 32;