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

	if (pba == NULL)
		return -IGC_ERR_PARAM;

	if (eeprom_buf == NULL) {
		ret_val = igc_write_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) {
			eeprom_buf[NVM_PBA_OFFSET_0] = pba->word[0];
			eeprom_buf[NVM_PBA_OFFSET_1] = pba->word[1];
		} else {
			return -IGC_ERR_PARAM;
		}
	}

	if (pba->word[0] == NVM_PBA_PTR_GUARD) {
		if (pba->pba_block == NULL)
			return -IGC_ERR_PARAM;

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

	return IGC_SUCCESS;
}
/**
 *  igc_write_pba_raw
 *  @hw: pointer to the HW structure
 *  @eeprom_buf: optional pointer to EEPROM image
 *  @eeprom_buf_size: size of EEPROM image in words
 *  @pba: pointer to PBA structure
 *
 *  Writes PBA to EEPROM image when eeprom_buf is not NULL.
 *  Writes PBA to physical EEPROM device when eeprom_buf is NULL.
 *
 **/
igc_write_pba_raw
@hw: pointer to the HW structure
@eeprom_buf: optional pointer to EEPROM image
@eeprom_buf_size: size of EEPROM image in words
@pba: pointer to PBA structure

Writes PBA to EEPROM image when eeprom_buf is not NULL.
Writes PBA to physical EEPROM device when eeprom_buf is NULL.
igc_write_pba_raw @hw : pointer to the HW structure @eeprom_buf : optional pointer to EEPROM image @eeprom_buf_size : size of EEPROM image in words @pba : pointer to PBA structure Writes PBA to EEPROM image when eeprom_buf is not NULL . Writes PBA to physical EEPROM device when eeprom_buf is NULL .
s32 igc_write_pba_raw(struct igc_hw *hw, u16 *eeprom_buf,
			u32 eeprom_buf_size, struct igc_pba *pba)
{
	s32 ret_val;
	if (pba == NULL)
		return -IGC_ERR_PARAM;
	if (eeprom_buf == NULL) {
		ret_val = igc_write_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) {
			eeprom_buf[NVM_PBA_OFFSET_0] = pba->word[0];
			eeprom_buf[NVM_PBA_OFFSET_1] = pba->word[1];
		} else {
			return -IGC_ERR_PARAM;
		}
	}
	if (pba->word[0] == NVM_PBA_PTR_GUARD) {
		if (pba->pba_block == NULL)
			return -IGC_ERR_PARAM;
		if (eeprom_buf == NULL) {
			ret_val = igc_write_nvm(hw, pba->word[1],
						  pba->pba_block[0],
						  pba->pba_block);
			if (ret_val)
				return ret_val;
		} else {
			if (eeprom_buf_size > (u32)(pba->word[1] +
					      pba->pba_block[0])) {
				memcpy(&eeprom_buf[pba->word[1]],
				       pba->pba_block,
				       pba->pba_block[0] * sizeof(u16));
			} else {
				return -IGC_ERR_PARAM;
			}
		}
	}
	return IGC_SUCCESS;
}
s32 igc_write_pba_raw ( struct igc_hw * hw , u16 * eeprom_buf , u32 eeprom_buf_size , struct igc_pba * pba ) { s32 ret_val ; if ( pba == NULL ) return - IGC_ERR_PARAM ; if ( eeprom_buf == NULL ) { ret_val = igc_write_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 ) { eeprom_buf [ NVM_PBA_OFFSET_0 ] = pba -> word [ 0 ] ; eeprom_buf [ NVM_PBA_OFFSET_1 ] = pba -> word [ 1 ] ; } else { return - IGC_ERR_PARAM ; } } if ( pba -> word [ 0 ] == NVM_PBA_PTR_GUARD ) { if ( pba -> pba_block == NULL ) return - IGC_ERR_PARAM ; if ( eeprom_buf == NULL ) { ret_val = igc_write_nvm ( hw , pba -> word [ 1 ] , pba -> pba_block [ 0 ] , pba -> pba_block ) ; if ( ret_val ) return ret_val ; } else { if ( eeprom_buf_size > ( u32 ) ( pba -> word [ 1 ] + pba -> pba_block [ 0 ] ) ) { memcpy ( & eeprom_buf [ pba -> word [ 1 ] ] , pba -> pba_block , pba -> pba_block [ 0 ] * sizeof ( u16 ) ) ; } else { return - IGC_ERR_PARAM ; } } } return IGC_SUCCESS ; }
igc_write_pba_raw
  @hw: pointer to the HW structure
  @eeprom_buf: optional pointer to EEPROM image
  @eeprom_buf_size: size of EEPROM image in words
  @pba: pointer to PBA structure
igc_write_pba_raw @hw : pointer to the HW structure @eeprom_buf : optional pointer to EEPROM image @eeprom_buf_size : size of EEPROM image in words @pba : pointer to PBA structure