コード例 #1
0
/*
 * Return the current station MAC address.
 * Note that the passed-in value must already be in network byte order.
 */
int netxen_niu_macaddr_get(struct netxen_adapter *adapter,
                           int phy, netxen_ethernet_macaddr_t * addr)
{
    u32 stationhigh;
    u32 stationlow;
    u8 val[8];

    if (addr == NULL)
        return -EINVAL;
    if ((phy < 0) || (phy > 3))
        return -EINVAL;

    if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy),
                              &stationhigh, 4))
        return -EIO;
    if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy),
                              &stationlow, 4))
        return -EIO;
    ((__le32 *)val)[1] = cpu_to_le32(stationhigh);
    ((__le32 *)val)[0] = cpu_to_le32(stationlow);

    memcpy(addr, val + 2, 6);

    return 0;
}
コード例 #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_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;
}
コード例 #3
0
ファイル: netxen_nic_niu.c プロジェクト: maraz/linux-2.6
/*
 * 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;
}
コード例 #4
0
	  NETXEN_NIU_TEST_MUX_CTL,

	  NETXEN_NIU_GB_MAC_CONFIG_0(0),
	  NETXEN_NIU_GB_MAC_CONFIG_1(0),
	  NETXEN_NIU_GB_HALF_DUPLEX_CTRL(0),
	  NETXEN_NIU_GB_MAX_FRAME_SIZE(0),
	  NETXEN_NIU_GB_TEST_REG(0),
	  NETXEN_NIU_GB_MII_MGMT_CONFIG(0),
	  NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
	  NETXEN_NIU_GB_MII_MGMT_ADDR(0),
	  NETXEN_NIU_GB_MII_MGMT_CTRL(0),
	  NETXEN_NIU_GB_MII_MGMT_STATUS(0),
	  NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
	  NETXEN_NIU_GB_INTERFACE_CTRL(0),
	  NETXEN_NIU_GB_INTERFACE_STATUS(0),
	  NETXEN_NIU_GB_STATION_ADDR_0(0),
	  NETXEN_NIU_GB_STATION_ADDR_1(0),
	  -1,
	  }
	 },
	{
	 /* XG Mode */
	 {
	  NETXEN_NIU_XG_SINGLE_TERM,
	  NETXEN_NIU_XG_DRIVE_HI,
	  NETXEN_NIU_XG_DRIVE_LO,
	  NETXEN_NIU_XG_DTX,
	  NETXEN_NIU_XG_DEQ,
	  NETXEN_NIU_XG_WORD_ALIGN,
	  NETXEN_NIU_XG_RESET,
	  NETXEN_NIU_XG_POWER_DOWN,