[Intel-wired-lan] [PATCH iwl-next v2 0/3] i40e: Add and use version check helpers

2023-10-24 Thread Ivan Vecera
The series moves an existing check for AQ API version to header file,
adds another ones for firmware version check and use them to refactor
existing open-coded version checks.

Series content:
Patch 1: Moves i40e_is_aq_api_ver_ge() helper to header file
Patch 2: Adds another helpers to check running FW version
Patch 3: Re-factors existing open-coded checks to use the new helpers

Changes:
v2 - Fixed indentation

Ivan Vecera (3):
  i40e: Move i40e_is_aq_api_ver_ge helper
  i40e: Add other helpers to check version of running firmware and AQ API
  i40e: Use helpers to check running FW and AQ API versions

 drivers/net/ethernet/intel/i40e/i40e_adminq.c | 56 ++-
 drivers/net/ethernet/intel/i40e/i40e_common.c | 48 +
 drivers/net/ethernet/intel/i40e/i40e_dcb.c|  7 +-
 drivers/net/ethernet/intel/i40e/i40e_main.c   |  6 +-
 drivers/net/ethernet/intel/i40e/i40e_type.h   | 68 +++
 5 files changed, 108 insertions(+), 77 deletions(-)

-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH iwl-next v2 1/3] i40e: Move i40e_is_aq_api_ver_ge helper

2023-10-24 Thread Ivan Vecera
Move i40e_is_aq_api_ver_ge helper function (used to check if AdminQ
API version is recent enough) to header so it can be used from
other .c files.

Signed-off-by: Ivan Vecera 
---
 drivers/net/ethernet/intel/i40e/i40e_common.c | 23 ---
 drivers/net/ethernet/intel/i40e/i40e_type.h   | 14 +++
 2 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c 
b/drivers/net/ethernet/intel/i40e/i40e_common.c
index 7fce881abc93..df7ba349030d 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_common.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_common.c
@@ -1749,21 +1749,6 @@ int i40e_aq_set_phy_debug(struct i40e_hw *hw, u8 
cmd_flags,
return status;
 }
 
-/**
- * i40e_is_aq_api_ver_ge
- * @aq: pointer to AdminQ info containing HW API version to compare
- * @maj: API major value
- * @min: API minor value
- *
- * Assert whether current HW API version is greater/equal than provided.
- **/
-static bool i40e_is_aq_api_ver_ge(struct i40e_adminq_info *aq, u16 maj,
- u16 min)
-{
-   return (aq->api_maj_ver > maj ||
-   (aq->api_maj_ver == maj && aq->api_min_ver >= min));
-}
-
 /**
  * i40e_aq_add_vsi
  * @hw: pointer to the hw struct
@@ -1890,14 +1875,14 @@ int i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw 
*hw,
 
if (set) {
flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
-   if (rx_only_promisc && i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
+   if (rx_only_promisc && i40e_is_aq_api_ver_ge(hw, 1, 5))
flags |= I40E_AQC_SET_VSI_PROMISC_RX_ONLY;
}
 
cmd->promiscuous_flags = cpu_to_le16(flags);
 
cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_UNICAST);
-   if (i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
+   if (i40e_is_aq_api_ver_ge(hw, 1, 5))
cmd->valid_flags |=
cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_RX_ONLY);
 
@@ -2000,13 +1985,13 @@ int i40e_aq_set_vsi_uc_promisc_on_vlan(struct i40e_hw 
*hw,
 
if (enable) {
flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
-   if (i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
+   if (i40e_is_aq_api_ver_ge(hw, 1, 5))
flags |= I40E_AQC_SET_VSI_PROMISC_RX_ONLY;
}
 
cmd->promiscuous_flags = cpu_to_le16(flags);
cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_UNICAST);
-   if (i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
+   if (i40e_is_aq_api_ver_ge(hw, 1, 5))
cmd->valid_flags |=
cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_RX_ONLY);
cmd->seid = cpu_to_le16(seid);
diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h 
b/drivers/net/ethernet/intel/i40e/i40e_type.h
index 22150368ba64..a21cc607c844 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_type.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_type.h
@@ -594,6 +594,20 @@ static inline bool i40e_is_vf(struct i40e_hw *hw)
hw->mac.type == I40E_MAC_X722_VF);
 }
 
+/**
+ * i40e_is_aq_api_ver_ge
+ * @hw: pointer to i40e_hw structure
+ * @maj: API major value to compare
+ * @min: API minor value to compare
+ *
+ * Assert whether current HW API version is greater/equal than provided.
+ **/
+static inline bool i40e_is_aq_api_ver_ge(struct i40e_hw *hw, u16 maj, u16 min)
+{
+   return (hw->aq.api_maj_ver > maj ||
+   (hw->aq.api_maj_ver == maj && hw->aq.api_min_ver >= min));
+}
+
 struct i40e_driver_version {
u8 major_version;
u8 minor_version;
-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH iwl-next v2 3/3] i40e: Use helpers to check running FW and AQ API versions

2023-10-24 Thread Ivan Vecera
Use new helpers to check versions of running FW and provided
AQ API to make the code more readable.

Signed-off-by: Ivan Vecera 
---
 drivers/net/ethernet/intel/i40e/i40e_adminq.c | 56 +++
 drivers/net/ethernet/intel/i40e/i40e_common.c | 25 -
 drivers/net/ethernet/intel/i40e/i40e_dcb.c|  7 +--
 drivers/net/ethernet/intel/i40e/i40e_main.c   |  6 +-
 4 files changed, 36 insertions(+), 58 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.c 
b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
index 86591140f748..29fc46abf690 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
@@ -508,42 +508,35 @@ static int i40e_shutdown_arq(struct i40e_hw *hw)
  **/
 static void i40e_set_hw_caps(struct i40e_hw *hw)
 {
-   struct i40e_adminq_info *aq = &hw->aq;
-
bitmap_zero(hw->caps, I40E_HW_CAPS_NBITS);
 
switch (hw->mac.type) {
case I40E_MAC_XL710:
-   if (aq->api_maj_ver > 1 ||
-   (aq->api_maj_ver == 1 &&
-aq->api_min_ver >= I40E_MINOR_VER_GET_LINK_INFO_XL710)) {
+   if (i40e_is_aq_api_ver_ge(hw, 1,
+ I40E_MINOR_VER_GET_LINK_INFO_XL710)) {
set_bit(I40E_HW_CAP_AQ_PHY_ACCESS, hw->caps);
set_bit(I40E_HW_CAP_FW_LLDP_STOPPABLE, hw->caps);
/* The ability to RX (not drop) 802.1ad frames */
set_bit(I40E_HW_CAP_802_1AD, hw->caps);
}
-   if ((aq->api_maj_ver == 1 && aq->api_min_ver > 4) ||
-   aq->api_maj_ver > 1) {
+   if (i40e_is_aq_api_ver_ge(hw, 1, 5)) {
/* Supported in FW API version higher than 1.4 */
set_bit(I40E_HW_CAP_GENEVE_OFFLOAD, hw->caps);
}
-   if ((aq->fw_maj_ver == 4 && aq->fw_min_ver < 33) ||
-   aq->fw_maj_ver < 4) {
+   if (i40e_is_fw_ver_lt(hw, 4, 33)) {
set_bit(I40E_HW_CAP_RESTART_AUTONEG, hw->caps);
/* No DCB support  for FW < v4.33 */
set_bit(I40E_HW_CAP_NO_DCB_SUPPORT, hw->caps);
}
-   if ((aq->fw_maj_ver == 4 && aq->fw_min_ver < 3) ||
-   aq->fw_maj_ver < 4) {
+   if (i40e_is_fw_ver_lt(hw, 4, 3)) {
/* Disable FW LLDP if FW < v4.3 */
set_bit(I40E_HW_CAP_STOP_FW_LLDP, hw->caps);
}
-   if ((aq->fw_maj_ver == 4 && aq->fw_min_ver >= 40) ||
-   aq->fw_maj_ver >= 5) {
-   /* Use the FW Set LLDP MIB API if FW > v4.40 */
+   if (i40e_is_fw_ver_ge(hw, 4, 40)) {
+   /* Use the FW Set LLDP MIB API if FW >= v4.40 */
set_bit(I40E_HW_CAP_USE_SET_LLDP_MIB, hw->caps);
}
-   if (aq->fw_maj_ver >= 6) {
+   if (i40e_is_fw_ver_ge(hw, 6, 0)) {
/* Enable PTP L4 if FW > v6.0 */
set_bit(I40E_HW_CAP_PTP_L4, hw->caps);
}
@@ -569,19 +562,16 @@ static void i40e_set_hw_caps(struct i40e_hw *hw)
clear_bit(I40E_HW_CAP_ATR_EVICT, hw->caps);
}
 
-   if (aq->api_maj_ver > 1 ||
-   (aq->api_maj_ver == 1 &&
-aq->api_min_ver >= I40E_MINOR_VER_FW_LLDP_STOPPABLE_X722))
+   if (i40e_is_aq_api_ver_ge(hw, 1,
+ 
I40E_MINOR_VER_FW_LLDP_STOPPABLE_X722))
set_bit(I40E_HW_CAP_FW_LLDP_STOPPABLE, hw->caps);
 
-   if (aq->api_maj_ver > 1 ||
-   (aq->api_maj_ver == 1 &&
-aq->api_min_ver >= I40E_MINOR_VER_GET_LINK_INFO_X722))
+   if (i40e_is_aq_api_ver_ge(hw, 1,
+ I40E_MINOR_VER_GET_LINK_INFO_X722))
set_bit(I40E_HW_CAP_AQ_PHY_ACCESS, hw->caps);
 
-   if (aq->api_maj_ver > 1 ||
-   (aq->api_maj_ver == 1 &&
-aq->api_min_ver >= I40E_MINOR_VER_FW_REQUEST_FEC_X722))
+   if (i40e_is_aq_api_ver_ge(hw, 1,
+ I40E_MINOR_VER_FW_REQUEST_FEC_X722))
set_bit(I40E_HW_CAP_X722_FEC_REQUEST, hw->caps);
 
fallthrough;
@@ -590,25 +580,17 @@ static void i40e_set_hw_caps(struct i40e_hw *hw)
}
 
/* Newer versions of firmware require lock when reading the NVM */
-   if (aq->api_maj_ver > 1 ||
-   (aq->api_maj_ver == 1 &&
-aq->api_min_ver >= 5))
+   if (i40e_is_aq_api_ver_ge(hw, 1, 5))
set_bit(I40E_HW_CAP_NVM_READ_REQUIRES_LOCK, hw->caps);
 
/* The ability to RX (not drop) 802.1ad frames was added in API 1.7 */
-   if (aq->

[Intel-wired-lan] [PATCH iwl-next v2 2/3] i40e: Add other helpers to check version of running firmware and AQ API

2023-10-24 Thread Ivan Vecera
Add another helper functions that will be used by subsequent
patch to refactor existing open-coded checks whether the version
of running firmware and AdminQ API is recent enough to provide
certain capabilities.

Signed-off-by: Ivan Vecera 
---
 drivers/net/ethernet/intel/i40e/i40e_type.h | 54 +
 1 file changed, 54 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h 
b/drivers/net/ethernet/intel/i40e/i40e_type.h
index a21cc607c844..9fda0cb6bdbe 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_type.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_type.h
@@ -608,6 +608,60 @@ static inline bool i40e_is_aq_api_ver_ge(struct i40e_hw 
*hw, u16 maj, u16 min)
(hw->aq.api_maj_ver == maj && hw->aq.api_min_ver >= min));
 }
 
+/**
+ * i40e_is_aq_api_ver_lt
+ * @hw: pointer to i40e_hw structure
+ * @maj: API major value to compare
+ * @min: API minor value to compare
+ *
+ * Assert whether current HW API version is less than provided.
+ **/
+static inline bool i40e_is_aq_api_ver_lt(struct i40e_hw *hw, u16 maj, u16 min)
+{
+   return !i40e_is_aq_api_ver_ge(hw, maj, min);
+}
+
+/**
+ * i40e_is_fw_ver_ge
+ * @hw: pointer to i40e_hw structure
+ * @maj: API major value to compare
+ * @min: API minor value to compare
+ *
+ * Assert whether current firmware version is greater/equal than provided.
+ **/
+static inline bool i40e_is_fw_ver_ge(struct i40e_hw *hw, u16 maj, u16 min)
+{
+   return (hw->aq.fw_maj_ver > maj ||
+   (hw->aq.fw_maj_ver == maj && hw->aq.fw_min_ver >= min));
+}
+
+/**
+ * i40e_is_fw_ver_lt
+ * @hw: pointer to i40e_hw structure
+ * @maj: API major value to compare
+ * @min: API minor value to compare
+ *
+ * Assert whether current firmware version is less than provided.
+ **/
+static inline bool i40e_is_fw_ver_lt(struct i40e_hw *hw, u16 maj, u16 min)
+{
+   return !i40e_is_fw_ver_ge(hw, maj, min);
+}
+
+/**
+ * i40e_is_fw_ver_eq
+ * @hw: pointer to i40e_hw structure
+ * @maj: API major value to compare
+ * @min: API minor value to compare
+ *
+ * Assert whether current firmware version is equal to provided.
+ **/
+static inline bool i40e_is_fw_ver_eq(struct i40e_hw *hw, u16 maj, u16 min)
+{
+   return (hw->aq.fw_maj_ver > maj ||
+   (hw->aq.fw_maj_ver == maj && hw->aq.fw_min_ver == min));
+}
+
 struct i40e_driver_version {
u8 major_version;
u8 minor_version;
-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH iwl-next 1/4] iavf: rely on netdev's own registered state

2023-10-24 Thread Romanowski, Rafal
> -Original Message-
> From: Intel-wired-lan  On Behalf Of
> Jacob Keller
> Sent: Tuesday, October 17, 2023 7:30 PM
> To: intel-wired-lan@osuosl.org
> Subject: Re: [Intel-wired-lan] [PATCH iwl-next 1/4] iavf: rely on netdev's own
> registered state
> 
> 
> 
> On 10/16/2023 9:48 AM, Michal Schmidt wrote:
> > The information whether a netdev has been registered is already
> > present in the netdev itself. There's no need for a driver flag with
> > the same meaning.
> >
> > Signed-off-by: Michal Schmidt 
> 
> Thanks!
> 
> Reviewed-by: Jacob Keller 
> ___


Tested-by: Rafal Romanowski 



___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH iwl-next 2/4] iavf: use unregister_netdev

2023-10-24 Thread Romanowski, Rafal
> -Original Message-
> From: Intel-wired-lan  On Behalf Of
> Drewek, Wojciech
> Sent: Tuesday, October 17, 2023 10:07 AM
> To: mschmidt ; intel-wired-...@lists.osuosl.org
> Cc: net...@vger.kernel.org; Nguyen, Anthony L
> ; Brandeburg, Jesse
> 
> Subject: Re: [Intel-wired-lan] [PATCH iwl-next 2/4] iavf: use 
> unregister_netdev
> 
> 
> 
> > -Original Message-
> > From: Intel-wired-lan  On Behalf
> > Of Michal Schmidt
> > Sent: Monday, October 16, 2023 6:49 PM
> > To: intel-wired-...@lists.osuosl.org
> > Cc: net...@vger.kernel.org; Nguyen, Anthony L
> > ; Brandeburg, Jesse
> > 
> > Subject: [Intel-wired-lan] [PATCH iwl-next 2/4] iavf: use
> > unregister_netdev
> >
> > Use unregister_netdev, which takes rtnl_lock for us. We don't have to
> > check the reg_state under rtnl_lock. There's nothing to race with. We
> > have just cancelled the finish_config work.
> >
> > Signed-off-by: Michal Schmidt 
> 
> Reviewed-by: Wojciech Drewek 
> 
> > ---
> >  drivers/net/ethernet/intel/iavf/iavf_main.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c
> > b/drivers/net/ethernet/intel/iavf/iavf_main.c
> > index d2f4648a6156..6036a4582196 100644
> > --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> > +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c


Tested-by: Rafal Romanowski 


___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH iwl-next 3/4] iavf: add a common function for undoing the interrupt scheme

2023-10-24 Thread Romanowski, Rafal
> -Original Message-
> From: Intel-wired-lan  On Behalf Of
> Jacob Keller
> Sent: Tuesday, October 17, 2023 7:36 PM
> To: intel-wired-lan@osuosl.org
> Subject: Re: [Intel-wired-lan] [PATCH iwl-next 3/4] iavf: add a common
> function for undoing the interrupt scheme
> 
> 
> 
> On 10/16/2023 9:48 AM, Michal Schmidt wrote:
> > Add a new function iavf_free_interrupt_scheme that does the inverse of
> > iavf_init_interrupt_scheme. Symmetry is nice. And there will be three
> > callers already.
> >
> > Signed-off-by: Michal Schmidt 
> > ---
> 
> Reviewed-by: Jacob Keller 
> 
> >  drivers/net/ethernet/intel/iavf/iavf_main.c | 26
> > -
> >  1 file changed, 15 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c
> > b/drivers/net/ethernet/intel/iavf/iavf_main.c
> > index 6036a4582196..791517cafc3c 100644
> > --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> > +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c


Tested-by: Rafal Romanowski 


___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH iwl-next 4/4] iavf: delete the iavf client interface

2023-10-24 Thread Romanowski, Rafal
> -Original Message-
> From: Intel-wired-lan  On Behalf Of
> Jacob Keller
> Sent: Tuesday, October 17, 2023 7:47 PM
> To: intel-wired-lan@osuosl.org
> Subject: Re: [Intel-wired-lan] [PATCH iwl-next 4/4] iavf: delete the iavf 
> client
> interface
> 
> 
> 
> On 10/16/2023 9:48 AM, Michal Schmidt wrote:
> > The iavf client interface was added in 2017 by commit ed0e894de7c1
> > ("i40evf: add client interface"), but there have never been any
> > in-tree callers.
> >
> > It's not useful for future development either. The Intel out-of-tree
> > iavf and irdma drivers instead use an auxiliary bus, which is a better
> > solution.
> >
> > Remove the iavf client interface code. Also gone are the client_task
> > work and the client_lock mutex.
> >
> > Signed-off-by: Michal Schmidt 
> > ---
> 
> Yea this interface is not supported by any current out-of-tree driver I could
> find either. From what I can tell the last version of out-of-tree iAVF which
> shipped this interface was 2021, iavf 4.2.1, which appears to have released in
> 2021.
> 
> I was unable to determine when the last time any software which used this
> interface was supported... It appears to have never been used in-tree at all.
> 
> Reviewed-by: Jacob Keller 
> ___
> Intel-wired-lan mailing list
> Intel-wired-lan@osuosl.org
> https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

Tested-by: Rafal Romanowski 


___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH iwl-next v2 1/3] i40e: Move i40e_is_aq_api_ver_ge helper

2023-10-24 Thread Wojciech Drewek



On 24.10.2023 10:12, Ivan Vecera wrote:
> Move i40e_is_aq_api_ver_ge helper function (used to check if AdminQ
> API version is recent enough) to header so it can be used from
> other .c files.
> 
> Signed-off-by: Ivan Vecera 
> ---

Thanks Ivan,
Reviewed-by: Wojciech Drewek 

>  drivers/net/ethernet/intel/i40e/i40e_common.c | 23 ---
>  drivers/net/ethernet/intel/i40e/i40e_type.h   | 14 +++
>  2 files changed, 18 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c 
> b/drivers/net/ethernet/intel/i40e/i40e_common.c
> index 7fce881abc93..df7ba349030d 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_common.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_common.c
> @@ -1749,21 +1749,6 @@ int i40e_aq_set_phy_debug(struct i40e_hw *hw, u8 
> cmd_flags,
>   return status;
>  }
>  
> -/**
> - * i40e_is_aq_api_ver_ge
> - * @aq: pointer to AdminQ info containing HW API version to compare
> - * @maj: API major value
> - * @min: API minor value
> - *
> - * Assert whether current HW API version is greater/equal than provided.
> - **/
> -static bool i40e_is_aq_api_ver_ge(struct i40e_adminq_info *aq, u16 maj,
> -   u16 min)
> -{
> - return (aq->api_maj_ver > maj ||
> - (aq->api_maj_ver == maj && aq->api_min_ver >= min));
> -}
> -
>  /**
>   * i40e_aq_add_vsi
>   * @hw: pointer to the hw struct
> @@ -1890,14 +1875,14 @@ int i40e_aq_set_vsi_unicast_promiscuous(struct 
> i40e_hw *hw,
>  
>   if (set) {
>   flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
> - if (rx_only_promisc && i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
> + if (rx_only_promisc && i40e_is_aq_api_ver_ge(hw, 1, 5))
>   flags |= I40E_AQC_SET_VSI_PROMISC_RX_ONLY;
>   }
>  
>   cmd->promiscuous_flags = cpu_to_le16(flags);
>  
>   cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_UNICAST);
> - if (i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
> + if (i40e_is_aq_api_ver_ge(hw, 1, 5))
>   cmd->valid_flags |=
>   cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_RX_ONLY);
>  
> @@ -2000,13 +1985,13 @@ int i40e_aq_set_vsi_uc_promisc_on_vlan(struct i40e_hw 
> *hw,
>  
>   if (enable) {
>   flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
> - if (i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
> + if (i40e_is_aq_api_ver_ge(hw, 1, 5))
>   flags |= I40E_AQC_SET_VSI_PROMISC_RX_ONLY;
>   }
>  
>   cmd->promiscuous_flags = cpu_to_le16(flags);
>   cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_UNICAST);
> - if (i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
> + if (i40e_is_aq_api_ver_ge(hw, 1, 5))
>   cmd->valid_flags |=
>   cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_RX_ONLY);
>   cmd->seid = cpu_to_le16(seid);
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h 
> b/drivers/net/ethernet/intel/i40e/i40e_type.h
> index 22150368ba64..a21cc607c844 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_type.h
> +++ b/drivers/net/ethernet/intel/i40e/i40e_type.h
> @@ -594,6 +594,20 @@ static inline bool i40e_is_vf(struct i40e_hw *hw)
>   hw->mac.type == I40E_MAC_X722_VF);
>  }
>  
> +/**
> + * i40e_is_aq_api_ver_ge
> + * @hw: pointer to i40e_hw structure
> + * @maj: API major value to compare
> + * @min: API minor value to compare
> + *
> + * Assert whether current HW API version is greater/equal than provided.
> + **/
> +static inline bool i40e_is_aq_api_ver_ge(struct i40e_hw *hw, u16 maj, u16 
> min)
> +{
> + return (hw->aq.api_maj_ver > maj ||
> + (hw->aq.api_maj_ver == maj && hw->aq.api_min_ver >= min));
> +}
> +
>  struct i40e_driver_version {
>   u8 major_version;
>   u8 minor_version;
___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH iwl-next 2/3] i40e: Add other helpers to check version of running firmware and AQ API

2023-10-24 Thread Wojciech Drewek



On 23.10.2023 18:29, Ivan Vecera wrote:
> Add another helper functions that will be used by subsequent
> patch to refactor existing open-coded checks whether the version
> of running firmware and AdminQ API is recent enough to provide
> certain capabilities.
> 
> Signed-off-by: Ivan Vecera 
> ---
>  drivers/net/ethernet/intel/i40e/i40e_type.h | 54 +
>  1 file changed, 54 insertions(+)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h 
> b/drivers/net/ethernet/intel/i40e/i40e_type.h
> index 050d479aeed3..bb62c14aa3d4 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_type.h
> +++ b/drivers/net/ethernet/intel/i40e/i40e_type.h
> @@ -608,6 +608,60 @@ static inline bool i40e_is_aq_api_ver_ge(struct i40e_hw 
> *hw, u16 maj, u16 min)
>   (hw->aq.api_maj_ver == maj && hw->aq.api_min_ver >= min));
>  }
>  
> +/**
> + * i40e_is_aq_api_ver_lt
> + * @hw: pointer to i40e_hw structure
> + * @maj: API major value to compare
> + * @min: API minor value to compare
> + *
> + * Assert whether current HW API version is less than provided.
> + **/
> +static inline bool i40e_is_aq_api_ver_lt(struct i40e_hw *hw, u16 maj, u16 
> min)
> +{
> + return !i40e_is_aq_api_ver_ge(hw, maj, min);
> +}

