src/dpdk/drivers/net/txgbe/base/txgbe_mng.c
static s32
txgbe_host_interface_command(struct txgbe_hw *hw, u32 *buffer,
				 u32 length, u32 timeout, bool return_data)
{
	u32 hdr_size = sizeof(struct txgbe_hic_hdr);
	struct txgbe_hic_hdr *resp = (struct txgbe_hic_hdr *)buffer;
	u16 buf_len;
	s32 err;
	u32 bi;
	u32 dword_len;

	DEBUGFUNC("txgbe_host_interface_command");

	if (length == 0 || length > TXGBE_PMMBX_BSIZE) {
		DEBUGOUT("Buffer length failure buffersize=%d.\n", length);
		return TXGBE_ERR_HOST_INTERFACE_COMMAND;
	}

	/* Take management host interface semaphore */
	err = hw->mac.acquire_swfw_sync(hw, TXGBE_MNGSEM_SWMBX);
	if (err)
		return err;

	err = txgbe_hic_unlocked(hw, buffer, length, timeout);
	if (err)
		goto rel_out;

	if (!return_data)
		goto rel_out;

	/* Calculate length in DWORDs */
	dword_len = hdr_size >> 2;

	/* first pull in the header so we know the buffer length */
	for (bi = 0; bi < dword_len; bi++)
		buffer[bi] = rd32a(hw, TXGBE_MNGMBX, bi);

	/*
	 * If there is any thing in data position pull it in
	 * Read Flash command requires reading buffer length from
	 * two byes instead of one byte
	 */
	if (resp->cmd == 0x30) {
		for (; bi < dword_len + 2; bi++)
			buffer[bi] = rd32a(hw, TXGBE_MNGMBX, bi);

		buf_len = (((u16)(resp->cmd_or_resp.ret_status) << 3)
				  & 0xF00) | resp->buf_len;
		hdr_size += (2 << 2);
	} else {
		buf_len = resp->buf_len;
	}
	if (!buf_len)
		goto rel_out;

	if (length < buf_len + hdr_size) {
		DEBUGOUT("Buffer not large enough for reply message.\n");
		err = TXGBE_ERR_HOST_INTERFACE_COMMAND;
		goto rel_out;
	}

	/* Calculate length in DWORDs, add 3 for odd lengths */
	dword_len = (buf_len + 3) >> 2;

	/* Pull in the rest of the buffer (bi is where we left off) */
	for (; bi <= dword_len; bi++)
		buffer[bi] = rd32a(hw, TXGBE_MNGMBX, bi);

rel_out:
	hw->mac.release_swfw_sync(hw, TXGBE_MNGSEM_SWMBX);

	return err;
}
/**
 *  txgbe_host_interface_command - Issue command to manageability block
 *  @hw: pointer to the HW structure
 *  @buffer: contains the command to write and where the return status will
 *   be placed
 *  @length: length of buffer, must be multiple of 4 bytes
 *  @timeout: time in ms to wait for command completion
 *  @return_data: read and return data from the buffer (true) or not (false)
 *   Needed because FW structures are big endian and decoding of
 *   these fields can be 8 bit or 16 bit based on command. Decoding
 *   is not easily understood without making a table of commands.
 *   So we will leave this up to the caller to read back the data
 *   in these cases.
 *
 *  Communicates with the manageability block. On success return 0
 *  else returns semaphore error when encountering an error acquiring
 *  semaphore or TXGBE_ERR_HOST_INTERFACE_COMMAND when command fails.
 **/


