예제 #1
0
mac_report e40::gen_report(uint32_t port)
{
    mac_reg instance = port == 0 ? mac_reg::mac0_ctrl : mac_reg::mac1_ctrl;
    mac_report report;
    report.port = port;
    uint32_t lo, hi;
    if (mac_read(instance, mac_reg::mac_cntr_tx_st_lo, lo) &&
        mac_read(instance, mac_reg::mac_cntr_tx_st_hi, hi))
    {
        report.cntr_tx_stat = hi;
        report.cntr_tx_stat <<= 32;
        report.cntr_tx_stat |= static_cast<uint64_t>(lo);
    }

    if (mac_read(instance, mac_reg::mac_cntr_rx_st_lo, lo) &&
        mac_read(instance, mac_reg::mac_cntr_rx_st_hi, hi))
    {
        report.cntr_rx_stat = hi;
        report.cntr_rx_stat <<= 32;
        report.cntr_rx_stat |= static_cast<uint64_t>(lo);
    }

    if (mac_read(instance, mac_reg::mac_cntr_rx_pause_lo, lo) &&
        mac_read(instance, mac_reg::mac_cntr_rx_pause_hi, hi))
    {
        report.cntr_rx_pause = hi;
        report.cntr_rx_pause <<= 32;
        report.cntr_rx_pause |= static_cast<uint64_t>(lo);
    }

    if (mac_read(instance, mac_reg::mac_cntr_rx_frag_lo, lo) &&
        mac_read(instance, mac_reg::mac_cntr_rx_frag_hi, hi))
    {
        report.cntr_rx_frag = hi;
        report.cntr_rx_frag <<= 32;
        report.cntr_rx_frag |= static_cast<uint64_t>(lo);
    }

    if (mac_read(instance, mac_reg::mac_cntr_rx_crcerr_lo, lo) &&
        mac_read(instance, mac_reg::mac_cntr_rx_crcerr_hi, hi))
    {
        report.cntr_rx_crcerr = hi;
        report.cntr_rx_crcerr <<= 32;
        report.cntr_rx_crcerr |= static_cast<uint64_t>(lo);
    }
    uint32_t status;
    if (eth_->read(eth_ctrl_reg::gen_pkt_stat, port, status))
    {
        report.gen_complete = status & static_cast<uint32_t>(gen_stat::complete);
    }

    if (eth_->read(eth_ctrl_reg::mon_pkt_stat, port, status))
    {
        report.mon_complete = status & static_cast<uint32_t>(mon_stat::complete);
        report.mon_dest_error   = status & static_cast<uint32_t>(mon_stat::destination_error);
        report.mon_src_error   = status & static_cast<uint32_t>(mon_stat::source_error);
        report.mon_pkt_length_error   = status & static_cast<uint32_t>(mon_stat::packet_length_error);
    }
    return report;
}
예제 #2
0
int do_print_mac(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
	if (argc != 1)
		return cmd_usage(cmdtp);

	mac_read();

	return 0;
}
예제 #3
0
int do_print_mac(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
	if (argc != 1) {
		cmd_usage(cmdtp);
		return 1;
	}

	mac_read();

	return 0;
}
예제 #4
0
bool system_identifier_read(system_identifier_t *system_id)
{
	os_read(system_id->os, sizeof(system_id->os));
	system_serial_read(system_id->system, sizeof(system_id->system));
	chassis_serial_read(system_id->chassis, sizeof(system_id->chassis));
	baseboard_serial_read(system_id->baseboard, sizeof(system_id->baseboard));

	unsigned char mac[6];
	mac_read(mac, sizeof(mac));
	sha1_calc(mac, sizeof(mac), system_id->mac, sizeof(system_id->mac));

	return true;
}
static void
net_s3c4510b_update (struct device_desc *dev)
{
	struct device_interrupt *intr = &dev->intr;
	struct net_device *net_dev = (struct net_device *) dev->dev;
	struct net_s3c4510b_io *io = (struct net_s3c4510b_io *) dev->data;
	struct machine_config *mc = (struct machine_config *) dev->mach;

	if ((io->bdmarxcon & RxEn)) {
		struct timeval tv;
		tv.tv_sec = 0;
		tv.tv_usec = 0;
		if(net_dev->net_wait_packet (net_dev, &tv) == 0) mac_read (dev);
	}
}
예제 #6
0
static void __init sh_eth_init(struct sh_eth_plat_data *pd)
{
	struct i2c_adapter *a = i2c_get_adapter(1);
	int i;

	if (!a) {
		pr_err("can not get I2C 1\n");
		return;
	}

	/* read MAC address from EEPROM */
	for (i = 0; i < sizeof(pd->mac_addr); i++) {
		pd->mac_addr[i] = mac_read(a, 0x10 + i);
		msleep(10);
	}

	i2c_put_adapter(a);
}
예제 #7
0
/* see which wds devices we are getting beacons from.  (this routine doesn't
 * look at the ethernet connection or the wlan connection.  those devices
 * are added at startup, the latter only if we were told to do so from the
 * command line.  they don't come and go.  only the wds devices
 * come and go.)
 *
 * this routine manages the device_list array, which includes if_index,
 * file descriptor, etc. to support actual low-level communication.
 */
