src/dpdk/drivers/net/igc/base/igc_mac.c
s32 igc_check_alt_mac_addr_generic(struct igc_hw *hw)
{
	u32 i;
	s32 ret_val;
	u16 offset, nvm_alt_mac_addr_offset, nvm_data;
	u8 alt_mac_addr[ETH_ADDR_LEN];

	DEBUGFUNC("igc_check_alt_mac_addr_generic");

	ret_val = hw->nvm.ops.read(hw, NVM_COMPAT, 1, &nvm_data);
	if (ret_val)
		return ret_val;

	/* not supported on older hardware or 82573 */
	if (hw->mac.type < igc_82571 || hw->mac.type == igc_82573)
		return IGC_SUCCESS;

	/* Alternate MAC address is handled by the option ROM for 82580
	 * and newer. SW support not required.
	 */
	if (hw->mac.type >= igc_82580)
		return IGC_SUCCESS;

	ret_val = hw->nvm.ops.read(hw, NVM_ALT_MAC_ADDR_PTR, 1,
				   &nvm_alt_mac_addr_offset);
	if (ret_val) {
		DEBUGOUT("NVM Read Error\n");
		return ret_val;
	}

	if (nvm_alt_mac_addr_offset == 0xFFFF ||
	    nvm_alt_mac_addr_offset == 0x0000)
		/* There is no Alternate MAC Address */
		return IGC_SUCCESS;

	if (hw->bus.func == IGC_FUNC_1)
		nvm_alt_mac_addr_offset += IGC_ALT_MAC_ADDRESS_OFFSET_LAN1;
	if (hw->bus.func == IGC_FUNC_2)
		nvm_alt_mac_addr_offset += IGC_ALT_MAC_ADDRESS_OFFSET_LAN2;

	if (hw->bus.func == IGC_FUNC_3)
		nvm_alt_mac_addr_offset += IGC_ALT_MAC_ADDRESS_OFFSET_LAN3;
	for (i = 0; i < ETH_ADDR_LEN; i += 2) {
		offset = nvm_alt_mac_addr_offset + (i >> 1);
		ret_val = hw->nvm.ops.read(hw, offset, 1, &nvm_data);
		if (ret_val) {
			DEBUGOUT("NVM Read Error\n");
			return ret_val;
		}

		alt_mac_addr[i] = (u8)(nvm_data & 0xFF);
		alt_mac_addr[i + 1] = (u8)(nvm_data >> 8);
	}

	/* if multicast bit is set, the alternate address will not be used */
	if (alt_mac_addr[0] & 0x01) {
		DEBUGOUT("Ignoring Alternate Mac Address with MC bit set\n");
		return IGC_SUCCESS;
	}

	/* We have a valid alternate MAC address, and we want to treat it the
	 * same as the normal permanent MAC address stored by the HW into the
	 * RAR. Do this by mapping this address into RAR0.
	 */
	hw->mac.ops.rar_set(hw, alt_mac_addr, 0);

	return IGC_SUCCESS;
}
/**
 *  igc_check_alt_mac_addr_generic - Check for alternate MAC addr
 *  @hw: pointer to the HW structure
 *
 *  Checks the nvm for an alternate MAC address.  An alternate MAC address
 *  can be setup by pre-boot software and must be treated like a permanent
 *  address and must override the actual permanent MAC address. If an
 *  alternate MAC address is found it is programmed into RAR0, replacing
 *  the permanent address that was installed into RAR0 by the Si on reset.
 *  This function will return SUCCESS unless it encounters an error while
 *  reading the EEPROM.
 **/
Check for alternate MAC addr
@hw: pointer to the HW structure

Checks the nvm for an alternate MAC address.  An alternate MAC address
can be setup by pre-boot software and must be treated like a permanent
address and must override the actual permanent MAC address. If an
alternate MAC address is found it is programmed into RAR0, replacing
the permanent address that was installed into RAR0 by the Si on reset.
This function will return SUCCESS unless it encounters an error while
reading the EEPROM.
Check for alternate MAC addr @hw : pointer to the HW structure Checks the nvm for an alternate MAC address . An alternate MAC address can be setup by pre - boot software and must be treated like a permanent address and must override the actual permanent MAC address . If an alternate MAC address is found it is programmed into RAR0 replacing the permanent address that was installed into RAR0 by the Si on reset . This function will return SUCCESS unless it encounters an error while reading the EEPROM .
s32 igc_check_alt_mac_addr_generic(struct igc_hw *hw)
{
	u32 i;
	s32 ret_val;
	u16 offset, nvm_alt_mac_addr_offset, nvm_data;
	u8 alt_mac_addr[ETH_ADDR_LEN];
	DEBUGFUNC("igc_check_alt_mac_addr_generic");
	ret_val = hw->nvm.ops.read(hw, NVM_COMPAT, 1, &nvm_data);
	if (ret_val)
		return ret_val;
	if (hw->mac.type < igc_82571 || hw->mac.type == igc_82573)
		return IGC_SUCCESS;
	if (hw->mac.type >= igc_82580)
		return IGC_SUCCESS;
	ret_val = hw->nvm.ops.read(hw, NVM_ALT_MAC_ADDR_PTR, 1,
				   &nvm_alt_mac_addr_offset);
	if (ret_val) {
		DEBUGOUT("NVM Read Error\n");
		return ret_val;
	}
	if (nvm_alt_mac_addr_offset == 0xFFFF ||
	    nvm_alt_mac_addr_offset == 0x0000)
		return IGC_SUCCESS;
	if (hw->bus.func == IGC_FUNC_1)
		nvm_alt_mac_addr_offset += IGC_ALT_MAC_ADDRESS_OFFSET_LAN1;
	if (hw->bus.func == IGC_FUNC_2)
		nvm_alt_mac_addr_offset += IGC_ALT_MAC_ADDRESS_OFFSET_LAN2;
	if (hw->bus.func == IGC_FUNC_3)
		nvm_alt_mac_addr_offset += IGC_ALT_MAC_ADDRESS_OFFSET_LAN3;
	for (i = 0; i < ETH_ADDR_LEN; i += 2) {
		offset = nvm_alt_mac_addr_offset + (i >> 1);
		ret_val = hw->nvm.ops.read(hw, offset, 1, &nvm_data);
		if (ret_val) {
			DEBUGOUT("NVM Read Error\n");
			return ret_val;
		}
		alt_mac_addr[i] = (u8)(nvm_data & 0xFF);
		alt_mac_addr[i + 1] = (u8)(nvm_data >> 8);
	}
	if (alt_mac_addr[0] & 0x01) {
		DEBUGOUT("Ignoring Alternate Mac Address with MC bit set\n");
		return IGC_SUCCESS;
	}
	hw->mac.ops.rar_set(hw, alt_mac_addr, 0);
	return IGC_SUCCESS;
}
s32 igc_check_alt_mac_addr_generic ( struct igc_hw * hw ) { u32 i ; s32 ret_val ; u16 offset , nvm_alt_mac_addr_offset , nvm_data ; u8 alt_mac_addr [ ETH_ADDR_LEN ] ; DEBUGFUNC ( " " ) ; ret_val = hw -> nvm . ops . read ( hw , NVM_COMPAT , 1 , & nvm_data ) ; if ( ret_val ) return ret_val ; if ( hw -> mac . type < igc_82571 || hw -> mac . type == igc_82573 ) return IGC_SUCCESS ; if ( hw -> mac . type >= igc_82580 ) return IGC_SUCCESS ; ret_val = hw -> nvm . ops . read ( hw , NVM_ALT_MAC_ADDR_PTR , 1 , & nvm_alt_mac_addr_offset ) ; if ( ret_val ) { DEBUGOUT ( " \n " ) ; return ret_val ; } if ( nvm_alt_mac_addr_offset == 0xFFFF || nvm_alt_mac_addr_offset == 0x0000 ) return IGC_SUCCESS ; if ( hw -> bus . func == IGC_FUNC_1 ) nvm_alt_mac_addr_offset += IGC_ALT_MAC_ADDRESS_OFFSET_LAN1 ; if ( hw -> bus . func == IGC_FUNC_2 ) nvm_alt_mac_addr_offset += IGC_ALT_MAC_ADDRESS_OFFSET_LAN2 ; if ( hw -> bus . func == IGC_FUNC_3 ) nvm_alt_mac_addr_offset += IGC_ALT_MAC_ADDRESS_OFFSET_LAN3 ; for ( i = 0 ; i < ETH_ADDR_LEN ; i += 2 ) { offset = nvm_alt_mac_addr_offset + ( i >> 1 ) ; ret_val = hw -> nvm . ops . read ( hw , offset , 1 , & nvm_data ) ; if ( ret_val ) { DEBUGOUT ( " \n " ) ; return ret_val ; } alt_mac_addr [ i ] = ( u8 ) ( nvm_data & 0xFF ) ; alt_mac_addr [ i + 1 ] = ( u8 ) ( nvm_data >> 8 ) ; } if ( alt_mac_addr [ 0 ] & 0x01 ) { DEBUGOUT ( " \n " ) ; return IGC_SUCCESS ; } hw -> mac . ops . rar_set ( hw , alt_mac_addr , 0 ) ; return IGC_SUCCESS ; }
igc_check_alt_mac_addr_generic - Check for alternate MAC addr
  @hw: pointer to the HW structure
igc_check_alt_mac_addr_generic - Check for alternate MAC addr @hw : pointer to the HW structure
/* not supported on older hardware or 82573 */ /* Alternate MAC address is handled by the option ROM for 82580
	 * and newer. SW support not required.
	 */ /* There is no Alternate MAC Address */ /* if multicast bit is set, the alternate address will not be used */ /* We have a valid alternate MAC address, and we want to treat it the
	 * same as the normal permanent MAC address stored by the HW into the
	 * RAR. Do this by mapping this address into RAR0.
	 */