It feels a bit off to have those helpers in i40e_type.h.
We don't have i40e_common.h though so I'd move them to i40e_prototype.h or 
i40e.h.
Same comment regarding 1st patch (I know I gave it my tag but I spotted the 
issue
while reading the 2nd patch).

> +
> +/**
> + * i40e_is_fw_ver_ge
> + * @hw: pointer to i40e_hw structure
> + * @maj: API major value to compare
> + * @min: API minor value to compare
> + *
> + * Assert whether current firmware version is greater/equal than provided.
> + **/
> +static bool inline i40e_is_fw_ver_ge(struct i40e_hw *hw, u16 maj, u16 min)
> +{
> +return (hw->aq.fw_maj_ver > maj ||
> +(hw->aq.fw_maj_ver == maj && hw->aq.fw_min_ver >= min));
> +}
> +
> +/**
> + * i40e_is_fw_ver_lt
> + * @hw: pointer to i40e_hw structure
> + * @maj: API major value to compare
> + * @min: API minor value to compare
> + *
> + * Assert whether current firmware version is less than provided.
> + **/
> +static bool inline i40e_is_fw_ver_lt(struct i40e_hw *hw, u16 maj, u16 min)
> +{
> + return !i40e_is_fw_ver_ge(hw, maj, min);
> +}
> +
> +/**
> + * i40e_is_fw_ver_eq
> + * @hw: pointer to i40e_hw structure
> + * @maj: API major value to compare
> + * @min: API minor value to compare
> + *
> + * Assert whether current firmware version is equal to provided.
> + **/
> +static bool inline i40e_is_fw_ver_eq(struct i40e_hw *hw, u16 maj, u16 min)
> +{
> +return (hw->aq.fw_maj_ver > maj ||
> +(hw->aq.fw_maj_ver == maj && hw->aq.fw_min_ver == min));
> +}
> +
>  struct i40e_driver_version {
>   u8 major_version;
>   u8 minor_version;
___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH iwl-next v5] ice: read internal temperature sensor

2023-10-24 Thread Konrad Knitter
Since 4.30 firmware exposes internal thermal sensor reading via admin
queue commands. Expose those readouts via hwmon API when supported.

Datasheet:

Get Sensor Reading Command (Opcode: 0x0632)

++++-+
| Name   | Bytes  | Value  |  Remarks|
++++-+
| Flags  | 1-0|| |
| Opcode | 2-3| 0x0632 | Command opcode  |
| Datalen| 4-5| 0  | No external buffer. |
| Return value   | 6-7|| Return value.   |
| Cookie High| 8-11   | Cookie | |
| Cookie Low | 12-15  | Cookie | |
| Sensor | 16 || 0x00: Internal temp |
|||| 0x01-0xFF: Reserved.|
| Format | 17 | Requested response | Only 0x00 is supported. |
||| format | 0x01-0xFF: Reserved.|
| Reserved   | 18-23  || |
| Data Address high  | 24-27  | Response buffer| |
||| address| |
| Data Address low   | 28-31  | Response buffer| |
||| address| |
++++-+

Get Sensor Reading Response (Opcode: 0x0632)

++++-+
| Name   | Bytes  | Value  |  Remarks|
++++-+
| Flags  | 1-0|| |
| Opcode | 2-3| 0x0632 | Command opcode  |
| Datalen| 4-5| 0  | No external buffer  |
| Return value   | 6-7|| Return value.   |
|||| EINVAL: Invalid |
|||| parameters  |
|||| ENOENT: Unsupported |
|||| sensor  |
|||| EIO: Sensor access  |
|||| error   |
| Cookie High| 8-11   | Cookie | |
| Cookie Low | 12-15  | Cookie | |
| Sensor Reading | 16-23  || Format of the reading   |
|||| is dependent on request |
| Data Address high  | 24-27  | Response buffer| |
||| address| |
| Data Address low   | 28-31  | Response buffer| |
||| address| |
++++-+

Sensor Reading for Sensor 0x00 (Internal Chip Temperature):

++++-+
| Name   | Bytes  | Value  |  Remarks|
++++-+
| Thermal Sensor | 0  || Reading in degrees  |
| reading||| Celsius. Signed int8|
| Warning High   | 1  || Warning High threshold  |
| threshold  ||| in degrees Celsius. |
|||| Unsigned int8.  |
|||| 0xFF when unsupported   |
| Critical High  | 2  || Critical High threshold |
| threshold  ||| in degrees Celsius. |
|||| Unsigned int8.  |
|||| 0xFF when unsupported   |
| Fatal High | 3  || Fatal High threshold|
| threshold  ||| in degrees Celsius. |
|||| Unsigned int8.  |
|||| 0xFF when unsupported   |
| Reserved   | 4-7|| |
+++--

[Intel-wired-lan] [PATCH iwl-next] ice: Reset VF on Tx MDD event

2023-10-24 Thread Pawel Chmielewski
From: Liang-min Wang 

In cases when VF sends malformed packets that are classified as malicious,
sometimes it causes Tx queue to freeze. This frozen queue can be stuck
for several minutes being unusable.

When MDD event occurs, perform graceful VF reset to quickly bring VF
back to operational state.

Signed-off-by: Liang-min Wang 
Signed-off-by: Pawel Chmielewski 
Reviewed-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice_main.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_main.c 
b/drivers/net/ethernet/intel/ice/ice_main.c
index 66095e9b094e..cf9fd1f168f7 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -1836,8 +1836,13 @@ static void ice_handle_mdd_event(struct ice_pf *pf)
vf->mdd_tx_events.count++;
set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state);
if (netif_msg_tx_err(pf))
-   dev_info(dev, "Malicious Driver Detection event 
TX_TCLAN detected on VF %d\n",
+   dev_info(dev,
+"Malicious Driver Detection event 
TX_TCLAN detected on VF %d\n",
 vf->vf_id);
+   dev_info(dev,
+"PF-to-VF reset on VF %d due to Tx MDD 
TX_TCLAN event\n",
+vf->vf_id);
+   ice_reset_vf(vf, ICE_VF_RESET_NOTIFY);
}
 
reg = rd32(hw, VP_MDET_TX_TDPU(vf->vf_id));
@@ -1846,8 +1851,13 @@ static void ice_handle_mdd_event(struct ice_pf *pf)
vf->mdd_tx_events.count++;
set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state);
if (netif_msg_tx_err(pf))
-   dev_info(dev, "Malicious Driver Detection event 
TX_TDPU detected on VF %d\n",
+   dev_info(dev,
+"Malicious Driver Detection event 
TX_TDPU detected on VF %d\n",
 vf->vf_id);
+   dev_info(dev,
+"PF-to-VF reset on VF %d due to Tx MDD 
TX_TCLAN event\n",
+vf->vf_id);
+   ice_reset_vf(vf, ICE_VF_RESET_NOTIFY);
}
 
reg = rd32(hw, VP_MDET_RX(vf->vf_id));
-- 
2.37.3

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH iwl-next v1 00/15] one by one port representors creation

2023-10-24 Thread Michal Swiatkowski
Hi,

Currently ice supports creating port representors only for VFs. For that
use case they can be created and removed in one step.

This patchset is refactoring current flow to support port representor
creation also for subfunctions and SIOV. In this case port representors
need to be createad and removed one by one. Also, they can be added and
removed while other port representors are running.

To achieve that we need to change the switchdev configuration flow.
Three first patches are only cosmetic (renaming, removing not used code).
Next few ones are preparation for new flow. The most important one
is "add VF representor one by one". It fully implements new flow.

New type of port representor (for subfunction) will be introduced in
follow up patchset.

Michal Swiatkowski (15):
  ice: rename switchdev to eswitch
  ice: remove redundant max_vsi_num variable
  ice: remove unused control VSI parameter
  ice: track q_id in representor
  ice: use repr instead of vf->repr
  ice: track port representors in xarray
  ice: remove VF pointer reference in eswitch code
  ice: make representor code generic
  ice: return pointer to representor
  ice: allow changing SWITCHDEV_CTRL VSI queues
  ice: set Tx topology every time new repr is added
  ice: realloc VSI stats arrays
  ice: add VF representors one by one
  ice: adjust switchdev rebuild path
  ice: reserve number of CP queues

 drivers/net/ethernet/intel/ice/ice.h  |  13 +-
 drivers/net/ethernet/intel/ice/ice_devlink.c  |  29 +
 drivers/net/ethernet/intel/ice/ice_devlink.h  |   1 +
 drivers/net/ethernet/intel/ice/ice_eswitch.c  | 562 ++
 drivers/net/ethernet/intel/ice/ice_eswitch.h  |  22 +-
 .../net/ethernet/intel/ice/ice_eswitch_br.c   |  22 +-
 drivers/net/ethernet/intel/ice/ice_lib.c  |  81 ++-
 drivers/net/ethernet/intel/ice/ice_main.c |   6 +-
 drivers/net/ethernet/intel/ice/ice_repr.c | 195 +++---
 drivers/net/ethernet/intel/ice/ice_repr.h |   9 +-
 drivers/net/ethernet/intel/ice/ice_sriov.c|  20 +-
 drivers/net/ethernet/intel/ice/ice_tc_lib.c   |   4 +-
 drivers/net/ethernet/intel/ice/ice_vf_lib.c   |   9 +-
 drivers/net/ethernet/intel/ice/ice_vf_lib.h   |   2 +-
 14 files changed, 553 insertions(+), 422 deletions(-)

-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH iwl-next v1 01/15] ice: rename switchdev to eswitch

2023-10-24 Thread Michal Swiatkowski
Eswitch is used as a prefix for related functions. Main structure
storing all data related to eswitch should also be named as eswitch
instead of ice_switchdev_info. Rename it.

Also rename switchdev to eswitch where the context is not about eswitch
mode.

::uplink_netdev was changed to netdev for simplicity. There is no other
netdev in function scope so it is obvious.

Reviewed-by: Wojciech Drewek 
Reviewed-by: Piotr Raczynski 
Reviewed-by: Jacob Keller 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice.h  |  6 +-
 drivers/net/ethernet/intel/ice/ice_eswitch.c  | 63 ++-
 .../net/ethernet/intel/ice/ice_eswitch_br.c   | 12 ++--
 drivers/net/ethernet/intel/ice/ice_tc_lib.c   |  4 +-
 4 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice.h 
b/drivers/net/ethernet/intel/ice/ice.h
index 351e0d36df44..6c59ca86d959 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -522,7 +522,7 @@ enum ice_misc_thread_tasks {
ICE_MISC_THREAD_NBITS   /* must be last */
 };
 
