{"id":806736,"url":"http://patchwork.ozlabs.org/api/1.0/patches/806736/?format=json","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.0/projects/7/?format=json","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},"msgid":"<20170828191748.19492-4-vivien.didelot@savoirfairelinux.com>","date":"2017-08-28T19:17:41","name":"[net-next,v2,03/10] net: dsa: debugfs: add tag_protocol","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":true,"hash":"e850934e3425a7fa94a7979213e51e4a1dded9bc","submitter":{"id":15889,"url":"http://patchwork.ozlabs.org/api/1.0/people/15889/?format=json","name":"Vivien Didelot","email":"vivien.didelot@savoirfairelinux.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.0/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170828191748.19492-4-vivien.didelot@savoirfairelinux.com/mbox/","series":[{"id":246,"url":"http://patchwork.ozlabs.org/api/1.0/series/246/?format=json","date":"2017-08-28T19:17:41","name":"net: dsa: add generic debugfs interface","version":2,"mbox":"http://patchwork.ozlabs.org/series/246/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/806736/checks/","tags":{},"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xh1qN5WWdz9t2V\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 29 Aug 2017 05:21:46 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751372AbdH1TVm (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 28 Aug 2017 15:21:42 -0400","from mail.savoirfairelinux.com ([208.88.110.44]:36288 \"EHLO\n\tmail.savoirfairelinux.com\" rhost-flags-OK-OK-OK-OK) by\n\tvger.kernel.org with ESMTP id S1751192AbdH1TVj (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 28 Aug 2017 15:21:39 -0400","from localhost (localhost [127.0.0.1])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTP id D6CA29C1D1A;\n\tMon, 28 Aug 2017 15:21:38 -0400 (EDT)","from mail.savoirfairelinux.com ([127.0.0.1])\n\tby localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new,\n\tport 10032)\n\twith ESMTP id CzbORs6EN2aB; Mon, 28 Aug 2017 15:21:37 -0400 (EDT)","from localhost (localhost [127.0.0.1])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTP id BD0009C1B45;\n\tMon, 28 Aug 2017 15:21:37 -0400 (EDT)","from mail.savoirfairelinux.com ([127.0.0.1])\n\tby localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new,\n\tport 10026)\n\twith ESMTP id iOt2iT4-8xKe; Mon, 28 Aug 2017 15:21:37 -0400 (EDT)","from weeman.mtl.sfl (unknown [192.168.50.91])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTPSA id 776049C1BC9;\n\tMon, 28 Aug 2017 15:21:37 -0400 (EDT)"],"X-Virus-Scanned":"amavisd-new at mail.savoirfairelinux.com","From":"Vivien Didelot <vivien.didelot@savoirfairelinux.com>","To":"netdev@vger.kernel.org","Cc":"linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com,\n\t\"David S. Miller\" <davem@davemloft.net>,\n\tFlorian Fainelli <f.fainelli@gmail.com>, Andrew Lunn <andrew@lunn.ch>,\n\tEgil Hjelmeland <privat@egil-hjelmeland.no>,\n\tJohn Crispin <john@phrozen.org>, Woojung Huh <Woojung.Huh@microchip.com>,\n\tSean Wang <sean.wang@mediatek.com>,\n\tNikita Yushchenko <nikita.yoush@cogentembedded.com>,\n\tChris Healy <cphealy@gmail.com>,\n\tVivien Didelot <vivien.didelot@savoirfairelinux.com>","Subject":"[PATCH net-next v2 03/10] net: dsa: debugfs: add tag_protocol","Date":"Mon, 28 Aug 2017 15:17:41 -0400","Message-Id":"<20170828191748.19492-4-vivien.didelot@savoirfairelinux.com>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":"<20170828191748.19492-1-vivien.didelot@savoirfairelinux.com>","References":"<20170828191748.19492-1-vivien.didelot@savoirfairelinux.com>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"Add a debug filesystem \"tag_protocol\" entry to query the switch tagging\nprotocol through the .get_tag_protocol operation.\n\n    # cat switch1/tag_protocol\n    EDSA\n\nTo ease maintenance of tag protocols, add a dsa_tag_protocol_name helper\nto the public API which to convert a tag protocol enum to a string.\n\nSigned-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>\n---\n include/net/dsa.h | 26 ++++++++++++++++++++++++++\n net/dsa/debugfs.c | 23 +++++++++++++++++++++++\n 2 files changed, 49 insertions(+)","diff":"diff --git a/include/net/dsa.h b/include/net/dsa.h\nindex 7341178319f5..1309ba0376ae 100644\n--- a/include/net/dsa.h\n+++ b/include/net/dsa.h\n@@ -39,6 +39,32 @@ enum dsa_tag_protocol {\n \tDSA_TAG_LAST,\t\t/* MUST BE LAST */\n };\n \n+static inline const char *dsa_tag_protocol_name(enum dsa_tag_protocol proto)\n+{\n+\tswitch (proto) {\n+\tcase DSA_TAG_PROTO_NONE:\n+\t\treturn \"none\";\n+\tcase DSA_TAG_PROTO_BRCM:\n+\t\treturn \"BRCM\";\n+\tcase DSA_TAG_PROTO_DSA:\n+\t\treturn \"DSA\";\n+\tcase DSA_TAG_PROTO_EDSA:\n+\t\treturn \"EDSA\";\n+\tcase DSA_TAG_PROTO_KSZ:\n+\t\treturn \"KSZ\";\n+\tcase DSA_TAG_PROTO_LAN9303:\n+\t\treturn \"LAN9303\";\n+\tcase DSA_TAG_PROTO_MTK:\n+\t\treturn \"MTK\";\n+\tcase DSA_TAG_PROTO_QCA:\n+\t\treturn \"QCA\";\n+\tcase DSA_TAG_PROTO_TRAILER:\n+\t\treturn \"TRAILER\";\n+\tdefault:\n+\t\treturn \"unknown\";\n+\t}\n+}\n+\n #define DSA_MAX_SWITCHES\t4\n #define DSA_MAX_PORTS\t\t12\n \ndiff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c\nindex 54e97e05a9d7..8a0e4311ff8c 100644\n--- a/net/dsa/debugfs.c\n+++ b/net/dsa/debugfs.c\n@@ -109,6 +109,24 @@ static int dsa_debugfs_create_file(struct dsa_switch *ds, struct dentry *dir,\n \treturn 0;\n }\n \n+static int dsa_debugfs_tag_protocol_read(struct dsa_switch *ds, int id,\n+\t\t\t\t\t struct seq_file *seq)\n+{\n+\tenum dsa_tag_protocol proto;\n+\n+\tif (!ds->ops->get_tag_protocol)\n+\t\treturn -EOPNOTSUPP;\n+\n+\tproto = ds->ops->get_tag_protocol(ds);\n+\tseq_printf(seq, \"%s\\n\", dsa_tag_protocol_name(proto));\n+\n+\treturn 0;\n+}\n+\n+static const struct dsa_debugfs_ops dsa_debugfs_tag_protocol_ops = {\n+\t.read = dsa_debugfs_tag_protocol_read,\n+};\n+\n static int dsa_debugfs_tree_read(struct dsa_switch *ds, int id,\n \t\t\t\t struct seq_file *seq)\n {\n@@ -150,6 +168,11 @@ static int dsa_debugfs_create_switch(struct dsa_switch *ds)\n \tif (IS_ERR_OR_NULL(ds->debugfs_dir))\n \t\treturn -EFAULT;\n \n+\terr = dsa_debugfs_create_file(ds, ds->debugfs_dir, \"tag_protocol\", -1,\n+\t\t\t\t      &dsa_debugfs_tag_protocol_ops);\n+\tif (err)\n+\t\treturn err;\n+\n \terr = dsa_debugfs_create_file(ds, ds->debugfs_dir, \"tree\", -1,\n \t\t\t\t      &dsa_debugfs_tree_ops);\n \tif (err)\n","prefixes":["net-next","v2","03/10"]}