src/dpdk/drivers/net/igc/base/igc_nvm.c
s32 igc_get_pba_block_size(struct igc_hw *hw, u16 *eeprom_buf,
			     u32 eeprom_buf_size, u16 *pba_block_size)
{
	s32 ret_val;
	u16 pba_word[2];
	u16 length;

	DEBUGFUNC("igc_get_pba_block_size");

	if (eeprom_buf == NULL) {
		ret_val = igc_read_nvm(hw, NVM_PBA_OFFSET_0, 2, &pba_word[0]);
		if (ret_val)
			return ret_val;
	} else {
		if (eeprom_buf_size > NVM_PBA_OFFSET_1) {
			pba_word[0] = eeprom_buf[NVM_PBA_OFFSET_0];
			pba_word[1] = eeprom_buf[NVM_PBA_OFFSET_1];
		} else {
			return -IGC_ERR_PARAM;
		}
	}

	if (pba_word[0] == NVM_PBA_PTR_GUARD) {
		if (eeprom_buf == NULL) {
			ret_val = igc_read_nvm(hw, pba_word[1] + 0, 1,
						 &length);
			if (ret_val)
				return ret_val;
		} else {
			if (eeprom_buf_size > pba_word[1])
				length = eeprom_buf[pba_word[1] + 0];
			else
				return -IGC_ERR_PARAM;
		}

		if (length == 0xFFFF || length == 0)
			return -IGC_ERR_NVM_PBA_SECTION;
	} else {
		/* PBA number in legacy format, there is no PBA Block. */
		length = 0;
	}

	if (pba_block_size != NULL)
		*pba_block_size = length;

	return IGC_SUCCESS;
}
/**
 *  igc_get_pba_block_size
 *  @hw: pointer to the HW structure
 *  @eeprom_buf: optional pointer to EEPROM image
 *  @eeprom_buf_size: size of EEPROM image in words
 *  @pba_data_size: pointer to output variable
 *
 *  Returns the size of the PBA block in words. Function operates on EEPROM
 *  image if the eeprom_buf pointer is not NULL otherwise it accesses physical
 *  EEPROM device.
 *
 **/
igc_get_pba_block_size
@hw: pointer to the HW structure
@eeprom_buf: optional pointer to EEPROM image
@eeprom_buf_size: size of EEPROM image in words
@pba_data_size: pointer to output variable

Returns the size of the PBA block in words. Function operates on EEPROM
image if the eeprom_buf pointer is not NULL otherwise it accesses physical
EEPROM device.
igc_get_pba_block_size @hw : pointer to the HW structure @eeprom_buf : optional pointer to EEPROM image @eeprom_buf_size : size of EEPROM image in words @pba_data_size : pointer to output variable Returns the size of the PBA block in words . Function operates on EEPROM image if the eeprom_buf pointer is not NULL otherwise it accesses physical EEPROM device .
s32 igc_get_pba_block_size(struct igc_hw *hw, u16 *eeprom_buf,
			     u32 eeprom_buf_size, u16 *pba_block_size)
{
	s32 ret_val;
	u16 pba_word[2];
	u16 length;
	DEBUGFUNC("igc_get_pba_block_size");
	if (eeprom_buf == NULL) {
		ret_val = igc_read_nvm(hw, NVM_PBA_OFFSET_0, 2, &pba_word[0]);
		if (ret_val)
			return ret_val;
	} else {
		if (eeprom_buf_size > NVM_PBA_OFFSET_1) {
			pba_word[0] = eeprom_buf[NVM_PBA_OFFSET_0];
			pba_word[1] = eeprom_buf[NVM_PBA_OFFSET_1];
		} else {
			return -IGC_ERR_PARAM;
		}
	}
	if (pba_word[0] == NVM_PBA_PTR_GUARD) {
		if (eeprom_buf == NULL) {
			ret_val = igc_read_nvm(hw, pba_word[1] + 0, 1,
						 &length);
			if (ret_val)
				return ret_val;
		} else {
			if (eeprom_buf_size > pba_word[1])
				length = eeprom_buf[pba_word[1] + 0];
			else
				return -IGC_ERR_PARAM;
		}
		if (length == 0xFFFF || length == 0)
			return -IGC_ERR_NVM_PBA_SECTION;
	} else {
		length = 0;
	}
	if (pba_block_size != NULL)
		*pba_block_size = length;
	return IGC_SUCCESS;
}
s32 igc_get_pba_block_size ( struct igc_hw * hw , u16 * eeprom_buf , u32 eeprom_buf_size , u16 * pba_block_size ) { s32 ret_val ; u16 pba_word [ 2 ] ; u16 length ; DEBUGFUNC ( " " ) ; if ( eeprom_buf == NULL ) { ret_val = igc_read_nvm ( hw , NVM_PBA_OFFSET_0 , 2 , & pba_word [ 0 ] ) ; if ( ret_val ) return ret_val ; } else { if ( eeprom_buf_size > NVM_PBA_OFFSET_1 ) { pba_word [ 0 ] = eeprom_buf [ NVM_PBA_OFFSET_0 ] ; pba_word [ 1 ] = eeprom_buf [ NVM_PBA_OFFSET_1 ] ; } else { return - IGC_ERR_PARAM ; } } if ( pba_word [ 0 ] == NVM_PBA_PTR_GUARD ) { if ( eeprom_buf == NULL ) { ret_val = igc_read_nvm ( hw , pba_word [ 1 ] + 0 , 1 , & length ) ; if ( ret_val ) return ret_val ; } else { if ( eeprom_buf_size > pba_word [ 1 ] ) length = eeprom_buf [ pba_word [ 1 ] + 0 ] ; else return - IGC_ERR_PARAM ; } if ( length == 0xFFFF || length == 0 ) return - IGC_ERR_NVM_PBA_SECTION ; } else { length = 0 ; } if ( pba_block_size != NULL ) * pba_block_size = length ; return IGC_SUCCESS ; }
igc_get_pba_block_size
  @hw: pointer to the HW structure
  @eeprom_buf: optional pointer to EEPROM image
  @eeprom_buf_size: size of EEPROM image in words
  @pba_data_size: pointer to output variable
igc_get_pba_block_size @hw : pointer to the HW structure @eeprom_buf : optional pointer to EEPROM image @eeprom_buf_size : size of EEPROM image in words @pba_data_size : pointer to output variable
/* PBA number in legacy format, there is no PBA Block. */