netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Piotr Raczynski <piotr.raczynski@intel.com>
To: Simon Horman <simon.horman@corigine.com>
Cc: <intel-wired-lan@lists.osuosl.org>, <netdev@vger.kernel.org>,
	<michal.swiatkowski@intel.com>, <shiraz.saleem@intel.com>,
	<jacob.e.keller@intel.com>, <sridhar.samudrala@intel.com>,
	<jesse.brandeburg@intel.com>, <aleksander.lobakin@intel.com>,
	<lukasz.czapnik@intel.com>,
	Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Subject: Re: [PATCH net-next v3 6/8] ice: add individual interrupt allocation
Date: Tue, 28 Mar 2023 18:16:15 +0200	[thread overview]
Message-ID: <ZCMSzzw1MTIc9dZW@nimitz> (raw)
In-Reply-To: <ZCBGC47iYuMloMms@corigine.com>

On Sun, Mar 26, 2023 at 03:18:03PM +0200, Simon Horman wrote:
> On Thu, Mar 23, 2023 at 01:24:38PM +0100, Piotr Raczynski wrote:
> > Currently interrupt allocations, depending on a feature are distributed
> > in batches. Also, after allocation there is a series of operations that
> > distributes per irq settings through that batch of interrupts.
> > 
> > Although driver does not yet support dynamic interrupt allocation, keep
> > allocated interrupts in a pool and add allocation abstraction logic to
> > make code more flexible. Keep per interrupt information in the
> > ice_q_vector structure, which yields ice_vsi::base_vector redundant.
> > Also, as a result there are a few functions that can be removed.
> > 
> > Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> > Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> > Signed-off-by: Piotr Raczynski <piotr.raczynski@intel.com>
> 
> Reviewed-by: Simon Horman <simon.horman@corigine.com>
> 
> I've made a few minor observations inline.
> I don't think there is a need to respin for any of them.
> 
Thanks.
> > ---
> >  drivers/net/ethernet/intel/ice/ice.h         |  11 +-
> >  drivers/net/ethernet/intel/ice/ice_arfs.c    |   5 +-
> >  drivers/net/ethernet/intel/ice/ice_base.c    |  36 ++-
> >  drivers/net/ethernet/intel/ice/ice_ethtool.c |   2 +-
> >  drivers/net/ethernet/intel/ice/ice_idc.c     |  45 ++--
> >  drivers/net/ethernet/intel/ice/ice_irq.c     |  46 +++-
> >  drivers/net/ethernet/intel/ice/ice_irq.h     |   3 +
> >  drivers/net/ethernet/intel/ice/ice_lib.c     | 225 ++-----------------
> 
> Nice code removal from ice_lib.c :)
> 
> >  drivers/net/ethernet/intel/ice/ice_lib.h     |   4 +-
> >  drivers/net/ethernet/intel/ice/ice_main.c    |  44 ++--
> >  drivers/net/ethernet/intel/ice/ice_ptp.c     |   2 +-
> >  drivers/net/ethernet/intel/ice/ice_sriov.c   |   2 +-
> >  drivers/net/ethernet/intel/ice/ice_xsk.c     |   5 +-
> >  13 files changed, 154 insertions(+), 276 deletions(-)
> 
> ...
> 
> > diff --git a/drivers/net/ethernet/intel/ice/ice_base.c b/drivers/net/ethernet/intel/ice/ice_base.c
> > index 1911d644dfa8..e5db23eaa3f4 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_base.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_base.c
> > @@ -118,9 +118,31 @@ static int ice_vsi_alloc_q_vector(struct ice_vsi *vsi, u16 v_idx)
> >  	q_vector->rx.itr_mode = ITR_DYNAMIC;
> >  	q_vector->tx.type = ICE_TX_CONTAINER;
> >  	q_vector->rx.type = ICE_RX_CONTAINER;
> > +	q_vector->irq.index = -ENOENT;
> >  
> > -	if (vsi->type == ICE_VSI_VF)
> > +	if (vsi->type == ICE_VSI_VF) {
> > +		q_vector->reg_idx = ice_calc_vf_reg_idx(vsi->vf, q_vector);
> >  		goto out;
> > +	} else if (vsi->type == ICE_VSI_CTRL && vsi->vf) {
> > +		struct ice_vsi *ctrl_vsi = ice_get_vf_ctrl_vsi(pf, vsi);
> > +
> > +		if (ctrl_vsi) {
> > +			if (unlikely(!ctrl_vsi->q_vectors))
> > +				return -ENOENT;
> > +			q_vector->irq = ctrl_vsi->q_vectors[0]->irq;
> > +			goto skip_alloc;
> 
> nit: I think goto for error paths is very much the norm.
>      But, FWIIW, I would have avoided using goto here.

Thanks will take a look.

> 
> > +		}
> > +	}
> > +
> > +	q_vector->irq = ice_alloc_irq(pf);
> > +	if (q_vector->irq.index < 0) {
> > +		kfree(q_vector);
> > +		return -ENOMEM;
> > +	}
> > +
> > +skip_alloc:
> > +	q_vector->reg_idx = q_vector->irq.index;
> > +
> >  	/* only set affinity_mask if the CPU is online */
> >  	if (cpu_online(v_idx))
> >  		cpumask_set_cpu(v_idx, &q_vector->affinity_mask);
> > @@ -168,6 +190,18 @@ static void ice_free_q_vector(struct ice_vsi *vsi, int v_idx)
> >  	if (vsi->netdev)
> >  		netif_napi_del(&q_vector->napi);
> >  
> > +	/* release MSIX interrupt if q_vector had interrupt allocated */
> > +	if (q_vector->irq.index < 0)
> > +		goto free_q_vector;
> > +
> > +	/* only free last VF ctrl vsi interrupt */
> > +	if (vsi->type == ICE_VSI_CTRL && vsi->vf &&
> > +	    ice_get_vf_ctrl_vsi(pf, vsi))
> > +		goto free_q_vector;
> 
> Ditto (x2).
Will also take a look.
> 
> > +
> > +	ice_free_irq(pf, q_vector->irq);
> > +
> > +free_q_vector:
> >  	devm_kfree(dev, q_vector);
> >  	vsi->q_vectors[v_idx] = NULL;
> >  }
> 
> ...
> 
> > diff --git a/drivers/net/ethernet/intel/ice/ice_irq.c b/drivers/net/ethernet/intel/ice/ice_irq.c
> > index f61be5d76373..ca1a1de26766 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_irq.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_irq.c
> > @@ -194,9 +194,53 @@ int ice_init_interrupt_scheme(struct ice_pf *pf)
> >  	}
> >  
> >  	/* populate SW interrupts pool with number of OS granted IRQs. */
> > -	pf->num_avail_sw_msix = (u16)vectors;
> >  	pf->irq_tracker->num_entries = (u16)vectors;
> >  	pf->irq_tracker->end = pf->irq_tracker->num_entries;
> >  
> >  	return 0;
> >  }
> > +
> > +/**
> > + * ice_alloc_irq - Allocate new interrupt vector
> > + * @pf: board private structure
> > + *
> > + * Allocate new interrupt vector for a given owner id.
> > + * return struct msi_map with interrupt details and track
> > + * allocated interrupt appropriately.
> > + *
> > + * This function mimics individual interrupt allocation,
> > + * even interrupts are actually already allocated with
> > + * pci_alloc_irq_vectors. Individual allocation helps
> > + * to track interrupts and simplifies interrupt related
> > + * handling.
> > + *
> > + * On failure, return map with negative .index. The caller
> > + * is expected to check returned map index.
> > + *
> > + */
> > +struct msi_map ice_alloc_irq(struct ice_pf *pf)
> > +{
> > +	struct msi_map map = { .index = -ENOENT };
> > +	int entry;
> > +
> > +	entry = ice_get_res(pf, pf->irq_tracker);
> > +	if (entry < 0)
> 
> nit: map.index could be initialised here.
> 
> > +		return map;
> > +
> > +	map.index = entry;
> > +	map.virq = pci_irq_vector(pf->pdev, map.index);
> > +
> > +	return map;
> > +}

  reply	other threads:[~2023-03-28 16:16 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 12:24 [PATCH net-next v3 0/8] ice: support dynamic interrupt allocation Piotr Raczynski
2023-03-23 12:24 ` [PATCH net-next v3 1/8] ice: move interrupt related code to separate file Piotr Raczynski
2023-03-26 13:34   ` Simon Horman
2023-04-21  5:36   ` [Intel-wired-lan] " Pucha, HimasekharX Reddy
2023-03-23 12:24 ` [PATCH net-next v3 2/8] ice: use pci_irq_vector helper function Piotr Raczynski
2023-03-26 13:35   ` Simon Horman
2023-04-21  5:41   ` [Intel-wired-lan] " Pucha, HimasekharX Reddy
2023-03-23 12:24 ` [PATCH net-next v3 3/8] ice: use preferred MSIX allocation api Piotr Raczynski
2023-03-26 13:35   ` Simon Horman
2023-04-21  5:45   ` [Intel-wired-lan] " Pucha, HimasekharX Reddy
2023-03-23 12:24 ` [PATCH net-next v3 4/8] ice: refactor VF control VSI interrupt handling Piotr Raczynski
2023-03-26 13:36   ` Simon Horman
2023-03-23 12:24 ` [PATCH net-next v3 5/8] ice: remove redundant SRIOV code Piotr Raczynski
2023-03-26 13:36   ` Simon Horman
2023-04-06  9:50     ` [Intel-wired-lan] " Romanowski, Rafal
2023-03-23 12:24 ` [PATCH net-next v3 6/8] ice: add individual interrupt allocation Piotr Raczynski
2023-03-26 13:18   ` Simon Horman
2023-03-28 16:16     ` Piotr Raczynski [this message]
2023-04-21  5:48   ` [Intel-wired-lan] " Pucha, HimasekharX Reddy
2023-03-23 12:24 ` [PATCH net-next v3 7/8] ice: track interrupt vectors with xarray Piotr Raczynski
2023-03-26 13:19   ` Simon Horman
2023-03-28 16:12     ` Piotr Raczynski
2023-04-21  5:53   ` [Intel-wired-lan] " Pucha, HimasekharX Reddy
2023-03-23 12:24 ` [PATCH net-next v3 8/8] ice: add dynamic interrupt allocation Piotr Raczynski
2023-03-26 13:37   ` Simon Horman
2023-04-21  5:55   ` [Intel-wired-lan] " Pucha, HimasekharX Reddy
2023-03-29 11:35 ` [PATCH net-next v3 0/8] ice: support " Leon Romanovsky

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=ZCMSzzw1MTIc9dZW@nimitz \
    --to=piotr.raczynski@intel.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jacob.e.keller@intel.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=lukasz.czapnik@intel.com \
    --cc=michal.swiatkowski@intel.com \
    --cc=michal.swiatkowski@linux.intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=shiraz.saleem@intel.com \
    --cc=simon.horman@corigine.com \
    --cc=sridhar.samudrala@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).