src/dpdk/drivers/net/e1000/base/e1000_manage.c
bool e1000_enable_tx_pkt_filtering_generic(struct e1000_hw *hw)
{
	struct e1000_host_mng_dhcp_cookie *hdr = &hw->mng_cookie;
	u32 *buffer = (u32 *)&hw->mng_cookie;
	u32 offset;
	s32 ret_val, hdr_csum, csum;
	u8 i, len;

	DEBUGFUNC("e1000_enable_tx_pkt_filtering_generic");

	hw->mac.tx_pkt_filtering = true;

	/* No manageability, no filtering */
	if (!hw->mac.ops.check_mng_mode(hw)) {
		hw->mac.tx_pkt_filtering = false;
		return hw->mac.tx_pkt_filtering;
	}

	/* If we can't read from the host interface for whatever
	 * reason, disable filtering.
	 */
	ret_val = e1000_mng_enable_host_if_generic(hw);
	if (ret_val != E1000_SUCCESS) {
		hw->mac.tx_pkt_filtering = false;
		return hw->mac.tx_pkt_filtering;
	}

	/* Read in the header.  Length and offset are in dwords. */
	len    = E1000_MNG_DHCP_COOKIE_LENGTH >> 2;
	offset = E1000_MNG_DHCP_COOKIE_OFFSET >> 2;
	for (i = 0; i < len; i++)
		*(buffer + i) = E1000_READ_REG_ARRAY_DWORD(hw, E1000_HOST_IF,
							   offset + i);
	hdr_csum = hdr->checksum;
	hdr->checksum = 0;
	csum = e1000_calculate_checksum((u8 *)hdr,
					E1000_MNG_DHCP_COOKIE_LENGTH);
	/* If either the checksums or signature don't match, then
	 * the cookie area isn't considered valid, in which case we
	 * take the safe route of assuming Tx filtering is enabled.
	 */
	if ((hdr_csum != csum) || (hdr->signature != E1000_IAMT_SIGNATURE)) {
		hw->mac.tx_pkt_filtering = true;
		return hw->mac.tx_pkt_filtering;
	}

	/* Cookie area is valid, make the final check for filtering. */
	if (!(hdr->status & E1000_MNG_DHCP_COOKIE_STATUS_PARSING))
		hw->mac.tx_pkt_filtering = false;

	return hw->mac.tx_pkt_filtering;
}
/**
 *  e1000_enable_tx_pkt_filtering_generic - Enable packet filtering on Tx
 *  @hw: pointer to the HW structure
 *
 *  Enables packet filtering on transmit packets if manageability is enabled
 *  and host interface is enabled.
 **/
Enable packet filtering on Tx
@hw: pointer to the HW structure

Enables packet filtering on transmit packets if manageability is enabled
and host interface is enabled.
Enable packet filtering on Tx @hw : pointer to the HW structure Enables packet filtering on transmit packets if manageability is enabled and host interface is enabled .
bool e1000_enable_tx_pkt_filtering_generic(struct e1000_hw *hw)
{
	struct e1000_host_mng_dhcp_cookie *hdr = &hw->mng_cookie;
	u32 *buffer = (u32 *)&hw->mng_cookie;
	u32 offset;
	s32 ret_val, hdr_csum, csum;
	u8 i, len;
	DEBUGFUNC("e1000_enable_tx_pkt_filtering_generic");
	hw->mac.tx_pkt_filtering = true;
	if (!hw->mac.ops.check_mng_mode(hw)) {
		hw->mac.tx_pkt_filtering = false;
		return hw->mac.tx_pkt_filtering;
	}
	ret_val = e1000_mng_enable_host_if_generic(hw);
	if (ret_val != E1000_SUCCESS) {
		hw->mac.tx_pkt_filtering = false;
		return hw->mac.tx_pkt_filtering;
	}
	len    = E1000_MNG_DHCP_COOKIE_LENGTH >> 2;
	offset = E1000_MNG_DHCP_COOKIE_OFFSET >> 2;
	for (i = 0; i < len; i++)
		*(buffer + i) = E1000_READ_REG_ARRAY_DWORD(hw, E1000_HOST_IF,
							   offset + i);
	hdr_csum = hdr->checksum;
	hdr->checksum = 0;
	csum = e1000_calculate_checksum((u8 *)hdr,
					E1000_MNG_DHCP_COOKIE_LENGTH);
	if ((hdr_csum != csum) || (hdr->signature != E1000_IAMT_SIGNATURE)) {
		hw->mac.tx_pkt_filtering = true;
		return hw->mac.tx_pkt_filtering;
	}
	if (!(hdr->status & E1000_MNG_DHCP_COOKIE_STATUS_PARSING))
		hw->mac.tx_pkt_filtering = false;
	return hw->mac.tx_pkt_filtering;
}
bool e1000_enable_tx_pkt_filtering_generic ( struct e1000_hw * hw ) { struct e1000_host_mng_dhcp_cookie * hdr = & hw -> mng_cookie ; u32 * buffer = ( u32 * ) & hw -> mng_cookie ; u32 offset ; s32 ret_val , hdr_csum , csum ; u8 i , len ; DEBUGFUNC ( " " ) ; hw -> mac . tx_pkt_filtering = true ; if ( ! hw -> mac . ops . check_mng_mode ( hw ) ) { hw -> mac . tx_pkt_filtering = false ; return hw -> mac . tx_pkt_filtering ; } ret_val = e1000_mng_enable_host_if_generic ( hw ) ; if ( ret_val != E1000_SUCCESS ) { hw -> mac . tx_pkt_filtering = false ; return hw -> mac . tx_pkt_filtering ; } len = E1000_MNG_DHCP_COOKIE_LENGTH >> 2 ; offset = E1000_MNG_DHCP_COOKIE_OFFSET >> 2 ; for ( i = 0 ; i < len ; i ++ ) * ( buffer + i ) = E1000_READ_REG_ARRAY_DWORD ( hw , E1000_HOST_IF , offset + i ) ; hdr_csum = hdr -> checksum ; hdr -> checksum = 0 ; csum = e1000_calculate_checksum ( ( u8 * ) hdr , E1000_MNG_DHCP_COOKIE_LENGTH ) ; if ( ( hdr_csum != csum ) || ( hdr -> signature != E1000_IAMT_SIGNATURE ) ) { hw -> mac . tx_pkt_filtering = true ; return hw -> mac . tx_pkt_filtering ; } if ( ! ( hdr -> status & E1000_MNG_DHCP_COOKIE_STATUS_PARSING ) ) hw -> mac . tx_pkt_filtering = false ; return hw -> mac . tx_pkt_filtering ; }
e1000_enable_tx_pkt_filtering_generic - Enable packet filtering on Tx
  @hw: pointer to the HW structure
e1000_enable_tx_pkt_filtering_generic - Enable packet filtering on Tx @hw : pointer to the HW structure
/* No manageability, no filtering */ /* If we can't read from the host interface for whatever
	 * reason, disable filtering.
	 */ /* Read in the header.  Length and offset are in dwords. */ /* If either the checksums or signature don't match, then
	 * the cookie area isn't considered valid, in which case we
	 * take the safe route of assuming Tx filtering is enabled.
	 */ /* Cookie area is valid, make the final check for filtering. */