From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 66474A04FD; Tue, 14 Jan 2020 12:06:06 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2AB091C203; Tue, 14 Jan 2020 12:06:06 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 66CA31C1AA for ; Tue, 14 Jan 2020 12:06:04 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2020 03:06:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,432,1571727600"; d="scan'208";a="372551787" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 14 Jan 2020 03:06:03 -0800 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 14 Jan 2020 03:06:03 -0800 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 14 Jan 2020 03:06:02 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.30]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.139]) with mapi id 14.03.0439.000; Tue, 14 Jan 2020 19:06:01 +0800 From: "Yang, Qiming" To: "Zhu, TaoX" , "Xing, Beilei" , "Zhang, Qi Z" CC: "dev@dpdk.org" , "Ye, Xiaolong" Thread-Topic: [PATCH v3] net/i40e: add PF MDD event handler Thread-Index: AQHVysnNwFvU/Sxgfki7U++gae1hDqfp/3+A Date: Tue, 14 Jan 2020 11:06:00 +0000 Message-ID: References: <20191209135928.31697-1-taox.zhu@intel.com> <20200114194326.9107-1-taox.zhu@intel.com> In-Reply-To: <20200114194326.9107-1-taox.zhu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiODYwNWM1YjItYTA3Yi00MzhhLWI5NzYtMDY5M2IwNjIyY2ExIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiU3VpZk5EY0duNmJIVXRFbDZyYnVUQng3Sm9iSmNnUVdHRHk5cXdyb1V4dHJXbVViM0NDYzJKRW5lbXVRR1NhYiJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3] net/i40e: add PF MDD event handler X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: Zhu, TaoX > Sent: Wednesday, January 15, 2020 3:43 AM > To: Xing, Beilei ; Zhang, Qi Z > Cc: dev@dpdk.org; Yang, Qiming ; Ye, Xiaolong > ; Zhu, TaoX > Subject: [PATCH v3] net/i40e: add PF MDD event handler >=20 > From: Zhu Tao >=20 > add warning and counter to handle the maliciouse driver detection event. Add/add Acked-by: Qiming Yang >=20 > Signed-off-by: Zhu Tao > --- > doc/guides/nics/i40e.rst | 1 + > doc/guides/rel_notes/release_20_02.rst | 4 ++ > drivers/net/i40e/i40e_ethdev.c | 89 +++++++++++++++++++++++++- > drivers/net/i40e/i40e_ethdev.h | 1 + > 4 files changed, 93 insertions(+), 2 deletions(-) >=20 > diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst index > 38acf5906..539ea5c57 100644 > --- a/doc/guides/nics/i40e.rst > +++ b/doc/guides/nics/i40e.rst > @@ -43,6 +43,7 @@ Features of the i40e PMD are: > - Dynamic Device Personalization (DDP) > - Queue region configuration > - Virtual Function Port Representors > +- Malicious Device Drive event catch and notify >=20 > Prerequisites > ------------- > diff --git a/doc/guides/rel_notes/release_20_02.rst > b/doc/guides/rel_notes/release_20_02.rst > index 0eaa45a76..5f39006a4 100644 > --- a/doc/guides/rel_notes/release_20_02.rst > +++ b/doc/guides/rel_notes/release_20_02.rst > @@ -56,6 +56,10 @@ New Features > Also, make sure to start the actual text at the margin. > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > +* **Updated the Intel i40e driver.** > + > + Added PF support Malicious Device Drive event catch and notify. > + >=20 > Removed Items > ------------- > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethde= v.c > index 5999c964b..a66069b48 100644 > --- a/drivers/net/i40e/i40e_ethdev.c > +++ b/drivers/net/i40e/i40e_ethdev.c > @@ -6760,6 +6760,87 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev) > rte_free(info.msg_buf); > } >=20 > +static void > +i40e_handle_mdd_event(struct rte_eth_dev *dev) { > + struct i40e_hw *hw =3D I40E_DEV_PRIVATE_TO_HW(dev->data- > >dev_private); > + struct i40e_pf *pf =3D I40E_DEV_PRIVATE_TO_PF(dev->data- > >dev_private); > + bool mdd_detected =3D false; > + struct i40e_pf_vf *vf; > + uint32_t reg; > + int i; > + > + /* find what triggered the MDD event */ > + reg =3D I40E_READ_REG(hw, I40E_GL_MDET_TX); > + if (reg & I40E_GL_MDET_TX_VALID_MASK) { > + uint8_t pf_num =3D (reg & I40E_GL_MDET_TX_PF_NUM_MASK) >> > + I40E_GL_MDET_TX_PF_NUM_SHIFT; > + uint16_t vf_num =3D (reg & > I40E_GL_MDET_TX_VF_NUM_MASK) >> > + I40E_GL_MDET_TX_VF_NUM_SHIFT; > + uint8_t event =3D (reg & I40E_GL_MDET_TX_EVENT_MASK) >> > + I40E_GL_MDET_TX_EVENT_SHIFT; > + uint16_t queue =3D ((reg & I40E_GL_MDET_TX_QUEUE_MASK) >> > + I40E_GL_MDET_TX_QUEUE_SHIFT) - > + hw->func_caps.base_queue; > + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event > 0x%02x on TX " > + "queue %d PF number 0x%02x VF number 0x%02x > device %s\n", > + event, queue, pf_num, vf_num, dev->data- > >name); > + I40E_WRITE_REG(hw, I40E_GL_MDET_TX, 0xffffffff); > + mdd_detected =3D true; > + } > + reg =3D I40E_READ_REG(hw, I40E_GL_MDET_RX); > + if (reg & I40E_GL_MDET_RX_VALID_MASK) { > + uint8_t func =3D (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >> > + I40E_GL_MDET_RX_FUNCTION_SHIFT; > + uint8_t event =3D (reg & I40E_GL_MDET_RX_EVENT_MASK) >> > + I40E_GL_MDET_RX_EVENT_SHIFT; > + uint16_t queue =3D ((reg & I40E_GL_MDET_RX_QUEUE_MASK) >> > + I40E_GL_MDET_RX_QUEUE_SHIFT) - > + hw->func_caps.base_queue; > + > + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event > 0x%02x on RX " > + "queue %d of function 0x%02x device %s\n", > + event, queue, func, dev->data->name); > + I40E_WRITE_REG(hw, I40E_GL_MDET_RX, 0xffffffff); > + mdd_detected =3D true; > + } > + > + if (mdd_detected) { > + reg =3D I40E_READ_REG(hw, I40E_PF_MDET_TX); > + if (reg & I40E_PF_MDET_TX_VALID_MASK) { > + I40E_WRITE_REG(hw, I40E_PF_MDET_TX, 0xFFFF); > + PMD_DRV_LOG(WARNING, "TX driver issue detected on > PF\n"); > + } > + reg =3D I40E_READ_REG(hw, I40E_PF_MDET_RX); > + if (reg & I40E_PF_MDET_RX_VALID_MASK) { > + I40E_WRITE_REG(hw, I40E_PF_MDET_RX, 0xFFFF); > + PMD_DRV_LOG(WARNING, "RX driver issue detected > on PF\n"); > + } > + } > + > + /* see if one of the VFs needs its hand slapped */ > + for (i =3D 0; i < pf->vf_num && mdd_detected; i++) { > + vf =3D &pf->vfs[i]; > + reg =3D I40E_READ_REG(hw, I40E_VP_MDET_TX(i)); > + if (reg & I40E_VP_MDET_TX_VALID_MASK) { > + I40E_WRITE_REG(hw, I40E_VP_MDET_TX(i), 0xFFFF); > + vf->num_mdd_events++; > + PMD_DRV_LOG(WARNING, "TX driver issue detected on > VF %d %-" > + PRIu64 "times\n", > + i, vf->num_mdd_events); > + } > + > + reg =3D I40E_READ_REG(hw, I40E_VP_MDET_RX(i)); > + if (reg & I40E_VP_MDET_RX_VALID_MASK) { > + I40E_WRITE_REG(hw, I40E_VP_MDET_RX(i), 0xFFFF); > + vf->num_mdd_events++; > + PMD_DRV_LOG(WARNING, "RX driver issue detected > on VF %d %-" > + PRIu64 "times\n", > + i, vf->num_mdd_events); > + } > + } > +} > + > /** > * Interrupt handler triggered by NIC for handling > * specific interrupt. > @@ -6792,8 +6873,10 @@ i40e_dev_interrupt_handler(void *param) > } > if (icr0 & I40E_PFINT_ICR0_ECC_ERR_MASK) > PMD_DRV_LOG(ERR, "ICR0: unrecoverable ECC error"); > - if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK) > + if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK) { > PMD_DRV_LOG(ERR, "ICR0: malicious programming detected"); > + i40e_handle_mdd_event(dev); > + } > if (icr0 & I40E_PFINT_ICR0_GRST_MASK) > PMD_DRV_LOG(INFO, "ICR0: global reset requested"); > if (icr0 & I40E_PFINT_ICR0_PCI_EXCEPTION_MASK) > @@ -6837,8 +6920,10 @@ i40e_dev_alarm_handler(void *param) > goto done; > if (icr0 & I40E_PFINT_ICR0_ECC_ERR_MASK) > PMD_DRV_LOG(ERR, "ICR0: unrecoverable ECC error"); > - if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK) > + if (icr0 & I40E_PFINT_ICR0_MAL_DETECT_MASK) { > PMD_DRV_LOG(ERR, "ICR0: malicious programming detected"); > + i40e_handle_mdd_event(dev); > + } > if (icr0 & I40E_PFINT_ICR0_GRST_MASK) > PMD_DRV_LOG(INFO, "ICR0: global reset requested"); > if (icr0 & I40E_PFINT_ICR0_PCI_EXCEPTION_MASK) > diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethde= v.h > index 295ad593b..b14521017 100644 > --- a/drivers/net/i40e/i40e_ethdev.h > +++ b/drivers/net/i40e/i40e_ethdev.h > @@ -426,6 +426,7 @@ struct i40e_pf_vf { > /* version of the virtchnl from VF */ > struct virtchnl_version_info version; > uint32_t request_caps; /* offload caps requested from VF */ > + uint64_t num_mdd_events; /* num of mdd events detected */ >=20 > /* > * Variables for store the arrival timestamp of VF messages. > -- > 2.17.1