Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4198928pxu; Tue, 20 Oct 2020 10:31:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPensFuz7zVZ7f1/7qVn2WKd303Ur4EyoOP7agadiZQcUrXXDD6SimEsEGZLWLYxYcXXL2 X-Received: by 2002:a17:906:f119:: with SMTP id gv25mr4284920ejb.373.1603215110394; Tue, 20 Oct 2020 10:31:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603215110; cv=none; d=google.com; s=arc-20160816; b=OQ4v5JglNiIz58awhuXoTz0JaEvAhD0aJhQGA4IaH9e7G4n9dO5LBigSjFu9EXCej5 wmJCovsWx9JOUJWxwbNKYRhHkB7BxelfZlDM2+isD6ZGS2YUR0ErY1Q/H7I2f5K5gR7I zedZ4Oon+uVdbTdRqGEcsC3eBqNX6cmmm5vaQyNiNDh7DkWNAJBa8Zn4txsIg94F4MU7 Re6DqCsyewVSoRMbq5Xk/0EPue55lXIfOujE7mrVX2fD3NriuaQHVShZwJqlucwfum/q pMByyQWGrsgnKEhO+fDktovDSqAY9ZQ8ccdeA8wNQ+TWML+UHlx10gNKghKXVy/ZXp9q 3k/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=cDpgFY/G/KSPP6OlpHZKcYCFv/WcaHqFGb5uXZJ1bBQ=; b=TJIsb2dpc6qTY6k2mkXke5PjuG5eWpQeZo+MfSHMJRFDNAenpUf1j5Gzp3ua8iDLe9 p5EVUFige90o9Ji919LKB9fHjX8hKIOKvtd+gKJrQJBMrmlSyJ9uZoH0fXtQa0p6b0jS 9c/GO3GO1o/1TfQWMh6eCRYC1f9rpdGJh0T6VFG6JovE3RwwOZygH6ocjDGVqlS6TOh1 rH1XOMocFl/lF3Gd4ehfZavljjzSzc6PXgl0QsseGmOxalVmhEhLaEziGc12eBdxKuk2 q/JfHKMNb5iVvUab2/NAJjfLORjsIBmA8/LprP3HkPOmDNUwzllV4qauS4c9qazSbFYP 2KEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id uz27si1736286ejb.212.2020.10.20.10.31.27; Tue, 20 Oct 2020 10:31:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391376AbgJTEOP (ORCPT + 99 others); Tue, 20 Oct 2020 00:14:15 -0400 Received: from inva021.nxp.com ([92.121.34.21]:37644 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726282AbgJTEOM (ORCPT ); Tue, 20 Oct 2020 00:14:12 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 13B752004D2; Tue, 20 Oct 2020 06:14:10 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id DC8922003DC; Tue, 20 Oct 2020 06:14:02 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 1DE1A40305; Tue, 20 Oct 2020 06:13:54 +0200 (CEST) From: Xiaoliang Yang To: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: vinicius.gomes@intel.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, kuba@kernel.org, Jose.Abreu@synopsys.com, allan.nielsen@microchip.com, joergen.andreasen@microchip.com, UNGLinuxDriver@microchip.com, xiaoliang.yang_1@nxp.com, po.liu@nxp.com, claudiu.manoil@nxp.com, alexandru.marginean@nxp.com, vladimir.oltean@nxp.com, leoyang.li@nxp.com, mingkai.hu@nxp.com Subject: [RFC, net-next 1/3] net: dsa: ethtool preempt ops support on slave ports Date: Tue, 20 Oct 2020 12:04:56 +0800 Message-Id: <20201020040458.39794-2-xiaoliang.yang_1@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201020040458.39794-1-xiaoliang.yang_1@nxp.com> References: <20201020040458.39794-1-xiaoliang.yang_1@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Preempt_set and preempt_get are new functions of ethtool ops, which is to configure frame preemption according to 802.1qbu and 802.3br. Add them on slave ports of DSA framework, so that DSA devices can support to configure frame preemption by using ethtool. Signed-off-by: Xiaoliang Yang --- include/net/dsa.h | 12 ++++++++++++ net/dsa/slave.c | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index 35429a140dfa..85b196ade511 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -499,6 +499,18 @@ struct dsa_switch_ops { int (*get_ts_info)(struct dsa_switch *ds, int port, struct ethtool_ts_info *ts); + /* + * ethtool --set-frame-preemption + */ + int (*set_preempt)(struct dsa_switch *ds, int port, + struct ethtool_fp *fpcmd); + + /* + * ethtool --show-frame-preemption + */ + int (*get_preempt)(struct dsa_switch *ds, int port, + struct ethtool_fp *fpcmd); + /* * Suspend and resume */ diff --git a/net/dsa/slave.c b/net/dsa/slave.c index e7c1d62fde99..f51a1575266c 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1281,6 +1281,30 @@ static int dsa_slave_get_ts_info(struct net_device *dev, return ds->ops->get_ts_info(ds, p->dp->index, ts); } +static int dsa_slave_set_preempt(struct net_device *dev, + struct ethtool_fp *fpcmd) +{ + struct dsa_slave_priv *p = netdev_priv(dev); + struct dsa_switch *ds = p->dp->ds; + + if (!ds->ops->set_preempt) + return -EOPNOTSUPP; + + return ds->ops->set_preempt(ds, p->dp->index, fpcmd); +} + +static int dsa_slave_get_preempt(struct net_device *dev, + struct ethtool_fp *fpcmd) +{ + struct dsa_slave_priv *p = netdev_priv(dev); + struct dsa_switch *ds = p->dp->ds; + + if (!ds->ops->get_preempt) + return -EOPNOTSUPP; + + return ds->ops->get_preempt(ds, p->dp->index, fpcmd); +} + static int dsa_slave_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) { @@ -1571,6 +1595,8 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = { .get_rxnfc = dsa_slave_get_rxnfc, .set_rxnfc = dsa_slave_set_rxnfc, .get_ts_info = dsa_slave_get_ts_info, + .set_preempt = dsa_slave_set_preempt, + .get_preempt = dsa_slave_get_preempt, }; /* legacy way, bypassing the bridge *****************************************/ -- 2.18.4