Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/477524/?format=api
{ "id": 477524, "url": "http://patchwork.ozlabs.org/api/patches/477524/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/1432863742-18427-3-git-send-email-mathieu@codeaurora.org/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api", "name": "Linux network development", "link_name": "netdev", "list_id": "netdev.vger.kernel.org", "list_email": "netdev@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1432863742-18427-3-git-send-email-mathieu@codeaurora.org>", "list_archive_url": null, "date": "2015-05-29T01:42:17", "name": "[2/7] net: dsa: ar8xxx: add ethtool hw statistics support", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "30607f58fce1dede89cca1291a0b295b1a176cf7", "submitter": { "id": 65737, "url": "http://patchwork.ozlabs.org/api/people/65737/?format=api", "name": "Mathieu Olivari", "email": "mathieu@codeaurora.org" }, "delegate": { "id": 34, "url": "http://patchwork.ozlabs.org/api/users/34/?format=api", "username": "davem", "first_name": "David", "last_name": "Miller", "email": "davem@davemloft.net" }, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/1432863742-18427-3-git-send-email-mathieu@codeaurora.org/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/477524/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/477524/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<netdev-owner@vger.kernel.org>", "X-Original-To": "patchwork-incoming@ozlabs.org", "Delivered-To": "patchwork-incoming@ozlabs.org", "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id F197F14016A\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 29 May 2015 11:44:17 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1755367AbbE2BnV (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 28 May 2015 21:43:21 -0400", "from smtp.codeaurora.org ([198.145.29.96]:37419 \"EHLO\n\tsmtp.codeaurora.org\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1754130AbbE2Bmc (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Thu, 28 May 2015 21:42:32 -0400", "from smtp.codeaurora.org (localhost [127.0.0.1])\n\tby smtp.codeaurora.org (Postfix) with ESMTP id E941A140DA4;\n\tFri, 29 May 2015 01:42:31 +0000 (UTC)", "by smtp.codeaurora.org (Postfix, from userid 486)\n\tid D28DA140DB4; Fri, 29 May 2015 01:42:31 +0000 (UTC)", "from mathieu-linux.qualcomm.com (qf-scl1nat.qualcomm.com\n\t[207.114.132.30])\n\t(using TLSv1.2 with cipher AES128-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\t(Authenticated sender: mathieu@smtp.codeaurora.org)\n\tby smtp.codeaurora.org (Postfix) with ESMTPSA id BE947140DA4;\n\tFri, 29 May 2015 01:42:30 +0000 (UTC)" ], "X-Spam-Checker-Version": "SpamAssassin 3.3.1 (2010-03-16) on\n\tpdx-caf-smtp.dmz.codeaurora.org", "X-Spam-Level": "", "X-Spam-Status": "No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00\n\tautolearn=ham version=3.3.1", "From": "Mathieu Olivari <mathieu@codeaurora.org>", "To": "robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com,\n\tijc+devicetree@hellion.org.uk, galak@codeaurora.org,\n\tdavem@davemloft.net, mathieu@codeaurora.org, andrew@lunn.ch,\n\tf.fainelli@gmail.com, linux@roeck-us.net, gang.chen.5i5j@gmail.com,\n\tjiri@resnulli.us, leitec@staticky.com, fabf@skynet.be,\n\talexander.h.duyck@intel.com, pavel.nakonechny@skitlab.ru,\n\tjoe@perches.com, sfeldma@gmail.com, nbd@openwrt.org, juhosg@openwrt.org", "Cc": "devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,\n\tnetdev@vger.kernel.org", "Subject": "[PATCH 2/7] net: dsa: ar8xxx: add ethtool hw statistics support", "Date": "Thu, 28 May 2015 18:42:17 -0700", "Message-Id": "<1432863742-18427-3-git-send-email-mathieu@codeaurora.org>", "X-Mailer": "git-send-email 2.1.4", "In-Reply-To": "<1432863742-18427-1-git-send-email-mathieu@codeaurora.org>", "References": "<1432863742-18427-1-git-send-email-mathieu@codeaurora.org>", "X-Virus-Scanned": "ClamAV using ClamSMTP", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "MIB counters can now be reported through each switch port by using\n\"ethtool -S\".\n\nSigned-off-by: Mathieu Olivari <mathieu@codeaurora.org>\n---\n drivers/net/dsa/ar8xxx.c | 106 +++++++++++++++++++++++++++++++++++++++++++----\n drivers/net/dsa/ar8xxx.h | 47 +++++++++++++++++++++\n 2 files changed, 146 insertions(+), 7 deletions(-)", "diff": "diff --git a/drivers/net/dsa/ar8xxx.c b/drivers/net/dsa/ar8xxx.c\nindex 4ce3ffc..2f0fa4d 100644\n--- a/drivers/net/dsa/ar8xxx.c\n+++ b/drivers/net/dsa/ar8xxx.c\n@@ -22,6 +22,55 @@\n \n #include \"ar8xxx.h\"\n \n+#define MIB_DESC(_s, _o, _n)\t\\\n+\t{\t\t\t\\\n+\t\t.size = (_s),\t\\\n+\t\t.offset = (_o),\t\\\n+\t\t.name = (_n),\t\\\n+\t}\n+\n+static const struct ar8xxx_mib_desc ar8327_mib[] = {\n+\tMIB_DESC(1, 0x00, \"RxBroad\"),\n+\tMIB_DESC(1, 0x04, \"RxPause\"),\n+\tMIB_DESC(1, 0x08, \"RxMulti\"),\n+\tMIB_DESC(1, 0x0c, \"RxFcsErr\"),\n+\tMIB_DESC(1, 0x10, \"RxAlignErr\"),\n+\tMIB_DESC(1, 0x14, \"RxRunt\"),\n+\tMIB_DESC(1, 0x18, \"RxFragment\"),\n+\tMIB_DESC(1, 0x1c, \"Rx64Byte\"),\n+\tMIB_DESC(1, 0x20, \"Rx128Byte\"),\n+\tMIB_DESC(1, 0x24, \"Rx256Byte\"),\n+\tMIB_DESC(1, 0x28, \"Rx512Byte\"),\n+\tMIB_DESC(1, 0x2c, \"Rx1024Byte\"),\n+\tMIB_DESC(1, 0x30, \"Rx1518Byte\"),\n+\tMIB_DESC(1, 0x34, \"RxMaxByte\"),\n+\tMIB_DESC(1, 0x38, \"RxTooLong\"),\n+\tMIB_DESC(2, 0x3c, \"RxGoodByte\"),\n+\tMIB_DESC(2, 0x44, \"RxBadByte\"),\n+\tMIB_DESC(1, 0x4c, \"RxOverFlow\"),\n+\tMIB_DESC(1, 0x50, \"Filtered\"),\n+\tMIB_DESC(1, 0x54, \"TxBroad\"),\n+\tMIB_DESC(1, 0x58, \"TxPause\"),\n+\tMIB_DESC(1, 0x5c, \"TxMulti\"),\n+\tMIB_DESC(1, 0x60, \"TxUnderRun\"),\n+\tMIB_DESC(1, 0x64, \"Tx64Byte\"),\n+\tMIB_DESC(1, 0x68, \"Tx128Byte\"),\n+\tMIB_DESC(1, 0x6c, \"Tx256Byte\"),\n+\tMIB_DESC(1, 0x70, \"Tx512Byte\"),\n+\tMIB_DESC(1, 0x74, \"Tx1024Byte\"),\n+\tMIB_DESC(1, 0x78, \"Tx1518Byte\"),\n+\tMIB_DESC(1, 0x7c, \"TxMaxByte\"),\n+\tMIB_DESC(1, 0x80, \"TxOverSize\"),\n+\tMIB_DESC(2, 0x84, \"TxByte\"),\n+\tMIB_DESC(1, 0x8c, \"TxCollision\"),\n+\tMIB_DESC(1, 0x90, \"TxAbortCol\"),\n+\tMIB_DESC(1, 0x94, \"TxMultiCol\"),\n+\tMIB_DESC(1, 0x98, \"TxSingleCol\"),\n+\tMIB_DESC(1, 0x9c, \"TxExcDefer\"),\n+\tMIB_DESC(1, 0xa0, \"TxDefer\"),\n+\tMIB_DESC(1, 0xa4, \"TxLateCol\"),\n+};\n+\n u32\n ar8xxx_mii_read32(struct mii_bus *bus, int phy_id, int regnum)\n {\n@@ -184,6 +233,10 @@ static int ar8xxx_setup(struct dsa_switch *ds)\n \tif (ret < 0)\n \t\treturn ret;\n \n+\t/* Enable MIB counters */\n+\tar8xxx_reg_set(ds, AR8327_REG_MIB, AR8327_MIB_CPU_KEEP);\n+\tar8xxx_write(ds, AR8327_REG_MODULE_EN, AR8327_MODULE_EN_MIB);\n+\n \t/* Disable forwarding by default on all ports */\n \tfor (i = 0; i < AR8327_NUM_PORTS; i++)\n \t\tar8xxx_rmw(ds, AR8327_PORT_LOOKUP_CTRL(i),\n@@ -228,6 +281,42 @@ ar8xxx_phy_write(struct dsa_switch *ds, int phy, int regnum, u16 val)\n \treturn mdiobus_write(bus, phy, regnum, val);\n }\n \n+static void ar8xxx_get_strings(struct dsa_switch *ds, int phy, uint8_t *data)\n+{\n+\tint i;\n+\n+\tfor (i = 0; i < ARRAY_SIZE(ar8327_mib); i++) {\n+\t\tstrncpy(data + i * ETH_GSTRING_LEN, ar8327_mib[i].name,\n+\t\t\tETH_GSTRING_LEN);\n+\t}\n+}\n+\n+static void ar8xxx_get_ethtool_stats(struct dsa_switch *ds, int phy,\n+\t\t\t\t uint64_t *data)\n+{\n+\tconst struct ar8xxx_mib_desc *mib;\n+\tuint32_t reg, i, port;\n+\tu64 hi;\n+\n+\tport = phy_to_port(phy);\n+\n+\tfor (i = 0; i < ARRAY_SIZE(ar8327_mib); i++) {\n+\t\tmib = &ar8327_mib[i];\n+\t\treg = AR8327_PORT_MIB_COUNTER(port) + mib->offset;\n+\n+\t\tdata[i] = ar8xxx_read(ds, reg);\n+\t\tif (mib->size == 2) {\n+\t\t\thi = ar8xxx_read(ds, reg + 4);\n+\t\t\tdata[i] |= hi << 32;\n+\t\t}\n+\t}\n+}\n+\n+static int ar8xxx_get_sset_count(struct dsa_switch *ds)\n+{\n+\treturn ARRAY_SIZE(ar8327_mib);\n+}\n+\n static void ar8xxx_poll_link(struct dsa_switch *ds)\n {\n \tint i = 0;\n@@ -275,13 +364,16 @@ static void ar8xxx_poll_link(struct dsa_switch *ds)\n }\n \n static struct dsa_switch_driver ar8xxx_switch_driver = {\n-\t.tag_protocol\t= DSA_TAG_PROTO_NONE,\n-\t.probe\t\t= ar8xxx_probe,\n-\t.setup\t\t= ar8xxx_setup,\n-\t.set_addr\t= ar8xxx_set_addr,\n-\t.poll_link\t= ar8xxx_poll_link,\n-\t.phy_read\t= ar8xxx_phy_read,\n-\t.phy_write\t= ar8xxx_phy_write,\n+\t.tag_protocol\t\t= DSA_TAG_PROTO_NONE,\n+\t.probe\t\t\t= ar8xxx_probe,\n+\t.setup\t\t\t= ar8xxx_setup,\n+\t.set_addr\t\t= ar8xxx_set_addr,\n+\t.poll_link\t\t= ar8xxx_poll_link,\n+\t.phy_read\t\t= ar8xxx_phy_read,\n+\t.phy_write\t\t= ar8xxx_phy_write,\n+\t.get_strings\t\t= ar8xxx_get_strings,\n+\t.get_ethtool_stats\t= ar8xxx_get_ethtool_stats,\n+\t.get_sset_count\t\t= ar8xxx_get_sset_count,\n };\n \n static int __init ar8xxx_init(void)\ndiff --git a/drivers/net/dsa/ar8xxx.h b/drivers/net/dsa/ar8xxx.h\nindex a29b6d3..7c7a125 100644\n--- a/drivers/net/dsa/ar8xxx.h\n+++ b/drivers/net/dsa/ar8xxx.h\n@@ -18,6 +18,12 @@\n \n #include <linux/delay.h>\n \n+struct ar8xxx_mib_desc {\n+\tunsigned int size;\n+\tunsigned int offset;\n+\tconst char *name;\n+};\n+\n #define AR8327_NUM_PORTS\t\t7\n \n #define PHY_ID_QCA8337\t\t\t0x004dd036\n@@ -31,6 +37,14 @@\n #define AR8327_PORT_PAD_RGMII_RX_DELAY_EN\tBIT(24)\n #define AR8327_PORT_PAD_SGMII_EN\t\tBIT(7)\n \n+#define AR8327_REG_MODULE_EN\t\t\t0x030\n+#define AR8327_MODULE_EN_MIB\t\t\tBIT(0)\n+#define\t AR8327_MODULE_EN_ACL\t\t\tBIT(1)\n+#define\t AR8327_MODULE_EN_L3\t\t\tBIT(2)\n+\n+#define AR8327_REG_MIB\t\t\t\t0x034\n+#define AR8327_MIB_CPU_KEEP\t\t\tBIT(20)\n+\n #define AR8327_REG_PORT_STATUS(_i)\t\t(0x07c + (_i) * 4)\n #define AR8XXX_PORT_STATUS_SPEED\tGENMASK(2, 0)\n #define AR8XXX_PORT_STATUS_SPEED_S\t0\n@@ -52,6 +66,8 @@\n #define AR8327_PORT_LOOKUP_LEARN\t\tBIT(20)\n #define AR8327_PORT_LOOKUP_ING_MIRROR_EN\tBIT(25)\n \n+#define AR8327_PORT_MIB_COUNTER(_i)\t\t(0x1000 + (_i) * 0x100)\n+\n /* port speed */\n enum {\n \tAR8XXX_PORT_SPEED_10M = 0,\n@@ -60,6 +76,25 @@ enum {\n \tAR8XXX_PORT_SPEED_ERR = 3,\n };\n \n+static inline int port_to_phy(int port)\n+{\n+\tif (port >= 1 && port <= 6)\n+\t\treturn port - 1;\n+\n+\treturn -1;\n+}\n+\n+static inline int phy_to_port(int phy)\n+{\n+\tif (phy < 5)\n+\t\treturn phy + 1;\n+\n+\treturn -1;\n+}\n+\n+u32\n+ar8xxx_rmw(struct dsa_switch *ds, int reg, u32 mask, u32 val);\n+\n static inline void\n split_addr(u32 regaddr, u16 *r1, u16 *r2, u16 *page)\n {\n@@ -79,4 +114,16 @@ wait_for_page_switch(void)\n \tudelay(5);\n }\n \n+static inline void\n+ar8xxx_reg_set(struct dsa_switch *ds, int reg, u32 val)\n+{\n+\tar8xxx_rmw(ds, reg, 0, val);\n+}\n+\n+static inline void\n+ar8xxx_reg_clear(struct dsa_switch *ds, int reg, u32 val)\n+{\n+\tar8xxx_rmw(ds, reg, val, 0);\n+}\n+\n #endif /* __AR8XXX_H */\n", "prefixes": [ "2/7" ] }