static s32 igb_read_mac_addr_82575(struct e1000_hw *hw)
{
	s32 ret_val = 0;

	ret_val = igb_check_alt_mac_addr(hw);
	if (ret_val)
		goto out;

	ret_val = igb_read_mac_addr(hw);

out:
	return ret_val;
}
Exemplo n.º 2
0
/**
 *  igb_read_mac_addr_82575 - Read device MAC address
 *  @hw: pointer to the HW structure
 **/
static s32 igb_read_mac_addr_82575(struct e1000_hw *hw)
{
	s32 ret_val = 0;

	/*
	 * If there's an alternate MAC address place it in RAR0
	 * so that it will override the Si installed default perm
	 * address.
	 */
	ret_val = igb_check_alt_mac_addr(hw);
	if (ret_val)
		goto out;

	ret_val = igb_read_mac_addr(hw);

out:
	return ret_val;
}
Exemplo n.º 3
0
int
igb_attach(char *dev_path, device_t *pdev)
{
	struct adapter	*adapter;
	struct igb_bind_cmd	bind;
	int		error = 0;

	if (NULL == pdev) return EINVAL;

	adapter = (struct adapter *)pdev->private_data;

	if (NULL != adapter) return EBUSY;

	/* allocate an adapter */
	pdev->private_data = malloc(sizeof(struct adapter));
	if (NULL == pdev->private_data) return ENXIO;

	memset(pdev->private_data, 0, sizeof(struct adapter));

	adapter = (struct adapter *)pdev->private_data;

	adapter->ldev = open("/dev/igb_avb", O_RDWR);
	if (adapter->ldev < 0) {
		error = ENXIO;
		goto err_prebind;
	}

	adapter->memlock =
		sem_open( IGB_SEM, O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP, 1 );
	if( adapter->memlock == ((sem_t *)SEM_FAILED)) {
		error = errno;
		close(adapter->ldev);
		goto err_prebind;
	}
	if( sem_wait( adapter->memlock ) != 0 ) {
		error = errno;
		close(adapter->ldev);
		sem_close( adapter->memlock );
		goto err_prebind;
	}

	/*
	 * dev_path should look something "0000:01:00.0"
	 */

	strncpy(bind.iface, dev_path, IGB_BIND_NAMESZ - 1);

	if (ioctl(adapter->ldev, IGB_BIND, &bind) < 0) {
		error = ENXIO;
		goto err_bind;
	}

	adapter->csr.paddr = 0;
	adapter->csr.mmap_size = bind.mmap_size;

	/* Determine hardware and mac info */
	adapter->hw.vendor_id = pdev->pci_vendor_id;
	adapter->hw.device_id = pdev->pci_vendor_id;
	adapter->hw.revision_id = 0;
	adapter->hw.subsystem_vendor_id = 0;
	adapter->hw.subsystem_device_id = 0;

	/* Set MAC type early for PCI setup */
	adapter->hw.mac.type = e1000_i210;
	/* Setup PCI resources */
	if (error = igb_allocate_pci_resources(adapter)) {
		goto err_pci;
	}

	/*
	 * Set the frame limits assuming
	 * standard ethernet sized frames.
	 */
	adapter->max_frame_size = 1518;
	adapter->min_frame_size = 64;

	/*
	** Copy the permanent MAC address out of the EEPROM
	*/
	if (igb_read_mac_addr(&adapter->hw) < 0) {
		error = EIO;
		goto err_late;
	}

	if( sem_post( adapter->memlock ) != 0 ) {
		error = errno;
		goto err_gen;
	}

	return (0);

 err_late:
 err_pci:
	igb_free_pci_resources(adapter);
 err_bind:
	sem_post( adapter->memlock );
	sem_close( adapter->memlock );
	close(adapter->ldev);
 err_prebind:
	free(pdev->private_data);
	pdev->private_data = NULL;

 err_gen:
	return (error);
}