get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/772050/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 772050,
    "url": "http://patchwork.ozlabs.org/api/patches/772050/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1496757688-63479-1-git-send-email-paul.greenwalt@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": "<1496757688-63479-1-git-send-email-paul.greenwalt@intel.com>",
    "list_archive_url": null,
    "date": "2017-06-06T14:01:28",
    "name": "ixgbe: Add malicious driver detection support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "3fa09d4d74b9976979fd0301ab0332a4d788ff3a",
    "submitter": {
        "id": 71166,
        "url": "http://patchwork.ozlabs.org/api/people/71166/?format=api",
        "name": "Paul Greenwalt",
        "email": "paul.greenwalt@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/1496757688-63479-1-git-send-email-paul.greenwalt@intel.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/772050/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/772050/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"
        ],
        "Received": [
            "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\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 3wj4BX5kCkz9ryQ\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed,  7 Jun 2017 07:12:04 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 4AFEB3055A;\n\tTue,  6 Jun 2017 21:12:03 +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 L3d-yRMzqk8q; Tue,  6 Jun 2017 21:12:01 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id ED5AF30490;\n\tTue,  6 Jun 2017 21:12:01 +0000 (UTC)",
            "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\tby ash.osuosl.org (Postfix) with ESMTP id 5B2411C07B7\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue,  6 Jun 2017 21:12:01 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 4B4AC872B3\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue,  6 Jun 2017 21:12:01 +0000 (UTC)",
            "from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 3czIeGX1L8rK for <intel-wired-lan@lists.osuosl.org>;\n\tTue,  6 Jun 2017 21:12:00 +0000 (UTC)",
            "from mga04.intel.com (mga04.intel.com [192.55.52.120])\n\tby whitealder.osuosl.org (Postfix) with ESMTPS id 43F39873D3\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue,  6 Jun 2017 21:12:00 +0000 (UTC)",
            "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t06 Jun 2017 14:11:59 -0700",
            "from unknown (HELO localhost.jf.intel.com) ([10.166.152.55])\n\tby FMSMGA003.fm.intel.com with ESMTP; 06 Jun 2017 14:11:59 -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-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.39,308,1493708400\"; d=\"scan'208\";a=\"865246749\"",
        "From": "Paul Greenwalt <paul.greenwalt@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org",
        "Date": "Tue,  6 Jun 2017 10:01:28 -0400",
        "Message-Id": "<1496757688-63479-1-git-send-email-paul.greenwalt@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "Subject": "[Intel-wired-lan] [PATCH] ixgbe: Add malicious driver detection\n\tsupport",
        "X-BeenThere": "intel-wired-lan@osuosl.org",
        "X-Mailman-Version": "2.1.18-1",
        "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": "Add malicious driver detection (MDD) support for X550, X550em_a,\nand X550em_x devices.\n\nMDD is a hardware SR-IOV security feature which the driver enables by\ndefault, but can be controlled on|off by ethtool set-priv-flags\nparameter. When enabled MDD disables a VF drivers transmit queue\nwhen a malformed descriptor is detected. The PF will log the event\nand re-enable the VF queue.\n\nSigned-off-by: Paul Greenwalt <paul.greenwalt@intel.com>\n---\n drivers/net/ethernet/intel/ixgbe/ixgbe.h         |   3 +\n drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c  |  25 +++-\n drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c |  13 ++-\n drivers/net/ethernet/intel/ixgbe/ixgbe_main.c    |   6 +\n drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c   |  50 ++++++++\n drivers/net/ethernet/intel/ixgbe/ixgbe_type.h    |   8 ++\n drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c    | 138 +++++++++++++++++++++++\n 7 files changed, 241 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h\nindex dd55787..2e9df66 100644\n--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h\n+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h\n@@ -563,6 +563,8 @@ struct ixgbe_mac_addr {\n #define IXGBE_TRY_LINK_TIMEOUT (4 * HZ)\n #define IXGBE_SFP_POLL_JIFFIES (2 * HZ)\t/* SFP poll every 2 seconds */\n \n+#define IXGBE_MDD_Q_BITMAP_DEPTH 2\n+\n /* board specific private data structure */\n struct ixgbe_adapter {\n \tunsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];\n@@ -603,6 +605,7 @@ struct ixgbe_adapter {\n #define IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER\tBIT(26)\n #define IXGBE_FLAG_DCB_CAPABLE\t\t\tBIT(27)\n #define IXGBE_FLAG_GENEVE_OFFLOAD_CAPABLE\tBIT(28)\n+#define IXGBE_FLAG_MDD_ENABLED\t\t\tBIT(29)\n \n \tu32 flags2;\n #define IXGBE_FLAG2_RSC_CAPABLE\t\t\tBIT(0)\ndiff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c\nindex 78c5237..d37d2b0 100644\n--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c\n+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c\n@@ -379,10 +379,22 @@ static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)\n \t\t} else {\n \t\t\thw->mac.ops.fc_enable(hw);\n \t\t}\n+\t\t/* Disable MDD before updating SRRCTL, because modifying the\n+\t\t * SRRCTL register while the queue is enabled will generate an\n+\t\t * MDD event.\n+\t\t */\n+\t\tif ((adapter->num_vfs) && (hw->mac.ops.disable_mdd) &&\n+\t\t    (adapter->flags & IXGBE_FLAG_MDD_ENABLED))\n+\t\t\thw->mac.ops.disable_mdd(hw);\n \n \t\tixgbe_set_rx_drop_en(adapter);\n \n-\t\tret = DCB_HW_CHG;\n+\t\tif ((adapter->num_vfs) && (hw->mac.ops.enable_mdd) &&\n+\t\t    (adapter->flags & IXGBE_FLAG_MDD_ENABLED))\n+\t\t\thw->mac.ops.enable_mdd(hw);\n+\n+\t\tif (ret != DCB_HW_CHG_RST)\n+\t\t\tret = DCB_HW_CHG;\n \t}\n \n #ifdef IXGBE_FCOE\n@@ -634,8 +646,19 @@ static int ixgbe_dcbnl_ieee_setpfc(struct net_device *dev,\n \telse\n \t\terr = hw->mac.ops.fc_enable(hw);\n \n+\t/* Disable MDD before updating SRRCTL, because modifying the SRRCTL\n+\t * register while the queue is enabled will generate an MDD event.\n+\t */\n+\tif ((adapter->num_vfs) && (hw->mac.ops.disable_mdd) &&\n+\t    (adapter->flags & IXGBE_FLAG_MDD_ENABLED))\n+\t\thw->mac.ops.disable_mdd(hw);\n+\n \tixgbe_set_rx_drop_en(adapter);\n \n+\tif ((adapter->num_vfs) && (hw->mac.ops.enable_mdd) &&\n+\t    (adapter->flags & IXGBE_FLAG_MDD_ENABLED))\n+\t\thw->mac.ops.enable_mdd(hw);\n+\n \treturn err;\n }\n \ndiff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c\nindex 2890e92..ea3a546 100644\n--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c\n+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c\n@@ -157,6 +157,8 @@ static const char ixgbe_gstrings_test[][ETH_GSTRING_LEN] = {\n static const char ixgbe_priv_flags_strings[][ETH_GSTRING_LEN] = {\n #define IXGBE_PRIV_FLAGS_LEGACY_RX\tBIT(0)\n \t\"legacy-rx\",\n+#define IXGBE_PRIV_FLAG_MDD_ENABLED\tBIT(1)\n+\t\"mdd\",\n };\n \n #define IXGBE_PRIV_FLAGS_STR_LEN ARRAY_SIZE(ixgbe_priv_flags_strings)\n@@ -3420,6 +3422,9 @@ static u32 ixgbe_get_priv_flags(struct net_device *netdev)\n \tstruct ixgbe_adapter *adapter = netdev_priv(netdev);\n \tu32 priv_flags = 0;\n \n+\tif (adapter->flags & IXGBE_FLAG_MDD_ENABLED)\n+\t\tpriv_flags |= IXGBE_PRIV_FLAG_MDD_ENABLED;\n+\n \tif (adapter->flags2 & IXGBE_FLAG2_RX_LEGACY)\n \t\tpriv_flags |= IXGBE_PRIV_FLAGS_LEGACY_RX;\n \n@@ -3430,13 +3435,19 @@ static int ixgbe_set_priv_flags(struct net_device *netdev, u32 priv_flags)\n {\n \tstruct ixgbe_adapter *adapter = netdev_priv(netdev);\n \tunsigned int flags2 = adapter->flags2;\n+\tunsigned int flags = adapter->flags;\n+\n+\tflags &= ~IXGBE_FLAG_MDD_ENABLED;\n+\tif (priv_flags & IXGBE_PRIV_FLAG_MDD_ENABLED)\n+\t\tflags |= IXGBE_FLAG_MDD_ENABLED;\n \n \tflags2 &= ~IXGBE_FLAG2_RX_LEGACY;\n \tif (priv_flags & IXGBE_PRIV_FLAGS_LEGACY_RX)\n \t\tflags2 |= IXGBE_FLAG2_RX_LEGACY;\n \n-\tif (flags2 != adapter->flags2) {\n+\tif (flags2 != adapter->flags2 || flags != adapter->flags) {\n \t\tadapter->flags2 = flags2;\n+\t\tadapter->flags = flags;\n \n \t\t/* reset interface to repopulate queues */\n \t\tif (netif_running(netdev))\ndiff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c\nindex c127faa..1d93dc0 100644\n--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c\n+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c\n@@ -6101,6 +6101,7 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter,\n \t\tadapter->flags &= ~IXGBE_FLAG_DCA_CAPABLE;\n #endif\n \t\tadapter->flags |= IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE;\n+\t\tadapter->flags |= IXGBE_FLAG_MDD_ENABLED;\n \t\tbreak;\n \tdefault:\n \t\tbreak;\n@@ -7227,6 +7228,11 @@ static void ixgbe_watchdog_link_is_up(struct ixgbe_adapter *adapter)\n \tnetif_carrier_on(netdev);\n \tixgbe_check_vf_rate_limit(adapter);\n \n+\t/* Turn on malicious driver detection */\n+\tif ((adapter->num_vfs) && (hw->mac.ops.enable_mdd) &&\n+\t    (adapter->flags & IXGBE_FLAG_MDD_ENABLED))\n+\t\thw->mac.ops.enable_mdd(hw);\n+\n \t/* enable transmits */\n \tnetif_tx_wake_all_queues(adapter->netdev);\n \ndiff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c\nindex 0760bd7..b77f992 100644\n--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c\n+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c\n@@ -257,6 +257,10 @@ int ixgbe_disable_sriov(struct ixgbe_adapter *adapter)\n \tif (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))\n \t\treturn 0;\n \n+\t/* Turn off malicious driver detection */\n+\tif ((hw->mac.ops.disable_mdd) &&\n+\t    (!(adapter->flags & IXGBE_FLAG_MDD_ENABLED)))\n+\t\thw->mac.ops.disable_mdd(hw);\n #ifdef CONFIG_PCI_IOV\n \t/*\n \t * If our VFs are assigned we cannot shut down SR-IOV\n@@ -1292,11 +1296,57 @@ static void ixgbe_rcv_ack_from_vf(struct ixgbe_adapter *adapter, u32 vf)\n \t\tixgbe_write_mbx(hw, &msg, 1, vf);\n }\n \n+static void ixgbe_check_mdd_event(struct ixgbe_adapter *adapter)\n+{\n+\tstruct ixgbe_hw *hw = &adapter->hw;\n+\tu32 vf_bitmap[IXGBE_MDD_Q_BITMAP_DEPTH] = { 0 };\n+\tu32 j, i;\n+\tu32 ping;\n+\n+\tif (!hw->mac.ops.mdd_event)\n+\t\treturn;\n+\n+\t/* Did we have a malicious event */\n+\thw->mac.ops.mdd_event(hw, vf_bitmap);\n+\n+\t/* Log any blocked queues and release lock */\n+\tfor (i = 0; i < IXGBE_MDD_Q_BITMAP_DEPTH; i++) {\n+\t\tfor (j = 0; j < 32 && vf_bitmap[i]; j++) {\n+\t\t\tu32 vf;\n+\n+\t\t\tif (!(vf_bitmap[i] & (1 << j)))\n+\t\t\t\tcontinue;\n+\n+\t\t\t/* The VF that malicious event occurred on */\n+\t\t\tvf = j + (i * 32);\n+\n+\t\t\tdev_warn(&adapter->pdev->dev,\n+\t\t\t\t \"Malicious event on VF %d tx:%x rx:%x\\n\", vf,\n+\t\t\t\t IXGBE_READ_REG(hw, IXGBE_LVMMC_TX),\n+\t\t\t\t IXGBE_READ_REG(hw, IXGBE_LVMMC_RX));\n+\n+\t\t\t/* restart the vf */\n+\t\t\tif (hw->mac.ops.restore_mdd_vf) {\n+\t\t\t\thw->mac.ops.restore_mdd_vf(hw, vf);\n+\n+\t\t\t\t/* get the VF to rebuild its queues */\n+\t\t\t\tadapter->vfinfo[vf].clear_to_send = 0;\n+\t\t\t\tping = IXGBE_PF_CONTROL_MSG |\n+\t\t\t\t       IXGBE_VT_MSGTYPE_CTS;\n+\t\t\t\tixgbe_write_mbx(hw, &ping, 1, vf);\n+\t\t\t}\n+\t\t}\n+\t}\n+}\n+\n void ixgbe_msg_task(struct ixgbe_adapter *adapter)\n {\n \tstruct ixgbe_hw *hw = &adapter->hw;\n \tu32 vf;\n \n+\tif (adapter->flags & IXGBE_FLAG_MDD_ENABLED && adapter->vfinfo)\n+\t\tixgbe_check_mdd_event(adapter);\n+\n \tfor (vf = 0; vf < adapter->num_vfs; vf++) {\n \t\t/* process any reset requests */\n \t\tif (!ixgbe_check_for_rst(hw, vf))\ndiff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h\nindex 9c2460c..805561c 100644\n--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h\n+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h\n@@ -380,6 +380,8 @@ struct ixgbe_thermal_sensor_data {\n #define IXGBE_MRCTL(_i)      (0x0F600 + ((_i) * 4))\n #define IXGBE_VMRVLAN(_i)    (0x0F610 + ((_i) * 4))\n #define IXGBE_VMRVM(_i)      (0x0F630 + ((_i) * 4))\n+#define IXGBE_LVMMC_RX\t     0x2FA8\n+#define IXGBE_LVMMC_TX\t     0x8108\n #define IXGBE_WQBR_RX(_i)    (0x2FB0 + ((_i) * 4)) /* 4 total */\n #define IXGBE_WQBR_TX(_i)    (0x8130 + ((_i) * 4)) /* 4 total */\n #define IXGBE_L34T_IMIR(_i)  (0x0E800 + ((_i) * 4)) /*128 of these (0-127)*/\n@@ -3462,6 +3464,12 @@ struct ixgbe_mac_operations {\n \ts32 (*dmac_config_tcs)(struct ixgbe_hw *hw);\n \ts32 (*read_iosf_sb_reg)(struct ixgbe_hw *, u32, u32, u32 *);\n \ts32 (*write_iosf_sb_reg)(struct ixgbe_hw *, u32, u32, u32);\n+\n+\t/* Malicious driver detection */\n+\tvoid (*disable_mdd)(struct ixgbe_hw *hw);\n+\tvoid (*enable_mdd)(struct ixgbe_hw *hw);\n+\tvoid (*mdd_event)(struct ixgbe_hw *hw, u32 *vf_bitmap);\n+\tvoid (*restore_mdd_vf)(struct ixgbe_hw *hw, u32 vf);\n };\n \n struct ixgbe_phy_operations {\ndiff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c\nindex 72d84a0..b90d676 100644\n--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c\n+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c\n@@ -3507,6 +3507,140 @@ static void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw,\n }\n \n /**\n+ *  ixgbe_disable_mdd_X550\n+ *  @hw: pointer to hardware structure\n+ *\n+ *  Disable malicious driver detection\n+ **/\n+void ixgbe_disable_mdd_X550(struct ixgbe_hw *hw)\n+{\n+\tu32 reg;\n+\n+\t/* Disable MDD for TX DMA and interrupt */\n+\treg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);\n+\treg &= ~(IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);\n+\tIXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);\n+\n+\t/* Disable MDD for RX and interrupt */\n+\treg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);\n+\treg &= ~(IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);\n+\tIXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);\n+}\n+\n+/**\n+ *  ixgbe_enable_mdd_X550\n+ *  @hw: pointer to hardware structure\n+ *\n+ *  Enable malicious driver detection\n+ **/\n+void ixgbe_enable_mdd_X550(struct ixgbe_hw *hw)\n+{\n+\tu32 reg;\n+\n+\t/* Enable MDD for TX DMA and interrupt */\n+\treg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);\n+\treg |= (IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);\n+\tIXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);\n+\n+\t/* Enable MDD for RX and interrupt */\n+\treg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);\n+\treg |= (IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);\n+\tIXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);\n+}\n+\n+/**\n+ *  ixgbe_restore_mdd_vf_X550\n+ *  @hw: pointer to hardware structure\n+ *  @vf: vf index\n+ *\n+ *  Restore VF that was disabled during malicious driver detection event\n+ **/\n+void ixgbe_restore_mdd_vf_X550(struct ixgbe_hw *hw, u32 vf)\n+{\n+\tu32 idx, reg, num_qs, start_q, bitmask;\n+\n+\t/* Map VF to queues */\n+\treg = IXGBE_READ_REG(hw, IXGBE_MRQC);\n+\tswitch (reg & IXGBE_MRQC_MRQE_MASK) {\n+\tcase IXGBE_MRQC_VMDQRT8TCEN:\n+\t\tnum_qs = 8;  /* 16 VFs / pools */\n+\t\tbitmask = 0x000000FF;\n+\t\tbreak;\n+\tcase IXGBE_MRQC_VMDQRSS32EN:\n+\tcase IXGBE_MRQC_VMDQRT4TCEN:\n+\t\tnum_qs = 4;  /* 32 VFs / pools */\n+\t\tbitmask = 0x0000000F;\n+\t\tbreak;\n+\tdefault:            /* 64 VFs / pools */\n+\t\tnum_qs = 2;\n+\t\tbitmask = 0x00000003;\n+\t\tbreak;\n+\t}\n+\tstart_q = vf * num_qs;\n+\n+\t/* Release vf's queues by clearing WQBR_TX and WQBR_RX (RW1C) */\n+\tidx = start_q / 32;\n+\treg = 0;\n+\treg |= (bitmask << (start_q % 32));\n+\tIXGBE_WRITE_REG(hw, IXGBE_WQBR_TX(idx), reg);\n+\tIXGBE_WRITE_REG(hw, IXGBE_WQBR_RX(idx), reg);\n+}\n+\n+/**\n+ *  ixgbe_mdd_event_X550\n+ *  @hw: pointer to hardware structure\n+ *  @vf_bitmap: vf bitmap of malicious vfs\n+ *\n+ *  Handle malicious driver detection event.\n+ **/\n+void ixgbe_mdd_event_X550(struct ixgbe_hw *hw, u32 *vf_bitmap)\n+{\n+\tu32 wqbr;\n+\tu32 i, j, reg, q, shift, vf, idx;\n+\n+\t/* figure out pool size for mapping to vf's */\n+\treg = IXGBE_READ_REG(hw, IXGBE_MRQC);\n+\tswitch (reg & IXGBE_MRQC_MRQE_MASK) {\n+\tcase IXGBE_MRQC_VMDQRT8TCEN:\n+\t\tshift = 3;  /* 16 VFs / pools */\n+\t\tbreak;\n+\tcase IXGBE_MRQC_VMDQRSS32EN:\n+\tcase IXGBE_MRQC_VMDQRT4TCEN:\n+\t\tshift = 2;  /* 32 VFs / pools */\n+\t\tbreak;\n+\tdefault:\n+\t\tshift = 1;  /* 64 VFs / pools */\n+\t\tbreak;\n+\t}\n+\n+\t/* Read WQBR_TX and WQBR_RX and check for malicious queues */\n+\tfor (i = 0; i < 4; i++) {\n+\t\twqbr = IXGBE_READ_REG(hw, IXGBE_WQBR_TX(i));\n+\t\twqbr |= IXGBE_READ_REG(hw, IXGBE_WQBR_RX(i));\n+\n+\t\tif (!wqbr)\n+\t\t\tcontinue;\n+\n+\t\t/* Get malicious queue */\n+\t\tfor (j = 0; j < 32 && wqbr; j++) {\n+\t\t\tif (!(wqbr & (1 << j)))\n+\t\t\t\tcontinue;\n+\n+\t\t\t/* Get queue from bitmask */\n+\t\t\tq = j + (i * 32);\n+\n+\t\t\t/* Map queue to vf */\n+\t\t\tvf = (q >> shift);\n+\n+\t\t\t/* Set vf bit in vf_bitmap */\n+\t\t\tidx = vf / 32;\n+\t\t\tvf_bitmap[idx] |= (1 << (vf % 32));\n+\t\t\twqbr &= ~(1 << j);\n+\t\t}\n+\t}\n+}\n+\n+/**\n  *  ixgbe_setup_fc_backplane_x550em_a - Set up flow control\n  *  @hw: pointer to hardware structure\n  *\n@@ -3791,6 +3925,10 @@ static s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,\n \t.init_thermal_sensor_thresh\t= NULL, \\\n \t.enable_rx\t\t\t= &ixgbe_enable_rx_generic, \\\n \t.disable_rx\t\t\t= &ixgbe_disable_rx_x550, \\\n+\t.enable_mdd                     = &ixgbe_enable_mdd_X550, \\\n+\t.disable_mdd                    = &ixgbe_disable_mdd_X550, \\\n+\t.mdd_event                      = &ixgbe_mdd_event_X550, \\\n+\t.restore_mdd_vf                 = &ixgbe_restore_mdd_vf_X550, \\\n \n static const struct ixgbe_mac_operations mac_ops_X550 = {\n \tX550_COMMON_MAC\n",
    "prefixes": []
}