get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 540138,
    "url": "http://patchwork.ozlabs.org/api/patches/540138/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1327466653.305871.1446575860238.JavaMail.zimbra@xes-inc.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": "<1327466653.305871.1446575860238.JavaMail.zimbra@xes-inc.com>",
    "list_archive_url": null,
    "date": "2015-11-03T18:37:40",
    "name": "[5/5] igb: Add I210 cable fault detection to self test",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "067db7c95be93affc263700bc32e11d9de1d5e22",
    "submitter": {
        "id": 10211,
        "url": "http://patchwork.ozlabs.org/api/people/10211/?format=api",
        "name": "Aaron Sierra",
        "email": "asierra@xes-inc.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/1327466653.305871.1446575860238.JavaMail.zimbra@xes-inc.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/540138/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/540138/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<intel-wired-lan-bounces@lists.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 hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\tby ozlabs.org (Postfix) with ESMTP id B65D41413DB\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu,  5 Nov 2015 05:59:31 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 09992939B8;\n\tWed,  4 Nov 2015 18:59:31 +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 xt7uYHH4DAzC; Wed,  4 Nov 2015 18:59:29 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id AD0AC939A6;\n\tWed,  4 Nov 2015 18:59:26 +0000 (UTC)",
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\tby ash.osuosl.org (Postfix) with ESMTP id 445261C15DE\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue,  3 Nov 2015 19:34:26 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 4100584294\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue,  3 Nov 2015 19:34:26 +0000 (UTC)",
            "from fraxinus.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id tljEb77medXF for <intel-wired-lan@lists.osuosl.org>;\n\tTue,  3 Nov 2015 19:34:25 +0000 (UTC)",
            "from xes-mad.com (xes-mad.com [216.165.139.218])\n\tby fraxinus.osuosl.org (Postfix) with ESMTPS id 65131841A0\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue,  3 Nov 2015 19:34:25 +0000 (UTC)",
            "from zimbra.xes-mad.com (zimbra.xes-mad.com [10.52.0.127])\n\tby xes-mad.com (8.13.8/8.13.8) with ESMTP id tA3Iberj028512;\n\tTue, 3 Nov 2015 12:37:40 -0600"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "from auto-whitelisted by SQLgrey-1.7.6",
        "Date": "Tue, 3 Nov 2015 12:37:40 -0600 (CST)",
        "From": "Aaron Sierra <asierra@xes-inc.com>",
        "To": "Jeff Kirsher <jeffrey.t.kirsher@intel.com>,\n\tintel-wired-lan@lists.osuosl.org",
        "Message-ID": "<1327466653.305871.1446575860238.JavaMail.zimbra@xes-inc.com>",
        "In-Reply-To": "<1611213829.304573.1446575372067.JavaMail.zimbra@xes-inc.com>",
        "MIME-Version": "1.0",
        "X-Originating-IP": "[10.52.16.65]",
        "X-Mailer": "Zimbra 8.0.6_GA_5922 (ZimbraWebClient - FF40 (Linux)/8.0.6_GA_5922)",
        "Thread-Topic": "Add I210 cable fault detection to self test",
        "Thread-Index": "6SmAb2eR8pHRSJ3Ix7jxGLgdpGmM8A==",
        "X-Mailman-Approved-At": "Wed, 04 Nov 2015 18:59:25 +0000",
        "Cc": "Joe Schultz <jschultz@xes-inc.com>",
        "Subject": "[Intel-wired-lan] [PATCH 5/5] igb: Add I210 cable fault detection\n\tto self test",
        "X-BeenThere": "intel-wired-lan@lists.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.lists.osuosl.org>",
        "List-Unsubscribe": "<http://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>",
        "List-Post": "<mailto:intel-wired-lan@lists.osuosl.org>",
        "List-Help": "<mailto:intel-wired-lan-request@lists.osuosl.org?subject=help>",
        "List-Subscribe": "<http://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "intel-wired-lan-bounces@lists.osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@lists.osuosl.org>"
    },
    "content": "From: Joe Schultz <jschultz@xes-inc.com>\n\nAdd an offline diagnostic test for the I210 internal PHY which checks\nfor cable faults and reports the distance along the cable where the\nfault was detected. Fault types detected include open, short, and\ncross-pair short.\n\nSigned-off-by: Joe Schultz <jschultz@xes-inc.com>\nSigned-off-by: Aaron Sierra <asierra@xes-inc.com>\n---\n drivers/net/ethernet/intel/igb/e1000_defines.h |  13 +-\n drivers/net/ethernet/intel/igb/igb_ethtool.c   | 192 ++++++++++++++++++++++++-\n 2 files changed, 199 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/igb/e1000_defines.h b/drivers/net/ethernet/intel/igb/e1000_defines.h\nindex 4ae3054..8effebf 100644\n--- a/drivers/net/ethernet/intel/igb/e1000_defines.h\n+++ b/drivers/net/ethernet/intel/igb/e1000_defines.h\n@@ -931,6 +931,7 @@\n #define I347AT4_PCDL1                  0x11 /* Pair 1 PHY Cable Diagnostics Length */\n #define I347AT4_PCDL2                  0x12 /* Pair 2 PHY Cable Diagnostics Length */\n #define I347AT4_PCDL3                  0x13 /* Pair 3 PHY Cable Diagnostics Length */\n+#define I347AT4_PCDR                   0x14 /* PHY Cable Diagnostics Results */\n #define I347AT4_PCDC                   0x15 /* PHY Cable Diagnostics Control */\n #define I347AT4_PAGE_SELECT            0x16\n \n@@ -951,7 +952,17 @@\n #define I347AT4_PSCR_DOWNSHIFT_8X     0x7000\n \n /* i347-AT4 PHY Cable Diagnostics Control */\n-#define I347AT4_PCDC_CABLE_LENGTH_UNIT 0x0400 /* 0=cm 1=meters */\n+#define I347AT4_PCDC_CABLE_LENGTH_UNIT\t0x0400 /* 0=cm 1=meters */\n+#define I347AT4_PCDC_CABLE_DIAG_STATUS\t0x0800\n+#define I347AT4_PCDC_DISABLE_CROSS_PAIR\t0x2000\n+#define I347AT4_PCDC_RUN_AT_AUTONEG\t0x4000\n+#define I347AT4_PCDC_RUN_TEST\t\t0x8000\n+\n+/* i347-AT4 PHY Cable Diagnostics Results */\n+#define I347AT4_PCDR_CABLE_OK\t\t0x0001 /* No faults detected on pair */\n+#define I347AT4_PCDR_CABLE_OPEN\t\t0x0002 /* Open pair detected */\n+#define I347AT4_PCDR_CABLE_SHORT\t0x0003 /* Shorted pair detected */\n+#define I347AT4_PCDR_CABLE_CROSS_SHORT\t0x0004 /* Cross-pair short detected */\n \n /* Marvell 1112 only registers */\n #define M88E1112_VCT_DSP_DISTANCE       0x001A\ndiff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c\nindex f5da885..96e6a20 100644\n--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c\n+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c\n@@ -132,7 +132,28 @@ enum igb_diagnostics_results {\n \tTEST_EEP,\n \tTEST_IRQ,\n \tTEST_LOOP,\n-\tTEST_LINK\n+\tTEST_LINK,\n+\t/* I210 superset */\n+\tTEST_FAULT_A,\n+\tTEST_FAULT_B,\n+\tTEST_FAULT_C,\n+\tTEST_FAULT_D,\n+\tTEST_LENGTH_A,\n+\tTEST_LENGTH_B,\n+\tTEST_LENGTH_C,\n+\tTEST_LENGTH_D,\n+\tTEST_OPEN_A,\n+\tTEST_OPEN_B,\n+\tTEST_OPEN_C,\n+\tTEST_OPEN_D,\n+\tTEST_SHORT_A,\n+\tTEST_SHORT_B,\n+\tTEST_SHORT_C,\n+\tTEST_SHORT_D,\n+\tTEST_CROSS_A,\n+\tTEST_CROSS_B,\n+\tTEST_CROSS_C,\n+\tTEST_CROSS_D\n };\n \n static const char igb_gstrings_test[][ETH_GSTRING_LEN] = {\n@@ -142,7 +163,50 @@ static const char igb_gstrings_test[][ETH_GSTRING_LEN] = {\n \t[TEST_LOOP] = \"Loopback test  (offline)\",\n \t[TEST_LINK] = \"Link test   (on/offline)\"\n };\n+\n+static const char igb_i210_gstrings_test[][ETH_GSTRING_LEN] = {\n+\t[TEST_REG]\t= \"Register test        (offline)\",\n+\t[TEST_EEP]\t= \"Eeprom test          (offline)\",\n+\t[TEST_IRQ]\t= \"Interrupt test       (offline)\",\n+\t[TEST_LOOP]\t= \"Loopback test        (offline)\",\n+\t[TEST_LINK]\t= \"Link test         (on/offline)\",\n+\t[TEST_FAULT_A]  = \"Pair A cable fault   (offline)\",\n+\t[TEST_FAULT_B]  = \"Pair B cable fault   (offline)\",\n+\t[TEST_FAULT_C]  = \"Pair C cable fault   (offline)\",\n+\t[TEST_FAULT_D]  = \"Pair D cable fault   (offline)\",\n+\t[TEST_LENGTH_A] = \"Pair A fault distance         \",\n+\t[TEST_LENGTH_B] = \"Pair B fault distance         \",\n+\t[TEST_LENGTH_C] = \"Pair C fault distance         \",\n+\t[TEST_LENGTH_D] = \"Pair D fault distance         \",\n+\t[TEST_OPEN_A]   = \"Pair A fault open             \",\n+\t[TEST_OPEN_B]   = \"Pair B fault open             \",\n+\t[TEST_OPEN_C]   = \"Pair C fault open             \",\n+\t[TEST_OPEN_D]   = \"Pair D fault open             \",\n+\t[TEST_SHORT_A]  = \"Pair A fault intra-pair short \",\n+\t[TEST_SHORT_B]  = \"Pair B fault intra-pair short \",\n+\t[TEST_SHORT_C]  = \"Pair C fault intra-pair short \",\n+\t[TEST_SHORT_D]  = \"Pair D fault intra-pair short \",\n+\t[TEST_CROSS_A]  = \"Pair A fault inter-pair short \",\n+\t[TEST_CROSS_B]  = \"Pair B fault inter-pair short \",\n+\t[TEST_CROSS_C]  = \"Pair C fault inter-pair short \",\n+\t[TEST_CROSS_D]  = \"Pair D fault inter-pair short \"\n+};\n+\n #define IGB_TEST_LEN (sizeof(igb_gstrings_test) / ETH_GSTRING_LEN)\n+#define IGB_I210_TEST_LEN (sizeof(igb_i210_gstrings_test) / ETH_GSTRING_LEN)\n+\n+static inline bool igb_has_i210_cable_fault_test(struct igb_adapter *adapter)\n+{\n+\tstruct e1000_hw *hw = &adapter->hw;\n+\n+\tif (hw->phy.media_type != e1000_media_type_copper)\n+\t\treturn false;\n+\n+\tif (hw->phy.id == I210_I_PHY_ID)\n+\t\treturn true;\n+\n+\treturn false;\n+}\n \n static int igb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)\n {\n@@ -853,7 +917,8 @@ static void igb_get_drvinfo(struct net_device *netdev,\n \tstrlcpy(drvinfo->bus_info, pci_name(adapter->pdev),\n \t\tsizeof(drvinfo->bus_info));\n \tdrvinfo->n_stats = IGB_STATS_LEN;\n-\tdrvinfo->testinfo_len = IGB_TEST_LEN;\n+\tdrvinfo->testinfo_len = igb_has_i210_cable_fault_test(adapter) ?\n+\t\tIGB_I210_TEST_LEN : IGB_TEST_LEN;\n \tdrvinfo->regdump_len = igb_get_regs_len(netdev);\n \tdrvinfo->eedump_len = igb_get_eeprom_len(netdev);\n }\n@@ -1987,6 +2052,104 @@ static int igb_link_test(struct igb_adapter *adapter, u64 *data)\n \treturn *data;\n }\n \n+static int igb_cable_fault_test_prep(struct igb_adapter *adapter)\n+{\n+\tstruct e1000_hw *hw = &adapter->hw;\n+\tu16 pcdc;\n+\ts32 ret_val;\n+\n+\tret_val = igb_write_phy_reg(hw, I347AT4_PAGE_SELECT, 0x7);\n+\tif (ret_val)\n+\t\tgoto done;\n+\n+\t/* Initiate diagnostics at next auto-negotiation */\n+\tpcdc = I347AT4_PCDC_CABLE_LENGTH_UNIT |\n+\t\tI347AT4_PCDC_RUN_AT_AUTONEG;\n+\n+\tret_val = igb_write_phy_reg(hw, I347AT4_PCDC, pcdc);\n+\n+done:\n+\tigb_write_phy_reg(hw, I347AT4_PAGE_SELECT, 0);\n+\treturn ret_val;\n+}\n+\n+static int igb_cable_fault_test(struct igb_adapter *adapter,\n+\t\t\t   struct ethtool_test *eth_test, u64 *data) {\n+\tstruct e1000_hw *hw = &adapter->hw;\n+\tu16 pcdc, pcdr;\n+\tu16 error_code = 0;\n+\tu32 timeout = 0;\n+\ts32 ret_val;\n+\tint i;\n+\n+\tret_val = igb_write_phy_reg(hw, I347AT4_PAGE_SELECT, 0x7);\n+\tif (ret_val)\n+\t\tgoto done;\n+\n+\tret_val = igb_write_phy_reg(hw, I347AT4_PCDC, pcdc);\n+\tif (ret_val)\n+\t\tgoto done;\n+\n+\t/* Wait up to 1.5s for the results to be ready */\n+\twhile (pcdc & I347AT4_PCDC_CABLE_DIAG_STATUS) {\n+\t\tret_val = igb_read_phy_reg(hw, I347AT4_PCDC, &pcdc);\n+\t\tif (ret_val || timeout == 1500)\n+\t\t\tbreak;\n+\t\tudelay(1000);\n+\t\ttimeout++;\n+\t}\n+\n+\tif (timeout >= 1500)\n+\t\tdev_warn(&adapter->pdev->dev,\n+\t\t\t\"Cable fault test timed out. Results may be invalid\");\n+\n+\tret_val = igb_read_phy_reg(hw, I347AT4_PCDR, &pcdr);\n+\tif (ret_val)\n+\t\tgoto done;\n+\n+\thw->phy.ops.get_cable_length(hw);\n+\n+\t/* Iterate over each cable pair */\n+\tfor (i = 0; i < 4; i++) {\n+\t\tdata[TEST_LENGTH_A + i] = hw->phy.pair_length[i];\n+\n+\t\terror_code = (pcdr >> (i * 4)) & 0xf;\n+\t\tswitch (error_code) {\n+\t\tcase I347AT4_PCDR_CABLE_OK:\n+\t\t\tdata[TEST_FAULT_A + i] = 0;\n+\t\t\tdata[TEST_LENGTH_A + i] = -1;\n+\t\t\t/* don't assign ret_val */\n+\t\t\tbreak;\n+\t\tcase I347AT4_PCDR_CABLE_OPEN:\n+\t\t\tdata[TEST_FAULT_A + i] = 1;\n+\t\t\tdata[TEST_OPEN_A + i] = 1;\n+\t\t\tret_val = -1;\n+\t\t\tbreak;\n+\t\tcase I347AT4_PCDR_CABLE_SHORT:\n+\t\t\tdata[TEST_FAULT_A + i] = 1;\n+\t\t\tdata[TEST_SHORT_A + i] = 1;\n+\t\t\tret_val = -1;\n+\t\t\tbreak;\n+\t\tcase I347AT4_PCDR_CABLE_CROSS_SHORT:\n+\t\t\tdata[TEST_FAULT_A + i] = 1;\n+\t\t\tdata[TEST_CROSS_A + i] = 1;\n+\t\t\tret_val = -1;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tdata[TEST_FAULT_A + i] = -1;\n+\t\t\tdata[TEST_LENGTH_A + i] = -1;\n+\t\t\tdata[TEST_OPEN_A + i] = -1;\n+\t\t\tdata[TEST_SHORT_A + i] = -1;\n+\t\t\tdata[TEST_CROSS_A + i] = -1;\n+\t\t\tret_val = -1;\n+\t\t}\n+\t}\n+\n+done:\n+\tigb_write_phy_reg(hw, I347AT4_PAGE_SELECT, 0);\n+\treturn ret_val;\n+}\n+\n static void igb_diag_test(struct net_device *netdev,\n \t\t\t  struct ethtool_test *eth_test, u64 *data)\n {\n@@ -1997,6 +2160,11 @@ static void igb_diag_test(struct net_device *netdev,\n \n \tset_bit(__IGB_TESTING, &adapter->state);\n \n+\tif (igb_has_i210_cable_fault_test(adapter)) {\n+\t\tmemset(&data[TEST_FAULT_A], 0x0,\n+\t\t\tsizeof(u64) * (IGB_I210_TEST_LEN - IGB_TEST_LEN));\n+\t}\n+\n \t/* can't do offline tests on media switching devices */\n \tif (adapter->hw.dev_spec._82575.mas_capable)\n \t\teth_test->flags &= ~ETH_TEST_FL_OFFLINE;\n@@ -2013,12 +2181,21 @@ static void igb_diag_test(struct net_device *netdev,\n \t\t/* power up link for link test */\n \t\tigb_power_up_link(adapter);\n \n+\t\tif (igb_has_i210_cable_fault_test(adapter))\n+\t\t\tigb_cable_fault_test_prep(adapter);\n+\n \t\t/* Link test performed before hardware reset so autoneg doesn't\n \t\t * interfere with test result\n \t\t */\n \t\tif (igb_link_test(adapter, &data[TEST_LINK]))\n \t\t\teth_test->flags |= ETH_TEST_FL_FAILED;\n \n+\t\t/* Test for cable faults before the PHY gets shut off */\n+\t\tif (igb_has_i210_cable_fault_test(adapter)) {\n+\t\t\tif (igb_cable_fault_test(adapter, eth_test, data))\n+\t\t\t\teth_test->flags |= ETH_TEST_FL_FAILED;\n+\t\t}\n+\n \t\tif (if_running)\n \t\t\t/* indicate we're in test mode */\n \t\t\tdev_close(netdev);\n@@ -2274,7 +2451,8 @@ static int igb_get_sset_count(struct net_device *netdev, int sset)\n \tcase ETH_SS_STATS:\n \t\treturn IGB_STATS_LEN;\n \tcase ETH_SS_TEST:\n-\t\treturn IGB_TEST_LEN;\n+\t\treturn igb_has_i210_cable_fault_test(netdev_priv(netdev)) ?\n+\t\t\tIGB_I210_TEST_LEN : IGB_TEST_LEN;\n \tdefault:\n \t\treturn -ENOTSUPP;\n \t}\n@@ -2344,8 +2522,12 @@ static void igb_get_strings(struct net_device *netdev, u32 stringset, u8 *data)\n \n \tswitch (stringset) {\n \tcase ETH_SS_TEST:\n-\t\tmemcpy(data, *igb_gstrings_test,\n-\t\t\tIGB_TEST_LEN*ETH_GSTRING_LEN);\n+\t\tif (igb_has_i210_cable_fault_test(adapter))\n+\t\t\tmemcpy(data, *igb_i210_gstrings_test,\n+\t\t\t\tIGB_I210_TEST_LEN*ETH_GSTRING_LEN);\n+\t\telse\n+\t\t\tmemcpy(data, *igb_gstrings_test,\n+\t\t\t\tIGB_TEST_LEN*ETH_GSTRING_LEN);\n \t\tbreak;\n \tcase ETH_SS_STATS:\n \t\tfor (i = 0; i < IGB_GLOBAL_STATS_LEN; i++) {\n",
    "prefixes": [
        "5/5"
    ]
}