Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Lobakin <alexandr.lobakin@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next 16/19] iecm: implement flow director
Date: Fri,  4 Feb 2022 11:08:28 +0100	[thread overview]
Message-ID: <20220204100828.77916-1-alexandr.lobakin@intel.com> (raw)
In-Reply-To: <CO1PR11MB518650C6F3DCE7DBAF6CFE5D8F289@CO1PR11MB5186.namprd11.prod.outlook.com>

From: Alan Brady <alan.brady@intel.com>
Date: Thu, 3 Feb 2022 03:41:26 +0100

> > -----Original Message-----
> > From: Lobakin, Alexandr <alexandr.lobakin@intel.com>
> > Sent: Friday, January 28, 2022 11:04 AM
> > To: Brady, Alan <alan.brady@intel.com>
> > Cc: Lobakin, Alexandr <alexandr.lobakin@intel.com>; Wang, Haiyue
> > <haiyue.wang@intel.com>; Burra, Phani R <phani.r.burra@intel.com>;
> > Chittim, Madhu <madhu.chittim@intel.com>; Linga, Pavan Kumar
> > <pavan.kumar.linga@intel.com>; intel-wired-lan at lists.osuosl.org
> > Subject: Re: [Intel-wired-lan] [PATCH net-next 16/19] iecm: implement flow
> > director
> > 
> > From: Alan Brady <alan.brady@intel.com>
> > Date: Thu, 27 Jan 2022 16:10:06 -0800
> > 
> > > From: Haiyue Wang <haiyue.wang@intel.com>
> > >
> > > This adds everthing needed to do flow director commands.
> > >
> > > Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
> > > ---
> > >  .../net/ethernet/intel/iecm/iecm_ethtool.c    |   17 +-
> > >  drivers/net/ethernet/intel/iecm/iecm_lib.c    | 1528
> > ++++++++++++++++-
> > >  .../net/ethernet/intel/iecm/iecm_virtchnl.c   |  119 ++
> > >  drivers/net/ethernet/intel/include/iecm.h     |  112 ++
> > >  4 files changed, 1770 insertions(+), 6 deletions(-)
> > >

--- 8< ---

> > > +	switch (fltr->flow_type) {
> > > +	case IECM_FDIR_FLOW_IPV4_TCP:
> > > +	case IECM_FDIR_FLOW_IPV4_UDP:
> > > +	case IECM_FDIR_FLOW_IPV4_SCTP:
> > > +		dev_info(dev, "Rule ID: %u dst_ip: %pI4 src_ip %pI4 %s:
> > dst_port %hu src_port %hu\n",
> > > +			 fltr->loc,
> > > +			 &fltr->ip_data.v4_addrs.dst_ip,
> > > +			 &fltr->ip_data.v4_addrs.src_ip,
> > > +			 proto,
> > > +			 ntohs(fltr->ip_data.dst_port),
> > > +			 ntohs(fltr->ip_data.src_port));
> > 
> > Some of those can fit into previous line, there's no need to put
> > each argument onto separate one.
> > 
> 
> It technically can fit on one line, but it's much easier for humans to parse what's going where the way it's written now.

Not sure there's a choice here, usually it's preferred to compress
lines if there's a possibility.

> 
> > > +		break;
> > > +	case IECM_FDIR_FLOW_IPV4_AH:

--- 8< ---

> > > +	fdir_config = &adapter->config_data.fdir_config;
> > > +	list_for_each_entry(rule, &fdir_config->fdir_fltr_list, list)
> > > +		if (rule->loc == loc)
> > > +			return rule;
> > 
> > Here's a good example that a single `if` statement shouldn't be
> > placed into a pair of braces.
> > 
> 
> You're right it does need some braces on the list_for_each, will fix.

I said the opposite, please don't present your opinion as mine. I'm
not sure it's a correct thing to do during the review.
As mentioned previously plenty of times, braces are expected only
when they're purely necessary. Your approach doesn't even improve
the readability as you claim.

> 
> > > +
> > > +	return NULL;
> > > +}
> > > +
> > > +/**
> > > + * iecm_fdir_list_add_fltr - add a new node to the flow director filter list

--- 8< ---

> > > + * If the mask is fully set return true. If it is not valid for field return
> > > + * false.
> > > + */
> > > +static bool iecm_is_mask_valid(u64 mask, u64 field)
> > > +{
> > > +	return (mask & field) == field;
> > > +}
> > 
> > That is something really basic and should at least be placed
> > somewhere in the headers and used module-wide.
> > 
> 
> I'm not convinced it makes sense to do that if it's not actually being used module wide. I'm pretty sure this is only validating user input for flow director filters.