-struct ice_switchdev_info {
+struct ice_eswitch {
struct ice_vsi *control_vsi;
struct ice_vsi *uplink_vsi;
struct ice_esw_br_offloads *br_offloads;
@@ -637,7 +637,7 @@ struct ice_pf {
struct ice_link_default_override_tlv link_dflt_override;
struct ice_lag *lag; /* Link Aggregation information */
 
-   struct ice_switchdev_info switchdev;
+   struct ice_eswitch eswitch;
struct ice_esw_br_port *br_port;
 
 #define ICE_INVALID_AGG_NODE_ID0
@@ -846,7 +846,7 @@ static inline struct ice_vsi *ice_find_vsi(struct ice_pf 
*pf, u16 vsi_num)
  */
 static inline bool ice_is_switchdev_running(struct ice_pf *pf)
 {
-   return pf->switchdev.is_running;
+   return pf->eswitch.is_running;
 }
 
 #define ICE_FD_STAT_CTR_BLOCK_COUNT256
diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c 
b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index a655d499abfa..e7f1e53314d7 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -16,12 +16,12 @@
  * @vf: pointer to VF struct
  *
  * This function adds advanced rule that forwards packets with
- * VF's VSI index to the corresponding switchdev ctrl VSI queue.
+ * VF's VSI index to the corresponding eswitch ctrl VSI queue.
  */
 static int
 ice_eswitch_add_vf_sp_rule(struct ice_pf *pf, struct ice_vf *vf)
 {
-   struct ice_vsi *ctrl_vsi = pf->switchdev.control_vsi;
+   struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi;
struct ice_adv_rule_info rule_info = { 0 };
struct ice_adv_lkup_elem *list;
struct ice_hw *hw = &pf->hw;
@@ -59,7 +59,7 @@ ice_eswitch_add_vf_sp_rule(struct ice_pf *pf, struct ice_vf 
*vf)
  * @vf: pointer to the VF struct
  *
  * Delete the advanced rule that was used to forward packets with the VF's VSI
- * index to the corresponding switchdev ctrl VSI queue.
+ * index to the corresponding eswitch ctrl VSI queue.
  */
 static void ice_eswitch_del_vf_sp_rule(struct ice_vf *vf)
 {
@@ -70,7 +70,7 @@ static void ice_eswitch_del_vf_sp_rule(struct ice_vf *vf)
 }
 
 /**
- * ice_eswitch_setup_env - configure switchdev HW filters
+ * ice_eswitch_setup_env - configure eswitch HW filters
  * @pf: pointer to PF struct
  *
  * This function adds HW filters configuration specific for switchdev
@@ -78,18 +78,18 @@ static void ice_eswitch_del_vf_sp_rule(struct ice_vf *vf)
  */
 static int ice_eswitch_setup_env(struct ice_pf *pf)
 {
-   struct ice_vsi *uplink_vsi = pf->switchdev.uplink_vsi;
-   struct net_device *uplink_netdev = uplink_vsi->netdev;
-   struct ice_vsi *ctrl_vsi = pf->switchdev.control_vsi;
+   struct ice_vsi *uplink_vsi = pf->eswitch.uplink_vsi;
+   struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi;
+   struct net_device *netdev = uplink_vsi->netdev;
struct ice_vsi_vlan_ops *vlan_ops;
bool rule_added = false;
 
ice_remove_vsi_fltr(&pf->hw, uplink_vsi->idx);
 
-   netif_addr_lock_bh(uplink_netdev);
-   __dev_uc_unsync(uplink_netdev, NULL);
-   __dev_mc_unsync(uplink_netdev, NULL);
-   netif_addr_unlock_bh(uplink_netdev);
+   netif_addr_lock_bh(netdev);
+   __dev_uc_unsync(netdev, NULL);
+   __dev_mc_unsync(netdev, NULL);
+   netif_addr_unlock_bh(netdev);
 
if (ice_vsi_add_vlan_zero(uplink_vsi))
goto err_def_rx;
@@ -132,10 +132,10 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
 }
 
 /**
- * ice_eswitch_remap_rings_to_vectors - reconfigure rings of switchdev ctrl VSI
+ * ice_eswitch_remap_rings_to_vectors - reconfigure rings of eswitch ctrl VSI
  * @pf: pointer to PF struct
  *
- * In switchdev number of allocated Tx/Rx rings is equal.
+ * In eswitch number of allocated Tx/Rx rings is equal.
  *
  * This function fills q_vectors structures associated with representor and
  * move each ring 

[Intel-wired-lan] [PATCH iwl-next v1 02/15] ice: remove redundant max_vsi_num variable

2023-10-24 Thread Michal Swiatkowski
It is a leftover from previous implementation. Accidentally it wasn't
removed. Do it now.

Commit that has removed it:
commit c1e5da5dd465 ("ice: improve switchdev's slow-path")

Reviewed-by: Wojciech Drewek 
Reviewed-by: Piotr Raczynski 
Reviewed-by: Jacob Keller 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c 
b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index e7f1e53314d7..fd8d59f4d97d 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -224,7 +224,6 @@ ice_eswitch_release_reprs(struct ice_pf *pf, struct ice_vsi 
*ctrl_vsi)
 static int ice_eswitch_setup_reprs(struct ice_pf *pf)
 {
struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi;
-   int max_vsi_num = 0;
struct ice_vf *vf;
unsigned int bkt;
 
@@ -267,9 +266,6 @@ static int ice_eswitch_setup_reprs(struct ice_pf *pf)
goto err;
}
 
-   if (max_vsi_num < vsi->vsi_num)
-   max_vsi_num = vsi->vsi_num;
-
netif_napi_add(vf->repr->netdev, &vf->repr->q_vector->napi,
   ice_napi_poll);
 
-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH iwl-next v1 03/15] ice: remove unused control VSI parameter

2023-10-24 Thread Michal Swiatkowski
It isn't used in ice_eswitch_release_reprs(). Probably leftover. Remove
it.

Commit that has removed usage of ctrl_vsi:
commit c1e5da5dd465 ("ice: improve switchdev's slow-path")

Reviewed-by: Wojciech Drewek 
Reviewed-by: Piotr Raczynski 
Reviewed-by: Jacob Keller 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c 
b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index fd8d59f4d97d..a862681c0f64 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -189,10 +189,9 @@ static void ice_eswitch_remap_rings_to_vectors(struct 
ice_pf *pf)
 /**
  * ice_eswitch_release_reprs - clear PR VSIs configuration
  * @pf: poiner to PF struct
- * @ctrl_vsi: pointer to eswitch control VSI
  */
 static void
-ice_eswitch_release_reprs(struct ice_pf *pf, struct ice_vsi *ctrl_vsi)
+ice_eswitch_release_reprs(struct ice_pf *pf)
 {
struct ice_vf *vf;
unsigned int bkt;
@@ -286,7 +285,7 @@ static int ice_eswitch_setup_reprs(struct ice_pf *pf)
return 0;
 
 err:
-   ice_eswitch_release_reprs(pf, ctrl_vsi);
+   ice_eswitch_release_reprs(pf);
 
return -ENODEV;
 }
@@ -532,7 +531,7 @@ static void ice_eswitch_disable_switchdev(struct ice_pf *pf)
ice_eswitch_napi_disable(pf);
ice_eswitch_br_offloads_deinit(pf);
ice_eswitch_release_env(pf);
-   ice_eswitch_release_reprs(pf, ctrl_vsi);
+   ice_eswitch_release_reprs(pf);
ice_vsi_release(ctrl_vsi);
ice_repr_rem_from_all_vfs(pf);
 }
-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH iwl-next v1 04/15] ice: track q_id in representor

2023-10-24 Thread Michal Swiatkowski
Previously queue index of control plane VSI used by port representor was
always id of VF. If we want to allow adding port representors for
different devices we have to track queue index in the port representor
structure.

Reviewed-by: Wojciech Drewek 
Reviewed-by: Piotr Raczynski 
Reviewed-by: Jacob Keller 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 2 +-
 drivers/net/ethernet/intel/ice/ice_repr.c| 1 +
 drivers/net/ethernet/intel/ice/ice_repr.h| 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c 
b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index a862681c0f64..119185564450 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -38,7 +38,7 @@ ice_eswitch_add_vf_sp_rule(struct ice_pf *pf, struct ice_vf 
*vf)
rule_info.sw_act.vsi_handle = ctrl_vsi->idx;
rule_info.sw_act.fltr_act = ICE_FWD_TO_Q;
rule_info.sw_act.fwd_id.q_id = hw->func_caps.common_cap.rxq_first_id +
-  ctrl_vsi->rxq_map[vf->vf_id];
+  ctrl_vsi->rxq_map[vf->repr->q_id];
rule_info.flags_info.act |= ICE_SINGLE_ACT_LB_ENABLE;
rule_info.flags_info.act_valid = true;
rule_info.tun_type = ICE_SW_TUN_AND_NON_TUN;
diff --git a/drivers/net/ethernet/intel/ice/ice_repr.c 
b/drivers/net/ethernet/intel/ice/ice_repr.c
index c686ac0935eb..a2dc216c964f 100644
--- a/drivers/net/ethernet/intel/ice/ice_repr.c
+++ b/drivers/net/ethernet/intel/ice/ice_repr.c
@@ -306,6 +306,7 @@ static int ice_repr_add(struct ice_vf *vf)
 
repr->src_vsi = vsi;
repr->vf = vf;
+   repr->q_id = vf->vf_id;
vf->repr = repr;
np = netdev_priv(repr->netdev);
np->repr = repr;
diff --git a/drivers/net/ethernet/intel/ice/ice_repr.h 
b/drivers/net/ethernet/intel/ice/ice_repr.h
index e1ee2d2c1d2d..f350273b8874 100644
--- a/drivers/net/ethernet/intel/ice/ice_repr.h
+++ b/drivers/net/ethernet/intel/ice/ice_repr.h
@@ -13,6 +13,7 @@ struct ice_repr {
struct net_device *netdev;
struct metadata_dst *dst;
struct ice_esw_br_port *br_port;
+   int q_id;
 #ifdef CONFIG_ICE_SWITCHDEV
/* info about slow path rule */
struct ice_rule_query_data sp_rule;
-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH iwl-next v1 05/15] ice: use repr instead of vf->repr

2023-10-24 Thread Michal Swiatkowski
Extract repr from vf->repr as it is often use in the ice_repr_rem().

Remove meaningless clearing of q_vector and netdev pointers as kfree is
called on repr pointer.

Reviewed-by: Przemek Kitszel 
Reviewed-by: Wojciech Drewek 
Reviewed-by: Jacob Keller 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice_repr.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_repr.c 
b/drivers/net/ethernet/intel/ice/ice_repr.c
index a2dc216c964f..903a3385eacb 100644
--- a/drivers/net/ethernet/intel/ice/ice_repr.c
+++ b/drivers/net/ethernet/intel/ice/ice_repr.c
@@ -355,16 +355,16 @@ static int ice_repr_add(struct ice_vf *vf)
  */
 static void ice_repr_rem(struct ice_vf *vf)
 {
-   if (!vf->repr)
+   struct ice_repr *repr = vf->repr;
+
+   if (!repr)
return;
 
-   kfree(vf->repr->q_vector);
-   vf->repr->q_vector = NULL;
-   unregister_netdev(vf->repr->netdev);
+   kfree(repr->q_vector);
+   unregister_netdev(repr->netdev);
ice_devlink_destroy_vf_port(vf);
-   free_netdev(vf->repr->netdev);
-   vf->repr->netdev = NULL;
-   kfree(vf->repr);
+   free_netdev(repr->netdev);
+   kfree(repr);
vf->repr = NULL;
 
ice_virtchnl_set_dflt_ops(vf);
-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH iwl-next v1 06/15] ice: track port representors in xarray

2023-10-24 Thread Michal Swiatkowski
Instead of assuming that each VF has pointer to port representor save it
in xarray. It will allow adding port representor for other device types.

Drop reference to VF where it is use only to get port representor. Get
it from xarray instead.

The functions will no longer by specific for VF, rename them.

Track id assigned by xarray in port representor structure. The id can't
be used as ::q_id, because it is fixed during port representor lifetime.
::q_id can change after adding / removing other port representors.

Side effect of removing VF pointer is that we are losing VF MAC
information used in unrolling. Store it in port representor as parent
MAC.

Reviewed-by: Piotr Raczynski 
Reviewed-by: Wojciech Drewek 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice.h |   1 +
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 182 +--
 drivers/net/ethernet/intel/ice/ice_main.c|   2 +
 drivers/net/ethernet/intel/ice/ice_repr.c|   8 +
 drivers/net/ethernet/intel/ice/ice_repr.h|   2 +
 5 files changed, 94 insertions(+), 101 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice.h 
b/drivers/net/ethernet/intel/ice/ice.h
index 6c59ca86d959..597bdb6945c6 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -526,6 +526,7 @@ struct ice_eswitch {
struct ice_vsi *control_vsi;
struct ice_vsi *uplink_vsi;
struct ice_esw_br_offloads *br_offloads;
+   struct xarray reprs;
bool is_running;
 };
 
diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c 
b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index 119185564450..a6b528bc2023 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -11,15 +11,15 @@
 #include "ice_tc_lib.h"
 
 /**
- * ice_eswitch_add_vf_sp_rule - add adv rule with VF's VSI index
+ * ice_eswitch_add_sp_rule - add adv rule with device's VSI index
  * @pf: pointer to PF struct
- * @vf: pointer to VF struct
+ * @repr: pointer to the repr struct
  *
  * This function adds advanced rule that forwards packets with
- * VF's VSI index to the corresponding eswitch ctrl VSI queue.
+ * device's VSI index to the corresponding eswitch ctrl VSI queue.
  */
 static int
-ice_eswitch_add_vf_sp_rule(struct ice_pf *pf, struct ice_vf *vf)
+ice_eswitch_add_sp_rule(struct ice_pf *pf, struct ice_repr *repr)
 {
struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi;
struct ice_adv_rule_info rule_info = { 0 };
@@ -38,35 +38,32 @@ ice_eswitch_add_vf_sp_rule(struct ice_pf *pf, struct ice_vf 
*vf)
rule_info.sw_act.vsi_handle = ctrl_vsi->idx;
rule_info.sw_act.fltr_act = ICE_FWD_TO_Q;
rule_info.sw_act.fwd_id.q_id = hw->func_caps.common_cap.rxq_first_id +
-  ctrl_vsi->rxq_map[vf->repr->q_id];
+  ctrl_vsi->rxq_map[repr->q_id];
rule_info.flags_info.act |= ICE_SINGLE_ACT_LB_ENABLE;
rule_info.flags_info.act_valid = true;
rule_info.tun_type = ICE_SW_TUN_AND_NON_TUN;
-   rule_info.src_vsi = vf->lan_vsi_idx;
+   rule_info.src_vsi = repr->src_vsi->idx;
 
err = ice_add_adv_rule(hw, list, lkups_cnt, &rule_info,
-  &vf->repr->sp_rule);
+  &repr->sp_rule);
if (err)
-   dev_err(ice_pf_to_dev(pf), "Unable to add VF slow-path rule in 
switchdev mode for VF %d",
-   vf->vf_id);
+   dev_err(ice_pf_to_dev(pf), "Unable to add slow-path rule in 
switchdev mode");
 
kfree(list);
return err;
 }
 
 /**
- * ice_eswitch_del_vf_sp_rule - delete adv rule with VF's VSI index
- * @vf: pointer to the VF struct
+ * ice_eswitch_del_sp_rule - delete adv rule with device's VSI index
+ * @pf: pointer to the PF struct
+ * @repr: pointer to the repr struct
  *
- * Delete the advanced rule that was used to forward packets with the VF's VSI
- * index to the corresponding eswitch ctrl VSI queue.
+ * Delete the advanced rule that was used to forward packets with the device's
+ * VSI index to the corresponding eswitch ctrl VSI queue.
  */
-static void ice_eswitch_del_vf_sp_rule(struct ice_vf *vf)
+static void ice_eswitch_del_sp_rule(struct ice_pf *pf, struct ice_repr *repr)
 {
-   if (!vf->repr)
-   return;
-
-   ice_rem_adv_rule_by_id(&vf->pf->hw, &vf->repr->sp_rule);
+   ice_rem_adv_rule_by_id(&pf->hw, &repr->sp_rule);
 }
 
 /**
@@ -193,26 +190,24 @@ static void ice_eswitch_remap_rings_to_vectors(struct 
ice_pf *pf)
 static void
 ice_eswitch_release_reprs(struct ice_pf *pf)
 {
-   struct ice_vf *vf;
-   unsigned int bkt;
-
-   lockdep_assert_held(&pf->vfs.table_lock);
+   struct ice_repr *repr;
+   unsigned long id;
 
-   ice_for_each_vf(pf, bkt, vf) {
-   struct ice_vsi *vsi = vf->repr->src_vsi;
+   xa_for_each(&pf->eswitch.reprs, id, repr) {
+ 

[Intel-wired-lan] [PATCH iwl-next v1 07/15] ice: remove VF pointer reference in eswitch code

2023-10-24 Thread Michal Swiatkowski
Make eswitch code generic by removing VF pointer reference in functions.
It is needed to support eswitch mode for other type of devices.

Previously queue id used for Rx was based on VF number. Use ::q_id saved
in port representor instead.

After adding or removing port representor ::q_id value can change. It
isn't good idea to iterate over representors list using this value.
Use xa_find starting from the first one instead to get next port
representor to remap.

The number of port representors has to be equal to ::num_rx/tx_q. Warn if
it isn't true.

Reviewed-by: Przemek Kitszel 
Reviewed-by: Wojciech Drewek 
Reviewed-by: Jacob Keller 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 39 ++--
 drivers/net/ethernet/intel/ice/ice_eswitch.h |  5 ++-
 drivers/net/ethernet/intel/ice/ice_repr.c|  1 +
 drivers/net/ethernet/intel/ice/ice_vf_lib.c  |  2 +-
 4 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c 
b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index a6b528bc2023..66cbe2c80fea 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -47,7 +47,8 @@ ice_eswitch_add_sp_rule(struct ice_pf *pf, struct ice_repr 
*repr)
err = ice_add_adv_rule(hw, list, lkups_cnt, &rule_info,
   &repr->sp_rule);
if (err)
-   dev_err(ice_pf_to_dev(pf), "Unable to add slow-path rule in 
switchdev mode");
+   dev_err(ice_pf_to_dev(pf), "Unable to add slow-path rule for 
eswitch for PR %d",
+   repr->id);
 
kfree(list);
return err;
@@ -142,6 +143,7 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
 static void ice_eswitch_remap_rings_to_vectors(struct ice_pf *pf)
 {
struct ice_vsi *vsi = pf->eswitch.control_vsi;
+   unsigned long repr_id = 0;
int q_id;
 
ice_for_each_txq(vsi, q_id) {
@@ -149,13 +151,14 @@ static void ice_eswitch_remap_rings_to_vectors(struct 
ice_pf *pf)
struct ice_tx_ring *tx_ring;
struct ice_rx_ring *rx_ring;
struct ice_repr *repr;
-   struct ice_vf *vf;
 
-   vf = ice_get_vf_by_id(pf, q_id);
-   if (WARN_ON(!vf))
-   continue;
+   repr = xa_find(&pf->eswitch.reprs, &repr_id, U32_MAX,
+  XA_PRESENT);
+   if (WARN_ON(!repr))
+   break;
 
-   repr = vf->repr;
+   repr_id += 1;
+   repr->q_id = q_id;
q_vector = repr->q_vector;
tx_ring = vsi->tx_rings[q_id];
rx_ring = vsi->rx_rings[q_id];
@@ -178,8 +181,6 @@ static void ice_eswitch_remap_rings_to_vectors(struct 
ice_pf *pf)
rx_ring->q_vector = q_vector;
rx_ring->next = NULL;
rx_ring->netdev = repr->netdev;
-
-   ice_put_vf(vf);
}
 }
 
@@ -284,20 +285,17 @@ static int ice_eswitch_setup_reprs(struct ice_pf *pf)
 
 /**
  * ice_eswitch_update_repr - reconfigure port representor
- * @vsi: VF VSI for which port representor is configured
+ * @repr: pointer to repr struct
+ * @vsi: VSI for which port representor is configured
  */
-void ice_eswitch_update_repr(struct ice_vsi *vsi)
+void ice_eswitch_update_repr(struct ice_repr *repr, struct ice_vsi *vsi)
 {
struct ice_pf *pf = vsi->back;
-   struct ice_repr *repr;
-   struct ice_vf *vf;
int ret;
 
if (!ice_is_switchdev_running(pf))
return;
 
-   vf = vsi->vf;
-   repr = vf->repr;
repr->src_vsi = vsi;
repr->dst->u.port_info.port_id = vsi->vsi_num;
 
@@ -306,9 +304,10 @@ void ice_eswitch_update_repr(struct ice_vsi *vsi)
 
ret = ice_vsi_update_security(vsi, ice_vsi_ctx_clear_antispoof);
if (ret) {
-   ice_fltr_add_mac_and_broadcast(vsi, vf->hw_lan_addr, 
ICE_FWD_TO_VSI);
-   dev_err(ice_pf_to_dev(pf), "Failed to update VF %d port 
representor",
-   vsi->vf->vf_id);
+   ice_fltr_add_mac_and_broadcast(vsi, repr->parent_mac,
+  ICE_FWD_TO_VSI);
+   dev_err(ice_pf_to_dev(pf), "Failed to update VSI of port 
representor %d",
+   repr->id);
}
 }
 
@@ -340,7 +339,7 @@ ice_eswitch_port_start_xmit(struct sk_buff *skb, struct 
net_device *netdev)
skb_dst_drop(skb);
dst_hold((struct dst_entry *)repr->dst);
skb_dst_set(skb, (struct dst_entry *)repr->dst);
-   skb->queue_mapping = repr->vf->vf_id;
+   skb->queue_mapping = repr->q_id;
 
return ice_start_xmit(skb, netdev);
 }
@@ -486,7 +485,7 @@ static int ice_eswitch_enable_switchdev(struct ice_pf *pf)
ice_eswitch_remap_rings_to_vectors(pf);
 
if (ice_vsi_open(ctrl_vsi))
-   goto e

[Intel-wired-lan] [PATCH iwl-next v1 08/15] ice: make representor code generic

2023-10-24 Thread Michal Swiatkowski
Representor code needs to be independent from specific device type, like
in this case VF. Make generic add / remove representor function and
specific add VF / rem VF function. New device types will follow this
scheme.

In bridge offload code there is a need to get representor pointer based
on VSI. Implement helper function to achieve that.

Reviewed-by: Piotr Raczynski 
Reviewed-by: Wojciech Drewek 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c  |   9 +-
 drivers/net/ethernet/intel/ice/ice_eswitch.h  |   4 +-
 .../net/ethernet/intel/ice/ice_eswitch_br.c   |  10 +-
 drivers/net/ethernet/intel/ice/ice_lib.c  |  10 +-
 drivers/net/ethernet/intel/ice/ice_repr.c | 184 ++
 drivers/net/ethernet/intel/ice/ice_repr.h |   2 +
 drivers/net/ethernet/intel/ice/ice_vf_lib.c   |   2 +-
 drivers/net/ethernet/intel/ice/ice_vf_lib.h   |   2 +-
 8 files changed, 131 insertions(+), 92 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c 
b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index 66cbe2c80fea..67231e43ffa6 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -285,17 +285,22 @@ static int ice_eswitch_setup_reprs(struct ice_pf *pf)
 
 /**
  * ice_eswitch_update_repr - reconfigure port representor
- * @repr: pointer to repr struct
+ * @repr_id: representor ID
  * @vsi: VSI for which port representor is configured
  */
-void ice_eswitch_update_repr(struct ice_repr *repr, struct ice_vsi *vsi)
+void ice_eswitch_update_repr(unsigned long repr_id, struct ice_vsi *vsi)
 {
struct ice_pf *pf = vsi->back;
+   struct ice_repr *repr;
int ret;
 
if (!ice_is_switchdev_running(pf))
return;
 
+   repr = xa_load(&pf->eswitch.reprs, repr_id);
+   if (!repr)
+   return;
+
repr->src_vsi = vsi;
repr->dst->u.port_info.port_id = vsi->vsi_num;
 
diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.h 
b/drivers/net/ethernet/intel/ice/ice_eswitch.h
index f43db1cce3ad..ff110bd9fc4c 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.h
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.h
@@ -17,7 +17,7 @@ ice_eswitch_mode_set(struct devlink *devlink, u16 mode,
 struct netlink_ext_ack *extack);
 bool ice_is_eswitch_mode_switchdev(struct ice_pf *pf);
 
-void ice_eswitch_update_repr(struct ice_repr *repr, struct ice_vsi *vsi);
+void ice_eswitch_update_repr(unsigned long repr_id, struct ice_vsi *vsi);
 
 void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf);
 
@@ -35,7 +35,7 @@ ice_eswitch_set_target_vsi(struct sk_buff *skb,
   struct ice_tx_offload_params *off) { }
 
 static inline void
-ice_eswitch_update_repr(struct ice_repr *repr, struct ice_vsi *vsi) { }
+ice_eswitch_update_repr(unsigned long repr_id, struct ice_vsi *vsi) { }
 
 static inline int ice_eswitch_configure(struct ice_pf *pf)
 {
diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch_br.c 
b/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
index 16bbcaca8fda..ac5beecd028b 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch_br.c
@@ -893,10 +893,14 @@ ice_eswitch_br_port_deinit(struct ice_esw_br *bridge,
ice_eswitch_br_fdb_entry_delete(bridge, fdb_entry);
}
 
-   if (br_port->type == ICE_ESWITCH_BR_UPLINK_PORT && vsi->back)
+   if (br_port->type == ICE_ESWITCH_BR_UPLINK_PORT && vsi->back) {
vsi->back->br_port = NULL;
-   else if (vsi->vf && vsi->vf->repr)
-   vsi->vf->repr->br_port = NULL;
+   } else {
+   struct ice_repr *repr = ice_repr_get_by_vsi(vsi);
+
+   if (repr)
+   repr->br_port = NULL;
+   }
 
xa_erase(&bridge->ports, br_port->vsi_idx);
ice_eswitch_br_port_vlans_flush(br_port);
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c 
b/drivers/net/ethernet/intel/ice/ice_lib.c
index 4b1e56396293..ae4b4220e1bb 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -519,16 +519,14 @@ static irqreturn_t ice_eswitch_msix_clean_rings(int 
__always_unused irq, void *d
 {
struct ice_q_vector *q_vector = (struct ice_q_vector *)data;
struct ice_pf *pf = q_vector->vsi->back;
-   struct ice_vf *vf;
-   unsigned int bkt;
+   struct ice_repr *repr;
+   unsigned long id;
 
if (!q_vector->tx.tx_ring && !q_vector->rx.rx_ring)
return IRQ_HANDLED;
 
-   rcu_read_lock();
-   ice_for_each_vf_rcu(pf, bkt, vf)
-   napi_schedule(&vf->repr->q_vector->napi);
-   rcu_read_unlock();
+   xa_for_each(&pf->eswitch.reprs, id, repr)
+   napi_schedule(&repr->q_vector->napi);
 
return IRQ_HANDLED;
 }
diff --git a/drivers/net/ethernet/intel/ice/ice_repr.c 
b/drivers/net/ethernet/intel/ice/ice_repr.c

[Intel-wired-lan] [PATCH iwl-next v1 09/15] ice: return pointer to representor

2023-10-24 Thread Michal Swiatkowski
In follow up patches it will be easier to obtain created port
representor pointer instead of the id. Without it the pattern from
eswitch side will look like:
- create PR
- get PR based on the id

Reviewed-by: Przemek Kitszel 
Reviewed-by: Wojciech Drewek 
Reviewed-by: Jacob Keller 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice_repr.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_repr.c 
b/drivers/net/ethernet/intel/ice/ice_repr.c
index fce25472d053..b29a3d010780 100644
--- a/drivers/net/ethernet/intel/ice/ice_repr.c
+++ b/drivers/net/ethernet/intel/ice/ice_repr.c
@@ -382,7 +382,7 @@ ice_repr_add(struct ice_pf *pf, struct ice_vsi *src_vsi, 
const u8 *parent_mac)
return ERR_PTR(err);
 }
 
-static int ice_repr_add_vf(struct ice_vf *vf)
+static struct ice_repr *ice_repr_add_vf(struct ice_vf *vf)
 {
struct ice_repr *repr;
struct ice_vsi *vsi;
@@ -390,11 +390,11 @@ static int ice_repr_add_vf(struct ice_vf *vf)
 
vsi = ice_get_vf_vsi(vf);
if (!vsi)
-   return -EINVAL;
+   return ERR_PTR(-ENOENT);
 
err = ice_devlink_create_vf_port(vf);
if (err)
-   return err;
+   return ERR_PTR(err);
 
repr = ice_repr_add(vf->pf, vsi, vf->hw_lan_addr);
if (IS_ERR(repr)) {
@@ -416,13 +416,13 @@ static int ice_repr_add_vf(struct ice_vf *vf)
 
ice_virtchnl_set_repr_ops(vf);
 
-   return 0;
+   return repr;
 
 err_netdev:
ice_repr_rem(&vf->pf->eswitch.reprs, repr);
 err_repr_add:
ice_devlink_destroy_vf_port(vf);
-   return err;
+   return ERR_PTR(err);
 }
 
 /**
@@ -432,6 +432,7 @@ static int ice_repr_add_vf(struct ice_vf *vf)
 int ice_repr_add_for_all_vfs(struct ice_pf *pf)
 {
struct devlink *devlink;
+   struct ice_repr *repr;
struct ice_vf *vf;
unsigned int bkt;
int err;
@@ -439,9 +440,11 @@ int ice_repr_add_for_all_vfs(struct ice_pf *pf)
lockdep_assert_held(&pf->vfs.table_lock);
 
ice_for_each_vf(pf, bkt, vf) {
-   err = ice_repr_add_vf(vf);
-   if (err)
+   repr = ice_repr_add_vf(vf);
+   if (IS_ERR(repr)) {
+   err = PTR_ERR(repr);
goto err;
+   }
}
 
/* only export if ADQ and DCB disabled */
-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH iwl-next v1 10/15] ice: allow changing SWITCHDEV_CTRL VSI queues

2023-10-24 Thread Michal Swiatkowski
Implement mechanism to change number of queues for SWITCHDEV_CTRL VSI
type.

Value from ::req_txq/rxq will be written to ::alloc_txq/rxq after
calling ice_vsi_rebuild().

Reviewed-by: Piotr Raczynski 
Reviewed-by: Wojciech Drewek 
Reviewed-by: Jacob Keller 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice_lib.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c 
b/drivers/net/ethernet/intel/ice/ice_lib.c
index ae4b4220e1bb..85a8cb28a489 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -212,11 +212,18 @@ static void ice_vsi_set_num_qs(struct ice_vsi *vsi)
 vsi->alloc_txq));
