From: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
To: Jacob Keller <jacob.e.keller@intel.com>
Cc: Anthony Nguyen <anthony.l.nguyen@intel.com>,
Intel Wired LAN <intel-wired-lan@lists.osuosl.org>
Subject: Re: [Intel-wired-lan] [PATCH net-next 04/13] ice: add helper function for checking VSI VF requirement
Date: Mon, 16 Jan 2023 11:56:23 +0100 [thread overview]
Message-ID: <Y8UtV5QqESWncLcP@localhost.localdomain> (raw)
In-Reply-To: <20230113223735.2514364-5-jacob.e.keller@intel.com>
On Fri, Jan 13, 2023 at 02:37:26PM -0800, Jacob Keller wrote:
> A few places in ice_lib.c WARN if the VSI type is VF and the VF pointer is
> NULL. This helps protect against accidentally creating a ICE_VSI_VF without
> providing a VF pointer.
>
> A future change is going to introduce another type of VSI which has the
> same requirement, ICE_VSI_ADI. Instead of expanding each WARN_ON check to
> include both types, introduce a helper function to do this check. The
> ice_vsi_requires_vf function returns true if the VSI *must* have a VF, and
> returns false otherwise.
>
> Of specific note is that some VSI types may optionally have a VF but do not
> require them, such as the ICE_VSI_CTRL type. These return false.
>
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_lib.c | 26 +++++++++++++++++++++---
> 1 file changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
> index f89279ede9a1..79555e22a9be 100644
> --- a/drivers/net/ethernet/intel/ice/ice_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_lib.c
> @@ -34,6 +34,26 @@ const char *ice_vsi_type_str(enum ice_vsi_type vsi_type)
> }
> }
>
> +/**
> + * ice_vsi_requires_vf - Does this VSI type always require a VF?
> + * @vsi_type: the VSI type
> + *
> + * Returns true if the VSI type *must* have a VF pointer. Returns false
> + * otherwise. In particular, VSI types which may *optionally* have a VF
> + * pointer return false.
> + *
> + * Used to WARN in cases where we always expect a VF pointer to be non-NULL.
> + */
> +static int ice_vsi_requires_vf(enum ice_vsi_type vsi_type)
> +{
> + switch (vsi_type) {
> + case ICE_VSI_VF:
> + return true;
> + default:
> + return false;
> + }
> +}
Looks a little strange right now. Maybe send this whole patch with SIOV
series?
> +
> /**
> * ice_vsi_ctrl_all_rx_rings - Start or stop a VSI's Rx rings
> * @vsi: the VSI being configured
> @@ -175,7 +195,7 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi)
> struct ice_pf *pf = vsi->back;
> struct ice_vf *vf = vsi->vf;
>
> - if (WARN_ON(vsi_type == ICE_VSI_VF && !vf))
> + if (WARN_ON(ice_vsi_requires_vf(vsi_type) && !vf))
> return;
>
> switch (vsi_type) {
> @@ -2854,7 +2874,7 @@ int ice_vsi_cfg(struct ice_vsi *vsi, enum ice_vsi_type vsi_type,
> struct ice_pf *pf = vsi->back;
> int ret;
>
> - if (WARN_ON(vsi_type == ICE_VSI_VF && !vf))
> + if (WARN_ON(ice_vsi_requires_vf(vsi_type) && !vf))
> return -EINVAL;
>
> vsi->type = vsi_type;
> @@ -3487,7 +3507,7 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, int init_vsi)
> return -EINVAL;
>
> pf = vsi->back;
> - if (WARN_ON(vsi->type == ICE_VSI_VF && !vsi->vf))
> + if (WARN_ON(ice_vsi_requires_vf(vsi->type) && !vsi->vf))
> return -EINVAL;
>
> coalesce = kcalloc(vsi->num_q_vectors,
> --
> 2.38.1.420.g319605f8f00e
>
> _______________________________________________
> Intel-wired-lan mailing list
> Intel-wired-lan@osuosl.org
> https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
next prev parent reply other threads:[~2023-01-16 10:56 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-13 22:37 [Intel-wired-lan] [PATCH net-next 00/13] ice: various virtualization cleanups Jacob Keller
2023-01-13 22:37 ` [Intel-wired-lan] [PATCH net-next 01/13] ice: fix function comment referring to ice_vsi_alloc Jacob Keller
2023-01-16 10:31 ` Michal Swiatkowski
2023-01-13 22:37 ` [Intel-wired-lan] [PATCH net-next 02/13] ice: drop unnecessary VF parameter from several VSI functions Jacob Keller
2023-01-16 10:34 ` Michal Swiatkowski
2023-01-13 22:37 ` [Intel-wired-lan] [PATCH net-next 03/13] ice: move vsi_type assignment from ice_vsi_alloc to ice_vsi_cfg Jacob Keller
2023-01-16 10:47 ` Michal Swiatkowski
2023-01-17 19:20 ` Jacob Keller
2023-01-18 5:37 ` Michal Swiatkowski
2023-01-18 20:50 ` Jacob Keller
2023-01-17 22:24 ` Jacob Keller
2023-01-13 22:37 ` [Intel-wired-lan] [PATCH net-next 04/13] ice: add helper function for checking VSI VF requirement Jacob Keller
2023-01-16 10:56 ` Michal Swiatkowski [this message]
2023-01-17 19:23 ` Jacob Keller
2023-01-18 5:24 ` Michal Swiatkowski
2023-01-18 20:49 ` Jacob Keller
2023-01-13 22:37 ` [Intel-wired-lan] [PATCH net-next 05/13] ice: Fix RDMA latency issue by allowing write-combining Jacob Keller
2023-01-14 0:37 ` kernel test robot
2023-01-14 1:58 ` kernel test robot
2023-01-13 22:37 ` [Intel-wired-lan] [PATCH net-next 06/13] ice: move ice_vf_vsi_release into ice_vf_lib.c Jacob Keller
2023-01-13 22:37 ` [Intel-wired-lan] [PATCH net-next 07/13] ice: Pull common tasks into ice_vf_post_vsi_rebuild Jacob Keller
2023-01-13 22:37 ` [Intel-wired-lan] [PATCH net-next 08/13] ice: add a function to initialize vf entry Jacob Keller
2023-01-13 22:37 ` [Intel-wired-lan] [PATCH net-next 09/13] ice: introduce ice_vf_init_host_cfg function Jacob Keller
2023-01-13 22:37 ` [Intel-wired-lan] [PATCH net-next 10/13] ice: convert vf_ops .vsi_rebuild to .create_vsi Jacob Keller
2023-01-27 9:46 ` Szlosek, Marek
2023-01-13 22:37 ` [Intel-wired-lan] [PATCH net-next 11/13] ice: introduce clear_reset_state operation Jacob Keller
2023-01-14 1:17 ` kernel test robot
2023-01-14 3:49 ` kernel test robot
2023-01-13 22:37 ` [Intel-wired-lan] [PATCH net-next 12/13] ice: introduce .irq_close VF operation Jacob Keller
2023-01-13 22:37 ` [Intel-wired-lan] [PATCH net-next 13/13] ice: remove unnecessary virtchnl_ether_addr struct use Jacob Keller
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=Y8UtV5QqESWncLcP@localhost.localdomain \
--to=michal.swiatkowski@linux.intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jacob.e.keller@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