char check_devices(void)
{
    char result = 0;
    int retval;
    static struct ifreq get_index;
    struct sockaddr_ll bind_arg;
    char wds_devices[MAX_CLOUD][64];
    mac_address_t wds_macs[MAX_CLOUD];
    int wds_count = 0;
    int w, d;
    char buf[64];

    FILE *wds = fopen(wds_file, "r");
    if (wds == NULL) {
        ddprintf("check_devices; fopen failed:  %s\n", strerror(errno));
        ddprintf("    file:  '%s'\n", wds_file);
        goto finish;
    }

    /* read the mac addresses of the wds devices into
     * local array wds_devices
     */
    while (1) {
        if (wds_count >= MAX_CLOUD) {
            ddprintf("check_devices:  too many wds devices\n");
            break;
        }

        if (skip_comment_line(wds) != 0) {
            ddprintf("check_devices; problem reading file.\n");
            break;
        }


        #ifdef WRT54G
            retval = mac_read(wds, wds_macs[wds_count]);
        #else
            retval = fscanf(wds, "%s", wds_devices[wds_count]);
        #endif

        if (retval != 1) { break; }

        #ifdef WRT54G
            retval = fscanf(wds, "%s", wds_devices[wds_count]);
        #else
            retval = mac_read(wds, wds_macs[wds_count]);
        #endif

        if (retval != 1) {
            ddprintf("check_devices; could not read device name from wds\n");
            goto finish;
        }
        wds_count++;
    }

    top :
    /* see if every wds device in our list matches current truth */
    for (d = 0; d < device_list_count; d++) {
        int found = 0;

        if (device_list[d].device_type != device_type_wds
            && device_list[d].device_type != device_type_cloud_wds)
        { continue; }
        
        for (w = 0; w < wds_count; w++) {
            if (mac_equal(device_list[d].mac_address, wds_macs[w])) {
                found = 1;
                break;
            }
        }

        if (!found
            || strstr(device_list[d].device_name, wds_devices[w]) == NULL)
        {
            result = 1;
            delete_device(d);
            goto top;
        }

        if (!use_pipes) {
            /* check to see that the if_index is still the same.
             * (if "wds0.2" gets deleted and then re-created, it probably
             * has a different if_index.)
             */
            sprintf(get_index.ifr_name, device_list[d].device_name);
            retval = ioctl(device_list[d].fd, SIOCGIFINDEX, &get_index);
            if (retval == -1) {
                ddprintf("check_devices; could not get device index:  %s\n",
                        strerror(errno));
                goto finish;
            }
            if (device_list[d].if_index != get_index.ifr_ifindex) {
                device_list[d].if_index = get_index.ifr_ifindex;
                memset(&bind_arg, 0, sizeof(bind_arg));
                bind_arg.sll_family = AF_PACKET;
                bind_arg.sll_ifindex = get_index.ifr_ifindex;
                bind_arg.sll_protocol = htons(ETH_P_ALL);

                retval = bind(device_list[d].fd, (struct sockaddr *) &bind_arg,
                        sizeof(bind_arg));
                if (retval == -1) {
                    ddprintf("check_devices; bind failed:  %s\n",
                            strerror(errno));
                    goto finish;
                }
                result = 1;
                goto top;
            }
        }
    }

    /* see if every device out there is in our local table */
    for (w = 0; w < wds_count; w++) {
        int found = 0;

        for (d = 0; d < device_list_count; d++) {
            if (mac_equal(device_list[d].mac_address, wds_macs[w])) {
                found = 1;
                break;
            }
        }

        if (!found) {
            result = 1;
            add_device(
                    ad_hoc_mode ? "ad-hoc device" : wds_devices[w],
                    wds_macs[w],
                    ad_hoc_mode ? device_type_ad_hoc : device_type_wds);

            if (!ad_hoc_mode && db[47].d) {
                sprintf(buf, "%s:1", wds_devices[w]);
                add_device(buf, wds_macs[w], device_type_cloud_wds);
            }
        }
    }

    finish :

    if (wds != NULL) { fclose(wds); }

    return result;

} /* check_devices */
예제 #8
0
/* read the mac_list in from its associated file.
 * return 0 on success, -1 on failure.
 * read up to a maximum of MAX_CLOUD mac addresses,
 * and read the extra info associated with each mac address, based on
 * the type of the mac_list.
 * initialize the mac address times to "now".
 */
int mac_list_read(mac_list_t *mac_list)
{
    int result = 0;
    struct timeval tv;
    struct timezone tz;
    FILE *f;

    if (gettimeofday(&tv, &tz)) {
        fprintf(stderr, "mac_list_read; gettimeofday failed\n");
        return -1;
    }

    f = fopen(mac_list->fname, "r");

    if (f == NULL) {
        perror("mac_list_read fopen failed");
        fprintf(stderr, "    could not open %s\n", mac_list->fname);
        result = -1;
        goto done;
    }

    mac_list->next_beacon = 0;

    while (1) {
        mac_address_t mac_addr;

        if (1 != mac_read(f, mac_addr)) {
            break;
        }

        if (mac_list->next_beacon >= MAX_CLOUD) {
            fprintf(stderr, "mac_list_read:  too many entries in file\n");
            result = -1;
            goto done;
        }

        mac_copy(mac_list->beacons[mac_list->next_beacon].mac_addr, mac_addr);
        mac_list->beacons[mac_list->next_beacon].tv_sec = tv.tv_sec;
        mac_list->beacons[mac_list->next_beacon].tv_usec = tv.tv_usec;

        /* check scanf results etc. to bullet-proof */
        switch (mac_list->type) {

        case mac_list_beacon_desc :
            fscanf(f, "%s", mac_list->desc[mac_list->next_beacon]);
            break;

        case mac_list_beacon_name :
            mac_read(f, mac_list->names[mac_list->next_beacon]);
            break;

        case mac_list_beacon_signal_strength :
            fscanf(f, " %d\n",
                    &mac_list->signal_strength[mac_list->next_beacon]);
            break;

        case mac_list_beacon :
            break;

        default :
            fprintf(stderr, "mac_list_read:  invalid type %d\n",
                    mac_list->type);
            break;
        }

        mac_list->next_beacon++;
    }

    done:

    if (f != NULL) { fclose(f); }

    return result;
}