src/dpdk/drivers/net/igc/base/igc_nvm.c
s32 igc_read_pba_length_generic(struct igc_hw *hw, u32 *pba_num_size)
{
	s32 ret_val;
	u16 nvm_data;
	u16 pba_ptr;
	u16 length;

	DEBUGFUNC("igc_read_pba_length_generic");

	if (pba_num_size == NULL) {
		DEBUGOUT("PBA buffer size was null\n");
		return -IGC_ERR_INVALID_ARGUMENT;
	}

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

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

	 /* if data is not ptr guard the PBA must be in legacy format */
	if (nvm_data != NVM_PBA_PTR_GUARD) {
		*pba_num_size = IGC_PBANUM_LENGTH;
		return IGC_SUCCESS;
	}

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

	if (length == 0xFFFF || length == 0) {
		DEBUGOUT("NVM PBA number section invalid length\n");
		return -IGC_ERR_NVM_PBA_SECTION;
	}

	/* Convert from length in u16 values to u8 chars, add 1 for NULL,
	 * and subtract 2 because length field is included in length.
	 */
	*pba_num_size = ((u32)length * 2) - 1;

	return IGC_SUCCESS;
}
/**
 *  igc_read_pba_length_generic - Read device part number length
 *  @hw: pointer to the HW structure
 *  @pba_num_size: size of part number buffer
 *
 *  Reads the product board assembly (PBA) number length from the EEPROM and
 *  stores the value in pba_num_size.
 **/
Read device part number length
@hw: pointer to the HW structure
@pba_num_size: size of part number buffer

Reads the product board assembly (PBA) number length from the EEPROM and
stores the value in pba_num_size.
Read device part number length @hw : pointer to the HW structure @pba_num_size : size of part number buffer Reads the product board assembly ( PBA ) number length from the EEPROM and stores the value in pba_num_size .
s32 igc_read_pba_length_generic(struct igc_hw *hw, u32 *pba_num_size)
{
	s32 ret_val;
	u16 nvm_data;
	u16 pba_ptr;
	u16 length;
	DEBUGFUNC("igc_read_pba_length_generic");
	if (pba_num_size == NULL) {
		DEBUGOUT("PBA buffer size was null\n");
		return -IGC_ERR_INVALID_ARGUMENT;
	}
	ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
	if (ret_val) {
		DEBUGOUT("NVM Read Error\n");
		return ret_val;
	}
	ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_1, 1, &pba_ptr);
	if (ret_val) {
		DEBUGOUT("NVM Read Error\n");
		return ret_val;
	}
	if (nvm_data != NVM_PBA_PTR_GUARD) {
		*pba_num_size = IGC_PBANUM_LENGTH;
		return IGC_SUCCESS;
	}
	ret_val = hw->nvm.ops.read(hw, pba_ptr, 1, &length);
	if (ret_val) {
		DEBUGOUT("NVM Read Error\n");
		return ret_val;
	}
	if (length == 0xFFFF || length == 0) {
		DEBUGOUT("NVM PBA number section invalid length\n");
		return -IGC_ERR_NVM_PBA_SECTION;
	}
	*pba_num_size = ((u32)length * 2) - 1;
	return IGC_SUCCESS;
}
s32 igc_read_pba_length_generic ( struct igc_hw * hw , u32 * pba_num_size ) { s32 ret_val ; u16 nvm_data ; u16 pba_ptr ; u16 length ; DEBUGFUNC ( " " ) ; if ( pba_num_size == NULL ) { DEBUGOUT ( " \n " ) ; return - IGC_ERR_INVALID_ARGUMENT ; } ret_val = hw -> nvm . ops . read ( hw , NVM_PBA_OFFSET_0 , 1 , & nvm_data ) ; if ( ret_val ) { DEBUGOUT ( " \n " ) ; return ret_val ; } ret_val = hw -> nvm . ops . read ( hw , NVM_PBA_OFFSET_1 , 1 , & pba_ptr ) ; if ( ret_val ) { DEBUGOUT ( " \n " ) ; return ret_val ; } if ( nvm_data != NVM_PBA_PTR_GUARD ) { * pba_num_size = IGC_PBANUM_LENGTH ; return IGC_SUCCESS ; } ret_val = hw -> nvm . ops . read ( hw , pba_ptr , 1 , & length ) ; if ( ret_val ) { DEBUGOUT ( " \n " ) ; return ret_val ; } if ( length == 0xFFFF || length == 0 ) { DEBUGOUT ( " \n " ) ; return - IGC_ERR_NVM_PBA_SECTION ; } * pba_num_size = ( ( u32 ) length * 2 ) - 1 ; return IGC_SUCCESS ; }
igc_read_pba_length_generic - Read device part number length
  @hw: pointer to the HW structure
  @pba_num_size: size of part number buffer
igc_read_pba_length_generic - Read device part number length @hw : pointer to the HW structure @pba_num_size : size of part number buffer
/* if data is not ptr guard the PBA must be in legacy format */ /* Convert from length in u16 values to u8 chars, add 1 for NULL,
	 * and subtract 2 because length field is included in length.
	 */