src/dpdk/drivers/net/e1000/base/e1000_manage.c
s32 e1000_host_interface_command(struct e1000_hw *hw, u8 *buffer, u32 length)
{
	u32 hicr, i;

	DEBUGFUNC("e1000_host_interface_command");

	if (!(hw->mac.arc_subsystem_valid)) {
		DEBUGOUT("Hardware doesn't support host interface command.\n");
		return E1000_SUCCESS;
	}

	if (!hw->mac.asf_firmware_present) {
		DEBUGOUT("Firmware is not present.\n");
		return E1000_SUCCESS;
	}

	if (length == 0 || length & 0x3 ||
	    length > E1000_HI_MAX_BLOCK_BYTE_LENGTH) {
		DEBUGOUT("Buffer length failure.\n");
		return -E1000_ERR_HOST_INTERFACE_COMMAND;
	}

	/* Check that the host interface is enabled. */
	hicr = E1000_READ_REG(hw, E1000_HICR);
	if (!(hicr & E1000_HICR_EN)) {
		DEBUGOUT("E1000_HOST_EN bit disabled.\n");
		return -E1000_ERR_HOST_INTERFACE_COMMAND;
	}

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

	/* The device driver writes the relevant command block
	 * into the ram area.
	 */
	for (i = 0; i < length; i++)
		E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, i,
					    *((u32 *)buffer + i));

	/* Setting this bit tells the ARC that a new command is pending. */
	E1000_WRITE_REG(hw, E1000_HICR, hicr | E1000_HICR_C);

	for (i = 0; i < E1000_HI_COMMAND_TIMEOUT; i++) {
		hicr = E1000_READ_REG(hw, E1000_HICR);
		if (!(hicr & E1000_HICR_C))
			break;
		msec_delay(1);
	}

	/* Check command successful completion. */
	if (i == E1000_HI_COMMAND_TIMEOUT ||
	    (!(E1000_READ_REG(hw, E1000_HICR) & E1000_HICR_SV))) {
		DEBUGOUT("Command has failed with no status valid.\n");
		return -E1000_ERR_HOST_INTERFACE_COMMAND;
	}

	for (i = 0; i < length; i++)
		*((u32 *)buffer + i) = E1000_READ_REG_ARRAY_DWORD(hw,
								  E1000_HOST_IF,
								  i);

	return E1000_SUCCESS;
}
/**
 *  e1000_host_interface_command - Writes buffer to host interface
 *  @hw: pointer to the HW structure
 *  @buffer: contains a command to write
 *  @length: the byte length of the buffer, must be multiple of 4 bytes
 *
 *  Writes a buffer to the Host Interface.  Upon success, returns E1000_SUCCESS
 *  else returns E1000_ERR_HOST_INTERFACE_COMMAND.
 **/
Writes buffer to host interface
@hw: pointer to the HW structure
@buffer: contains a command to write
@length: the byte length of the buffer, must be multiple of 4 bytes