break;
case ICE_VSI_SWITCHDEV_CTRL:
-   /* The number of queues for ctrl VSI is equal to number of VFs.
+   /* The number of queues for ctrl VSI is equal to number of PRs
 * Each ring is associated to the corresponding VF_PR netdev.
+* Tx and Rx rings are always equal
 */
-   vsi->alloc_txq = ice_get_num_vfs(pf);
-   vsi->alloc_rxq = vsi->alloc_txq;
+   if (vsi->req_txq && vsi->req_rxq) {
+   vsi->alloc_txq = vsi->req_txq;
+   vsi->alloc_rxq = vsi->req_rxq;
+   } else {
+   vsi->alloc_txq = 1;
+   vsi->alloc_rxq = 1;
+   }
+
vsi->num_q_vectors = 1;
break;
case ICE_VSI_VF:
-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH iwl-next v1 11/15] ice: set Tx topology every time new repr is added

2023-10-24 Thread Michal Swiatkowski
It is needed to track correct Tx topology. Update it every time new
representor is created or remove node in case of removing corresponding
representor.

Still clear all node when removing switchdev mode as part of Tx topology
isn't related only to representors. Also clear ::rate_note value to
prevent skipping this node next time Tx topology is created.

Reviewed-by: Piotr Raczynski 
Reviewed-by: Wojciech Drewek 
Reviewed-by: Jacob Keller 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice_devlink.c | 29 
 drivers/net/ethernet/intel/ice/ice_devlink.h |  1 +
 drivers/net/ethernet/intel/ice/ice_eswitch.c |  9 ++
 drivers/net/ethernet/intel/ice/ice_repr.c| 27 +-
 4 files changed, 59 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_devlink.c 
