Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/951921/?format=api
{ "id": 951921, "url": "http://patchwork.ozlabs.org/api/patches/951921/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20180801040433.5865-10-anirudh.venkataramanan@intel.com/", "project": { "id": 46, "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api", "name": "Intel Wired Ethernet development", "link_name": "intel-wired-lan", "list_id": "intel-wired-lan.osuosl.org", "list_email": "intel-wired-lan@osuosl.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20180801040433.5865-10-anirudh.venkataramanan@intel.com>", "list_archive_url": null, "date": "2018-08-01T04:04:29", "name": "[v2,09/13] ice: Add support for Tx hang, Tx timeout and malicious driver detection", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "4a3cd64aaaed55498eadc0d5665177560c9a0fde", "submitter": { "id": 73601, "url": "http://patchwork.ozlabs.org/api/people/73601/?format=api", "name": "Anirudh Venkataramanan", "email": "anirudh.venkataramanan@intel.com" }, "delegate": { "id": 68, "url": "http://patchwork.ozlabs.org/api/users/68/?format=api", "username": "jtkirshe", "first_name": "Jeff", "last_name": "Kirsher", "email": "jeffrey.t.kirsher@intel.com" }, "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20180801040433.5865-10-anirudh.venkataramanan@intel.com/mbox/", "series": [ { "id": 58674, "url": "http://patchwork.ozlabs.org/api/series/58674/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=58674", "date": "2018-08-01T04:04:20", "name": "Feature updates for ice", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/58674/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/951921/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/951921/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<intel-wired-lan-bounces@osuosl.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "intel-wired-lan@lists.osuosl.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "intel-wired-lan@lists.osuosl.org" ], "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=osuosl.org\n\t(client-ip=140.211.166.133; helo=hemlock.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=intel.com" ], "Received": [ "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 41gKTK04Lxz9rxx\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 1 Aug 2018 14:05:08 +1000 (AEST)", "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 7584A87F21;\n\tWed, 1 Aug 2018 04:05:07 +0000 (UTC)", "from hemlock.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id Yndt8WFDF3BM; Wed, 1 Aug 2018 04:04:59 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id D0AE587F3A;\n\tWed, 1 Aug 2018 04:04:56 +0000 (UTC)", "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id AB4351C0BBC\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 1 Aug 2018 04:04:53 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id A82C425636\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 1 Aug 2018 04:04:53 +0000 (UTC)", "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id ZFAU6X6Cj0fZ for <intel-wired-lan@lists.osuosl.org>;\n\tWed, 1 Aug 2018 04:04:52 +0000 (UTC)", "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n\tby silver.osuosl.org (Postfix) with ESMTPS id A6B3925BF8\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 1 Aug 2018 04:04:52 +0000 (UTC)", "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t31 Jul 2018 21:04:51 -0700", "from lnahar-mobl.amr.corp.intel.com (HELO\n\tavenkata-mobl4.localdomain) ([10.252.134.1])\n\tby FMSMGA003.fm.intel.com with ESMTP; 31 Jul 2018 21:04:51 -0700" ], "X-Virus-Scanned": [ "amavisd-new at osuosl.org", "amavisd-new at osuosl.org" ], "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6", "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.51,430,1526367600\"; d=\"scan'208\";a=\"69105120\"", "From": "Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>", "To": "intel-wired-lan@lists.osuosl.org", "Date": "Tue, 31 Jul 2018 21:04:29 -0700", "Message-Id": "<20180801040433.5865-10-anirudh.venkataramanan@intel.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20180801040433.5865-1-anirudh.venkataramanan@intel.com>", "References": "<20180801040433.5865-1-anirudh.venkataramanan@intel.com>", "Subject": "[Intel-wired-lan] [PATCH v2 09/13] ice: Add support for Tx hang,\n\tTx timeout and malicious driver detection", "X-BeenThere": "intel-wired-lan@osuosl.org", "X-Mailman-Version": "2.1.24", "Precedence": "list", "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>", "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>", "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>", "List-Post": "<mailto:intel-wired-lan@osuosl.org>", "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>", "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "intel-wired-lan-bounces@osuosl.org", "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>" }, "content": "From: Sudheer Mogilappagari <sudheer.mogilappagari@intel.com>\n\nWhen a malicious operation is detected, the firmware triggers an\ninterrupt, which is then picked up by the service task (specifically by\nice_handle_mdd_event). A reset is scheduled if required.\n\nTx hang detection works in a similar way, except the logic here monitors\nthe VSI's Tx queues and tries to revive them if stalled. If the hang is\nnot resolved, the kernel eventually calls ndo_tx_timeout, which is\nhandled by ice_tx_timeout.\n\nSigned-off-by: Sudheer Mogilappagari <sudheer.mogilappagari@intel.com>\nSigned-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>\n---\n[Anirudh Venkataramanan <anirudh.venkataramanan@intel.com> cleaned up commit message]\n---\n drivers/net/ethernet/intel/ice/ice.h | 4 +\n .../net/ethernet/intel/ice/ice_hw_autogen.h | 39 +++\n drivers/net/ethernet/intel/ice/ice_main.c | 286 ++++++++++++++++++\n drivers/net/ethernet/intel/ice/ice_txrx.c | 1 +\n drivers/net/ethernet/intel/ice/ice_txrx.h | 1 +\n 5 files changed, 331 insertions(+)", "diff": "diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h\nindex e17030db0bee..6f44a850c4b2 100644\n--- a/drivers/net/ethernet/intel/ice/ice.h\n+++ b/drivers/net/ethernet/intel/ice/ice.h\n@@ -134,6 +134,7 @@ enum ice_state {\n \t__ICE_SUSPENDED,\t\t/* set on module remove path */\n \t__ICE_RESET_FAILED,\t\t/* set by reset/rebuild */\n \t__ICE_ADMINQ_EVENT_PENDING,\n+\t__ICE_MDD_EVENT_PENDING,\n \t__ICE_FLTR_OVERFLOW_PROMISC,\n \t__ICE_CFG_BUSY,\n \t__ICE_SERVICE_SCHED,\n@@ -272,6 +273,9 @@ struct ice_pf {\n \tstruct ice_hw_port_stats stats_prev;\n \tstruct ice_hw hw;\n \tu8 stat_prev_loaded;\t/* has previous stats been loaded */\n+\tu32 tx_timeout_count;\n+\tunsigned long tx_timeout_last_recovery;\n+\tu32 tx_timeout_recovery_level;\n \tchar int_name[ICE_INT_NAME_STR_LEN];\n };\n \ndiff --git a/drivers/net/ethernet/intel/ice/ice_hw_autogen.h b/drivers/net/ethernet/intel/ice/ice_hw_autogen.h\nindex 067ca26a1d94..88f11498804b 100644\n--- a/drivers/net/ethernet/intel/ice/ice_hw_autogen.h\n+++ b/drivers/net/ethernet/intel/ice/ice_hw_autogen.h\n@@ -123,6 +123,45 @@\n #define QRX_CTRL_QENA_STAT_M\t\t\tBIT(2)\n #define QRX_ITR(_QRX)\t\t\t\t(0x00292000 + ((_QRX) * 4))\n #define QRX_TAIL(_QRX)\t\t\t\t(0x00290000 + ((_QRX) * 4))\n+#define QRX_TAIL_MAX_INDEX\t\t\t2047\n+#define QRX_TAIL_TAIL_S\t\t\t\t0\n+#define QRX_TAIL_TAIL_M\t\t\t\tICE_M(0x1FFF, 0)\n+#define GL_MDET_RX\t\t\t\t0x00294C00\n+#define GL_MDET_RX_QNUM_S\t\t\t0\n+#define GL_MDET_RX_QNUM_M\t\t\tICE_M(0x7FFF, 0)\n+#define GL_MDET_RX_VF_NUM_S\t\t\t15\n+#define GL_MDET_RX_VF_NUM_M\t\t\tICE_M(0xFF, 15)\n+#define GL_MDET_RX_PF_NUM_S\t\t\t23\n+#define GL_MDET_RX_PF_NUM_M\t\t\tICE_M(0x7, 23)\n+#define GL_MDET_RX_MAL_TYPE_S\t\t\t26\n+#define GL_MDET_RX_MAL_TYPE_M\t\t\tICE_M(0x1F, 26)\n+#define GL_MDET_RX_VALID_M\t\t\tBIT(31)\n+#define GL_MDET_TX_PQM\t\t\t\t0x002D2E00\n+#define GL_MDET_TX_PQM_PF_NUM_S\t\t\t0\n+#define GL_MDET_TX_PQM_PF_NUM_M\t\t\tICE_M(0x7, 0)\n+#define GL_MDET_TX_PQM_VF_NUM_S\t\t\t4\n+#define GL_MDET_TX_PQM_VF_NUM_M\t\t\tICE_M(0xFF, 4)\n+#define GL_MDET_TX_PQM_QNUM_S\t\t\t12\n+#define GL_MDET_TX_PQM_QNUM_M\t\t\tICE_M(0x3FFF, 12)\n+#define GL_MDET_TX_PQM_MAL_TYPE_S\t\t26\n+#define GL_MDET_TX_PQM_MAL_TYPE_M\t\tICE_M(0x1F, 26)\n+#define GL_MDET_TX_PQM_VALID_M\t\t\tBIT(31)\n+#define GL_MDET_TX_TCLAN\t\t\t0x000FC068\n+#define GL_MDET_TX_TCLAN_QNUM_S\t\t\t0\n+#define GL_MDET_TX_TCLAN_QNUM_M\t\t\tICE_M(0x7FFF, 0)\n+#define GL_MDET_TX_TCLAN_VF_NUM_S\t\t15\n+#define GL_MDET_TX_TCLAN_VF_NUM_M\t\tICE_M(0xFF, 15)\n+#define GL_MDET_TX_TCLAN_PF_NUM_S\t\t23\n+#define GL_MDET_TX_TCLAN_PF_NUM_M\t\tICE_M(0x7, 23)\n+#define GL_MDET_TX_TCLAN_MAL_TYPE_S\t\t26\n+#define GL_MDET_TX_TCLAN_MAL_TYPE_M\t\tICE_M(0x1F, 26)\n+#define GL_MDET_TX_TCLAN_VALID_M\t\tBIT(31)\n+#define PF_MDET_RX\t\t\t\t0x00294280\n+#define PF_MDET_RX_VALID_M\t\t\tBIT(0)\n+#define PF_MDET_TX_PQM\t\t\t\t0x002D2C80\n+#define PF_MDET_TX_PQM_VALID_M\t\t\tBIT(0)\n+#define PF_MDET_TX_TCLAN\t\t\t0x000FC000\n+#define PF_MDET_TX_TCLAN_VALID_M\t\tBIT(0)\n #define GLNVM_FLA\t\t\t\t0x000B6108\n #define GLNVM_FLA_LOCKED_M\t\t\tBIT(6)\n #define GLNVM_GENS\t\t\t\t0x000B6100\ndiff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c\nindex 60f988bfcc95..1e42833d8337 100644\n--- a/drivers/net/ethernet/intel/ice/ice_main.c\n+++ b/drivers/net/ethernet/intel/ice/ice_main.c\n@@ -36,6 +36,81 @@ static void ice_vsi_release_all(struct ice_pf *pf);\n static void ice_update_vsi_stats(struct ice_vsi *vsi);\n static void ice_update_pf_stats(struct ice_pf *pf);\n \n+/**\n+ * ice_get_tx_pending - returns number of Tx descriptors not processed\n+ * @ring: the ring of descriptors\n+ */\n+static u32 ice_get_tx_pending(struct ice_ring *ring)\n+{\n+\tu32 head, tail;\n+\n+\thead = ring->next_to_clean;\n+\ttail = readl(ring->tail);\n+\n+\tif (head != tail)\n+\t\treturn (head < tail) ?\n+\t\t\ttail - head : (tail + ring->count - head);\n+\treturn 0;\n+}\n+\n+/**\n+ * ice_check_for_hang_subtask - check for and recover hung queues\n+ * @pf: pointer to PF struct\n+ */\n+static void ice_check_for_hang_subtask(struct ice_pf *pf)\n+{\n+\tstruct ice_vsi *vsi = NULL;\n+\tunsigned int i;\n+\tu32 v, v_idx;\n+\tint packets;\n+\n+\tice_for_each_vsi(pf, v)\n+\t\tif (pf->vsi[v] && pf->vsi[v]->type == ICE_VSI_PF) {\n+\t\t\tvsi = pf->vsi[v];\n+\t\t\tbreak;\n+\t\t}\n+\n+\tif (!vsi || test_bit(__ICE_DOWN, vsi->state))\n+\t\treturn;\n+\n+\tif (!(vsi->netdev && netif_carrier_ok(vsi->netdev)))\n+\t\treturn;\n+\n+\tfor (i = 0; i < vsi->num_txq; i++) {\n+\t\tstruct ice_ring *tx_ring = vsi->tx_rings[i];\n+\n+\t\tif (tx_ring && tx_ring->desc) {\n+\t\t\tint itr = ICE_ITR_NONE;\n+\n+\t\t\t/* If packet counter has not changed the queue is\n+\t\t\t * likely stalled, so force an interrupt for this\n+\t\t\t * queue.\n+\t\t\t *\n+\t\t\t * prev_pkt would be negative if there was no\n+\t\t\t * pending work.\n+\t\t\t */\n+\t\t\tpackets = tx_ring->stats.pkts & INT_MAX;\n+\t\t\tif (tx_ring->tx_stats.prev_pkt == packets) {\n+\t\t\t\t/* Trigger sw interrupt to revive the queue */\n+\t\t\t\tv_idx = tx_ring->q_vector->v_idx;\n+\t\t\t\twr32(&vsi->back->hw,\n+\t\t\t\t GLINT_DYN_CTL(vsi->base_vector + v_idx),\n+\t\t\t\t (itr << GLINT_DYN_CTL_ITR_INDX_S) |\n+\t\t\t\t GLINT_DYN_CTL_SWINT_TRIG_M |\n+\t\t\t\t GLINT_DYN_CTL_INTENA_MSK_M);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\t/* Memory barrier between read of packet count and call\n+\t\t\t * to ice_get_tx_pending()\n+\t\t\t */\n+\t\t\tsmp_rmb();\n+\t\t\ttx_ring->tx_stats.prev_pkt =\n+\t\t\t ice_get_tx_pending(tx_ring) ? packets : -1;\n+\t\t}\n+\t}\n+}\n+\n /**\n * ice_get_free_slot - get the next non-NULL location index in array\n * @array: array to search\n@@ -1003,6 +1078,114 @@ static void ice_service_timer(struct timer_list *t)\n \tice_service_task_schedule(pf);\n }\n \n+/**\n+ * ice_handle_mdd_event - handle malicious driver detect event\n+ * @pf: pointer to the PF structure\n+ *\n+ * Called from service task. OICR interrupt handler indicates MDD event\n+ */\n+static void ice_handle_mdd_event(struct ice_pf *pf)\n+{\n+\tstruct ice_hw *hw = &pf->hw;\n+\tbool mdd_detected = false;\n+\tu32 reg;\n+\n+\tif (!test_bit(__ICE_MDD_EVENT_PENDING, pf->state))\n+\t\treturn;\n+\n+\t/* find what triggered the MDD event */\n+\treg = rd32(hw, GL_MDET_TX_PQM);\n+\tif (reg & GL_MDET_TX_PQM_VALID_M) {\n+\t\tu8 pf_num = (reg & GL_MDET_TX_PQM_PF_NUM_M) >>\n+\t\t\t\tGL_MDET_TX_PQM_PF_NUM_S;\n+\t\tu16 vf_num = (reg & GL_MDET_TX_PQM_VF_NUM_M) >>\n+\t\t\t\tGL_MDET_TX_PQM_VF_NUM_S;\n+\t\tu8 event = (reg & GL_MDET_TX_PQM_MAL_TYPE_M) >>\n+\t\t\t\tGL_MDET_TX_PQM_MAL_TYPE_S;\n+\t\tu16 queue = ((reg & GL_MDET_TX_PQM_QNUM_M) >>\n+\t\t\t\tGL_MDET_TX_PQM_QNUM_S);\n+\n+\t\tif (netif_msg_tx_err(pf))\n+\t\t\tdev_info(&pf->pdev->dev, \"Malicious Driver Detection event %d on TX queue %d PF# %d VF# %d\\n\",\n+\t\t\t\t event, queue, pf_num, vf_num);\n+\t\twr32(hw, GL_MDET_TX_PQM, 0xffffffff);\n+\t\tmdd_detected = true;\n+\t}\n+\n+\treg = rd32(hw, GL_MDET_TX_TCLAN);\n+\tif (reg & GL_MDET_TX_TCLAN_VALID_M) {\n+\t\tu8 pf_num = (reg & GL_MDET_TX_TCLAN_PF_NUM_M) >>\n+\t\t\t\tGL_MDET_TX_TCLAN_PF_NUM_S;\n+\t\tu16 vf_num = (reg & GL_MDET_TX_TCLAN_VF_NUM_M) >>\n+\t\t\t\tGL_MDET_TX_TCLAN_VF_NUM_S;\n+\t\tu8 event = (reg & GL_MDET_TX_TCLAN_MAL_TYPE_M) >>\n+\t\t\t\tGL_MDET_TX_TCLAN_MAL_TYPE_S;\n+\t\tu16 queue = ((reg & GL_MDET_TX_TCLAN_QNUM_M) >>\n+\t\t\t\tGL_MDET_TX_TCLAN_QNUM_S);\n+\n+\t\tif (netif_msg_rx_err(pf))\n+\t\t\tdev_info(&pf->pdev->dev, \"Malicious Driver Detection event %d on TX queue %d PF# %d VF# %d\\n\",\n+\t\t\t\t event, queue, pf_num, vf_num);\n+\t\twr32(hw, GL_MDET_TX_TCLAN, 0xffffffff);\n+\t\tmdd_detected = true;\n+\t}\n+\n+\treg = rd32(hw, GL_MDET_RX);\n+\tif (reg & GL_MDET_RX_VALID_M) {\n+\t\tu8 pf_num = (reg & GL_MDET_RX_PF_NUM_M) >>\n+\t\t\t\tGL_MDET_RX_PF_NUM_S;\n+\t\tu16 vf_num = (reg & GL_MDET_RX_VF_NUM_M) >>\n+\t\t\t\tGL_MDET_RX_VF_NUM_S;\n+\t\tu8 event = (reg & GL_MDET_RX_MAL_TYPE_M) >>\n+\t\t\t\tGL_MDET_RX_MAL_TYPE_S;\n+\t\tu16 queue = ((reg & GL_MDET_RX_QNUM_M) >>\n+\t\t\t\tGL_MDET_RX_QNUM_S);\n+\n+\t\tif (netif_msg_rx_err(pf))\n+\t\t\tdev_info(&pf->pdev->dev, \"Malicious Driver Detection event %d on RX queue %d PF# %d VF# %d\\n\",\n+\t\t\t\t event, queue, pf_num, vf_num);\n+\t\twr32(hw, GL_MDET_RX, 0xffffffff);\n+\t\tmdd_detected = true;\n+\t}\n+\n+\tif (mdd_detected) {\n+\t\tbool pf_mdd_detected = false;\n+\n+\t\treg = rd32(hw, PF_MDET_TX_PQM);\n+\t\tif (reg & PF_MDET_TX_PQM_VALID_M) {\n+\t\t\twr32(hw, PF_MDET_TX_PQM, 0xFFFF);\n+\t\t\tdev_info(&pf->pdev->dev, \"TX driver issue detected, PF reset issued\\n\");\n+\t\t\tpf_mdd_detected = true;\n+\t\t}\n+\n+\t\treg = rd32(hw, PF_MDET_TX_TCLAN);\n+\t\tif (reg & PF_MDET_TX_TCLAN_VALID_M) {\n+\t\t\twr32(hw, PF_MDET_TX_TCLAN, 0xFFFF);\n+\t\t\tdev_info(&pf->pdev->dev, \"TX driver issue detected, PF reset issued\\n\");\n+\t\t\tpf_mdd_detected = true;\n+\t\t}\n+\n+\t\treg = rd32(hw, PF_MDET_RX);\n+\t\tif (reg & PF_MDET_RX_VALID_M) {\n+\t\t\twr32(hw, PF_MDET_RX, 0xFFFF);\n+\t\t\tdev_info(&pf->pdev->dev, \"RX driver issue detected, PF reset issued\\n\");\n+\t\t\tpf_mdd_detected = true;\n+\t\t}\n+\t\t/* Queue belongs to the PF initiate a reset */\n+\t\tif (pf_mdd_detected) {\n+\t\t\tset_bit(__ICE_NEEDS_RESTART, pf->state);\n+\t\t\tice_service_task_schedule(pf);\n+\t\t}\n+\t}\n+\n+\t/* re-enable MDD interrupt cause */\n+\tclear_bit(__ICE_MDD_EVENT_PENDING, pf->state);\n+\treg = rd32(hw, PFINT_OICR_ENA);\n+\treg |= PFINT_OICR_MAL_DETECT_M;\n+\twr32(hw, PFINT_OICR_ENA, reg);\n+\tice_flush(hw);\n+}\n+\n /**\n * ice_service_task - manage and run subtasks\n * @work: pointer to work_struct contained by the PF struct\n@@ -1025,7 +1208,9 @@ static void ice_service_task(struct work_struct *work)\n \t\treturn;\n \t}\n \n+\tice_check_for_hang_subtask(pf);\n \tice_sync_fltr_subtask(pf);\n+\tice_handle_mdd_event(pf);\n \tice_watchdog_subtask(pf);\n \tice_clean_adminq_subtask(pf);\n \n@@ -1037,6 +1222,7 @@ static void ice_service_task(struct work_struct *work)\n \t * schedule the service task now.\n \t */\n \tif (time_after(jiffies, (start_time + pf->serv_tmr_period)) ||\n+\t test_bit(__ICE_MDD_EVENT_PENDING, pf->state) ||\n \t test_bit(__ICE_ADMINQ_EVENT_PENDING, pf->state))\n \t\tmod_timer(&pf->serv_tmr, jiffies);\n }\n@@ -1745,8 +1931,14 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)\n \toicr = rd32(hw, PFINT_OICR);\n \tena_mask = rd32(hw, PFINT_OICR_ENA);\n \n+\tif (oicr & PFINT_OICR_MAL_DETECT_M) {\n+\t\tena_mask &= ~PFINT_OICR_MAL_DETECT_M;\n+\t\tset_bit(__ICE_MDD_EVENT_PENDING, pf->state);\n+\t}\n+\n \tif (oicr & PFINT_OICR_GRST_M) {\n \t\tu32 reset;\n+\n \t\t/* we have a reset warning */\n \t\tena_mask &= ~PFINT_OICR_GRST_M;\n \t\treset = (rd32(hw, GLGEN_RSTAT) & GLGEN_RSTAT_RESET_TYPE_M) >>\n@@ -5501,6 +5693,99 @@ int ice_get_rss(struct ice_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size)\n \treturn 0;\n }\n \n+/**\n+ * ice_tx_timeout - Respond to a Tx Hang\n+ * @netdev: network interface device structure\n+ */\n+static void ice_tx_timeout(struct net_device *netdev)\n+{\n+\tstruct ice_netdev_priv *np = netdev_priv(netdev);\n+\tstruct ice_ring *tx_ring = NULL;\n+\tstruct ice_vsi *vsi = np->vsi;\n+\tstruct ice_pf *pf = vsi->back;\n+\tu32 head, val = 0, i;\n+\tint hung_queue = -1;\n+\n+\tpf->tx_timeout_count++;\n+\n+\t/* find the stopped queue the same way the stack does */\n+\tfor (i = 0; i < netdev->num_tx_queues; i++) {\n+\t\tstruct netdev_queue *q;\n+\t\tunsigned long trans_start;\n+\n+\t\tq = netdev_get_tx_queue(netdev, i);\n+\t\ttrans_start = q->trans_start;\n+\t\tif (netif_xmit_stopped(q) &&\n+\t\t time_after(jiffies,\n+\t\t\t (trans_start + netdev->watchdog_timeo))) {\n+\t\t\thung_queue = i;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\tif (i == netdev->num_tx_queues) {\n+\t\tnetdev_info(netdev, \"tx_timeout: no netdev hung queue found\\n\");\n+\t} else {\n+\t\t/* now that we have an index, find the tx_ring struct */\n+\t\tfor (i = 0; i < vsi->num_txq; i++) {\n+\t\t\tif (vsi->tx_rings[i] && vsi->tx_rings[i]->desc) {\n+\t\t\t\tif (hung_queue ==\n+\t\t\t\t vsi->tx_rings[i]->q_index) {\n+\t\t\t\t\ttx_ring = vsi->tx_rings[i];\n+\t\t\t\t\tbreak;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\t/* Reset recovery level if enough time has elapsed after last timeout.\n+\t * Also ensure no new reset action happens before next timeout period.\n+\t */\n+\tif (time_after(jiffies, (pf->tx_timeout_last_recovery + HZ * 20)))\n+\t\tpf->tx_timeout_recovery_level = 1;\n+\telse if (time_before(jiffies, (pf->tx_timeout_last_recovery +\n+\t\t\t\t netdev->watchdog_timeo)))\n+\t\treturn;\n+\n+\tif (tx_ring) {\n+\t\thead = tx_ring->next_to_clean;\n+\t\t/* Read interrupt register */\n+\t\tif (test_bit(ICE_FLAG_MSIX_ENA, pf->flags))\n+\t\t\tval = rd32(&pf->hw,\n+\t\t\t\t GLINT_DYN_CTL(tx_ring->q_vector->v_idx +\n+\t\t\t\t\t\ttx_ring->vsi->base_vector - 1));\n+\n+\t\tnetdev_info(netdev, \"tx_timeout: VSI_num: %d, Q %d, NTC: 0x%x, HWB: 0x%x, NTU: 0x%x, TAIL: 0x%x, INT: 0x%x\\n\",\n+\t\t\t vsi->vsi_num, hung_queue, tx_ring->next_to_clean,\n+\t\t\t head, tx_ring->next_to_use,\n+\t\t\t readl(tx_ring->tail), val);\n+\t}\n+\n+\tpf->tx_timeout_last_recovery = jiffies;\n+\tnetdev_info(netdev, \"tx_timeout recovery level %d, hung_queue %d\\n\",\n+\t\t pf->tx_timeout_recovery_level, hung_queue);\n+\n+\tswitch (pf->tx_timeout_recovery_level) {\n+\tcase 1:\n+\t\tset_bit(__ICE_PFR_REQ, pf->state);\n+\t\tbreak;\n+\tcase 2:\n+\t\tset_bit(__ICE_CORER_REQ, pf->state);\n+\t\tbreak;\n+\tcase 3:\n+\t\tset_bit(__ICE_GLOBR_REQ, pf->state);\n+\t\tbreak;\n+\tdefault:\n+\t\tnetdev_err(netdev, \"tx_timeout recovery unsuccessful, device is in unrecoverable state.\\n\");\n+\t\tset_bit(__ICE_DOWN, pf->state);\n+\t\tset_bit(__ICE_NEEDS_RESTART, vsi->state);\n+\t\tbreak;\n+\t}\n+\n+\tice_service_task_schedule(pf);\n+\tpf->tx_timeout_recovery_level++;\n+}\n+\n /**\n * ice_open - Called when a network interface becomes active\n * @netdev: network interface device structure\n@@ -5622,4 +5907,5 @@ static const struct net_device_ops ice_netdev_ops = {\n \t.ndo_set_features = ice_set_features,\n \t.ndo_fdb_add = ice_fdb_add,\n \t.ndo_fdb_del = ice_fdb_del,\n+\t.ndo_tx_timeout = ice_tx_timeout,\n };\ndiff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c\nindex 6481e3d86374..5dae968d853e 100644\n--- a/drivers/net/ethernet/intel/ice/ice_txrx.c\n+++ b/drivers/net/ethernet/intel/ice/ice_txrx.c\n@@ -251,6 +251,7 @@ int ice_setup_tx_ring(struct ice_ring *tx_ring)\n \n \ttx_ring->next_to_use = 0;\n \ttx_ring->next_to_clean = 0;\n+\ttx_ring->tx_stats.prev_pkt = -1;\n \treturn 0;\n \n err:\ndiff --git a/drivers/net/ethernet/intel/ice/ice_txrx.h b/drivers/net/ethernet/intel/ice/ice_txrx.h\nindex 31bc998fe200..839fd9ff6043 100644\n--- a/drivers/net/ethernet/intel/ice/ice_txrx.h\n+++ b/drivers/net/ethernet/intel/ice/ice_txrx.h\n@@ -71,6 +71,7 @@ struct ice_txq_stats {\n \tu64 restart_q;\n \tu64 tx_busy;\n \tu64 tx_linearize;\n+\tint prev_pkt; /* negative if no pending Tx descriptors */\n };\n \n struct ice_rxq_stats {\n", "prefixes": [ "v2", "09/13" ] }