public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Slepecki <jakub.slepecki@intel.com>
To: intel-wired-lan@lists.osuosl.org
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	przemyslaw.kitszel@intel.com, anthony.l.nguyen@intel.com,
	michal.swiatkowski@linux.intel.com, jakub.slepecki@intel.com,
	aleksandr.loktionov@intel.com
Subject: [PATCH iwl-next v4 5/7] ice: add functions to query for vsi's pvids
Date: Wed,  4 Feb 2026 16:44:16 +0100	[thread overview]
Message-ID: <20260204154418.1285309-6-jakub.slepecki@intel.com> (raw)
In-Reply-To: <20260204154418.1285309-1-jakub.slepecki@intel.com>

PVID information is set across two structs and several members depending
primarily on DVM support and VSI type.  Add function that guess whether
PVID is set and where and allow to access raw VLAN ID set.  This is
intended to be used later on to decide what MAC{,VLAN} filters to set
for a VSI.

Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Jakub Slepecki <jakub.slepecki@intel.com>

---
No changes iv v4.
No changes in v3.
No changes in v2.
---
 drivers/net/ethernet/intel/ice/ice_lib.c | 56 ++++++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_lib.h |  2 +
 2 files changed, 58 insertions(+)

diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index 041278caf8e3..ff4763cea2e5 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -4136,3 +4136,59 @@ void ice_vsi_update_l2tsel(struct ice_vsi *vsi, enum ice_l2tsel l2tsel)
 		wr32(hw, qrx_context_offset, regval);
 	}
 }
+
+/**
+ * ice_vsi_has_outer_pvid - check if VSI has outer Port VLAN ID assigned
+ * @info: props of VSI in question
+ *
+ * Return: true if VSI has outer PVID, false otherwise.
+ */
+static bool
+ice_vsi_has_outer_pvid(const struct ice_aqc_vsi_props *info)
+{
+	return info->outer_vlan_flags & ICE_AQ_VSI_OUTER_VLAN_PORT_BASED_INSERT;
+}
+
+/**
+ * ice_vsi_has_inner_pvid - check if VSI has inner Port VLAN ID assigned
+ * @info: props of VSI in question
+ *
+ * Return: true if VSI has inner PVID, false otherwise.
+ */
+static bool
+ice_vsi_has_inner_pvid(const struct ice_aqc_vsi_props *info)
+{
+	return info->inner_vlan_flags & ICE_AQ_VSI_INNER_VLAN_INSERT_PVID;
+}
+
+/**
+ * ice_vsi_has_pvid - check if VSI has Port VLAN ID assigned
+ * @vsi: VSI in question
+ *
+ * Return: true if VSI has either outer or inner PVID, false otherwise.
+ */
+bool
+ice_vsi_has_pvid(struct ice_vsi *vsi)
+{
+	return ice_vsi_has_outer_pvid(&vsi->info) ||
+	       ice_vsi_has_inner_pvid(&vsi->info);
+}
+
+/**
+ * ice_vsi_pvid - retrieve VSI's Port VLAN ID
+ * @vsi: VSI in question
+ *
+ * Return: VSI's PVID; it is valid only if ice_vsi_has_pvid is true.
+ */
+u16
+ice_vsi_pvid(struct ice_vsi *vsi)
+{
+	__le16 vlan_info = 0;
+
+	if (ice_vsi_has_outer_pvid(&vsi->info))
+		vlan_info = vsi->info.port_based_outer_vlan;
+	else if (ice_vsi_has_inner_pvid(&vsi->info))
+		vlan_info = vsi->info.port_based_inner_vlan;
+
+	return le16_to_cpu(vlan_info) & VLAN_VID_MASK;
+}
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.h b/drivers/net/ethernet/intel/ice/ice_lib.h
index 2d3168458891..46152e26a995 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.h
+++ b/drivers/net/ethernet/intel/ice/ice_lib.h
@@ -134,6 +134,8 @@ void ice_clear_feature_support(struct ice_pf *pf, enum ice_feature f);
 void ice_init_feature_support(struct ice_pf *pf);
 bool ice_vsi_is_rx_queue_active(struct ice_vsi *vsi);
 void ice_vsi_update_l2tsel(struct ice_vsi *vsi, enum ice_l2tsel l2tsel);
+bool ice_vsi_has_pvid(struct ice_vsi *vsi);
+u16 ice_vsi_pvid(struct ice_vsi *vsi);
 
 extern const struct netdev_queue_mgmt_ops ice_queue_mgmt_ops;
 
-- 
2.43.0


  parent reply	other threads:[~2026-02-04 15:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-04 15:44 [PATCH iwl-next v4 0/7] ice: in VEB, prevent "cross-vlan" traffic Jakub Slepecki
2026-02-04 15:44 ` [PATCH iwl-next v4 1/7] ice: in dvm, use outer VLAN in MAC,VLAN lookup Jakub Slepecki
2026-03-02 17:35   ` [Intel-wired-lan] [PATCH iwl-next v4 1/7] ice: in dvm, use outer VLAN in MAC, VLAN lookup Romanowski, Rafal
2026-02-04 15:44 ` [PATCH iwl-next v4 2/7] ice: allow creating mac,vlan filters along mac filters Jakub Slepecki
2026-03-02 17:36   ` [Intel-wired-lan] [PATCH iwl-next v4 2/7] ice: allow creating mac, vlan " Romanowski, Rafal
2026-02-04 15:44 ` [PATCH iwl-next v4 3/7] ice: allow overriding lan_en, lb_en in switch Jakub Slepecki
2026-03-02 17:37   ` [Intel-wired-lan] " Romanowski, Rafal
2026-02-04 15:44 ` [PATCH iwl-next v4 4/7] ice: update mac,vlan rules when toggling between VEB and VEPA Jakub Slepecki
2026-03-02 17:38   ` [Intel-wired-lan] [PATCH iwl-next v4 4/7] ice: update mac, vlan " Romanowski, Rafal
2026-02-04 15:44 ` Jakub Slepecki [this message]
2026-03-02 17:39   ` [Intel-wired-lan] [PATCH iwl-next v4 5/7] ice: add functions to query for vsi's pvids Romanowski, Rafal
2026-02-04 15:44 ` [PATCH iwl-next v4 6/7] ice: add mac vlan to filter API Jakub Slepecki
2026-03-02 17:39   ` [Intel-wired-lan] " Romanowski, Rafal
2026-02-04 15:44 ` [PATCH iwl-next v4 7/7] ice: in VEB, prevent "cross-vlan" traffic from hitting loopback Jakub Slepecki
2026-03-02 17:40   ` [Intel-wired-lan] " Romanowski, Rafal
2026-02-27 13:51 ` [Intel-wired-lan] [PATCH iwl-next v4 0/7] ice: in VEB, prevent "cross-vlan" traffic Romanowski, Rafal

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=20260204154418.1285309-6-jakub.slepecki@intel.com \
    --to=jakub.slepecki@intel.com \
    --cc=aleksandr.loktionov@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.swiatkowski@linux.intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=przemyslaw.kitszel@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