Writes a buffer to the Host Interface.  Upon success, returns E1000_SUCCESS
else returns E1000_ERR_HOST_INTERFACE_COMMAND.
Writes buffer to host interface @hw : pointer to the HW structure @buffer : contains a command to write @length : the byte length of the buffer must be multiple of 4 bytes Writes a buffer to the Host Interface . Upon success returns E1000_SUCCESS else returns E1000_ERR_HOST_INTERFACE_COMMAND .
s32 e1000_host_interface_command(struct e1000_hw *hw, u8 *buffer, u32 length)
{
	u32 hicr, i;
	DEBUGFUNC("e1000_host_interface_command");
	if (!(hw->mac.arc_subsystem_valid)) {
		DEBUGOUT("Hardware doesn't support host interface command.\n");
		return E1000_SUCCESS;
	}
	if (!hw->mac.asf_firmware_present) {
		DEBUGOUT("Firmware is not present.\n");
		return E1000_SUCCESS;
	}
	if (length == 0 || length & 0x3 ||
	    length > E1000_HI_MAX_BLOCK_BYTE_LENGTH) {
		DEBUGOUT("Buffer length failure.\n");
		return -E1000_ERR_HOST_INTERFACE_COMMAND;
	}
	hicr = E1000_READ_REG(hw, E1000_HICR);
	if (!(hicr & E1000_HICR_EN)) {
		DEBUGOUT("E1000_HOST_EN bit disabled.\n");
		return -E1000_ERR_HOST_INTERFACE_COMMAND;
	}
	length >>= 2;
	for (i = 0; i < length; i++)
		E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, i,
					    *((u32 *)buffer + i));
	E1000_WRITE_REG(hw, E1000_HICR, hicr | E1000_HICR_C);
	for (i = 0; i < E1000_HI_COMMAND_TIMEOUT; i++) {
		hicr = E1000_READ_REG(hw, E1000_HICR);
		if (!(hicr & E1000_HICR_C))
			break;
		msec_delay(1);
	}
	if (i == E1000_HI_COMMAND_TIMEOUT ||
	    (!(E1000_READ_REG(hw, E1000_HICR) & E1000_HICR_SV))) {
		DEBUGOUT("Command has failed with no status valid.\n");
		return -E1000_ERR_HOST_INTERFACE_COMMAND;
	}
	for (i = 0; i < length; i++)
		*((u32 *)buffer + i) = E1000_READ_REG_ARRAY_DWORD(hw,
								  E1000_HOST_IF,
								  i);
	return E1000_SUCCESS;
}
s32 e1000_host_interface_command ( struct e1000_hw * hw , u8 * buffer , u32 length ) { u32 hicr , i ; DEBUGFUNC ( " " ) ; if ( ! ( hw -> mac . arc_subsystem_valid ) ) { DEBUGOUT ( " \n " ) ; return E1000_SUCCESS ; } if ( ! hw -> mac . asf_firmware_present ) { DEBUGOUT ( " \n " ) ; return E1000_SUCCESS ; } if ( length == 0 || length & 0x3 || length > E1000_HI_MAX_BLOCK_BYTE_LENGTH ) { DEBUGOUT ( " \n " ) ; return - E1000_ERR_HOST_INTERFACE_COMMAND ; } hicr = E1000_READ_REG ( hw , E1000_HICR ) ; if ( ! ( hicr & E1000_HICR_EN ) ) { DEBUGOUT ( " \n " ) ; return - E1000_ERR_HOST_INTERFACE_COMMAND ; } length >>= 2 ; for ( i = 0 ; i < length ; i ++ ) E1000_WRITE_REG_ARRAY_DWORD ( hw , E1000_HOST_IF , i , * ( ( u32 * ) buffer + i ) ) ; E1000_WRITE_REG ( hw , E1000_HICR , hicr | E1000_HICR_C ) ; for ( i = 0 ; i < E1000_HI_COMMAND_TIMEOUT ; i ++ ) { hicr = E1000_READ_REG ( hw , E1000_HICR ) ; if ( ! ( hicr & E1000_HICR_C ) ) break ; msec_delay ( 1 ) ; } if ( i == E1000_HI_COMMAND_TIMEOUT || ( ! ( E1000_READ_REG ( hw , E1000_HICR ) & E1000_HICR_SV ) ) ) { DEBUGOUT ( " \n " ) ; return - E1000_ERR_HOST_INTERFACE_COMMAND ; } for ( i = 0 ; i < length ; i ++ ) * ( ( u32 * ) buffer + i ) = E1000_READ_REG_ARRAY_DWORD ( hw , E1000_HOST_IF , i ) ; return E1000_SUCCESS ; }
e1000_host_interface_command - Writes buffer to host interface
  @hw: pointer to the HW structure
  @buffer: contains a command to write
  @length: the byte length of the buffer, must be multiple of 4 bytes
e1000_host_interface_command - Writes buffer to host interface @hw : pointer to the HW structure @buffer : contains a command to write @length : the byte length of the buffer must be multiple of 4 bytes
/* Check that the host interface is enabled. */ /* Calculate length in DWORDs */ /* The device driver writes the relevant command block
	 * into the ram area.
	 */ /* Setting this bit tells the ARC that a new command is pending. */ /* Check command successful completion. */