{"id":815629,"url":"http://patchwork.ozlabs.org/api/patches/815629/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170919155700.14474-4-vivien.didelot@savoirfairelinux.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/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,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170919155700.14474-4-vivien.didelot@savoirfairelinux.com>","list_archive_url":null,"date":"2017-09-19T15:56:59","name":"[net-next,3/4] net: dsa: setup master ethtool after dsa_ptr","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"2307d417f6fbc2615d96f457e930557251c693dd","submitter":{"id":15889,"url":"http://patchwork.ozlabs.org/api/people/15889/?format=json","name":"Vivien Didelot","email":"vivien.didelot@savoirfairelinux.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170919155700.14474-4-vivien.didelot@savoirfairelinux.com/mbox/","series":[{"id":3916,"url":"http://patchwork.ozlabs.org/api/series/3916/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=3916","date":"2017-09-19T15:56:59","name":"net: dsa: move master ethtool code","version":1,"mbox":"http://patchwork.ozlabs.org/series/3916/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/815629/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/815629/checks/","tags":{},"related":[],"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 3xxSJx5KR8z9sMN\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 20 Sep 2017 02:00:49 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751780AbdISQAs (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 19 Sep 2017 12:00:48 -0400","from mail.savoirfairelinux.com ([208.88.110.44]:46196 \"EHLO\n\tmail.savoirfairelinux.com\" rhost-flags-OK-OK-OK-OK) by\n\tvger.kernel.org with ESMTP id S1751343AbdISQAq (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Tue, 19 Sep 2017 12:00:46 -0400","from localhost (localhost [127.0.0.1])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTP id 7D0D59C2CA4;\n\tTue, 19 Sep 2017 12:00:45 -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 Qm-DRwQCnH5o; Tue, 19 Sep 2017 12:00:45 -0400 (EDT)","from localhost (localhost [127.0.0.1])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTP id E628E9C2C4A;\n\tTue, 19 Sep 2017 12:00:44 -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 J_8leN5091Xx; Tue, 19 Sep 2017 12:00:44 -0400 (EDT)","from weeman.mtl.sfl (unknown [192.168.49.104])\n\tby mail.savoirfairelinux.com (Postfix) with ESMTPSA id A82319C2C9B;\n\tTue, 19 Sep 2017 12:00:44 -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\tVivien Didelot <vivien.didelot@savoirfairelinux.com>","Subject":"[PATCH net-next 3/4] net: dsa: setup master ethtool after dsa_ptr","Date":"Tue, 19 Sep 2017 11:56:59 -0400","Message-Id":"<20170919155700.14474-4-vivien.didelot@savoirfairelinux.com>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":"<20170919155700.14474-1-vivien.didelot@savoirfairelinux.com>","References":"<20170919155700.14474-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":"DSA overrides the master's ethtool ops so that we can inject its CPU\nport's statistics. Because of that, we need to setup the ethtool ops\nafter the master's dsa_ptr pointer has been assigned, not before.\n\nThis patch setups the ethtool ops after dsa_ptr is assigned, and\nrestores them before it gets cleared.\n\nSigned-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>\n---\n net/dsa/dsa2.c   | 12 +++++++-----\n net/dsa/legacy.c | 10 +++-------\n 2 files changed, 10 insertions(+), 12 deletions(-)","diff":"diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c\nindex bd19304f862f..032f8bc3e788 100644\n--- a/net/dsa/dsa2.c\n+++ b/net/dsa/dsa2.c\n@@ -433,16 +433,17 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst)\n \t\t\treturn err;\n \t}\n \n-\terr = dsa_cpu_port_ethtool_setup(dst->cpu_dp);\n-\tif (err)\n-\t\treturn err;\n-\n \t/* If we use a tagging format that doesn't have an ethertype\n \t * field, make sure that all packets from this point on get\n \t * sent to the tag format's receive function.\n \t */\n \twmb();\n \tdst->cpu_dp->netdev->dsa_ptr = dst;\n+\n+\terr = dsa_cpu_port_ethtool_setup(dst->cpu_dp);\n+\tif (err)\n+\t\treturn err;\n+\n \tdst->applied = true;\n \n \treturn 0;\n@@ -456,6 +457,8 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)\n \tif (!dst->applied)\n \t\treturn;\n \n+\tdsa_cpu_port_ethtool_restore(dst->cpu_dp);\n+\n \tdst->cpu_dp->netdev->dsa_ptr = NULL;\n \n \t/* If we used a tagging format that doesn't have an ethertype\n@@ -472,7 +475,6 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)\n \t\tdsa_ds_unapply(dst, ds);\n \t}\n \n-\tdsa_cpu_port_ethtool_restore(dst->cpu_dp);\n \tdst->cpu_dp = NULL;\n \n \tpr_info(\"DSA: tree %d unapplied\\n\", dst->tree);\ndiff --git a/net/dsa/legacy.c b/net/dsa/legacy.c\nindex 91e6f7981d39..163910699db7 100644\n--- a/net/dsa/legacy.c\n+++ b/net/dsa/legacy.c\n@@ -206,10 +206,6 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,\n \t\tnetdev_err(master, \"[%d] : can't configure CPU and DSA ports\\n\",\n \t\t\t   index);\n \n-\tret = dsa_cpu_port_ethtool_setup(ds->dst->cpu_dp);\n-\tif (ret)\n-\t\treturn ret;\n-\n \treturn 0;\n }\n \n@@ -606,7 +602,7 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,\n \twmb();\n \tdev->dsa_ptr = dst;\n \n-\treturn 0;\n+\treturn dsa_cpu_port_ethtool_setup(dst->cpu_dp);\n }\n \n static int dsa_probe(struct platform_device *pdev)\n@@ -671,6 +667,8 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)\n {\n \tint i;\n \n+\tdsa_cpu_port_ethtool_restore(dst->cpu_dp);\n+\n \tdst->cpu_dp->netdev->dsa_ptr = NULL;\n \n \t/* If we used a tagging format that doesn't have an ethertype\n@@ -686,8 +684,6 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)\n \t\t\tdsa_switch_destroy(ds);\n \t}\n \n-\tdsa_cpu_port_ethtool_restore(dst->cpu_dp);\n-\n \tdev_put(dst->cpu_dp->netdev);\n }\n \n","prefixes":["net-next","3/4"]}