From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Fainelli Subject: Re: [PATCH RFC,net-next 10/10] dsa: bcm_sf2: use flow_rule infrastructure Date: Wed, 26 Sep 2018 11:41:30 -0700 Message-ID: <9db26fa8-e1b0-acc5-80e8-6443d089fe2e@gmail.com> References: <20180925192001.2482-1-pablo@netfilter.org> <20180925192001.2482-11-pablo@netfilter.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: davem@davemloft.net, thomas.lendacky@amd.com, ariel.elior@cavium.com, michael.chan@broadcom.com, santosh@chelsio.com, madalin.bucur@nxp.com, yisen.zhuang@huawei.com, salil.mehta@huawei.com, jeffrey.t.kirsher@intel.com, tariqt@mellanox.com, saeedm@mellanox.com, jiri@mellanox.com, idosch@mellanox.com, ganeshgr@chelsio.com, jakub.kicinski@netronome.com, linux-net-drivers@solarflare.com, peppe.cavallaro@st.com, alexandre.torgue@st.com, joabreu@synopsys.com, grygorii.strashko@ti.com, andrew@lunn.ch, vivien.didelot@savoirfairelinux.com To: Pablo Neira Ayuso , netdev@vger.kernel.org Return-path: Received: from mail-wm1-f65.google.com ([209.85.128.65]:51956 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725806AbeI0A4d (ORCPT ); Wed, 26 Sep 2018 20:56:33 -0400 Received: by mail-wm1-f65.google.com with SMTP id y25-v6so3333106wmi.1 for ; Wed, 26 Sep 2018 11:42:15 -0700 (PDT) In-Reply-To: <20180925192001.2482-11-pablo@netfilter.org> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: Hi Pablo, On 09/25/2018 12:20 PM, Pablo Neira Ayuso wrote: > Update this driver to use the flow_rule infrastructure, hence the same > code to populate hardware IR can be used from ethtool_rx_flow and the > cls_flower interfaces. Thanks for doing the conversion, I believe we could change things a little bit such that there are fewer things to audit for correctness, see below: > > Signed-off-by: Pablo Neira Ayuso > --- > drivers/net/dsa/bcm_sf2_cfp.c | 311 ++++++++++++++++++++++-------------------- > 1 file changed, 166 insertions(+), 145 deletions(-) > > diff --git a/drivers/net/dsa/bcm_sf2_cfp.c b/drivers/net/dsa/bcm_sf2_cfp.c > index 47c5f272a084..9dace0e25a3a 100644 > --- a/drivers/net/dsa/bcm_sf2_cfp.c > +++ b/drivers/net/dsa/bcm_sf2_cfp.c > @@ -251,10 +251,12 @@ static int bcm_sf2_cfp_act_pol_set(struct bcm_sf2_priv *priv, > } > > static void bcm_sf2_cfp_slice_ipv4(struct bcm_sf2_priv *priv, > - struct ethtool_tcpip4_spec *v4_spec, > + struct flow_rule *flow_rule, > unsigned int slice_num, > bool mask) > { > + struct flow_match_ipv4_addrs ipv4; > + struct flow_match_ports ports; > u32 reg, offset; > > /* C-Tag [31:24] > @@ -268,41 +270,54 @@ static void bcm_sf2_cfp_slice_ipv4(struct bcm_sf2_priv *priv, > offset = CORE_CFP_DATA_PORT(4); > core_writel(priv, reg, offset); > > + flow_rule_match_ipv4_addrs(flow_rule, &ipv4); > + flow_rule_match_ports(flow_rule, &ports); > + > /* UDF_n_A7 [31:24] > * UDF_n_A6 [23:8] > * UDF_n_A5 [7:0] > */ > - reg = be16_to_cpu(v4_spec->pdst) >> 8; > - if (mask) > + if (mask) { > + reg = be16_to_cpu(ports.mask->dst) >> 8; > offset = CORE_CFP_MASK_PORT(3); > - else > + } else { > + reg = be16_to_cpu(ports.key->dst) >> 8; > offset = CORE_CFP_DATA_PORT(3); > + } For instance here, instead of having to assign "reg" differently, just have an intermediate struct flow_match_ports variable that either points to &ports.mask or &ports.key. I quickly glanced through the changes, and I suspect that they are correct, but there is unfortunately way too much code movement within the functions which greatly hinders the ability to have complete confidence in the changes :) Can you find a way to only perform the ethtool_rx_flow_spec to flow_rule conversion as close as possible from the point of use within the callee? Thanks! -- Florian