b/drivers/net/ethernet/intel/ice/ice_devlink.c
index 80dc5445b50d..f4e24d11ebd0 100644
--- a/drivers/net/ethernet/intel/ice/ice_devlink.c
+++ b/drivers/net/ethernet/intel/ice/ice_devlink.c
@@ -810,6 +810,10 @@ static void ice_traverse_tx_tree(struct devlink *devlink, 
struct ice_sched_node
struct ice_vf *vf;
int i;
 
+   if (node->rate_node)
+   /* already added, skip to the next */
+   goto traverse_children;
+
if (node->parent == tc_node) {
/* create root node */
rate_node = devl_rate_node_create(devlink, node, node->name, 
NULL);
@@ -831,6 +835,7 @@ static void ice_traverse_tx_tree(struct devlink *devlink, 
struct ice_sched_node
if (rate_node && !IS_ERR(rate_node))
node->rate_node = rate_node;
 
+traverse_children:
for (i = 0; i < node->num_children; i++)
ice_traverse_tx_tree(devlink, node->children[i], tc_node, pf);
 }
@@ -861,6 +866,30 @@ int ice_devlink_rate_init_tx_topology(struct devlink 
*devlink, struct ice_vsi *v
return 0;
 }
 
+static void ice_clear_rate_nodes(struct ice_sched_node *node)
+{
+   node->rate_node = NULL;
+
+   for (int i = 0; i < node->num_children; i++)
+   ice_clear_rate_nodes(node->children[i]);
+}
+
+/**
+ * ice_devlink_rate_clear_tx_topology - clear node->rate_node
+ * @vsi: main vsi struct
+ *
+ * Clear rate_node to cleanup creation of Tx topology.
+ *
+ */
+void ice_devlink_rate_clear_tx_topology(struct ice_vsi *vsi)
+{
+   struct ice_port_info *pi = vsi->port_info;
+
+   mutex_lock(&pi->sched_lock);
+   ice_clear_rate_nodes(pi->root->children[0]);
+   mutex_unlock(&pi->sched_lock);
+}
+
 /**
  * ice_set_object_tx_share - sets node scheduling parameter
  * @pi: devlink struct instance
diff --git a/drivers/net/ethernet/intel/ice/ice_devlink.h 
b/drivers/net/ethernet/intel/ice/ice_devlink.h
index 6ec96779f52e..d291c0e2e17b 100644
--- a/drivers/net/ethernet/intel/ice/ice_devlink.h
+++ b/drivers/net/ethernet/intel/ice/ice_devlink.h
@@ -20,5 +20,6 @@ void ice_devlink_destroy_regions(struct ice_pf *pf);
 
 int ice_devlink_rate_init_tx_topology(struct devlink *devlink, struct ice_vsi 
*vsi);
 void ice_tear_down_devlink_rate_tree(struct ice_pf *pf);
+void ice_devlink_rate_clear_tx_topology(struct ice_vsi *vsi);
 
 #endif /* _ICE_DEVLINK_H_ */
diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c 
b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index 67231e43ffa6..db70a62429e3 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -519,6 +519,7 @@ static int ice_eswitch_enable_switchdev(struct ice_pf *pf)
 static void ice_eswitch_disable_switchdev(struct ice_pf *pf)
 {
struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi;
+   struct devlink *devlink = priv_to_devlink(pf);
 
ice_eswitch_napi_disable(&pf->eswitch.reprs);
ice_eswitch_br_offloads_deinit(pf);
@@ -526,6 +527,14 @@ static void ice_eswitch_disable_switchdev(struct ice_pf 
*pf)
ice_eswitch_release_reprs(pf);
ice_vsi_release(ctrl_vsi);
ice_repr_rem_from_all_vfs(pf);
+
+   /* since all port representors are destroyed, there is
+* no point in keeping the nodes
+*/
+   ice_devlink_rate_clear_tx_topology(ice_get_main_vsi(pf));
+   devl_lock(devlink);
+   devl_rate_nodes_destroy(devlink);
+   devl_unlock(devlink);
 }
 
 /**
diff --git a/drivers/net/ethernet/intel/ice/ice_repr.c 
b/drivers/net/ethernet/intel/ice/ice_repr.c
index b29a3d010780..fa36cc932c5f 100644
--- a/drivers/net/ethernet/intel/ice/ice_repr.c
+++ b/drivers/net/ethernet/intel/ice/ice_repr.c
@@ -278,6 +278,13 @@ ice_repr_reg_netdev(struct net_device *netdev)
return register_netdev(netdev);
 }
 
+static void ice_repr_remove_node(struct devlink_port *devlink_port)
+{
+   devl_lock(devlink_port->devlink);
+   devl_rate_leaf_destroy(devlink_port);
+   devl_unlock(devlink_port->devlink);
+}
+
 /**
  * ice_repr_rem - remove representor from VF
  * @reprs: xarray storing representors
@@ -298,6 +305,7 @@ sta

[Intel-wired-lan] [PATCH iwl-next v1 12/15] ice: realloc VSI stats arrays

2023-10-24 Thread Michal Swiatkowski
Previously only case when queues amount is lower was covered. Implement
realloc for case when queues amount is higher than previous one. Use
krealloc() function and zero new allocated elements.

It has to be done before ice_vsi_def_cfg(), because stats element for
ring is set there.

Reviewed-by: Wojciech Drewek 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice_lib.c | 58 
 1 file changed, 39 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c 
b/drivers/net/ethernet/intel/ice/ice_lib.c
index 85a8cb28a489..d826b5afa143 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -3076,27 +3076,26 @@ ice_vsi_rebuild_set_coalesce(struct ice_vsi *vsi,
 }
 
 /**
- * ice_vsi_realloc_stat_arrays - Frees unused stat structures
+ * ice_vsi_realloc_stat_arrays - Frees unused stat structures or alloc new ones
  * @vsi: VSI pointer
- * @prev_txq: Number of Tx rings before ring reallocation
- * @prev_rxq: Number of Rx rings before ring reallocation
  */
-static void
-ice_vsi_realloc_stat_arrays(struct ice_vsi *vsi, int prev_txq, int prev_rxq)
+static int
+ice_vsi_realloc_stat_arrays(struct ice_vsi *vsi)
 {
+   u16 req_txq = vsi->req_txq ? vsi->req_txq : vsi->alloc_txq;
+   u16 req_rxq = vsi->req_rxq ? vsi->req_rxq : vsi->alloc_rxq;
+   struct ice_ring_stats **tx_ring_stats;
+   struct ice_ring_stats **rx_ring_stats;
struct ice_vsi_stats *vsi_stat;
struct ice_pf *pf = vsi->back;
+   u16 prev_txq = vsi->alloc_txq;
+   u16 prev_rxq = vsi->alloc_rxq;
int i;
 
-   if (!prev_txq || !prev_rxq)
-   return;
-   if (vsi->type == ICE_VSI_CHNL)
-   return;
-
vsi_stat = pf->vsi_stats[vsi->idx];
 
-   if (vsi->num_txq < prev_txq) {
-   for (i = vsi->num_txq; i < prev_txq; i++) {
+   if (req_txq < prev_txq) {
+   for (i = req_txq; i < prev_txq; i++) {
if (vsi_stat->tx_ring_stats[i]) {
kfree_rcu(vsi_stat->tx_ring_stats[i], rcu);
WRITE_ONCE(vsi_stat->tx_ring_stats[i], NULL);
@@ -3104,14 +3103,36 @@ ice_vsi_realloc_stat_arrays(struct ice_vsi *vsi, int 
prev_txq, int prev_rxq)
}
}
 
-   if (vsi->num_rxq < prev_rxq) {
-   for (i = vsi->num_rxq; i < prev_rxq; i++) {
+   tx_ring_stats = vsi_stat->rx_ring_stats;
+   vsi_stat->tx_ring_stats =
+   krealloc_array(vsi_stat->tx_ring_stats, req_txq,
+  sizeof(*vsi_stat->tx_ring_stats),
+  GFP_KERNEL | __GFP_ZERO);
+   if (!vsi_stat->tx_ring_stats) {
+   vsi_stat->tx_ring_stats = tx_ring_stats;
+   return -ENOMEM;
+   }
+
+   if (req_rxq < prev_rxq) {
+   for (i = req_rxq; i < prev_rxq; i++) {
if (vsi_stat->rx_ring_stats[i]) {
kfree_rcu(vsi_stat->rx_ring_stats[i], rcu);
WRITE_ONCE(vsi_stat->rx_ring_stats[i], NULL);
}
}
}
+
+   rx_ring_stats = vsi_stat->rx_ring_stats;
+   vsi_stat->rx_ring_stats =
+   krealloc_array(vsi_stat->rx_ring_stats, req_rxq,
+  sizeof(*vsi_stat->rx_ring_stats),
+  GFP_KERNEL | __GFP_ZERO);
+   if (!vsi_stat->rx_ring_stats) {
+   vsi_stat->rx_ring_stats = rx_ring_stats;
+   return -ENOMEM;
+   }
+
+   return 0;
 }
 
 /**
@@ -3128,9 +3149,9 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, u32 vsi_flags)
 {
struct ice_vsi_cfg_params params = {};
struct ice_coalesce_stored *coalesce;
-   int ret, prev_txq, prev_rxq;
int prev_num_q_vectors = 0;
struct ice_pf *pf;
+   int ret;
 
if (!vsi)
return -EINVAL;
@@ -3149,8 +3170,9 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, u32 vsi_flags)
 
prev_num_q_vectors = ice_vsi_rebuild_get_coalesce(vsi, coalesce);
 
-   prev_txq = vsi->num_txq;
-   prev_rxq = vsi->num_rxq;
+   ret = ice_vsi_realloc_stat_arrays(vsi);
+   if (ret)
+   goto err_vsi_cfg;
 
ice_vsi_decfg(vsi);
ret = ice_vsi_cfg_def(vsi, ¶ms);
@@ -3168,8 +3190,6 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, u32 vsi_flags)
return ice_schedule_reset(pf, ICE_RESET_PFR);
}
 
-   ice_vsi_realloc_stat_arrays(vsi, prev_txq, prev_rxq);
-
ice_vsi_rebuild_set_coalesce(vsi, coalesce, prev_num_q_vectors);
kfree(coalesce);
 
-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH iwl-next v1 13/15] ice: add VF representors one by one

2023-10-24 Thread Michal Swiatkowski
Implement adding representors one by one. Always set switchdev
environment when first representor is being added and clear environment
when last one is being removed.

Basic switchdev configuration remains the same. Code related to creating
and configuring representor was changed.

Instead of setting whole representors in one function handle only one
representor in setup function. The same with removing representors.

Stop representors when new one is being added or removed. Stop means,
disabling napi, stopping traffic and removing slow path rule. It is
needed because ::q_id will change after remapping, so each representor
will need new rule.

When representor are stopped rebuild control plane VSI with one more or
one less queue. One more if new representor is being added, one less if
representor is being removed.

Bridge port is removed during unregister_netdev() call on PR, so there
is no need to call it from driver side.

After that do remap new queues to correct vector. At the end start all
representors (napi enable, start queues, add slow path rule).

Reviewed-by: Piotr Raczynski 
Reviewed-by: Wojciech Drewek 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 351 +++
 drivers/net/ethernet/intel/ice/ice_eswitch.h |  13 +-
 drivers/net/ethernet/intel/ice/ice_repr.c|  85 +
 drivers/net/ethernet/intel/ice/ice_repr.h|   4 +-
 drivers/net/ethernet/intel/ice/ice_sriov.c   |  17 +-
 5 files changed, 228 insertions(+), 242 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c 
b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index db70a62429e3..de5744aa5c2a 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -10,6 +10,24 @@
 #include "ice_devlink.h"
 #include "ice_tc_lib.h"
 
+/**
+ * ice_eswitch_del_sp_rules - delete adv rules added on PRs
+ * @pf: pointer to the PF struct
+ *
+ * Delete all advanced rules that were used to forward packets with the
+ * device's VSI index to the corresponding eswitch ctrl VSI queue.
+ */
+static void ice_eswitch_del_sp_rules(struct ice_pf *pf)
+{
+   struct ice_repr *repr;
+   unsigned long id;
+
+   xa_for_each(&pf->eswitch.reprs, id, repr) {
+   if (repr->sp_rule.rid)
+   ice_rem_adv_rule_by_id(&pf->hw, &repr->sp_rule);
+   }
+}
+
 /**
  * ice_eswitch_add_sp_rule - add adv rule with device's VSI index
  * @pf: pointer to PF struct
@@ -18,8 +36,7 @@
  * This function adds advanced rule that forwards packets with
  * device's VSI index to the corresponding eswitch ctrl VSI queue.
  */
-static int
-ice_eswitch_add_sp_rule(struct ice_pf *pf, struct ice_repr *repr)
+static int ice_eswitch_add_sp_rule(struct ice_pf *pf, struct ice_repr *repr)
 {
struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi;
struct ice_adv_rule_info rule_info = { 0 };
@@ -54,17 +71,22 @@ ice_eswitch_add_sp_rule(struct ice_pf *pf, struct ice_repr 
*repr)
return err;
 }
 
-/**
- * ice_eswitch_del_sp_rule - delete adv rule with device's VSI index
- * @pf: pointer to the PF struct
- * @repr: pointer to the repr struct
- *
- * Delete the advanced rule that was used to forward packets with the device's
- * VSI index to the corresponding eswitch ctrl VSI queue.
- */
-static void ice_eswitch_del_sp_rule(struct ice_pf *pf, struct ice_repr *repr)
+static int
+ice_eswitch_add_sp_rules(struct ice_pf *pf)
 {
-   ice_rem_adv_rule_by_id(&pf->hw, &repr->sp_rule);
+   struct ice_repr *repr;
+   unsigned long id;
+   int err;
+
+   xa_for_each(&pf->eswitch.reprs, id, repr) {
+   err = ice_eswitch_add_sp_rule(pf, repr);
+   if (err) {
+   ice_eswitch_del_sp_rules(pf);
+   return err;
+   }
+   }
+
+   return 0;
 }
 
 /**
@@ -131,7 +153,7 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
 
 /**
  * ice_eswitch_remap_rings_to_vectors - reconfigure rings of eswitch ctrl VSI
- * @pf: pointer to PF struct
+ * @eswitch: pointer to eswitch struct
  *
  * In eswitch number of allocated Tx/Rx rings is equal.
  *
@@ -140,9 +162,9 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
  * will have dedicated 1 Tx/Rx ring pair, so number of rings pair is equal to
  * number of VFs.
  */
-static void ice_eswitch_remap_rings_to_vectors(struct ice_pf *pf)
+static void ice_eswitch_remap_rings_to_vectors(struct ice_eswitch *eswitch)
 {
-   struct ice_vsi *vsi = pf->eswitch.control_vsi;
+   struct ice_vsi *vsi = eswitch->control_vsi;
unsigned long repr_id = 0;
int q_id;
 
@@ -152,7 +174,7 @@ static void ice_eswitch_remap_rings_to_vectors(struct 
ice_pf *pf)
struct ice_rx_ring *rx_ring;
struct ice_repr *repr;
 
-   repr = xa_find(&pf->eswitch.reprs, &repr_id, U32_MAX,
+   repr = xa_find(&eswitch->reprs, &repr_id, U32_MAX,
  

[Intel-wired-lan] [PATCH iwl-next v1 14/15] ice: adjust switchdev rebuild path

2023-10-24 Thread Michal Swiatkowski
There is no need to use specific functions for rebuilding path. Let's
use current implementation by removing all representors and as the
result remove switchdev environment.

It will be added in devices rebuild path. For example during adding VFs,
port representors for them also will be created.

Rebuild control plane VSI before removing representors with INIT_VSI
flag set to reinit VSI in hardware after reset.

Reviewed-by: Wojciech Drewek 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 66 +++-
 drivers/net/ethernet/intel/ice/ice_main.c|  4 +-
 drivers/net/ethernet/intel/ice/ice_vf_lib.c  |  7 +--
 3 files changed, 28 insertions(+), 49 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c 
b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index de5744aa5c2a..9ff4fe4fb133 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -406,19 +406,6 @@ ice_eswitch_vsi_setup(struct ice_pf *pf, struct 
ice_port_info *pi)
return ice_vsi_setup(pf, ¶ms);
 }
 
-/**
- * ice_eswitch_napi_del - remove NAPI handle for all port representors
- * @reprs: xarray of reprs
- */
-static void ice_eswitch_napi_del(struct xarray *reprs)
-{
-   struct ice_repr *repr;
-   unsigned long id;
-
-   xa_for_each(reprs, id, repr)
-   netif_napi_del(&repr->q_vector->napi);
-}
-
 /**
  * ice_eswitch_napi_enable - enable NAPI for all port representors
  * @reprs: xarray of reprs
@@ -624,36 +611,6 @@ static void ice_eswitch_start_reprs(struct ice_pf *pf)
ice_eswitch_add_sp_rules(pf);
 }
 
-/**
- * ice_eswitch_rebuild - rebuild eswitch
- * @pf: pointer to PF structure
- */
-int ice_eswitch_rebuild(struct ice_pf *pf)
-{
-   struct ice_vsi *ctrl_vsi = pf->eswitch.control_vsi;
-   int status;
-
-   ice_eswitch_napi_disable(&pf->eswitch.reprs);
-   ice_eswitch_napi_del(&pf->eswitch.reprs);
-
-   status = ice_eswitch_setup_env(pf);
-   if (status)
-   return status;
-
-   ice_eswitch_remap_rings_to_vectors(&pf->eswitch);
-
-   ice_replay_tc_fltrs(pf);
-
-   status = ice_vsi_open(ctrl_vsi);
-   if (status)
-   return status;
-
-   ice_eswitch_napi_enable(&pf->eswitch.reprs);
-   ice_eswitch_start_all_tx_queues(pf);
-
-   return 0;
-}
-
 static void
 ice_eswitch_cp_change_queues(struct ice_eswitch *eswitch, int change)
 {
@@ -752,3 +709,26 @@ void ice_eswitch_detach(struct ice_pf *pf, struct ice_vf 
*vf)
ice_eswitch_start_reprs(pf);
}
 }
+
+/**
+ * ice_eswitch_rebuild - rebuild eswitch
+ * @pf: pointer to PF structure
+ */
+int ice_eswitch_rebuild(struct ice_pf *pf)
+{
+   struct ice_repr *repr;
+   unsigned long id;
+   int err;
+
+   if (!ice_is_switchdev_running(pf))
+   return 0;
+
+   err = ice_vsi_rebuild(pf->eswitch.control_vsi, ICE_VSI_FLAG_INIT);
+   if (err)
+   return err;
+
+   xa_for_each(&pf->eswitch.reprs, id, repr)
+   ice_eswitch_detach(pf, repr->vf);
+
+   return 0;
+}
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c 
b/drivers/net/ethernet/intel/ice/ice_main.c
index cb0ff015647f..58d2a6267918 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -7412,9 +7412,9 @@ static void ice_rebuild(struct ice_pf *pf, enum 
ice_reset_req reset_type)
ice_ptp_cfg_timestamp(pf, true);
}
 
-   err = ice_vsi_rebuild_by_type(pf, ICE_VSI_SWITCHDEV_CTRL);
+   err = ice_eswitch_rebuild(pf);
if (err) {
-   dev_err(dev, "Switchdev CTRL VSI rebuild failed: %d\n", err);
+   dev_err(dev, "Switchdev rebuild failed: %d\n", err);
goto err_vsi_rebuild;
}
 
diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c 
b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
index 68f9de0a7a8f..d2a99a20c4ad 100644
--- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
@@ -760,6 +760,7 @@ void ice_reset_all_vfs(struct ice_pf *pf)
ice_for_each_vf(pf, bkt, vf) {
mutex_lock(&vf->cfg_lock);
 
+   ice_eswitch_detach(pf, vf);
vf->driver_caps = 0;
ice_vc_set_default_allowlist(vf);
 
@@ -775,13 +776,11 @@ void ice_reset_all_vfs(struct ice_pf *pf)
ice_vf_rebuild_vsi(vf);
ice_vf_post_vsi_rebuild(vf);
 
+   ice_eswitch_attach(pf, vf);
+
mutex_unlock(&vf->cfg_lock);
}
 
-   if (ice_is_eswitch_mode_switchdev(pf))
-   if (ice_eswitch_rebuild(pf))
-   dev_warn(dev, "eswitch rebuild failed\n");
-
ice_flush(hw);
clear_bit(ICE_VF_DIS, pf->state);
 
-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/

[Intel-wired-lan] [PATCH iwl-next v1 15/15] ice: reserve number of CP queues

2023-10-24 Thread Michal Swiatkowski
Rebuilding CP VSI each time the PR is created drastically increase the
time of maximum VFs creation. Add function to reserve number of CP
queues to deal with this problem.

Use the same function to decrease number of queues in case of removing
VFs. Assume that caller of ice_eswitch_reserve_cp_queues() will also
call ice_eswitch_attach/detach() correct number of times.

Still one by one PR adding is handy for VF resetting routine.

Reviewed-by: Wojciech Drewek 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice.h |  6 +++
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 52 +---
 drivers/net/ethernet/intel/ice/ice_eswitch.h |  4 ++
 drivers/net/ethernet/intel/ice/ice_sriov.c   |  3 ++
 4 files changed, 58 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice.h 
b/drivers/net/ethernet/intel/ice/ice.h
index 597bdb6945c6..cd7dcd0fa7f2 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -528,6 +528,12 @@ struct ice_eswitch {
struct ice_esw_br_offloads *br_offloads;
struct xarray reprs;
bool is_running;
+   /* struct to allow cp queues management optimization */
+   struct {
+   int to_reach;
+   int value;
+   bool is_reaching;
+   } qs;
 };
 
 struct ice_agg_node {
diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c 
b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index 9ff4fe4fb133..3f80e2081e5d 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -176,7 +176,7 @@ static void ice_eswitch_remap_rings_to_vectors(struct 
ice_eswitch *eswitch)
 
repr = xa_find(&eswitch->reprs, &repr_id, U32_MAX,
   XA_PRESENT);
-   if (WARN_ON(!repr))
+   if (!repr)
break;
 
repr_id += 1;
@@ -455,6 +455,8 @@ static int ice_eswitch_enable_switchdev(struct ice_pf *pf)
return -ENODEV;
 
ctrl_vsi = pf->eswitch.control_vsi;
+   /* cp VSI is createad with 1 queue as default */
+   pf->eswitch.qs.value = 1;
pf->eswitch.uplink_vsi = uplink_vsi;
 
if (ice_eswitch_setup_env(pf))
@@ -487,6 +489,7 @@ static void ice_eswitch_disable_switchdev(struct ice_pf *pf)
ice_vsi_release(ctrl_vsi);
 
pf->eswitch.is_running = false;
+   pf->eswitch.qs.is_reaching = false;
 }
 
 /**
@@ -615,15 +618,33 @@ static void
 ice_eswitch_cp_change_queues(struct ice_eswitch *eswitch, int change)
 {
struct ice_vsi *cp = eswitch->control_vsi;
+   int queues = 0;
+
+   if (eswitch->qs.is_reaching) {
+   if (eswitch->qs.to_reach >= eswitch->qs.value + change) {
+   queues = eswitch->qs.to_reach;
+   eswitch->qs.is_reaching = false;
+   } else {
+   queues = 0;
+   }
+   } else if ((change > 0 && cp->alloc_txq <= eswitch->qs.value) ||
+  change < 0) {
+   queues = cp->alloc_txq + change;
+   }
 
-   ice_vsi_close(cp);
+   if (queues) {
+   cp->req_txq = queues;
+   cp->req_rxq = queues;
+   ice_vsi_close(cp);
+   ice_vsi_rebuild(cp, ICE_VSI_FLAG_NO_INIT);
+   ice_vsi_open(cp);
+   } else if (!change) {
+   /* change == 0 means that VSI wasn't open, open it here */
+   ice_vsi_open(cp);
+   }
 
-   cp->req_txq = cp->alloc_txq + change;
-   cp->req_rxq = cp->alloc_rxq + change;
-   ice_vsi_rebuild(cp, ICE_VSI_FLAG_NO_INIT);
+   eswitch->qs.value += change;
ice_eswitch_remap_rings_to_vectors(eswitch);
-
-   ice_vsi_open(cp);
 }
 
 int
@@ -641,6 +662,7 @@ ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf)
if (err)
return err;
/* Control plane VSI is created with 1 queue as default */
+   pf->eswitch.qs.to_reach -= 1;
change = 0;
}
 
@@ -732,3 +754,19 @@ int ice_eswitch_rebuild(struct ice_pf *pf)
 
return 0;
 }
+
+/**
+ * ice_eswitch_reserve_cp_queues - reserve control plane VSI queues
+ * @pf: pointer to PF structure
+ * @change: how many more (or less) queues is needed
+ *
+ * Remember to call ice_eswitch_attach/detach() the "change" times.
+ */
+void ice_eswitch_reserve_cp_queues(struct ice_pf *pf, int change)
+{
+   if (pf->eswitch.qs.value + change < 0)
+   return;
+
+   pf->eswitch.qs.to_reach = pf->eswitch.qs.value + change;
+   pf->eswitch.qs.is_reaching = true;
+}
diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.h 
b/drivers/net/ethernet/intel/ice/ice_eswitch.h
index 59d51c0d14e5..1a288a03a79a 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.h
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.h
@@ -26,6 +26,7 @@ void ice_eswitch_set_tar

Re: [Intel-wired-lan] [PATCH iwl-next] ice: Reset VF on Tx MDD event

2023-10-24 Thread Paul Menzel

Dear Pawel, dear Liang-min,


Am 24.10.23 um 13:29 schrieb Pawel Chmielewski:

From: Liang-min Wang 


Should min start with a capital letter Liang-Min?


In cases when VF sends malformed packets that are classified as malicious,
sometimes it causes Tx queue to freeze. This frozen queue can be stuck
for several minutes being unusable.


Did you analyze the cause for this. Why does it freeze only sometimes? 
Are you able to reproduce it?



When MDD event occurs, perform graceful VF reset to quickly bring VF
back to operational state.


I’d spell out Malicious Driver Detection.

Please mention, that a new log message is added.


Signed-off-by: Liang-min Wang 
Signed-off-by: Pawel Chmielewski 
Reviewed-by: Michal Swiatkowski 
---
  drivers/net/ethernet/intel/ice/ice_main.c | 14 --
  1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_main.c 
b/drivers/net/ethernet/intel/ice/ice_main.c
index 66095e9b094e..cf9fd1f168f7 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -1836,8 +1836,13 @@ static void ice_handle_mdd_event(struct ice_pf *pf)
vf->mdd_tx_events.count++;
set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state);
if (netif_msg_tx_err(pf))
-   dev_info(dev, "Malicious Driver Detection event 
TX_TCLAN detected on VF %d\n",
+   dev_info(dev,
+"Malicious Driver Detection event TX_TCLAN 
detected on VF %d\n",
 vf->vf_id);


I’d refrain from formatting changes.


+   dev_info(dev,
+"PF-to-VF reset on VF %d due to Tx MDD TX_TCLAN 
event\n",
+vf->vf_id);
+   ice_reset_vf(vf, ICE_VF_RESET_NOTIFY);
}
  
  		reg = rd32(hw, VP_MDET_TX_TDPU(vf->vf_id));

@@ -1846,8 +1851,13 @@ static void ice_handle_mdd_event(struct ice_pf *pf)
vf->mdd_tx_events.count++;
set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state);
if (netif_msg_tx_err(pf))
-   dev_info(dev, "Malicious Driver Detection event 
TX_TDPU detected on VF %d\n",
+   dev_info(dev,
+"Malicious Driver Detection event TX_TDPU 
detected on VF %d\n",
 vf->vf_id);
+   dev_info(dev,
+"PF-to-VF reset on VF %d due to Tx MDD TX_TCLAN 
event\n",
+vf->vf_id);
+   ice_reset_vf(vf, ICE_VF_RESET_NOTIFY);
}
  
  		reg = rd32(hw, VP_MDET_RX(vf->vf_id));


