Re: [PATCH V3 net 1/2] net: hns: fix wrong head when modify the tx feature when sending packets

From: Paolo Abeni
Date: Wed Dec 06 2023 - 09:28:08 EST


On Wed, 2023-12-06 at 20:31 +0800, Jijie Shao wrote:
> on 2023/12/6 19:18, Paolo Abeni wrote:
> > + priv->ops.fill_desc = fill_desc_v2;
> > + priv->ops.maybe_stop_tx = hns_nic_maybe_stop_tx_v2;
> > Side note: since both 'fill_desc' and 'maybe_stop_tx' have constant
> > values, for net-next you should really consider replacing the function
> > pointers with direct-calls.
> >
> > You currently have at least 2 indirect calls per wire packet, which
> > hurt performances a lot in case security issues mitigations are in
> > place.
> >
> > Cheers,
> >
> > Paolo
>
> Thank you for your advice. Currently, because the hardware behavior is
> different, the two versions of ops are retained to unify the subsequent
> process. We will try to unify the two version ops, and if that does not
> work, we will consider maintaining the status quo. Thanks again! Jijie

Note that even if you will have to resort to call different functions
for different H/W revisions, from performance PoV you will be far
better off doing a test at runtime to call the corresponding helper.

Or you can use the indirect call wrappers - have a look into:

include/linux/indirect_call_wrapper.h

Cheers,

Paolo