From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pablo Neira Ayuso Subject: Re: [PATCH net-next 12/12] qede: use ethtool_rx_flow_rule() to remove duplicated parser code Date: Mon, 19 Nov 2018 17:12:40 +0100 Message-ID: <20181119161240.wwnyxf73dyccssuf@salvia> References: <20181119001519.12124-1-pablo@netfilter.org> <20181119001519.12124-13-pablo@netfilter.org> <20181119160013.GA2364@nanopsycho> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: netdev@vger.kernel.org, davem@davemloft.net, thomas.lendacky@amd.com, f.fainelli@gmail.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, jakub.kicinski@netronome.com, peppe.cavallaro@st.com, grygorii.strashko@ti.com, andrew@lunn.ch, vivien.didelot@savoirfairelinux.com, alexandre.torgue@st.com, joabreu@synopsys.com, linux-net-drivers@solarflare.com, ganeshgr@chelsio.com, ogerlitz@mellanox.com To: Jiri Pirko Return-path: Received: from mail.us.es ([193.147.175.20]:49868 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729796AbeKTCgr (ORCPT ); Mon, 19 Nov 2018 21:36:47 -0500 Received: from antivirus1-rhel7.int (unknown [192.168.2.11]) by mail.us.es (Postfix) with ESMTP id 9A12A17AE3C for ; Mon, 19 Nov 2018 17:12:43 +0100 (CET) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id 7DF79DA7A6 for ; Mon, 19 Nov 2018 17:12:43 +0100 (CET) Content-Disposition: inline In-Reply-To: <20181119160013.GA2364@nanopsycho> Sender: netdev-owner@vger.kernel.org List-ID: On Mon, Nov 19, 2018 at 05:00:13PM +0100, Jiri Pirko wrote: > Mon, Nov 19, 2018 at 01:15:19AM CET, pablo@netfilter.org wrote: [...] > >-static int qede_flow_spec_to_tuple(struct qede_dev *edev, > >- struct qede_arfs_tuple *t, > >- struct ethtool_rx_flow_spec *fs) > >+static int qede_flow_spec_to_rule(struct qede_dev *edev, > >+ struct qede_arfs_tuple *t, > >+ struct ethtool_rx_flow_spec *fs) > > { > >- memset(t, 0, sizeof(*t)); > >- > >- if (qede_flow_spec_validate_unused(edev, fs)) > >- return -EOPNOTSUPP; > >+ struct tc_cls_flower_offload f = {}; > >+ struct flow_rule *flow_rule; > >+ __be16 proto; > >+ int err = 0; > > > > switch ((fs->flow_type & ~FLOW_EXT)) { > > case TCP_V4_FLOW: > >- return qede_flow_spec_to_tuple_tcpv4(edev, t, fs); > > case UDP_V4_FLOW: > >- return qede_flow_spec_to_tuple_udpv4(edev, t, fs); > >+ proto = htons(ETH_P_IP); > >+ break; > > case TCP_V6_FLOW: > >- return qede_flow_spec_to_tuple_tcpv6(edev, t, fs); > > case UDP_V6_FLOW: > >- return qede_flow_spec_to_tuple_udpv6(edev, t, fs); > >+ proto = htons(ETH_P_IPV6); > >+ break; > > default: > > DP_VERBOSE(edev, NETIF_MSG_IFUP, > > "Can't support flow of type %08x\n", fs->flow_type); > > return -EOPNOTSUPP; > > } > > > >- return 0; > >+ flow_rule = ethtool_rx_flow_rule(fs); > >+ if (!flow_rule) > >+ return -ENOMEM; > >+ > >+ f.rule = *flow_rule; > > This does not look right. I undersntand that you want to use the same > driver code to parse same struct coming either from tc-flower or > ethtool. That is why you introduced flow_rule as a intermediate layer. > However, here, you use struct that is very tc-flower specific. Common > parser should work on struct flow_rule. > > qede_parse_flower_attr() should accept struct flow_rule * and should be > renamed to something like qede_parse_flow_rule(). That was intentional, to keep the number of changes in this drivers as small as possible while introducing the flow_rule infrastructure. I'll rework the driver as you're asking, so I can pass struct flow_rule instead to all parser functions. The patchset is already rather large, and involving many driver, I was trying to keep changes to minimal but I'll update this driver as you request, no problem. Thanks.