It look like, a patch could be added ahead to factor these parts in a 
separate function.



Kind regards,

Paul
___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH iwl-next v1 00/15] one by one port representors creation

2023-10-24 Thread Jiri Pirko
Tue, Oct 24, 2023 at 01:09:14PM CEST, michal.swiatkow...@linux.intel.com wrote:
>Hi,
>
>Currently ice supports creating port representors only for VFs. For that
>use case they can be created and removed in one step.
>
>This patchset is refactoring current flow to support port representor
>creation also for subfunctions and SIOV. In this case port representors
>need to be createad and removed one by one. Also, they can be added and
>removed while other port representors are running.
>
>To achieve that we need to change the switchdev configuration flow.
>Three first patches are only cosmetic (renaming, removing not used code).
>Next few ones are preparation for new flow. The most important one
>is "add VF representor one by one". It fully implements new flow.
>
>New type of port representor (for subfunction) will be introduced in
>follow up patchset.

Examples please. Show new outputs of devlink commands.

Thanks!


>
>Michal Swiatkowski (15):
>  ice: rename switchdev to eswitch
>  ice: remove redundant max_vsi_num variable
>  ice: remove unused control VSI parameter
>  ice: track q_id in representor
>  ice: use repr instead of vf->repr
>  ice: track port representors in xarray
>  ice: remove VF pointer reference in eswitch code
>  ice: make representor code generic
>  ice: return pointer to representor
>  ice: allow changing SWITCHDEV_CTRL VSI queues
>  ice: set Tx topology every time new repr is added
>  ice: realloc VSI stats arrays
>  ice: add VF representors one by one
>  ice: adjust switchdev rebuild path
>  ice: reserve number of CP queues
>
> drivers/net/ethernet/intel/ice/ice.h  |  13 +-
> drivers/net/ethernet/intel/ice/ice_devlink.c  |  29 +
> drivers/net/ethernet/intel/ice/ice_devlink.h  |   1 +
> drivers/net/ethernet/intel/ice/ice_eswitch.c  | 562 ++
> drivers/net/ethernet/intel/ice/ice_eswitch.h  |  22 +-
> .../net/ethernet/intel/ice/ice_eswitch_br.c   |  22 +-
> drivers/net/ethernet/intel/ice/ice_lib.c  |  81 ++-
> drivers/net/ethernet/intel/ice/ice_main.c |   6 +-
> drivers/net/ethernet/intel/ice/ice_repr.c | 195 +++---
> drivers/net/ethernet/intel/ice/ice_repr.h |   9 +-
> drivers/net/ethernet/intel/ice/ice_sriov.c|  20 +-
> drivers/net/ethernet/intel/ice/ice_tc_lib.c   |   4 +-
> drivers/net/ethernet/intel/ice/ice_vf_lib.c   |   9 +-
> drivers/net/ethernet/intel/ice/ice_vf_lib.h   |   2 +-
> 14 files changed, 553 insertions(+), 422 deletions(-)
>
>-- 
>2.41.0
>
>
___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH iwl-next] ice: Reset VF on Tx MDD event

2023-10-24 Thread Pawel Chmielewski
Dear Paul,

Thank you for your review!

> > From: Liang-min Wang 
> 
> Should min start with a capital letter Liang-Min?

That's right, I'll correct it.

> > In cases when VF sends malformed packets that are classified as malicious,
> > sometimes it causes Tx queue to freeze. This frozen queue can be stuck
> > for several minutes being unusable.
> 
> Did you analyze the cause for this. Why does it freeze only sometimes? Are
> you able to reproduce it?

Yes, we could re-produce the issue using a user space application, testpmd, 
from DPDK

> 
> > When MDD event occurs, perform graceful VF reset to quickly bring VF
> > back to operational state.
> 
> I’d spell out Malicious Driver Detection.

Will do.

> 
> Please mention, that a new log message is added.

I'll add this information.
 
> 
> It look like, a patch could be added ahead to factor these parts in a
> separate function.

Which parts (lines) do you have in mind?


Regards,
Pawel
___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH 2/2] i40e: Fix devlink port unregistering

2023-10-24 Thread Ivan Vecera
Ensure that devlink port is unregistered after unregistering
of net device.

Reproducer:
[root@host ~]# rmmod i40e
[ 4742.939386] i40e :02:00.1: i40e_ptp_stop: removed PHC on enp2s0f1np1
[ 4743.059269] [ cut here ]
[ 4743.063900] WARNING: CPU: 21 PID: 10766 at net/devlink/port.c:1078 
devl_port_unregister+0x69/0x80
...

Fixes: 9e479d64dc58 ("i40e: Add initial devlink support")
Signed-off-by: Ivan Vecera 
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c 
b/drivers/net/ethernet/intel/i40e/i40e_main.c
index df058540d277..3f396c100835 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -14181,8 +14181,7 @@ int i40e_vsi_release(struct i40e_vsi *vsi)
}
set_bit(__I40E_VSI_RELEASING, vsi->state);
uplink_seid = vsi->uplink_seid;
-   if (vsi->type == I40E_VSI_MAIN)
-   i40e_devlink_destroy_port(pf);
+
if (vsi->type != I40E_VSI_SRIOV) {
if (vsi->netdev_registered) {
vsi->netdev_registered = false;
@@ -14196,6 +14195,9 @@ int i40e_vsi_release(struct i40e_vsi *vsi)
i40e_vsi_disable_irq(vsi);
}
 
+   if (vsi->type == I40E_VSI_MAIN)
+   i40e_devlink_destroy_port(pf);
+
spin_lock_bh(&vsi->mac_filter_hash_lock);
 
/* clear the sync flag on all filters */
@@ -14370,14 +14372,14 @@ static struct i40e_vsi *i40e_vsi_reinit_setup(struct 
i40e_vsi *vsi)
 
 err_rings:
i40e_vsi_free_q_vectors(vsi);
-   if (vsi->type == I40E_VSI_MAIN)
-   i40e_devlink_destroy_port(pf);
if (vsi->netdev_registered) {
vsi->netdev_registered = false;
unregister_netdev(vsi->netdev);
free_netdev(vsi->netdev);
vsi->netdev = NULL;
}
+   if (vsi->type == I40E_VSI_MAIN)
+   i40e_devlink_destroy_port(pf);
i40e_aq_delete_element(&pf->hw, vsi->seid, NULL);
 err_vsi:
i40e_vsi_clear(vsi);
-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH 1/2] i40e: Do not call devlink_port_type_clear()

2023-10-24 Thread Ivan Vecera
Do not call devlink_port_type_clear() prior devlink port unregister
and let devlink core to take care about it.

Reproducer:
[root@host ~]# rmmod i40e
[ 4539.964699] i40e :02:00.0: devlink port type for port 0 cleared without 
a software interface reference, device type not supported by the kernel?
[ 4540.319811] i40e :02:00.1: devlink port type for port 1 cleared without 
a software interface reference, device type not supported by the kernel?

Fixes: 9e479d64dc58 ("i40e: Add initial devlink support")
Signed-off-by: Ivan Vecera 
---
 drivers/net/ethernet/intel/i40e/i40e_devlink.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_devlink.c 
b/drivers/net/ethernet/intel/i40e/i40e_devlink.c
index 74bc111b4849..cc4e9e2addb7 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_devlink.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_devlink.c
@@ -231,6 +231,5 @@ int i40e_devlink_create_port(struct i40e_pf *pf)
  **/
 void i40e_devlink_destroy_port(struct i40e_pf *pf)
 {
-   devlink_port_type_clear(&pf->devlink_port);
devlink_port_unregister(&pf->devlink_port);
 }
-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH 1/2] i40e: Do not call devlink_port_type_clear()

2023-10-24 Thread Ivan Vecera




On 24. 10. 23 14:42, Ivan Vecera wrote:

Do not call devlink_port_type_clear() prior devlink port unregister
and let devlink core to take care about it.

Reproducer:
[root@host ~]# rmmod i40e
[ 4539.964699] i40e :02:00.0: devlink port type for port 0 cleared without 
a software interface reference, device type not supported by the kernel?
[ 4540.319811] i40e :02:00.1: devlink port type for port 1 cleared without 
a software interface reference, device type not supported by the kernel?

Fixes: 9e479d64dc58 ("i40e: Add initial devlink support")
Signed-off-by: Ivan Vecera 
---
  drivers/net/ethernet/intel/i40e/i40e_devlink.c | 1 -
  1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_devlink.c 
b/drivers/net/ethernet/intel/i40e/i40e_devlink.c
index 74bc111b4849..cc4e9e2addb7 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_devlink.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_devlink.c
@@ -231,6 +231,5 @@ int i40e_devlink_create_port(struct i40e_pf *pf)
   **/
  void i40e_devlink_destroy_port(struct i40e_pf *pf)
  {
-   devlink_port_type_clear(&pf->devlink_port);
devlink_port_unregister(&pf->devlink_port);
  }


Please drop... there is missing net-next target.
Will post v2.

Ivan

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH net-next 1/2] i40e: Do not call devlink_port_type_clear()

2023-10-24 Thread Ivan Vecera
Do not call devlink_port_type_clear() prior devlink port unregister
and let devlink core to take care about it.

Reproducer:
[root@host ~]# rmmod i40e
[ 4539.964699] i40e :02:00.0: devlink port type for port 0 cleared without 
a software interface reference, device type not supported by the kernel?
[ 4540.319811] i40e :02:00.1: devlink port type for port 1 cleared without 
a software interface reference, device type not supported by the kernel?

Fixes: 9e479d64dc58 ("i40e: Add initial devlink support")
Signed-off-by: Ivan Vecera 
---
 drivers/net/ethernet/intel/i40e/i40e_devlink.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_devlink.c 
b/drivers/net/ethernet/intel/i40e/i40e_devlink.c
index 74bc111b4849..cc4e9e2addb7 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_devlink.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_devlink.c
@@ -231,6 +231,5 @@ int i40e_devlink_create_port(struct i40e_pf *pf)
  **/
 void i40e_devlink_destroy_port(struct i40e_pf *pf)
 {
-   devlink_port_type_clear(&pf->devlink_port);
devlink_port_unregister(&pf->devlink_port);
 }
-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH net-next 2/2] i40e: Fix devlink port unregistering

2023-10-24 Thread Ivan Vecera
Ensure that devlink port is unregistered after unregistering
of net device.

Reproducer:
[root@host ~]# rmmod i40e
[ 4742.939386] i40e :02:00.1: i40e_ptp_stop: removed PHC on enp2s0f1np1
[ 4743.059269] [ cut here ]
[ 4743.063900] WARNING: CPU: 21 PID: 10766 at net/devlink/port.c:1078 
devl_port_unregister+0x69/0x80
...

