FreeBSD/sys/dev/ixl/ixl_pf_main.c
/**
 * ixl_handle_mdd_event
 *
 * Called from interrupt handler to identify possibly malicious vfs
 * (But also detects events from the PF, as well)
 **/
ixl_handle_mdd_event
Called from interrupt handler to identify possibly malicious vfs
(But also detects events from the PF, as well)
ixl_handle_mdd_event Called from interrupt handler to identify possibly malicious vfs ( But also detects events from the PF as well )
void
ixl_handle_mdd_event(struct ixl_pf *pf)
{
	struct i40e_hw *hw = &pf->hw;
	device_t dev = pf->dev;
	bool mdd_detected = false;
	bool pf_mdd_detected = false;
	u32 reg;
	reg = rd32(hw, I40E_GL_MDET_TX);
	if (reg & I40E_GL_MDET_TX_VALID_MASK) {
		u8 pf_num = (reg & I40E_GL_MDET_TX_PF_NUM_MASK) >>
				I40E_GL_MDET_TX_PF_NUM_SHIFT;
		u8 event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >>
				I40E_GL_MDET_TX_EVENT_SHIFT;
		u16 queue = (reg & I40E_GL_MDET_TX_QUEUE_MASK) >>
				I40E_GL_MDET_TX_QUEUE_SHIFT;
		device_printf(dev,
		    "Malicious Driver Detection event %d"
		    " on TX queue %d, pf number %d\n",
		    event, queue, pf_num);
		wr32(hw, I40E_GL_MDET_TX, 0xffffffff);
		mdd_detected = true;
	}
	reg = rd32(hw, I40E_GL_MDET_RX);
	if (reg & I40E_GL_MDET_RX_VALID_MASK) {
		u8 pf_num = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >>
				I40E_GL_MDET_RX_FUNCTION_SHIFT;
		u8 event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >>
				I40E_GL_MDET_RX_EVENT_SHIFT;
		u16 queue = (reg & I40E_GL_MDET_RX_QUEUE_MASK) >>
				I40E_GL_MDET_RX_QUEUE_SHIFT;
		device_printf(dev,
		    "Malicious Driver Detection event %d"
		    " on RX queue %d, pf number %d\n",
		    event, queue, pf_num);
		wr32(hw, I40E_GL_MDET_RX, 0xffffffff);
		mdd_detected = true;
	}
	if (mdd_detected) {
		reg = rd32(hw, I40E_PF_MDET_TX);
		if (reg & I40E_PF_MDET_TX_VALID_MASK) {
			wr32(hw, I40E_PF_MDET_TX, 0xFFFF);
			device_printf(dev,
			    "MDD TX event is for this function!");
			pf_mdd_detected = true;
		}
		reg = rd32(hw, I40E_PF_MDET_RX);
		if (reg & I40E_PF_MDET_RX_VALID_MASK) {
			wr32(hw, I40E_PF_MDET_RX, 0xFFFF);
			device_printf(dev,
			    "MDD RX event is for this function!");
			pf_mdd_detected = true;
		}
	}
	reg = rd32(hw, I40E_PFINT_ICR0_ENA);
	reg |= I40E_PFINT_ICR0_ENA_MAL_DETECT_MASK;
	wr32(hw, I40E_PFINT_ICR0_ENA, reg);
	ixl_flush(hw);
}
void ixl_handle_mdd_event ( struct ixl_pf * pf ) { struct i40e_hw * hw = & pf -> hw ; device_t dev = pf -> dev ; bool mdd_detected = false ; bool pf_mdd_detected = false ; u32 reg ; reg = rd32 ( hw , I40E_GL_MDET_TX ) ; if ( reg & I40E_GL_MDET_TX_VALID_MASK ) { u8 pf_num = ( reg & I40E_GL_MDET_TX_PF_NUM_MASK ) >> I40E_GL_MDET_TX_PF_NUM_SHIFT ; u8 event = ( reg & I40E_GL_MDET_TX_EVENT_MASK ) >> I40E_GL_MDET_TX_EVENT_SHIFT ; u16 queue = ( reg & I40E_GL_MDET_TX_QUEUE_MASK ) >> I40E_GL_MDET_TX_QUEUE_SHIFT ; device_printf ( dev , " " " \n " , event , queue , pf_num ) ; wr32 ( hw , I40E_GL_MDET_TX , 0xffffffff ) ; mdd_detected = true ; } reg = rd32 ( hw , I40E_GL_MDET_RX ) ; if ( reg & I40E_GL_MDET_RX_VALID_MASK ) { u8 pf_num = ( reg & I40E_GL_MDET_RX_FUNCTION_MASK ) >> I40E_GL_MDET_RX_FUNCTION_SHIFT ; u8 event = ( reg & I40E_GL_MDET_RX_EVENT_MASK ) >> I40E_GL_MDET_RX_EVENT_SHIFT ; u16 queue = ( reg & I40E_GL_MDET_RX_QUEUE_MASK ) >> I40E_GL_MDET_RX_QUEUE_SHIFT ; device_printf ( dev , " " " \n " , event , queue , pf_num ) ; wr32 ( hw , I40E_GL_MDET_RX , 0xffffffff ) ; mdd_detected = true ; } if ( mdd_detected ) { reg = rd32 ( hw , I40E_PF_MDET_TX ) ; if ( reg & I40E_PF_MDET_TX_VALID_MASK ) { wr32 ( hw , I40E_PF_MDET_TX , 0xFFFF ) ; device_printf ( dev , " " ) ; pf_mdd_detected = true ; } reg = rd32 ( hw , I40E_PF_MDET_RX ) ; if ( reg & I40E_PF_MDET_RX_VALID_MASK ) { wr32 ( hw , I40E_PF_MDET_RX , 0xFFFF ) ; device_printf ( dev , " " ) ; pf_mdd_detected = true ; } } reg = rd32 ( hw , I40E_PFINT_ICR0_ENA ) ; reg |= I40E_PFINT_ICR0_ENA_MAL_DETECT_MASK ; wr32 ( hw , I40E_PFINT_ICR0_ENA , reg ) ; ixl_flush ( hw ) ; }
ixl_handle_mdd_event
 Called from interrupt handler to identify possibly malicious vfs
 (But also detects events from the PF, as well)
ixl_handle_mdd_event Called from interrupt handler to identify possibly malicious vfs ( But also detects events from the PF as well )
/* find what triggered the MDD event */ /* re-enable mdd interrupt cause */