From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: Re: [PATCH v2 net-next] net: stmmac: Add support for U32 TC filter using Flexible RX Parser Date: Fri, 4 May 2018 18:33:38 -0700 Message-ID: <20180504183338.586f2903@cakuba.netronome.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, "David S. Miller" , Joao Pinto , Vitor Soares , Giuseppe Cavallaro , Alexandre Torgue To: Jose Abreu Return-path: Received: from mx3.wp.pl ([212.77.101.10]:10837 "EHLO mx3.wp.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751508AbeEEBdr (ORCPT ); Fri, 4 May 2018 21:33:47 -0400 In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: On Fri, 4 May 2018 10:01:38 +0100, Jose Abreu wrote: > This adds support for U32 filter by using an HW only feature called > Flexible RX Parser. This allow us to match any given packet field with a > pattern and accept/reject or even route the packet to a specific DMA > channel. > > Right now we only support acception or rejection of frame and we only > support simple rules. Though, the Parser has the flexibility of jumping to > specific rules as an if condition so complex rules can be established. > > This is only supported in GMAC5.10+. > > The following commands can be used to test this code: > > 1) Setup an ingress qdisk: > # tc qdisc add dev eth0 handle ffff: ingress > > 2) Setup a filter (e.g. filter by IP): > # tc filter add dev eth0 parent ffff: protocol ip u32 match ip \ > src 192.168.0.3 skip_sw action drop > > In every tests performed we always used the "skip_sw" flag to make sure > only the RX Parser was involved. > > Signed-off-by: Jose Abreu > Cc: David S. Miller > Cc: Joao Pinto > Cc: Vitor Soares > Cc: Giuseppe Cavallaro > Cc: Alexandre Torgue > Cc: Jakub Kicinski > --- > Changes from v1: > - Follow Linux network coding style (David) > - Use tc_cls_can_offload_and_chain0() (Jakub) Thanks! > @@ -4223,6 +4277,11 @@ int stmmac_dvr_probe(struct device *device, > ndev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | > NETIF_F_RXCSUM; > > + ret = stmmac_tc_init(priv, priv); > + if (!ret) { > + ndev->hw_features |= NETIF_F_HW_TC; > + } > + > if ((priv->plat->tso_en) && (priv->dma_cap.tsoen)) { > ndev->hw_features |= NETIF_F_TSO | NETIF_F_TSO6; > priv->tso = true; One more comment, but perhaps not a showstopper, it's considered good practice to disallow clearing/disabling this flag while filters are installed. Driver should return -EBUSY from .ndo_set_features if TC rules are offloaded and user wants to disable HW_TC feature flag.