Communicates with the manageability block. On success return 0
else returns semaphore error when encountering an error acquiring
semaphore or TXGBE_ERR_HOST_INTERFACE_COMMAND when command fails.
Communicates with the manageability block . On success return 0 else returns semaphore error when encountering an error acquiring semaphore or TXGBE_ERR_HOST_INTERFACE_COMMAND when command fails .
static s32
txgbe_host_interface_command(struct txgbe_hw *hw, u32 *buffer,
				 u32 length, u32 timeout, bool return_data)
{
	u32 hdr_size = sizeof(struct txgbe_hic_hdr);
	struct txgbe_hic_hdr *resp = (struct txgbe_hic_hdr *)buffer;
	u16 buf_len;
	s32 err;
	u32 bi;
	u32 dword_len;
	DEBUGFUNC("txgbe_host_interface_command");
	if (length == 0 || length > TXGBE_PMMBX_BSIZE) {
		DEBUGOUT("Buffer length failure buffersize=%d.\n", length);
		return TXGBE_ERR_HOST_INTERFACE_COMMAND;
	}
	err = hw->mac.acquire_swfw_sync(hw, TXGBE_MNGSEM_SWMBX);
	if (err)
		return err;
	err = txgbe_hic_unlocked(hw, buffer, length, timeout);
	if (err)
		goto rel_out;
	if (!return_data)
		goto rel_out;
	dword_len = hdr_size >> 2;
	for (bi = 0; bi < dword_len; bi++)
		buffer[bi] = rd32a(hw, TXGBE_MNGMBX, bi);
	if (resp->cmd == 0x30) {
		for (; bi < dword_len + 2; bi++)
			buffer[bi] = rd32a(hw, TXGBE_MNGMBX, bi);
		buf_len = (((u16)(resp->cmd_or_resp.ret_status) << 3)
				  & 0xF00) | resp->buf_len;
		hdr_size += (2 << 2);
	} else {
		buf_len = resp->buf_len;
	}
	if (!buf_len)
		goto rel_out;
	if (length < buf_len + hdr_size) {
		DEBUGOUT("Buffer not large enough for reply message.\n");
		err = TXGBE_ERR_HOST_INTERFACE_COMMAND;
		goto rel_out;
	}
	dword_len = (buf_len + 3) >> 2;
	for (; bi <= dword_len; bi++)
		buffer[bi] = rd32a(hw, TXGBE_MNGMBX, bi);
rel_out:
	hw->mac.release_swfw_sync(hw, TXGBE_MNGSEM_SWMBX);
	return err;
}
static s32 txgbe_host_interface_command ( struct txgbe_hw * hw , u32 * buffer , u32 length , u32 timeout , bool return_data ) { u32 hdr_size = sizeof ( struct txgbe_hic_hdr ) ; struct txgbe_hic_hdr * resp = ( struct txgbe_hic_hdr * ) buffer ; u16 buf_len ; s32 err ; u32 bi ; u32 dword_len ; DEBUGFUNC ( " " ) ; if ( length == 0 || length > TXGBE_PMMBX_BSIZE ) { DEBUGOUT ( " \n " , length ) ; return TXGBE_ERR_HOST_INTERFACE_COMMAND ; } err = hw -> mac . acquire_swfw_sync ( hw , TXGBE_MNGSEM_SWMBX ) ; if ( err ) return err ; err = txgbe_hic_unlocked ( hw , buffer , length , timeout ) ; if ( err ) goto rel_out ; if ( ! return_data ) goto rel_out ; dword_len = hdr_size >> 2 ; for ( bi = 0 ; bi < dword_len ; bi ++ ) buffer [ bi ] = rd32a ( hw , TXGBE_MNGMBX , bi ) ; if ( resp -> cmd == 0x30 ) { for ( ; bi < dword_len + 2 ; bi ++ ) buffer [ bi ] = rd32a ( hw , TXGBE_MNGMBX , bi ) ; buf_len = ( ( ( u16 ) ( resp -> cmd_or_resp . ret_status ) << 3 ) & 0xF00 ) | resp -> buf_len ; hdr_size += ( 2 << 2 ) ; } else { buf_len = resp -> buf_len ; } if ( ! buf_len ) goto rel_out ; if ( length < buf_len + hdr_size ) { DEBUGOUT ( " \n " ) ; err = TXGBE_ERR_HOST_INTERFACE_COMMAND ; goto rel_out ; } dword_len = ( buf_len + 3 ) >> 2 ; for ( ; bi <= dword_len ; bi ++ ) buffer [ bi ] = rd32a ( hw , TXGBE_MNGMBX , bi ) ; rel_out : hw -> mac . release_swfw_sync ( hw , TXGBE_MNGSEM_SWMBX ) ; return err ; }
txgbe_host_interface_command - Issue command to manageability block
  @hw: pointer to the HW structure
  @buffer: contains the command to write and where the return status will
   be placed
  @length: length of buffer, must be multiple of 4 bytes
  @timeout: time in ms to wait for command completion
  @return_data: read and return data from the buffer (true) or not (false)
   Needed because FW structures are big endian and decoding of
   these fields can be 8 bit or 16 bit based on command.
txgbe_host_interface_command - Issue command to manageability block @hw : pointer to the HW structure @buffer : contains the command to write and where the return status will be placed @length : length of buffer must be multiple of 4 bytes @timeout : time in ms to wait for command completion @return_data : read and return data from the buffer ( true ) or not ( false ) Needed because FW structures are big endian and decoding of these fields can be 8 bit or 16 bit based on command .
/* Take management host interface semaphore */ /* Calculate length in DWORDs */ /* first pull in the header so we know the buffer length */ /*
	 * If there is any thing in data position pull it in
	 * Read Flash command requires reading buffer length from
	 * two byes instead of one byte
	 */ /* Calculate length in DWORDs, add 3 for odd lengths */ /* Pull in the rest of the buffer (bi is where we left off) */