src/dpdk/drivers/net/e1000/base/e1000_manage.c
s32 e1000_mng_host_if_write_generic(struct e1000_hw *hw, u8 *buffer,
				    u16 length, u16 offset, u8 *sum)
{
	u8 *tmp;
	u8 *bufptr = buffer;
	u32 data = 0;
	u16 remaining, i, j, prev_bytes;

	DEBUGFUNC("e1000_mng_host_if_write_generic");

	/* sum = only sum of the data and it is not checksum */

	if (length == 0 || offset + length > E1000_HI_MAX_MNG_DATA_LENGTH)
		return -E1000_ERR_PARAM;

	tmp = (u8 *)&data;
	prev_bytes = offset & 0x3;
	offset >>= 2;

	if (prev_bytes) {
		data = E1000_READ_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset);
		for (j = prev_bytes; j < sizeof(u32); j++) {
			*(tmp + j) = *bufptr++;
			*sum += *(tmp + j);
		}
		E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset, data);
		length -= j - prev_bytes;
		offset++;
	}

	remaining = length & 0x3;
	length -= remaining;

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

	/* The device driver writes the relevant command block into the
	 * ram area.
	 */
	for (i = 0; i < length; i++) {
		for (j = 0; j < sizeof(u32); j++) {
			*(tmp + j) = *bufptr++;
			*sum += *(tmp + j);
		}

		E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset + i,
					    data);
	}
	if (remaining) {
		for (j = 0; j < sizeof(u32); j++) {
			if (j < remaining)
				*(tmp + j) = *bufptr++;
			else
				*(tmp + j) = 0;

			*sum += *(tmp + j);
		}
		E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset + i,
					    data);
	}

	return E1000_SUCCESS;
}
/**
 *  e1000_mng_host_if_write_generic - Write to the manageability host interface
 *  @hw: pointer to the HW structure
 *  @buffer: pointer to the host interface buffer
 *  @length: size of the buffer
 *  @offset: location in the buffer to write to
 *  @sum: sum of the data (not checksum)
 *
 *  This function writes the buffer content at the offset given on the host if.
 *  It also does alignment considerations to do the writes in most efficient
 *  way.  Also fills up the sum of the buffer in *buffer parameter.
 **/


This function writes the buffer content at the offset given on the host if.
It also does alignment considerations to do the writes in most efficient
way.  Also fills up the sum of the buffer in *buffer parameter.
This function writes the buffer content at the offset given on the host if . It also does alignment considerations to do the writes in most efficient way . Also fills up the sum of the buffer in * buffer parameter .
s32 e1000_mng_host_if_write_generic(struct e1000_hw *hw, u8 *buffer,
				    u16 length, u16 offset, u8 *sum)
{
	u8 *tmp;
	u8 *bufptr = buffer;
	u32 data = 0;
	u16 remaining, i, j, prev_bytes;
	DEBUGFUNC("e1000_mng_host_if_write_generic");
	if (length == 0 || offset + length > E1000_HI_MAX_MNG_DATA_LENGTH)
		return -E1000_ERR_PARAM;
	tmp = (u8 *)&data;
	prev_bytes = offset & 0x3;
	offset >>= 2;
	if (prev_bytes) {
		data = E1000_READ_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset);
		for (j = prev_bytes; j < sizeof(u32); j++) {
			*(tmp + j) = *bufptr++;
			*sum += *(tmp + j);
		}
		E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset, data);
		length -= j - prev_bytes;
		offset++;
	}
	remaining = length & 0x3;
	length -= remaining;
	length >>= 2;
	for (i = 0; i < length; i++) {
		for (j = 0; j < sizeof(u32); j++) {
			*(tmp + j) = *bufptr++;
			*sum += *(tmp + j);
		}
		E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset + i,
					    data);
	}
	if (remaining) {
		for (j = 0; j < sizeof(u32); j++) {
			if (j < remaining)
				*(tmp + j) = *bufptr++;
			else
				*(tmp + j) = 0;
			*sum += *(tmp + j);
		}
		E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset + i,
					    data);
	}
	return E1000_SUCCESS;
}
s32 e1000_mng_host_if_write_generic ( struct e1000_hw * hw , u8 * buffer , u16 length , u16 offset , u8 * sum ) { u8 * tmp ; u8 * bufptr = buffer ; u32 data = 0 ; u16 remaining , i , j , prev_bytes ; DEBUGFUNC ( " " ) ; if ( length == 0 || offset + length > E1000_HI_MAX_MNG_DATA_LENGTH ) return - E1000_ERR_PARAM ; tmp = ( u8 * ) & data ; prev_bytes = offset & 0x3 ; offset >>= 2 ; if ( prev_bytes ) { data = E1000_READ_REG_ARRAY_DWORD ( hw , E1000_HOST_IF , offset ) ; for ( j = prev_bytes ; j < sizeof ( u32 ) ; j ++ ) { * ( tmp + j ) = * bufptr ++ ; * sum += * ( tmp + j ) ; } E1000_WRITE_REG_ARRAY_DWORD ( hw , E1000_HOST_IF , offset , data ) ; length -= j - prev_bytes ; offset ++ ; } remaining = length & 0x3 ; length -= remaining ; length >>= 2 ; for ( i = 0 ; i < length ; i ++ ) { for ( j = 0 ; j < sizeof ( u32 ) ; j ++ ) { * ( tmp + j ) = * bufptr ++ ; * sum += * ( tmp + j ) ; } E1000_WRITE_REG_ARRAY_DWORD ( hw , E1000_HOST_IF , offset + i , data ) ; } if ( remaining ) { for ( j = 0 ; j < sizeof ( u32 ) ; j ++ ) { if ( j < remaining ) * ( tmp + j ) = * bufptr ++ ; else * ( tmp + j ) = 0 ; * sum += * ( tmp + j ) ; } E1000_WRITE_REG_ARRAY_DWORD ( hw , E1000_HOST_IF , offset + i , data ) ; } return E1000_SUCCESS ; }
e1000_mng_host_if_write_generic - Write to the manageability host interface
  @hw: pointer to the HW structure
  @buffer: pointer to the host interface buffer
  @length: size of the buffer
  @offset: location in the buffer to write to
  @sum: sum of the data (not checksum)
e1000_mng_host_if_write_generic - Write to the manageability host interface @hw : pointer to the HW structure @buffer : pointer to the host interface buffer @length : size of the buffer @offset : location in the buffer to write to @sum : sum of the data ( not checksum )
/* sum = only sum of the data and it is not checksum */ /* Calculate length in DWORDs */ /* The device driver writes the relevant command block into the
	 * ram area.
	 */