src/dpdk/drivers/net/igc/base/igc_nvm.c
s32 igc_read_pba_raw(struct igc_hw *hw, u16 *eeprom_buf,
		       u32 eeprom_buf_size, u16 max_pba_block_size,
		       struct igc_pba *pba)
{
	s32 ret_val;
	u16 pba_block_size;

	if (pba == NULL)
		return -IGC_ERR_PARAM;

	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 (pba->pba_block == NULL)
			return -IGC_ERR_PARAM;

		ret_val = igc_get_pba_block_size(hw, eeprom_buf,
						   eeprom_buf_size,
						   &pba_block_size);
		if (ret_val)
			return ret_val;

		if (pba_block_size > max_pba_block_size)
			return -IGC_ERR_PARAM;

		if (eeprom_buf == NULL) {
			ret_val = igc_read_nvm(hw, pba->word[1],
						 pba_block_size,
						 pba->pba_block);
			if (ret_val)
				return ret_val;
		} else {
			if (eeprom_buf_size > (u32)(pba->word[1] +
					      pba_block_size)) {
				memcpy(pba->pba_block,
				       &eeprom_buf[pba->word[1]],
				       pba_block_size * sizeof(u16));
			} else {
				return -IGC_ERR_PARAM;
			}
		}
	}

	return IGC_SUCCESS;
}
/**
 *  igc_read_pba_raw
 *  @hw: pointer to the HW structure
 *  @eeprom_buf: optional pointer to EEPROM image
 *  @eeprom_buf_size: size of EEPROM image in words
 *  @max_pba_block_size: PBA block size limit
 *  @pba: pointer to output PBA structure
 *
 *  Reads PBA from EEPROM image when eeprom_buf is not NULL.
 *  Reads PBA from physical EEPROM device when eeprom_buf is NULL.
 *
 **/


Reads PBA from EEPROM image when eeprom_buf is not NULL.
Reads PBA from physical EEPROM device when eeprom_buf is NULL.
Reads PBA from EEPROM image when eeprom_buf is not NULL . Reads PBA from physical EEPROM device when eeprom_buf is NULL .
s32 igc_read_pba_raw(struct igc_hw *hw, u16 *eeprom_buf,
		       u32 eeprom_buf_size, u16 max_pba_block_size,
		       struct igc_pba *pba)
{
	s32 ret_val;
	u16 pba_block_size;
	if (pba == NULL)
		return -IGC_ERR_PARAM;
	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 (pba->pba_block == NULL)
			return -IGC_ERR_PARAM;
		ret_val = igc_get_pba_block_size(hw, eeprom_buf,
						   eeprom_buf_size,
						   &pba_block_size);
		if (ret_val)
			return ret_val;
		if (pba_block_size > max_pba_block_size)
			return -IGC_ERR_PARAM;
		if (eeprom_buf == NULL) {
			ret_val = igc_read_nvm(hw, pba->word[1],
						 pba_block_size,
						 pba->pba_block);
			if (ret_val)
				return ret_val;
		} else {
			if (eeprom_buf_size > (u32)(pba->word[1] +
					      pba_block_size)) {
				memcpy(pba->pba_block,
				       &eeprom_buf[pba->word[1]],
				       pba_block_size * sizeof(u16));
			} else {
				return -IGC_ERR_PARAM;
			}
		}
	}
	return IGC_SUCCESS;
}
s32 igc_read_pba_raw ( struct igc_hw * hw , u16 * eeprom_buf , u32 eeprom_buf_size , u16 max_pba_block_size , struct igc_pba * pba ) { s32 ret_val ; u16 pba_block_size ; if ( pba == NULL ) return - IGC_ERR_PARAM ; 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 ( pba -> pba_block == NULL ) return - IGC_ERR_PARAM ; ret_val = igc_get_pba_block_size ( hw , eeprom_buf , eeprom_buf_size , & pba_block_size ) ; if ( ret_val ) return ret_val ; if ( pba_block_size > max_pba_block_size ) return - IGC_ERR_PARAM ; if ( eeprom_buf == NULL ) { ret_val = igc_read_nvm ( hw , pba -> word [ 1 ] , pba_block_size , pba -> pba_block ) ; if ( ret_val ) return ret_val ; } else { if ( eeprom_buf_size > ( u32 ) ( pba -> word [ 1 ] + pba_block_size ) ) { memcpy ( pba -> pba_block , & eeprom_buf [ pba -> word [ 1 ] ] , pba_block_size * sizeof ( u16 ) ) ; } else { return - IGC_ERR_PARAM ; } } } return IGC_SUCCESS ; }
igc_read_pba_raw
  @hw: pointer to the HW structure
  @eeprom_buf: optional pointer to EEPROM image
  @eeprom_buf_size: size of EEPROM image in words
  @max_pba_block_size: PBA block size limit
  @pba: pointer to output PBA structure
igc_read_pba_raw @hw : pointer to the HW structure @eeprom_buf : optional pointer to EEPROM image @eeprom_buf_size : size of EEPROM image in words @max_pba_block_size : PBA block size limit @pba : pointer to output PBA structure