Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/580572/?format=api
{ "id": 580572, "url": "http://patchwork.ozlabs.org/api/patches/580572/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/520205889.412690.1454977910808.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": "<520205889.412690.1454977910808.JavaMail.zimbra@xes-inc.com>", "list_archive_url": null, "date": "2016-02-09T00:31:50", "name": "[v4] igb: Add I210 cable fault detection to self test", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": false, "hash": "1bf3d44984e076950d983857dbfdd78c5dd32cfd", "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/520205889.412690.1454977910808.JavaMail.zimbra@xes-inc.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/580572/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/580572/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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\tby ozlabs.org (Postfix) with ESMTP id BE5A0140BAB\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 9 Feb 2016 11:32:02 +1100 (AEDT)", "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id EDF5991ED3;\n\tTue, 9 Feb 2016 00:32:00 +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 IPQ6TivDv4RA; Tue, 9 Feb 2016 00:31:59 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 4AD7191ECC;\n\tTue, 9 Feb 2016 00:31:59 +0000 (UTC)", "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id 605221CF406\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 9 Feb 2016 00:31:57 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 556ED32EED\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 9 Feb 2016 00:31:57 +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 NipVjElZYl2C for <intel-wired-lan@lists.osuosl.org>;\n\tTue, 9 Feb 2016 00:31:55 +0000 (UTC)", "from xes-mad.com (xes-mad.com [216.165.139.218])\n\tby silver.osuosl.org (Postfix) with ESMTPS id 6195A332D2\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 9 Feb 2016 00:31:54 +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 u190VpNs023296;\n\tMon, 8 Feb 2016 18:31:51 -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": "Mon, 8 Feb 2016 18:31:50 -0600 (CST)", "From": "Aaron Sierra <asierra@xes-inc.com>", "To": "Jeffrey T Kirsher <jeffrey.t.kirsher@intel.com>,\n\tintel-wired-lan@lists.osuosl.org", "Message-ID": "<520205889.412690.1454977910808.JavaMail.zimbra@xes-inc.com>", "In-Reply-To": "<499972187.409005.1454977422998.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 - FF43 (Linux)/8.0.6_GA_5922)", "Thread-Topic": "Add I210 cable fault detection to self test", "Thread-Index": "59CQ0HJDs28lnO/i0SlgdRDtbIySEw==", "Cc": "Joe Schultz <jschultz@xes-inc.com>", "Subject": "[Intel-wired-lan] [PATCH v4] igb: Add I210 cable fault detection to\n\tself 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 v2 - account for changes made by this patch in dev-queue:\n drivers/net: get rid of unnecessary initializations in .get_drvinfo()\n v3 - fix uninitialized variable compile warning\n - remove unneeded igb_cable_fault_test_prep() function\n - don't add unused define to e1000_defines.h\n - only run cable diagnostic if link test fails\n v4 - only set no-fault, link-present cable distance for I210\n\n drivers/net/ethernet/intel/igb/e1000_defines.h | 12 +-\n drivers/net/ethernet/intel/igb/igb_ethtool.c | 186 ++++++++++++++++++++++++-\n 2 files changed, 192 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 240902e..707e1ba 100644\n--- a/drivers/net/ethernet/intel/igb/e1000_defines.h\n+++ b/drivers/net/ethernet/intel/igb/e1000_defines.h\n@@ -932,6 +932,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@@ -952,7 +953,16 @@\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_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 1d329f1..a135bf3 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@@ -1983,6 +2047,97 @@ static int igb_link_test(struct igb_adapter *adapter, u64 *data)\n \treturn *data;\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 old_pcdc, pcdc;\n+\tu16 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 no_set_page;\n+\n+\t/* Save PCDC register and initiate immediate diagnostic */\n+\tret_val = igb_read_phy_reg(hw, I347AT4_PCDC, &pcdc);\n+\tif (ret_val)\n+\t\tgoto no_pcdc;\n+\n+\told_pcdc = pcdc;\n+\tpcdc &= ~I347AT4_PCDC_DISABLE_CROSS_PAIR;\n+\tpcdc |= I347AT4_PCDC_CABLE_LENGTH_UNIT | I347AT4_PCDC_RUN_TEST;\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+\tdo {\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} while (pcdc & I347AT4_PCDC_CABLE_DIAG_STATUS);\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+\t/* Restore PCDC */\n+\tigb_write_phy_reg(hw, I347AT4_PCDC, old_pcdc);\n+no_pcdc:\n+\tigb_write_phy_reg(hw, I347AT4_PAGE_SELECT, 0);\n+no_set_page:\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@@ -1993,6 +2148,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@@ -2012,8 +2172,19 @@ static void igb_diag_test(struct net_device *netdev,\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\tif (!igb_has_i210_cable_fault_test(adapter)) {\n+\t\t\tif (igb_link_test(adapter, &data[TEST_LINK]))\n+\t\t\t\teth_test->flags |= ETH_TEST_FL_FAILED;\n+\t\t} else if (igb_link_test(adapter, &data[TEST_LINK])) {\n \t\t\teth_test->flags |= ETH_TEST_FL_FAILED;\n+\t\t\tigb_cable_fault_test(adapter, eth_test, data);\n+\t\t} else {\n+\t\t\t/* I210: link present, no fault */\n+\t\t\tdata[TEST_LENGTH_A] = -1;\n+\t\t\tdata[TEST_LENGTH_B] = -1;\n+\t\t\tdata[TEST_LENGTH_C] = -1;\n+\t\t\tdata[TEST_LENGTH_D] = -1;\n+\t\t}\n \n \t\tif (if_running)\n \t\t\t/* indicate we're in test mode */\n@@ -2270,7 +2441,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@@ -2340,8 +2512,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": [ "v4" ] }