`(mask & field) == field` pattern is used widely across iecm code.
This function simply won't pass the review. If it reflects FD logics
somehow, this should be explained in the kdoc block, so there'll be
less questions why it's here at all. For now it looks like a generic
function, not FD-specific one.
Anyway, I've just highlighted all references to this function and
it's used only *once* throughout the code. So it's a pure overkill
and should be just open-coded there.

> 
> > > +
> > > +/**
> > > + * iecm_parse_rx_flow_user_data - deconstruct user-defined data

--- 8< ---

> > > +enum iecm_fdir_flow_type {
> > > +	/* NONE - used for undef/error */
> > > +	IECM_FDIR_FLOW_NONE = 0,
> > 
> > Enums always start with 0 unless other value specified, this is a
> > bit excessive.
> > 
> 
> AFAIK this is the normal thing to do in Linux kernel.  In cases where the value actually matters, as is here, it's better to be explicit even though yes you're right it should be getting the default value of zero.

Does it? It mostly only matters when it's being passed to HW anyhow,
but I'm not sure it's the case here.
Anyways, I admit it's rather a personal preference, so I don't mind.

> 
> E.g. in kernel/sched/sched.h you can find:
> 
> /* The regions in numa_faults array from task_struct */
> enum numa_faults_stats {
>         NUMA_MEM = 0,
>         NUMA_CPU,
>         NUMA_MEMBUF,
>         NUMA_CPUBUF
> };
> 
> and probably many more.
> 
> > > +	IECM_FDIR_FLOW_IPV4_TCP,

--- 8< ---

> > > --
> > > 2.33.0
> > 
> > Thanks,
> > Al

