[dpdk-dev] [PATCH v2 5/5] net/mlx5: fix non-dv compilation errors

Gregory Etelson getelson at nvidia.com
Sat Nov 14 19:31:45 CET 2020


> 14/11/2020 18:41, Gregory Etelson:
> > > 13/11/2020 15:52, Gregory Etelson:
> > > > +       ret = mlx5_flow_group_to_table(dev, tunnel, jump_data-
> >group,
> > > > +                                      &flow_table, grp_info,
> > > > + error);
> > >
> > > The parameter grp_info is a struct passed as value.
> > > I believe it should be passed as a pointer.
> >
> > struct flow_grp_info is a 64 bit-field:
> > struct flow_grp_info {
> >       uint64_t external:1;
> >       uint64_t transfer:1;
> >       uint64_t fdb_def_rule:1;
> >       /* force standard group translation */
> >       uint64_t std_tbl_fix:1;
> >       uint64_t skip_scale:1;
> > };
> > Since mlx5_flow_group_to_table() does not change bits configuration,
> > there is no need to pass this type as a pointer.
> 
> I feel passing struct as pointer is a better practice.
>

The parameter in question is 64 bit unsigned long value.
Structure coating is a syntactic sugar, because
C language does not have bit-field types.
In general, if structure size does not exceed 64 bit it can be passed
by value.
Passing it by reference would create unnecessary indirect access.

> > > I see some other functions are passing arrays with [] syntax, which
> > > does not make sense in parameters. I should be a simple pointer.
> >
> > I agree that arrays should not be passed with [] syntax.
> > However, I kept existing rte flow style - see rte_flow_create
> 
> I recommend not following this bad code style.
> Later other occurences should be fixed.
> 
> > > Matan, Slava, as maintainers, what are your policies in mlx5 code?
> 
> 



More information about the dev mailing list