Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5561966imm; Tue, 12 Jun 2018 09:38:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJLtwkBnGbusCLdEYZDG5KdU1l0jkc5fuo6iCAo1ufFs7y90Qx7iYBkFTDt4hrsr0zBkK0b X-Received: by 2002:a65:5a07:: with SMTP id y7-v6mr915230pgs.177.1528821530528; Tue, 12 Jun 2018 09:38:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528821530; cv=none; d=google.com; s=arc-20160816; b=hs50wdGb/w8VHklYl+IOTj4QRoRxCdhcaRSMhv4FPJHC5EC/YVfYN7Z6tQneRMQjbv VabZza0N0fjFUgdK+tbDG9JoazksG90W9ZzYZ1nlwwObLWfJe7JUkzg+RQS27MV9cLeL LT+nkErLicZORcA2KP6MCxk4VU3khep7PF5EP2mJUGo6pBa/he22vmz+Pm7MqyOzkTD+ qPlIjJnfTneJDvUYuAwEx/7NQ/R4e5R4uIz4UxvDQmKavoNNAWqvvkBMCKjQYQdk6Rux SQSeacrVvksC3KHFv9vngfMbkiiUfisSWi3rVK2CdjjhRacdTejnWCJbPBb9fFpdtbMK on5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=w97tT2UQ0+kxupA3gb536xDSpohNS15Yz3bP84jsk5U=; b=FFcvfpABQlP1mwZYMqzzdTVF4+dl4DUKTy58/P8ijIP6OB2wlvevkzjf/ZPv0tFRD+ 2gjzqf8ZAoDmVlBUOoMl/jUBCCBALMpxvwyuZ+qTom4rn5c8MAIINXTIo/0pfeXR44vJ zfIPtIpV8/iZ/jehdESFxISJcJN1lu684PGCDotfm7+5IpwFtqzWPZPBtxKEBw1lsUXv xtfxf3kvmxpCtnw4om/jxG28oXVuVxE54ObHV587mIVf64WOmAh5/+B7OLdOZF16PXR3 /9lvzFwS+LluuUoy/rm3fSVFgcHrs0MCrNb1OAgqphhNHPgEXSUdXx7lBT05mOy5NglC Ao9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@lunn.ch header.s=20171124 header.b=IIipsKui; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k14-v6si353870pgn.99.2018.06.12.09.38.05; Tue, 12 Jun 2018 09:38:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@lunn.ch header.s=20171124 header.b=IIipsKui; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934131AbeFLQhK (ORCPT + 99 others); Tue, 12 Jun 2018 12:37:10 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:59788 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933638AbeFLQhI (ORCPT ); Tue, 12 Jun 2018 12:37:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=NAGGVcBPMvS05EZ2nRe1likAnCLqpWac5M+NiRMJlss=; b=IIipsKui9p7Ntkn98tlnwuc3vd8+DrKofCuxjwKp6ipZYyIXccpmf7LhWP4NvkpWJU68hjTIdB/EkaGr5JVdTr2MztPhZxqIsnE78qnQjRZsPL3XkKx/RxB6Y1ITqV5CcE8KfZXM8DACyUuDtmxl2WGQ4n27K97gewavRcClg3Q=; Received: from andrew by vps0.lunn.ch with local (Exim 4.84_2) (envelope-from ) id 1fSmHz-0003YT-05; Tue, 12 Jun 2018 18:36:59 +0200 Date: Tue, 12 Jun 2018 18:36:58 +0200 From: Andrew Lunn To: Ivan Khoronzhuk Cc: grygorii.strashko@ti.com, davem@davemloft.net, corbet@lwn.net, akpm@linux-foundation.org, netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, vinicius.gomes@intel.com, henrik@austad.us, jesus.sanchez-palencia@intel.com, ilias.apalodimas@linaro.org, p-varis@ti.com, spatton@ti.com, francois.ozog@linaro.org, yogeshs@ti.com, nsekhar@ti.com Subject: Re: [PATCH net-next 3/6] net: ethernet: ti: cpsw: add MQPRIO Qdisc offload Message-ID: <20180612163658.GC12251@lunn.ch> References: <20180611133047.4818-1-ivan.khoronzhuk@linaro.org> <20180611133047.4818-4-ivan.khoronzhuk@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180611133047.4818-4-ivan.khoronzhuk@linaro.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 11, 2018 at 04:30:44PM +0300, Ivan Khoronzhuk wrote: > That's possible to offload vlan to tc priority mapping with > assumption sk_prio == L2 prio. > > Example: > $ ethtool -L eth0 rx 1 tx 4 > > $ qdisc replace dev eth0 handle 100: parent root mqprio num_tc 3 \ > map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@0 1@1 2@2 hw 1 > > $ tc -g class show dev eth0 > +---(100:ffe2) mqprio > | ???+---(100:3) mqprio > | ???+---(100:4) mqprio > | ??? > +---(100:ffe1) mqprio > | ???+---(100:2) mqprio > | ??? > +---(100:ffe0) mqprio > ????+---(100:1) mqprio > > Here, 100:1 is txq0, 100:2 is txq1, 100:3 is txq2, 100:4 is txq3 > txq0 belongs to tc0, txq1 to tc1, txq2 and txq3 to tc2 > The offload part only maps L2 prio to classes of traffic, but not > to transmit queues, so to direct traffic to traffic class vlan has > to be created with appropriate egress map. > > Signed-off-by: Ivan Khoronzhuk > --- > drivers/net/ethernet/ti/cpsw.c | 82 ++++++++++++++++++++++++++++++++++ > 1 file changed, 82 insertions(+) > > diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c > index 406537d74ec1..fd967d2bce5d 100644 > --- a/drivers/net/ethernet/ti/cpsw.c > +++ b/drivers/net/ethernet/ti/cpsw.c > @@ -39,6 +39,7 @@ > #include > > #include > +#include > > #include "cpsw.h" > #include "cpsw_ale.h" > @@ -153,6 +154,8 @@ do { \ > #define IRQ_NUM 2 > #define CPSW_MAX_QUEUES 8 > #define CPSW_CPDMA_DESCS_POOL_SIZE_DEFAULT 256 > +#define CPSW_TC_NUM 4 > +#define CPSW_FIFO_SHAPERS_NUM (CPSW_TC_NUM - 1) > > #define CPSW_RX_VLAN_ENCAP_HDR_PRIO_SHIFT 29 > #define CPSW_RX_VLAN_ENCAP_HDR_PRIO_MSK GENMASK(2, 0) > @@ -453,6 +456,7 @@ struct cpsw_priv { > u8 mac_addr[ETH_ALEN]; > bool rx_pause; > bool tx_pause; > + bool mqprio_hw; > u32 emac_port; > struct cpsw_common *cpsw; > }; > @@ -1577,6 +1581,14 @@ static void cpsw_slave_stop(struct cpsw_slave *slave, struct cpsw_common *cpsw) > soft_reset_slave(slave); > } > > +static int cpsw_tc_to_fifo(int tc, int num_tc) > +{ > + if (tc == num_tc - 1) > + return 0; > + > + return CPSW_FIFO_SHAPERS_NUM - tc; > +} > + > static int cpsw_ndo_open(struct net_device *ndev) > { > struct cpsw_priv *priv = netdev_priv(ndev); > @@ -2190,6 +2202,75 @@ static int cpsw_ndo_set_tx_maxrate(struct net_device *ndev, int queue, u32 rate) > return ret; > } > > +static int cpsw_set_tc(struct net_device *ndev, void *type_data) > +{ Hi Ivan Maybe this is not the best of names. What if you add support for another TC qdisc? So you have another case in the switch statement below? Maybe call it cpsw_set_mqprio? > +static int cpsw_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type type, > + void *type_data) > +{ > + switch (type) { > + case TC_SETUP_QDISC_MQPRIO: > + return cpsw_set_tc(ndev, type_data); > + > + default: > + return -EOPNOTSUPP; > + } > +} Andrew