Thanks,
Al

  reply	other threads:[~2022-02-04 10:08 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-28  0:09 [Intel-wired-lan] [PATCH net-next 00/19] Add iecm and idpf Alan Brady
2022-01-28  0:09 ` [Intel-wired-lan] [PATCH net-next 01/19] virtchnl: Add new virtchnl2 ops Alan Brady
2022-02-02 22:13   ` Brady, Alan
2022-01-28  0:09 ` [Intel-wired-lan] [PATCH net-next 02/19] iecm: add basic module init and documentation Alan Brady
2022-01-28 11:56   ` Alexander Lobakin
2022-02-02 22:15     ` Brady, Alan
2022-02-01 19:44   ` Shannon Nelson
2022-02-03  3:08     ` Brady, Alan
2022-01-28  0:09 ` [Intel-wired-lan] [PATCH net-next 03/19] iecm: add probe and remove Alan Brady
2022-02-01 20:02   ` Shannon Nelson
2022-02-03  3:13     ` Brady, Alan
2022-01-28  0:09 ` [Intel-wired-lan] [PATCH net-next 04/19] iecm: add api_init and controlq init Alan Brady
2022-01-28 12:09   ` Alexander Lobakin
2022-02-02 22:16     ` Brady, Alan
2022-02-01 21:26   ` Shannon Nelson
2022-02-03  3:24     ` Brady, Alan
2022-02-03  3:40       ` Brady, Alan
2022-02-03  5:26         ` Shannon Nelson
2022-02-03 13:13       ` Alexander Lobakin
2022-01-28  0:09 ` [Intel-wired-lan] [PATCH net-next 05/19] iecm: add vport alloc and virtchnl messages Alan Brady
2022-01-28  4:19   ` kernel test robot
2022-01-28 12:39     ` Alexander Lobakin
2022-02-02 22:23       ` Brady, Alan
2022-01-28 12:32   ` Alexander Lobakin
2022-02-02 22:21     ` Brady, Alan
2022-02-03 13:23       ` Alexander Lobakin
2022-01-28  0:09 ` [Intel-wired-lan] [PATCH net-next 06/19] iecm: add virtchnl messages for queues Alan Brady
2022-01-28 13:03   ` Alexander Lobakin
2022-02-02 22:48     ` Brady, Alan
2022-02-03 10:08       ` Maciej Fijalkowski
2022-02-03 14:09       ` Alexander Lobakin
2022-01-28  0:09 ` [Intel-wired-lan] [PATCH net-next 07/19] iecm: finish virtchnl messages Alan Brady
2022-01-28 13:19   ` Alexander Lobakin
2022-02-02 23:06     ` Brady, Alan
2022-02-03 15:05       ` Alexander Lobakin
2022-02-03 15:16         ` Maciej Fijalkowski
2022-01-28  0:09 ` [Intel-wired-lan] [PATCH net-next 08/19] iecm: add interrupts and configure netdev Alan Brady
2022-01-28 13:34   ` Alexander Lobakin
2022-02-02 23:17     ` Brady, Alan
2022-02-03 15:55       ` Alexander Lobakin
2022-01-28  0:09 ` [Intel-wired-lan] [PATCH net-next 09/19] iecm: alloc vport TX resources Alan Brady
2022-02-02 23:45   ` Brady, Alan
2022-02-03 17:56     ` Alexander Lobakin
2022-01-28  0:10 ` [Intel-wired-lan] [PATCH net-next 10/19] iecm: alloc vport RX resources Alan Brady
2022-01-28 14:16   ` Alexander Lobakin
2022-02-03  0:13     ` Brady, Alan
2022-02-03 18:29       ` Alexander Lobakin
2022-01-28  0:10 ` [Intel-wired-lan] [PATCH net-next 11/19] iecm: add start_xmit and set_rx_mode Alan Brady
2022-01-28 16:35   ` Alexander Lobakin
2022-01-28  0:10 ` [Intel-wired-lan] [PATCH net-next 12/19] iecm: finish netdev_ops Alan Brady
2022-01-28 17:06   ` Alexander Lobakin
2022-01-28  0:10 ` [Intel-wired-lan] [PATCH net-next 13/19] iecm: implement splitq napi_poll Alan Brady
2022-01-28  5:21   ` kernel test robot
2022-01-28 17:44     ` Alexander Lobakin
2022-02-03  1:15       ` Brady, Alan
2022-01-28 17:38   ` Alexander Lobakin
2022-02-03  1:07     ` Brady, Alan
2022-02-04 11:50       ` Alexander Lobakin
2022-01-28  0:10 ` [Intel-wired-lan] [PATCH net-next 14/19] iecm: implement singleq napi_poll Alan Brady
2022-01-28 17:57   ` Alexander Lobakin
2022-02-03  1:45     ` Brady, Alan
2022-02-03 19:05       ` Alexander Lobakin
2022-01-28  0:10 ` [Intel-wired-lan] [PATCH net-next 15/19] iecm: implement ethtool callbacks Alan Brady
2022-01-28 18:13   ` Alexander Lobakin
2022-02-03  2:13     ` Brady, Alan
2022-02-03 19:54       ` Alexander Lobakin
2022-01-28  0:10 ` [Intel-wired-lan] [PATCH net-next 16/19] iecm: implement flow director Alan Brady
2022-01-28 19:04   ` Alexander Lobakin
2022-02-03  2:41     ` Brady, Alan
2022-02-04 10:08       ` Alexander Lobakin [this message]
2022-01-28  0:10 ` [Intel-wired-lan] [PATCH net-next 17/19] iecm: implement cloud filters Alan Brady
2022-01-28 19:38   ` Alexander Lobakin
2022-02-03  2:53     ` Brady, Alan
2022-01-28  0:10 ` [Intel-wired-lan] [PATCH net-next 18/19] iecm: add advanced rss Alan Brady
2022-01-28 19:53   ` Alexander Lobakin
2022-02-03  2:55     ` Brady, Alan
2022-02-03 10:46       ` Maciej Fijalkowski
2022-02-04 10:22       ` Alexander Lobakin
2022-01-28  0:10 ` [Intel-wired-lan] [PATCH net-next 19/19] idpf: introduce idpf driver Alan Brady
2022-01-28 20:08   ` Alexander Lobakin
2022-02-03  3:07     ` Brady, Alan
2022-02-04 10:35       ` Alexander Lobakin
2022-02-04 12:05 ` [Intel-wired-lan] [PATCH net-next 00/19] Add iecm and idpf Alexander Lobakin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220204100828.77916-1-alexandr.lobakin@intel.com \
    --to=alexandr.lobakin@intel.com \
    --cc=intel-wired-lan@osuosl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox