Ejemplo n.º 1
0
/*
 * Set the station MAC address.
 * Note that the passed-in value must already be in network byte order.
 */
int netxen_niu_macaddr_set(struct netxen_port *port,
                           netxen_ethernet_macaddr_t addr)
{
    u8 temp[4];
    u32 val;
    struct netxen_adapter *adapter = port->adapter;
    int phy = port->portnum;
    unsigned char mac_addr[6];
    int i;

    for (i = 0; i < 10; i++) {
        temp[0] = temp[1] = 0;
        memcpy(temp + 2, addr, 2);
        val = le32_to_cpu(*(__le32 *)temp);
        if (netxen_nic_hw_write_wx
                (adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy), &val, 4))
            return -EIO;

        memcpy(temp, ((u8 *) addr) + 2, sizeof(__le32));
        val = le32_to_cpu(*(__le32 *)temp);
        if (netxen_nic_hw_write_wx
                (adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy), &val, 4))
            return -2;

        netxen_niu_macaddr_get(adapter, phy,
                               (netxen_ethernet_macaddr_t *) mac_addr);
        if (memcmp(mac_addr, addr, 6) == 0)
            break;
    }

    if (i == 10) {
        printk(KERN_ERR "%s: cannot set Mac addr for %s\n",
               netxen_nic_driver_name, port->netdev->name);
        printk(KERN_ERR "MAC address set: "
               "%02x:%02x:%02x:%02x:%02x:%02x.\n",
               addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);

        printk(KERN_ERR "MAC address get: "
               "%02x:%02x:%02x:%02x:%02x:%02x.\n",
               mac_addr[0],
               mac_addr[1],
               mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
    }
    return 0;
}
Ejemplo n.º 2
0
/*
 * Set the station MAC address.
 * Note that the passed-in value must already be in network byte order.
 */
int netxen_niu_macaddr_set(struct netxen_adapter *adapter,
			   netxen_ethernet_macaddr_t addr)
{
	u8 temp[4];
	u32 val;
	int phy = adapter->physical_port;
	unsigned char mac_addr[6];
	int i;
	DECLARE_MAC_BUF(mac);

	for (i = 0; i < 10; i++) {
		temp[0] = temp[1] = 0;
		memcpy(temp + 2, addr, 2);
		val = le32_to_cpu(*(__le32 *)temp);
		if (netxen_nic_hw_write_wx
		    (adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy), &val, 4))
			return -EIO;

		memcpy(temp, ((u8 *) addr) + 2, sizeof(__le32));
		val = le32_to_cpu(*(__le32 *)temp);
		if (netxen_nic_hw_write_wx
		    (adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy), &val, 4))
			return -2;

		netxen_niu_macaddr_get(adapter,
				       (netxen_ethernet_macaddr_t *) mac_addr);
		if (memcmp(mac_addr, addr, 6) == 0)
			break;
	}

	if (i == 10) {
		printk(KERN_ERR "%s: cannot set Mac addr for %s\n",
		       netxen_nic_driver_name, adapter->netdev->name);
		printk(KERN_ERR "MAC address set: %s.\n",
		       print_mac(mac, addr));
		printk(KERN_ERR "MAC address get: %s.\n",
		       print_mac(mac, mac_addr));
	}
	return 0;
}