src/dpdk/drivers/net/ixgbe/base/ixgbe_x540.c
s32 ixgbe_calc_eeprom_checksum_X540(struct ixgbe_hw *hw)
{
	u16 i, j;
	u16 checksum = 0;
	u16 length = 0;
	u16 pointer = 0;
	u16 word = 0;
	u16 ptr_start = IXGBE_PCIE_ANALOG_PTR;

	/* Do not use hw->eeprom.ops.read because we do not want to take
	 * the synchronization semaphores here. Instead use
	 * ixgbe_read_eerd_generic
	 */

	DEBUGFUNC("ixgbe_calc_eeprom_checksum_X540");

	/* Include 0x0 up to IXGBE_EEPROM_CHECKSUM; do not include the
	 * checksum itself
	 */
	for (i = 0; i < IXGBE_EEPROM_CHECKSUM; i++) {
		if (ixgbe_read_eerd_generic(hw, i, &word)) {
			DEBUGOUT("EEPROM read failed\n");
			return IXGBE_ERR_EEPROM;
		}
		checksum += word;
	}

	/* Include all data from pointers 0x3, 0x6-0xE.  This excludes the
	 * FW, PHY module, and PCIe Expansion/Option ROM pointers.
	 */
	for (i = ptr_start; i < IXGBE_FW_PTR; i++) {
		if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
			continue;

		if (ixgbe_read_eerd_generic(hw, i, &pointer)) {
			DEBUGOUT("EEPROM read failed\n");
			return IXGBE_ERR_EEPROM;
		}

		/* Skip pointer section if the pointer is invalid. */
		if (pointer == 0xFFFF || pointer == 0 ||
		    pointer >= hw->eeprom.word_size)
			continue;

		if (ixgbe_read_eerd_generic(hw, pointer, &length)) {
			DEBUGOUT("EEPROM read failed\n");
			return IXGBE_ERR_EEPROM;
		}

		/* Skip pointer section if length is invalid. */
		if (length == 0xFFFF || length == 0 ||
		    (pointer + length) >= hw->eeprom.word_size)
			continue;

		for (j = pointer + 1; j <= pointer + length; j++) {
			if (ixgbe_read_eerd_generic(hw, j, &word)) {
				DEBUGOUT("EEPROM read failed\n");
				return IXGBE_ERR_EEPROM;
			}
			checksum += word;
		}
	}

	checksum = (u16)IXGBE_EEPROM_SUM - checksum;

	return (s32)checksum;
}
/**
 * ixgbe_calc_eeprom_checksum_X540 - Calculates and returns the checksum
 *
 * This function does not use synchronization for EERD and EEWR. It can
 * be used internally by function which utilize ixgbe_acquire_swfw_sync_X540.
 *
 * @hw: pointer to hardware structure
 *
 * Returns a negative error code on error, or the 16-bit checksum
 **/
Calculates and returns the checksum
This function does not use synchronization for EERD and EEWR. It can
be used internally by function which utilize ixgbe_acquire_swfw_sync_X540.

@hw: pointer to hardware structure

Returns a negative error code on error, or the 16-bit checksum
Calculates and returns the checksum This function does not use synchronization for EERD and EEWR . It can be used internally by function which utilize ixgbe_acquire_swfw_sync_X540 . @hw : pointer to hardware structure Returns a negative error code on error or the 16 - bit checksum
s32 ixgbe_calc_eeprom_checksum_X540(struct ixgbe_hw *hw)
{
	u16 i, j;
	u16 checksum = 0;
	u16 length = 0;
	u16 pointer = 0;
	u16 word = 0;
	u16 ptr_start = IXGBE_PCIE_ANALOG_PTR;
	DEBUGFUNC("ixgbe_calc_eeprom_checksum_X540");
	for (i = 0; i < IXGBE_EEPROM_CHECKSUM; i++) {
		if (ixgbe_read_eerd_generic(hw, i, &word)) {
			DEBUGOUT("EEPROM read failed\n");
			return IXGBE_ERR_EEPROM;
		}
		checksum += word;
	}
	for (i = ptr_start; i < IXGBE_FW_PTR; i++) {
		if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
			continue;
		if (ixgbe_read_eerd_generic(hw, i, &pointer)) {
			DEBUGOUT("EEPROM read failed\n");
			return IXGBE_ERR_EEPROM;
		}
		if (pointer == 0xFFFF || pointer == 0 ||
		    pointer >= hw->eeprom.word_size)
			continue;
		if (ixgbe_read_eerd_generic(hw, pointer, &length)) {
			DEBUGOUT("EEPROM read failed\n");
			return IXGBE_ERR_EEPROM;
		}
		if (length == 0xFFFF || length == 0 ||
		    (pointer + length) >= hw->eeprom.word_size)
			continue;
		for (j = pointer + 1; j <= pointer + length; j++) {
			if (ixgbe_read_eerd_generic(hw, j, &word)) {
				DEBUGOUT("EEPROM read failed\n");
				return IXGBE_ERR_EEPROM;
			}
			checksum += word;
		}
	}
	checksum = (u16)IXGBE_EEPROM_SUM - checksum;
	return (s32)checksum;
}
s32 ixgbe_calc_eeprom_checksum_X540 ( struct ixgbe_hw * hw ) { u16 i , j ; u16 checksum = 0 ; u16 length = 0 ; u16 pointer = 0 ; u16 word = 0 ; u16 ptr_start = IXGBE_PCIE_ANALOG_PTR ; DEBUGFUNC ( " " ) ; for ( i = 0 ; i < IXGBE_EEPROM_CHECKSUM ; i ++ ) { if ( ixgbe_read_eerd_generic ( hw , i , & word ) ) { DEBUGOUT ( " \n " ) ; return IXGBE_ERR_EEPROM ; } checksum += word ; } for ( i = ptr_start ; i < IXGBE_FW_PTR ; i ++ ) { if ( i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR ) continue ; if ( ixgbe_read_eerd_generic ( hw , i , & pointer ) ) { DEBUGOUT ( " \n " ) ; return IXGBE_ERR_EEPROM ; } if ( pointer == 0xFFFF || pointer == 0 || pointer >= hw -> eeprom . word_size ) continue ; if ( ixgbe_read_eerd_generic ( hw , pointer , & length ) ) { DEBUGOUT ( " \n " ) ; return IXGBE_ERR_EEPROM ; } if ( length == 0xFFFF || length == 0 || ( pointer + length ) >= hw -> eeprom . word_size ) continue ; for ( j = pointer + 1 ; j <= pointer + length ; j ++ ) { if ( ixgbe_read_eerd_generic ( hw , j , & word ) ) { DEBUGOUT ( " \n " ) ; return IXGBE_ERR_EEPROM ; } checksum += word ; } } checksum = ( u16 ) IXGBE_EEPROM_SUM - checksum ; return ( s32 ) checksum ; }
ixgbe_calc_eeprom_checksum_X540 - Calculates and returns the checksum
 This function does not use synchronization for EERD and EEWR.
ixgbe_calc_eeprom_checksum_X540 - Calculates and returns the checksum This function does not use synchronization for EERD and EEWR .
/* Do not use hw->eeprom.ops.read because we do not want to take
	 * the synchronization semaphores here. Instead use
	 * ixgbe_read_eerd_generic
	 */ /* Include 0x0 up to IXGBE_EEPROM_CHECKSUM; do not include the
	 * checksum itself
	 */ /* Include all data from pointers 0x3, 0x6-0xE.  This excludes the
	 * FW, PHY module, and PCIe Expansion/Option ROM pointers.
	 */ /* Skip pointer section if the pointer is invalid. */ /* Skip pointer section if length is invalid. */