Fixes: 9e479d64dc58 ("i40e: Add initial devlink support")
Signed-off-by: Ivan Vecera 
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c 
b/drivers/net/ethernet/intel/i40e/i40e_main.c
index df058540d277..3f396c100835 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -14181,8 +14181,7 @@ int i40e_vsi_release(struct i40e_vsi *vsi)
}
set_bit(__I40E_VSI_RELEASING, vsi->state);
uplink_seid = vsi->uplink_seid;
-   if (vsi->type == I40E_VSI_MAIN)
-   i40e_devlink_destroy_port(pf);
+
if (vsi->type != I40E_VSI_SRIOV) {
if (vsi->netdev_registered) {
vsi->netdev_registered = false;
@@ -14196,6 +14195,9 @@ int i40e_vsi_release(struct i40e_vsi *vsi)
i40e_vsi_disable_irq(vsi);
}
 
+   if (vsi->type == I40E_VSI_MAIN)
+   i40e_devlink_destroy_port(pf);
+
spin_lock_bh(&vsi->mac_filter_hash_lock);
 
/* clear the sync flag on all filters */
@@ -14370,14 +14372,14 @@ static struct i40e_vsi *i40e_vsi_reinit_setup(struct 
i40e_vsi *vsi)
 
 err_rings:
i40e_vsi_free_q_vectors(vsi);
-   if (vsi->type == I40E_VSI_MAIN)
-   i40e_devlink_destroy_port(pf);
if (vsi->netdev_registered) {
vsi->netdev_registered = false;
unregister_netdev(vsi->netdev);
free_netdev(vsi->netdev);
vsi->netdev = NULL;
}
+   if (vsi->type == I40E_VSI_MAIN)
+   i40e_devlink_destroy_port(pf);
i40e_aq_delete_element(&pf->hw, vsi->seid, NULL);
 err_vsi:
i40e_vsi_clear(vsi);
-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH net-next 1/2] i40e: Do not call devlink_port_type_clear()

2023-10-24 Thread Jiri Pirko
Tue, Oct 24, 2023 at 02:51:08PM CEST, ivec...@redhat.com wrote:
>Do not call devlink_port_type_clear() prior devlink port unregister
>and let devlink core to take care about it.
>
>Reproducer:
>[root@host ~]# rmmod i40e
>[ 4539.964699] i40e :02:00.0: devlink port type for port 0 cleared without 
>a software interface reference, device type not supported by the kernel?
>[ 4540.319811] i40e :02:00.1: devlink port type for port 1 cleared without 
>a software interface reference, device type not supported by the kernel?
>
>Fixes: 9e479d64dc58 ("i40e: Add initial devlink support")
>Signed-off-by: Ivan Vecera 

Ivan, I see that even if we have checks and warnings, it is not enough :)

Reviewed-by: Jiri Pirko 

Btw, some (even brief) cover letter for patchset would be nice.
___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH net-next 2/2] i40e: Fix devlink port unregistering

2023-10-24 Thread Jiri Pirko
Tue, Oct 24, 2023 at 02:51:09PM CEST, ivec...@redhat.com wrote:
>Ensure that devlink port is unregistered after unregistering
>of net device.
>
>Reproducer:
>[root@host ~]# rmmod i40e
>[ 4742.939386] i40e :02:00.1: i40e_ptp_stop: removed PHC on enp2s0f1np1
>[ 4743.059269] [ cut here ]
>[ 4743.063900] WARNING: CPU: 21 PID: 10766 at net/devlink/port.c:1078 
>devl_port_unregister+0x69/0x80
>...
>
>Fixes: 9e479d64dc58 ("i40e: Add initial devlink support")
>Signed-off-by: Ivan Vecera 

Reviewed-by: Jiri Pirko 
___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH iwl-next 2/3] i40e: Add other helpers to check version of running firmware and AQ API

2023-10-24 Thread Ivan Vecera




On 24. 10. 23 12:24, Wojciech Drewek wrote:

On 23.10.2023 18:29, Ivan Vecera wrote:

Add another helper functions that will be used by subsequent
patch to refactor existing open-coded checks whether the version
of running firmware and AdminQ API is recent enough to provide
certain capabilities.

Signed-off-by: Ivan Vecera
---
  drivers/net/ethernet/intel/i40e/i40e_type.h | 54 +
  1 file changed, 54 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h 
b/drivers/net/ethernet/intel/i40e/i40e_type.h
index 050d479aeed3..bb62c14aa3d4 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_type.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_type.h
@@ -608,6 +608,60 @@ static inline bool i40e_is_aq_api_ver_ge(struct i40e_hw 
*hw, u16 maj, u16 min)
(hw->aq.api_maj_ver == maj && hw->aq.api_min_ver >= min));
  }
  
+/**

+ * i40e_is_aq_api_ver_lt
+ * @hw: pointer to i40e_hw structure
+ * @maj: API major value to compare
+ * @min: API minor value to compare
+ *
+ * Assert whether current HW API version is less than provided.
+ **/
+static inline bool i40e_is_aq_api_ver_lt(struct i40e_hw *hw, u16 maj, u16 min)
+{
+   return !i40e_is_aq_api_ver_ge(hw, maj, min);
+}

It feels a bit off to have those helpers in i40e_type.h.
We don't have i40e_common.h though so I'd move them to i40e_prototype.h or 
i40e.h.
Same comment regarding 1st patch (I know I gave it my tag but I spotted the 
issue
while reading the 2nd patch).


I'm sorry I already submitted v2 and helpers are present i40e_type.h.
I would submit v3 but there is also i40e_is_vf() inline function already 
present in i40e_type. Would you be OK with a follow-up that would move 
all these inlines into i40e_prototype.h?


Btw i40e.h is not a good idea as this would bring a dependency on i40e.h 
into i40e_adminq.c, i40e_common.c and i40e_dcb.c.


Regards,
Ivan

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH iwl-next 2/3] i40e: Add other helpers to check version of running firmware and AQ API

2023-10-24 Thread Wojciech Drewek


On 24.10.2023 15:01, Ivan Vecera wrote:
> 
> 
> On 24. 10. 23 12:24, Wojciech Drewek wrote:
>> On 23.10.2023 18:29, Ivan Vecera wrote:
>>> Add another helper functions that will be used by subsequent
>>> patch to refactor existing open-coded checks whether the version
>>> of running firmware and AdminQ API is recent enough to provide
>>> certain capabilities.
>>>
>>> Signed-off-by: Ivan Vecera
>>> ---
>>>   drivers/net/ethernet/intel/i40e/i40e_type.h | 54 +
>>>   1 file changed, 54 insertions(+)
>>>
>>> diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h 
>>> b/drivers/net/ethernet/intel/i40e/i40e_type.h
>>> index 050d479aeed3..bb62c14aa3d4 100644
>>> --- a/drivers/net/ethernet/intel/i40e/i40e_type.h
>>> +++ b/drivers/net/ethernet/intel/i40e/i40e_type.h
>>> @@ -608,6 +608,60 @@ static inline bool i40e_is_aq_api_ver_ge(struct 
>>> i40e_hw *hw, u16 maj, u16 min)
>>>   (hw->aq.api_maj_ver == maj && hw->aq.api_min_ver >= min));
>>>   }
>>>   +/**
>>> + * i40e_is_aq_api_ver_lt
>>> + * @hw: pointer to i40e_hw structure
>>> + * @maj: API major value to compare
>>> + * @min: API minor value to compare
>>> + *
>>> + * Assert whether current HW API version is less than provided.
>>> + **/
>>> +static inline bool i40e_is_aq_api_ver_lt(struct i40e_hw *hw, u16 maj, u16 
>>> min)
>>> +{
>>> +    return !i40e_is_aq_api_ver_ge(hw, maj, min);
>>> +}
>> It feels a bit off to have those helpers in i40e_type.h.
>> We don't have i40e_common.h though so I'd move them to i40e_prototype.h or 
>> i40e.h.
>> Same comment regarding 1st patch (I know I gave it my tag but I spotted the 
>> issue
>> while reading the 2nd patch).
> 
> I'm sorry I already submitted v2 and helpers are present i40e_type.h.
> I would submit v3 but there is also i40e_is_vf() inline function already 
> present in i40e_type. Would you be OK with a follow-up that would move all 
> these inlines into i40e_prototype.h?

Sounds good

> 
> Btw i40e.h is not a good idea as this would bring a dependency on i40e.h into 
> i40e_adminq.c, i40e_common.c and i40e_dcb.c.

Got it

> 
> Regards,
> Ivan
> 
> 
___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH iwl-next v1 00/15] one by one port representors creation

2023-10-24 Thread Michal Swiatkowski
On Tue, Oct 24, 2023 at 01:50:16PM +0200, Jiri Pirko wrote:
> Tue, Oct 24, 2023 at 01:09:14PM CEST, michal.swiatkow...@linux.intel.com 
> wrote:
> >Hi,
> >
> >Currently ice supports creating port representors only for VFs. For that
> >use case they can be created and removed in one step.
> >
> >This patchset is refactoring current flow to support port representor
> >creation also for subfunctions and SIOV. In this case port representors
> >need to be createad and removed one by one. Also, they can be added and
> >removed while other port representors are running.
> >
> >To achieve that we need to change the switchdev configuration flow.
> >Three first patches are only cosmetic (renaming, removing not used code).
> >Next few ones are preparation for new flow. The most important one
> >is "add VF representor one by one". It fully implements new flow.
> >
> >New type of port representor (for subfunction) will be introduced in
> >follow up patchset.
> 
> Examples please. Show new outputs of devlink commands.
> 
> Thanks!
>

If you mean outputs after refactor to one by one solution nothing
has changed:

# devlink port show (after creating 4 VFs in switchdev mode)
pci/:18:00.0/0: type eth netdev ens785f0np0 flavour physical port 0 
splittable true lanes 8
pci/:18:00.0/2: type eth netdev ens785f0np0_0 flavour pcivf controller 0 
pfnum 0 vfnum 0 external false splittable false
pci/:18:00.0/4: type eth netdev ens785f0np0_3 flavour pcivf controller 0 
pfnum 0 vfnum 3 external false splittable false
pci/:18:00.0/5: type eth netdev ens785f0np0_1 flavour pcivf controller 0 
pfnum 0 vfnum 1 external false splittable false
pci/:18:00.0/6: type eth netdev ens785f0np0_2 flavour pcivf controller 0 
pfnum 0 vfnum 2 external false splittable false

According subfunction, it will also be in cover latter for patchset that
is implementing subfunction.

Commands:
# devlink dev eswitch set pci/:18:00.0 mode switchdev
# devlink port add pci/:18:00.0 flavour pcisf pfnum 0 sfnum 1000
# devlink port function set pci/:18:00.0/3 state active

Outputs:
Don't have it saved, will send it here after rebasing subfunction of top
of this one.

Thanks,
Michal

> >
> >Michal Swiatkowski (15):
> >  ice: rename switchdev to eswitch
> >  ice: remove redundant max_vsi_num variable
> >  ice: remove unused control VSI parameter
> >  ice: track q_id in representor
> >  ice: use repr instead of vf->repr
> >  ice: track port representors in xarray
> >  ice: remove VF pointer reference in eswitch code
> >  ice: make representor code generic
> >  ice: return pointer to representor
> >  ice: allow changing SWITCHDEV_CTRL VSI queues
> >  ice: set Tx topology every time new repr is added
> >  ice: realloc VSI stats arrays
> >  ice: add VF representors one by one
> >  ice: adjust switchdev rebuild path
> >  ice: reserve number of CP queues
> >
> > drivers/net/ethernet/intel/ice/ice.h  |  13 +-
> > drivers/net/ethernet/intel/ice/ice_devlink.c  |  29 +
> > drivers/net/ethernet/intel/ice/ice_devlink.h  |   1 +
> > drivers/net/ethernet/intel/ice/ice_eswitch.c  | 562 ++
> > drivers/net/ethernet/intel/ice/ice_eswitch.h  |  22 +-
> > .../net/ethernet/intel/ice/ice_eswitch_br.c   |  22 +-
> > drivers/net/ethernet/intel/ice/ice_lib.c  |  81 ++-
> > drivers/net/ethernet/intel/ice/ice_main.c |   6 +-
> > drivers/net/ethernet/intel/ice/ice_repr.c | 195 +++---
> > drivers/net/ethernet/intel/ice/ice_repr.h |   9 +-
> > drivers/net/ethernet/intel/ice/ice_sriov.c|  20 +-
> > drivers/net/ethernet/intel/ice/ice_tc_lib.c   |   4 +-
> > drivers/net/ethernet/intel/ice/ice_vf_lib.c   |   9 +-
> > drivers/net/ethernet/intel/ice/ice_vf_lib.h   |   2 +-
> > 14 files changed, 553 insertions(+), 422 deletions(-)
> >
> >-- 
> >2.41.0
> >
> >
___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH iwl-next] ice: Reset VF on Tx MDD event

2023-10-24 Thread Michal Swiatkowski
On Tue, Oct 24, 2023 at 01:29:12PM +0200, Pawel Chmielewski wrote:
> From: Liang-min Wang 
> 
> In cases when VF sends malformed packets that are classified as malicious,
> sometimes it causes Tx queue to freeze. This frozen queue can be stuck
> for several minutes being unusable.
> 
> When MDD event occurs, perform graceful VF reset to quickly bring VF
> back to operational state.
> 
> Signed-off-by: Liang-min Wang 
> Signed-off-by: Pawel Chmielewski 
> Reviewed-by: Michal Swiatkowski 
> ---
>  drivers/net/ethernet/intel/ice/ice_main.c | 14 --
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c 
> b/drivers/net/ethernet/intel/ice/ice_main.c
> index 66095e9b094e..cf9fd1f168f7 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c
> @@ -1836,8 +1836,13 @@ static void ice_handle_mdd_event(struct ice_pf *pf)
>   vf->mdd_tx_events.count++;
>   set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state);
>   if (netif_msg_tx_err(pf))
> - dev_info(dev, "Malicious Driver Detection event 
> TX_TCLAN detected on VF %d\n",
> + dev_info(dev,
> +  "Malicious Driver Detection event 
> TX_TCLAN detected on VF %d\n",
>vf->vf_id);
> + dev_info(dev,
> +  "PF-to-VF reset on VF %d due to Tx MDD 
> TX_TCLAN event\n",
> +  vf->vf_id);
> + ice_reset_vf(vf, ICE_VF_RESET_NOTIFY);
>   }
>  
>   reg = rd32(hw, VP_MDET_TX_TDPU(vf->vf_id));
> @@ -1846,8 +1851,13 @@ static void ice_handle_mdd_event(struct ice_pf *pf)
>   vf->mdd_tx_events.count++;
>   set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state);
>   if (netif_msg_tx_err(pf))
> - dev_info(dev, "Malicious Driver Detection event 
> TX_TDPU detected on VF %d\n",
> + dev_info(dev,
> +  "Malicious Driver Detection event 
> TX_TDPU detected on VF %d\n",
>vf->vf_id);
> + dev_info(dev,
> +  "PF-to-VF reset on VF %d due to Tx MDD 
> TX_TCLAN event\n",
> +  vf->vf_id);
You forgot to change TX_TCLAN to TX_TDPU.

> + ice_reset_vf(vf, ICE_VF_RESET_NOTIFY);
>   }
>  
>   reg = rd32(hw, VP_MDET_RX(vf->vf_id));
> -- 
> 2.37.3
> 
___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH iwl-next v1 00/15] one by one port representors creation

2023-10-24 Thread Jiri Pirko
Tue, Oct 24, 2023 at 03:10:46PM CEST, michal.swiatkow...@linux.intel.com wrote:
>On Tue, Oct 24, 2023 at 01:50:16PM +0200, Jiri Pirko wrote:
>> Tue, Oct 24, 2023 at 01:09:14PM CEST, michal.swiatkow...@linux.intel.com 
>> wrote:
>> >Hi,
>> >
>> >Currently ice supports creating port representors only for VFs. For that
>> >use case they can be created and removed in one step.
>> >
>> >This patchset is refactoring current flow to support port representor
>> >creation also for subfunctions and SIOV. In this case port representors
>> >need to be createad and removed one by one. Also, they can be added and
>> >removed while other port representors are running.
>> >
>> >To achieve that we need to change the switchdev configuration flow.
>> >Three first patches are only cosmetic (renaming, removing not used code).
>> >Next few ones are preparation for new flow. The most important one
>> >is "add VF representor one by one". It fully implements new flow.
>> >
>> >New type of port representor (for subfunction) will be introduced in
>> >follow up patchset.
>> 
>> Examples please. Show new outputs of devlink commands.
>> 
>> Thanks!
>>
>
>If you mean outputs after refactor to one by one solution nothing
>has changed:
>
># devlink port show (after creating 4 VFs in switchdev mode)
>pci/:18:00.0/0: type eth netdev ens785f0np0 flavour physical port 0 
>splittable true lanes 8
>pci/:18:00.0/2: type eth netdev ens785f0np0_0 flavour pcivf controller 0 
>pfnum 0 vfnum 0 external false splittable false
>pci/:18:00.0/4: type eth netdev ens785f0np0_3 flavour pcivf controller 0 
>pfnum 0 vfnum 3 external false splittable false
>pci/:18:00.0/5: type eth netdev ens785f0np0_1 flavour pcivf controller 0 
>pfnum 0 vfnum 1 external false splittable false
>pci/:18:00.0/6: type eth netdev ens785f0np0_2 flavour pcivf controller 0 
>pfnum 0 vfnum 2 external false splittable false
>
>According subfunction, it will also be in cover latter for patchset that
>is implementing subfunction.
>
>Commands:
># devlink dev eswitch set pci/:18:00.0 mode switchdev
># devlink port add pci/:18:00.0 flavour pcisf pfnum 0 sfnum 1000
># devlink port function set pci/:18:00.0/3 state active
>
>Outputs:
>Don't have it saved, will send it here after rebasing subfunction of top
>of this one.

Ah, I was under impression it is part of this set. Sorry.


>
>Thanks,
>Michal
>
>> >
>> >Michal Swiatkowski (15):
>> >  ice: rename switchdev to eswitch
>> >  ice: remove redundant max_vsi_num variable
>> >  ice: remove unused control VSI parameter
>> >  ice: track q_id in representor
>> >  ice: use repr instead of vf->repr
>> >  ice: track port representors in xarray
>> >  ice: remove VF pointer reference in eswitch code
>> >  ice: make representor code generic
>> >  ice: return pointer to representor
>> >  ice: allow changing SWITCHDEV_CTRL VSI queues
>> >  ice: set Tx topology every time new repr is added
>> >  ice: realloc VSI stats arrays
>> >  ice: add VF representors one by one
>> >  ice: adjust switchdev rebuild path
>> >  ice: reserve number of CP queues
>> >
>> > drivers/net/ethernet/intel/ice/ice.h  |  13 +-
>> > drivers/net/ethernet/intel/ice/ice_devlink.c  |  29 +
>> > drivers/net/ethernet/intel/ice/ice_devlink.h  |   1 +
>> > drivers/net/ethernet/intel/ice/ice_eswitch.c  | 562 ++
>> > drivers/net/ethernet/intel/ice/ice_eswitch.h  |  22 +-
>> > .../net/ethernet/intel/ice/ice_eswitch_br.c   |  22 +-
>> > drivers/net/ethernet/intel/ice/ice_lib.c  |  81 ++-
>> > drivers/net/ethernet/intel/ice/ice_main.c |   6 +-
>> > drivers/net/ethernet/intel/ice/ice_repr.c | 195 +++---
>> > drivers/net/ethernet/intel/ice/ice_repr.h |   9 +-
>> > drivers/net/ethernet/intel/ice/ice_sriov.c|  20 +-
>> > drivers/net/ethernet/intel/ice/ice_tc_lib.c   |   4 +-
>> > drivers/net/ethernet/intel/ice/ice_vf_lib.c   |   9 +-
>> > drivers/net/ethernet/intel/ice/ice_vf_lib.h   |   2 +-
>> > 14 files changed, 553 insertions(+), 422 deletions(-)
>> >
>> >-- 
>> >2.41.0
>> >
>> >
___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH iwl-next v1] ice: change vfs.num_msix_per to vf->num_msix

2023-10-24 Thread Michal Swiatkowski
vfs::num_msix_per should be only used as default value for
vf->num_msix. For other use cases vf->num_msix should be used, as VF can
have different MSI-X amount values.

Fix incorrect register index calculation. vfs::num_msix_per and
pf->sriov_base_vector shouldn't be used after implementation of changing
MSI-X amount on VFs. Instead vf->first_vector_idx should be used, as it
is storing value for first irq index.

Fixes: fe1c5ca2fe76 ("ice: implement num_msix field per VF")
Reviewed-by: Jacob Keller 
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/ice/ice_sriov.c| 7 +--
 drivers/net/ethernet/intel/ice/ice_virtchnl.c | 5 ++---
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c 
b/drivers/net/ethernet/intel/ice/ice_sriov.c
index 2a5e6616cc0a..e1494f24f661 100644
--- a/drivers/net/ethernet/intel/ice/ice_sriov.c
+++ b/drivers/net/ethernet/intel/ice/ice_sriov.c
@@ -374,16 +374,11 @@ static void ice_ena_vf_mappings(struct ice_vf *vf)
  */
 int ice_calc_vf_reg_idx(struct ice_vf *vf, struct ice_q_vector *q_vector)
 {
-   struct ice_pf *pf;
-
if (!vf || !q_vector)
return -EINVAL;
 
-   pf = vf->pf;
-
/* always add one to account for the OICR being the first MSIX */
-   return pf->sriov_base_vector + pf->vfs.num_msix_per * vf->vf_id +
-   q_vector->v_idx + 1;
+   return vf->first_vector_idx + q_vector->v_idx + 1;
 }
 
 /**
diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl.c 
b/drivers/net/ethernet/intel/ice/ice_virtchnl.c
index cdf17b1e2f25..5261ba802c36 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl.c
@@ -1523,7 +1523,6 @@ static int ice_vc_cfg_irq_map_msg(struct ice_vf *vf, u8 
*msg)
u16 num_q_vectors_mapped, vsi_id, vector_id;
struct virtchnl_irq_map_info *irqmap_info;
struct virtchnl_vector_map *map;
-   struct ice_pf *pf = vf->pf;
struct ice_vsi *vsi;
int i;
 
@@ -1535,7 +1534,7 @@ static int ice_vc_cfg_irq_map_msg(struct ice_vf *vf, u8 
*msg)
 * there is actually at least a single VF queue vector mapped
 */
if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states) ||
-   pf->vfs.num_msix_per < num_q_vectors_mapped ||
+   vf->num_msix < num_q_vectors_mapped ||
!num_q_vectors_mapped) {
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
goto error_param;
@@ -1557,7 +1556,7 @@ static int ice_vc_cfg_irq_map_msg(struct ice_vf *vf, u8 
*msg)
/* vector_id is always 0-based for each VF, and can never be
 * larger than or equal to the max allowed interrupts per VF
 */
-   if (!(vector_id < pf->vfs.num_msix_per) ||
+   if (!(vector_id < vf->num_msix) ||
!ice_vc_isvalid_vsi_id(vf, vsi_id) ||
(!vector_id && (map->rxq_map || map->txq_map))) {
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
-- 
2.41.0

___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


Re: [Intel-wired-lan] [PATCH iwl-next] ice: Reset VF on Tx MDD event

2023-10-24 Thread Pawel Chmielewski
On Tue, Oct 24, 2023 at 03:12:54PM +0200, Michal Swiatkowski wrote:
> > if (netif_msg_tx_err(pf))
> > -   dev_info(dev, "Malicious Driver Detection event 
> > TX_TDPU detected on VF %d\n",
> > +   dev_info(dev,
> > +"Malicious Driver Detection event 
> > TX_TDPU detected on VF %d\n",
> >  vf->vf_id);
> > +   dev_info(dev,
> > +"PF-to-VF reset on VF %d due to Tx MDD 
> > TX_TCLAN event\n",
> > +vf->vf_id);
> You forgot to change TX_TCLAN to TX_TDPU.
 
Thank you for noticing, I've overlooked that. Will fix in v2
___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [PATCH iwl-next] ice: Fix VF Reset when interface in a failed over aggregate

2023-10-24 Thread Dave Ertman
There is an error interface has the following conditions:
- PF is in an aggregate (bond)
- PF has VFs created on it
- bond is in a state where it is failed-over to the secondary interface
- A VF reset is issued on one or more of those VFs

The issue is generated by the originating PF trying to tear down the VF
resources and recreate them for the reset.  Since the bond is failed over
to the secondary interface the queue contexts are in a modified state.

To fix this issue, have the originating interface reclaim its resources
prior to the tear-down and rebuild for the reset.  Then after the reset is
complete, move the resources back to the active interface.

Signed-off-by: Dave Ertman 
---
 drivers/net/ethernet/intel/ice/ice_lag.c|  2 +-
 drivers/net/ethernet/intel/ice/ice_lag.h|  1 +
 drivers/net/ethernet/intel/ice/ice_vf_lib.c | 47 +
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_lag.c 
b/drivers/net/ethernet/intel/ice/ice_lag.c
index b980f89dc892..9b915c0da06a 100644
--- a/drivers/net/ethernet/intel/ice/ice_lag.c
+++ b/drivers/net/ethernet/intel/ice/ice_lag.c
@@ -664,7 +664,7 @@ void ice_lag_move_new_vf_nodes(struct ice_vf *vf)
  * @oldport: lport of previous interface
  * @newport: lport of destination interface
  */
-static void ice_lag_move_vf_nodes(struct ice_lag *lag, u8 oldport, u8 newport)
+void ice_lag_move_vf_nodes(struct ice_lag *lag, u8 oldport, u8 newport)
 {
struct ice_pf *pf;
int i;
diff --git a/drivers/net/ethernet/intel/ice/ice_lag.h 
b/drivers/net/ethernet/intel/ice/ice_lag.h
index 9557e8605a07..b5e920c03ceb 100644
--- a/drivers/net/ethernet/intel/ice/ice_lag.h
+++ b/drivers/net/ethernet/intel/ice/ice_lag.h
@@ -65,4 +65,5 @@ int ice_init_lag(struct ice_pf *pf);
 void ice_deinit_lag(struct ice_pf *pf);
 void ice_lag_rebuild(struct ice_pf *pf);
 bool ice_lag_is_switchdev_running(struct ice_pf *pf);
+void ice_lag_move_vf_nodes(struct ice_lag *lag, u8 oldport, u8 newport);
 #endif /* _ICE_LAG_H_ */
diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c 
b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
index aca1f2ea5034..8d97acacc1b2 100644
--- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
@@ -828,13 +828,19 @@ static void ice_notify_vf_reset(struct ice_vf *vf)
  */
 int ice_reset_vf(struct ice_vf *vf, u32 flags)
 {
+   struct ice_lag_netdev_list ndlist;
struct ice_pf *pf = vf->pf;
+   struct list_head *tmp, *n;
+   struct ice_lag *lag;
struct ice_vsi *vsi;
struct device *dev;
+   u8 act_pt, pri_pt;
int err = 0;
bool rsd;
 
dev = ice_pf_to_dev(pf);
+   act_pt = ICE_LAG_INVALID_PORT;
+   pri_pt = pf->hw.port_info->lport;
 
if (flags & ICE_VF_RESET_NOTIFY)
ice_notify_vf_reset(vf);
@@ -845,6 +851,33 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)
return 0;
}
 
+   lag = pf->lag;
+   mutex_lock(&pf->lag_mutex);
+   if (lag && lag->bonded && lag->primary) {
+   act_pt = lag->active_port;
+   if (act_pt != pri_pt && act_pt != ICE_LAG_INVALID_PORT &&
+   lag->upper_netdev) {
+   struct ice_lag_netdev_list *nl;
+   struct net_device *tmp_nd;
+
+   INIT_LIST_HEAD(&ndlist.node);
+   rcu_read_lock();
+   for_each_netdev_in_bond_rcu(lag->upper_netdev, tmp_nd) {
+   nl = kzalloc(sizeof(*nl), GFP_KERNEL);
+   if (!nl)
+   break;
+
+   nl->netdev = tmp_nd;
+   list_add(&nl->node, &ndlist.node);
+   }
+   rcu_read_unlock();
+   lag->netdev_head = &ndlist.node;
+   ice_lag_move_vf_nodes(lag, act_pt, pri_pt);
+   } else {
+   act_pt = ICE_LAG_INVALID_PORT;
+   }
+   }
+
if (flags & ICE_VF_RESET_LOCK)
mutex_lock(&vf->cfg_lock);
else
@@ -937,6 +970,20 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)
if (flags & ICE_VF_RESET_LOCK)
mutex_unlock(&vf->cfg_lock);
 
+   if (lag && lag->bonded && lag->primary &&
+   act_pt != ICE_LAG_INVALID_PORT) {
+   ice_lag_move_vf_nodes(lag, pri_pt, act_pt);
+   list_for_each_safe(tmp, n, &ndlist.node) {
+   struct ice_lag_netdev_list *entry;
+
+   entry = list_entry(tmp, struct ice_lag_netdev_list, 
node);
+   list_del(&entry->node);
+   kfree(entry);
+   }
+   lag->netdev_head = NULL;
+   }
+   mutex_unlock(&pf->lag_mutex);
+
return err;
 }
 
-- 
2.40.1

__

Re: [Intel-wired-lan] [PATCH iwl-next 2/3] i40e: Add other helpers to check version of running firmware and AQ API

2023-10-24 Thread Jacob Keller



On 10/24/2023 6:01 AM, Ivan Vecera wrote:
> 
> 
> On 24. 10. 23 12:24, Wojciech Drewek wrote:
>> On 23.10.2023 18:29, Ivan Vecera wrote:
>>> Add another helper functions that will be used by subsequent
>>> patch to refactor existing open-coded checks whether the version
>>> of running firmware and AdminQ API is recent enough to provide
>>> certain capabilities.
>>>
>>> Signed-off-by: Ivan Vecera
>>> ---
>>>   drivers/net/ethernet/intel/i40e/i40e_type.h | 54 +
>>>   1 file changed, 54 insertions(+)
>>>
>>> diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h 
>>> b/drivers/net/ethernet/intel/i40e/i40e_type.h
>>> index 050d479aeed3..bb62c14aa3d4 100644
>>> --- a/drivers/net/ethernet/intel/i40e/i40e_type.h
>>> +++ b/drivers/net/ethernet/intel/i40e/i40e_type.h
>>> @@ -608,6 +608,60 @@ static inline bool i40e_is_aq_api_ver_ge(struct 
>>> i40e_hw *hw, u16 maj, u16 min)
>>> (hw->aq.api_maj_ver == maj && hw->aq.api_min_ver >= min));
>>>   }
>>>   
>>> +/**
>>> + * i40e_is_aq_api_ver_lt
>>> + * @hw: pointer to i40e_hw structure
>>> + * @maj: API major value to compare
>>> + * @min: API minor value to compare
>>> + *
>>> + * Assert whether current HW API version is less than provided.
>>> + **/
>>> +static inline bool i40e_is_aq_api_ver_lt(struct i40e_hw *hw, u16 maj, u16 
>>> min)
>>> +{
>>> +   return !i40e_is_aq_api_ver_ge(hw, maj, min);
>>> +}
>> It feels a bit off to have those helpers in i40e_type.h.
>> We don't have i40e_common.h though so I'd move them to i40e_prototype.h or 
>> i40e.h.
>> Same comment regarding 1st patch (I know I gave it my tag but I spotted the 
>> issue
>> while reading the 2nd patch).
> 
> I'm sorry I already submitted v2 and helpers are present i40e_type.h.
> I would submit v3 but there is also i40e_is_vf() inline function already 
> present in i40e_type. Would you be OK with a follow-up that would move 
> all these inlines into i40e_prototype.h?
> 
> Btw i40e.h is not a good idea as this would bring a dependency on i40e.h 
> into i40e_adminq.c, i40e_common.c and i40e_dcb.c.
> 

i40e_prototype.h seems reasonable to me. And yes, please don't use
i40e.h, as the driver design tries to separate the code related to
ice_hw from the rest of the driver at least to some extent. I don't
think that should be changed without care.

Thanks,
Jake
___
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan


[Intel-wired-lan] [tnguy-next-queue:100GbE_Live_Migration] BUILD SUCCESS 5b4255a57ac48844e6e38479f5f715a6ef6b799d

2023-10-24 Thread kernel test robot
tree/branch: 
https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue.git 
100GbE_Live_Migration
branch HEAD: 5b4255a57ac48844e6e38479f5f715a6ef6b799d  vfio/ice: Implement 
vfio_pci driver for E800 devices

elapsed time: 1476m

configs tested: 184
configs skipped: 2

The following configs have been built successfully.
More configs may be tested in the coming days.

tested configs:
alpha allnoconfig   gcc  
alphaallyesconfig   gcc  
alpha   defconfig   gcc  
arc  allmodconfig   gcc  
arc   allnoconfig   gcc  
arc  allyesconfig   gcc  
arc defconfig   gcc  
archsdk_defconfig   gcc  
arc   randconfig-001-20231024   gcc  
arc   randconfig-001-20231025   gcc  
arm  allmodconfig   gcc  
arm   allnoconfig   gcc  
arm  allyesconfig   gcc  
arm defconfig   gcc  
arm   randconfig-001-20231025   gcc  
arm   u8500_defconfig   gcc  
arm64allmodconfig   gcc  
arm64 allnoconfig   gcc  
arm64allyesconfig   gcc  
arm64   defconfig   gcc  
csky alldefconfig   gcc  
csky allmodconfig   gcc  
csky  allnoconfig   gcc  
csky allyesconfig   gcc  
cskydefconfig   gcc  
i386 allmodconfig   gcc  
i386  allnoconfig   gcc  
i386 allyesconfig   gcc  
i386 buildonly-randconfig-001-20231024   gcc  
i386 buildonly-randconfig-001-20231025   gcc  
i386 buildonly-randconfig-002-20231024   gcc  
i386 buildonly-randconfig-002-20231025   gcc  
i386 buildonly-randconfig-003-20231024   gcc  
i386 buildonly-randconfig-003-20231025   gcc  
i386 buildonly-randconfig-004-20231024   gcc  
i386 buildonly-randconfig-004-20231025   gcc  
i386 buildonly-randconfig-005-20231024   gcc  
i386 buildonly-randconfig-005-20231025   gcc  
i386 buildonly-randconfig-006-20231024   gcc  
i386 buildonly-randconfig-006-20231025   gcc  
i386  debian-10.3   gcc  
i386defconfig   gcc  
i386  randconfig-001-20231024   gcc  
i386  randconfig-001-20231025   gcc  
i386  randconfig-002-20231024   gcc  
i386  randconfig-002-20231025   gcc  
i386  randconfig-003-20231024   gcc  
i386  randconfig-003-20231025   gcc  
i386  randconfig-004-20231024   gcc  
i386  randconfig-004-20231025   gcc  
i386  randconfig-005-20231024   gcc  
i386  randconfig-005-20231025   gcc  
i386  randconfig-006-20231024   gcc  
i386  randconfig-006-20231025   gcc  
i386  randconfig-011-20231024   gcc  
i386  randconfig-011-20231025   gcc  
i386  randconfig-012-20231024   gcc  
i386  randconfig-012-20231025   gcc  
i386  randconfig-013-20231024   gcc  
i386  randconfig-013-20231025   gcc  
i386  randconfig-014-20231024   gcc  
i386  randconfig-014-20231025   gcc  
i386  randconfig-015-20231024   gcc  
i386  randconfig-015-20231025   gcc  
i386  randconfig-016-20231024   gcc  
i386  randconfig-016-20231025   gcc  
loongarchallmodconfig   gcc  
loongarch allnoconfig   gcc  
loongarchallyesconfig   gcc  
loongarch   defconfig   gcc  
loongarch randconfig-001-20231024   gcc  
loongarch randconfig-001-20231025   gcc  
m68k allmodconfig   gcc  
m68k  allnoconfig   gcc  
m68k allyesconfig   gcc  
m68kdefconfig   gcc  
microblaze   allmodconfig   gcc  
microblazeallnoconfig   gcc  
microblaze   allyesconfig   gcc  
microblaze  defconfig   gcc  
mips allmodconfig   gcc  
mips  allnoconfig   gcc  
mips allyesconfig   gcc  
mips cu1000-neo_defconfig   clang
nios2allmodconfig   gcc