Re: [Intel-wired-lan] [PATCH iwl-next v5 01/15] devlink: add value check to devlink_info_version_put()

2025-03-03 Thread Kalesh Anakkur Purayil
On Fri, Feb 21, 2025 at 5:37 PM Jedrzej Jagielski
 wrote:
>
> Prevent from proceeding if there's nothing to print.
>
> Suggested-by: Przemek Kitszel 
> Reviewed-by: Jiri Pirko 
> Signed-off-by: Jedrzej Jagielski 
Reviewed-by: Kalesh AP 


-- 
Regards,
Kalesh AP


smime.p7s
Description: S/MIME Cryptographic Signature


Re: [Intel-wired-lan] [iwl-net v2 5/5] ice: fix using untrusted value of pkt_len in ice_vc_fdir_parse_raw()

2025-03-03 Thread Szapar-Mudlaw, Martyna




On 2/28/2025 6:09 PM, Simon Horman wrote:

On Tue, Feb 25, 2025 at 10:08:49AM +0100, Martyna Szapar-Mudlaw wrote:

From: Mateusz Polchlopek 

Fix using the untrusted value of proto->raw.pkt_len in function
ice_vc_fdir_parse_raw() by verifying if it does not exceed the
VIRTCHNL_MAX_SIZE_RAW_PACKET value.

Fixes: 99f419df8a5c ("ice: enable FDIR filters from raw binary patterns for 
VFs")
Signed-off-by: Mateusz Polchlopek 
Signed-off-by: Martyna Szapar-Mudlaw 
---
  .../ethernet/intel/ice/ice_virtchnl_fdir.c| 25 +--
  1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c 
b/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c
index 14e3f0f89c78..6250629ee8f9 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c
@@ -835,18 +835,27 @@ ice_vc_fdir_parse_raw(struct ice_vf *vf,
u8 *pkt_buf, *msk_buf __free(kfree);
struct ice_parser_result rslt;
struct ice_pf *pf = vf->pf;
+   u16 pkt_len, udp_port = 0;
struct ice_parser *psr;
int status = -ENOMEM;
struct ice_hw *hw;
-   u16 udp_port = 0;
  
-	pkt_buf = kzalloc(proto->raw.pkt_len, GFP_KERNEL);

-   msk_buf = kzalloc(proto->raw.pkt_len, GFP_KERNEL);
+   if (!proto->raw.pkt_len)
+   return -EINVAL;
+
+   pkt_len = proto->raw.pkt_len;


Hi Martyna,

A check is made for !proto->raw.pkt_len above.
And a check is made for !pkt_len below.

This seems redundant.


Right, thank you for spotting it, will fix




+
+   if (!pkt_len || pkt_len > VIRTCHNL_MAX_SIZE_RAW_PACKET)
+   return -EINVAL;


...




Re: [Intel-wired-lan] [iwl-net v2 5/5] ice: fix using untrusted value of pkt_len in ice_vc_fdir_parse_raw()

2025-03-03 Thread Szapar-Mudlaw, Martyna




On 3/3/2025 11:00 AM, Przemek Kitszel wrote:

On 2/28/25 18:17, Simon Horman wrote:

On Tue, Feb 25, 2025 at 10:08:49AM +0100, Martyna Szapar-Mudlaw wrote:

From: Mateusz Polchlopek 

Fix using the untrusted value of proto->raw.pkt_len in function
ice_vc_fdir_parse_raw() by verifying if it does not exceed the
VIRTCHNL_MAX_SIZE_RAW_PACKET value.

Fixes: 99f419df8a5c ("ice: enable FDIR filters from raw binary 
patterns for VFs")

Signed-off-by: Mateusz Polchlopek 
Signed-off-by: Martyna Szapar-Mudlaw mud...@linux.intel.com>

---
  .../ethernet/intel/ice/ice_virtchnl_fdir.c    | 25 +--
  1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c b/ 
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c

index 14e3f0f89c78..6250629ee8f9 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c
@@ -835,18 +835,27 @@ ice_vc_fdir_parse_raw(struct ice_vf *vf,
  u8 *pkt_buf, *msk_buf __free(kfree);
  struct ice_parser_result rslt;
  struct ice_pf *pf = vf->pf;
+    u16 pkt_len, udp_port = 0;
  struct ice_parser *psr;
  int status = -ENOMEM;
  struct ice_hw *hw;
-    u16 udp_port = 0;
-    pkt_buf = kzalloc(proto->raw.pkt_len, GFP_KERNEL);
-    msk_buf = kzalloc(proto->raw.pkt_len, GFP_KERNEL);
+    if (!proto->raw.pkt_len)
+    return -EINVAL;


Hi Martyna,

It seems to me that the use of __free() above will result in
kfree(msk_buf) being called here. But msk_buf is not initialised at this
point.

My suggest would be to drop the use of __free().
But if not, I think that in order to be safe it would be best to do this
(completely untested;

u8 *pkt_buf, *msk_buf __free(kfree) = NULL;


Oh yeah!, thank you Simon for catching that.

I would say "naked __free()" was harmful here.



Thank you for suggestions, will send fixed v3



[Intel-wired-lan] [PATCH iwl-next v7 5/9] igc: Add support for frame preemption verification

2025-03-03 Thread Faizal Rahim
This patch implements the "ethtool --set-mm" callback to trigger the
frame preemption verification handshake.

Uses the MAC Merge Software Verification (mmsv) mechanism in ethtool
to perform the verification handshake for igc.
The structure fpe.mmsv is set by mmsv in ethtool and should remain
read-only for the driver.

Other mmsv callbacks:
a) configure_tx() -> not used yet at this point
   - igc lacks registers to configure FPE in the transmit direction, so
 this API is not utilized for now. A future patch will use it to
 control preemptible queue config.

b) configure_pmac() -> not used
   - this callback dynamically controls pmac_enabled at runtime. For
 example, mmsv calls configure_pmac() and disables pmac_enabled when
 the link partner goes down, even if the user previously enabled it.
 The intention is to save power but it is not feasible in igc
 because it causes an endless adapter reset loop:

   1) Board A and Board B complete the verification handshake. Tx mode
  register for both boards are in TSN mode.
   2) Board B link goes down.

   On Board A:
   3) mmsv calls configure_pmac() with pmac_enabled = false.
   4) configure_pmac() in igc updates a new field based on pmac_enabled.
  Driver uses this field in igc_tsn_new_flags() to indicate that the
  user enabled/disabled FPE.
   5) configure_pmac() in igc calls igc_tsn_offload_apply() to check
  whether an adapter reset is needed. Calls existing logic in
  igc_tsn_will_tx_mode_change() and igc_tsn_new_flags().
   6) Since pmac_enabled is now disabled and no other TSN feature is
  active, igc_tsn_will_tx_mode_change() evaluates to true because Tx
  mode will switch from TSN to Legacy.
   7) Driver resets the adapter.
   8) Registers are set, and Tx mode switches to Legacy.
   9) When link partner is up, steps 3–8 repeat, but this time with
  pmac_enabled = true, reactivating TSN.
  igc_tsn_will_tx_mode_change() evaluates to true again, since Tx
  mode will switch from Legacy to TSN.
  10) Driver resets the adapter.
  11) Rest adapter completes, registers are set, and Tx mode switches to
  TSN.

  On Board B:
  12) Adapter reset on Board A at step 10 causes it to detect its link
  partner as down.
  13) Repeats steps 3–8.
  14) Once reset adapter on Board A is completed at step 11, it detects
  its link partner as up.
  15) Repeats steps 9–11.

   - this cycle repeats indefinitely. To avoid this issue, igc only uses
 mmsv.pmac_enabled to track whether FPE is enabled or disabled.

Co-developed-by: Vinicius Costa Gomes 
Signed-off-by: Vinicius Costa Gomes 
Co-developed-by: Choong Yong Liang 
Signed-off-by: Choong Yong Liang 
Signed-off-by: Faizal Rahim 
---
 drivers/net/ethernet/intel/igc/igc.h |  12 +-
 drivers/net/ethernet/intel/igc/igc_base.h|   1 +
 drivers/net/ethernet/intel/igc/igc_defines.h |   8 +-
 drivers/net/ethernet/intel/igc/igc_ethtool.c |  21 +++
 drivers/net/ethernet/intel/igc/igc_main.c|  53 ++-
 drivers/net/ethernet/intel/igc/igc_tsn.c | 146 ++-
 drivers/net/ethernet/intel/igc/igc_tsn.h |  51 +++
 7 files changed, 287 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc.h 
b/drivers/net/ethernet/intel/igc/igc.h
index 22ecdac26cf4..d9ecb7cf80c9 100644
--- a/drivers/net/ethernet/intel/igc/igc.h
+++ b/drivers/net/ethernet/intel/igc/igc.h
@@ -40,6 +40,10 @@ void igc_ethtool_set_ops(struct net_device *);
 
 #define IGC_MAX_TX_TSTAMP_REGS 4
 
+struct igc_fpe_t {
+   struct ethtool_mmsv mmsv;
+};
+
 enum igc_mac_filter_type {
IGC_MAC_FILTER_TYPE_DST = 0,
IGC_MAC_FILTER_TYPE_SRC
@@ -332,6 +336,8 @@ struct igc_adapter {
struct timespec64 period;
} perout[IGC_N_PEROUT];
 
+   struct igc_fpe_t fpe;
+
/* LEDs */
struct mutex led_mutex;
struct igc_led_classdev *leds;
@@ -389,10 +395,11 @@ extern char igc_driver_name[];
 #define IGC_FLAG_TSN_QBV_ENABLED   BIT(17)
 #define IGC_FLAG_TSN_QAV_ENABLED   BIT(18)
 #define IGC_FLAG_TSN_LEGACY_ENABLEDBIT(19)
+#define IGC_FLAG_TSN_PREEMPT_ENABLED   BIT(20)
 
 #define IGC_FLAG_TSN_ANY_ENABLED   \
(IGC_FLAG_TSN_QBV_ENABLED | IGC_FLAG_TSN_QAV_ENABLED |  \
-IGC_FLAG_TSN_LEGACY_ENABLED)
+IGC_FLAG_TSN_LEGACY_ENABLED | IGC_FLAG_TSN_PREEMPT_ENABLED)
 
 #define IGC_FLAG_RSS_FIELD_IPV4_UDPBIT(6)
 #define IGC_FLAG_RSS_FIELD_IPV6_UDPBIT(7)
@@ -736,7 +743,10 @@ struct igc_nfc_rule *igc_get_nfc_rule(struct igc_adapter 
*adapter,
  u32 location);
 int igc_add_nfc_rule(struct igc_adapter *adapter, struct igc_nfc_rule *rule);
 void igc_del_nfc_rule(struct igc_adapter *adapter, struct igc_nfc_rule *rule);
+void igc_disable_empty_addr_recv(struct igc_adapter *adapter);
+int igc_enable_empty_addr_recv(struct igc_adapter *adapter);
 struct igc_ring *igc_get_tx_ring(struct igc_adapter *adap

[Intel-wired-lan] [PATCH] e1000: Adicionado const para melhorar a segurança do código

2025-03-03 Thread joaomboni
Signed-off-by: joaomboni 
---
 drivers/net/ethernet/intel/e1000/e1000_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c 
b/drivers/net/ethernet/intel/e1000/e1000_main.c
index 3f089c3d47b2..96bc85f09aaf 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -9,7 +9,7 @@
 #include 
 
 char e1000_driver_name[] = "e1000";
-static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
+static const char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
 static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel 
Corporation.";
 
 /* e1000_pci_tbl - PCI Device ID Table
-- 
2.48.1



[Intel-wired-lan] [PATCH iwl-next v3] igc: Change Tx mode for MQPRIO offloading

2025-03-03 Thread Kurt Kanzenbach
The current MQPRIO offload implementation uses the legacy TSN Tx mode. In
this mode the hardware uses four packet buffers and considers queue
priorities.

In order to harmonize the TAPRIO implementation with MQPRIO, switch to the
regular TSN Tx mode. This mode also uses four packet buffers and considers
queue priorities. In addition to the legacy mode, transmission is always
coupled to Qbv. The driver already has mechanisms to use a dummy schedule
of 1 second with all gates open for ETF. Simply use this for MQPRIO too.

This reduces code and makes it easier to add support for frame preemption
later.

While at it limit the netdev_tc calls to MQPRIO only.

Tested on i225 with real time application using high priority queue, iperf3
using low priority queue and network TAP device.

Signed-off-by: Kurt Kanzenbach 
---
Changes in v3:
- Commit message (Paul)
- Link to v2: 
https://lore.kernel.org/r/20250224-igc_mqprio_tx_mode-v2-1-9666da13c...@linutronix.de

Changes in v2:
- Add comma to commit message (Faizal)
- Simplify if condition (Faizal)
- Link to v1: 
https://lore.kernel.org/r/20250217-igc_mqprio_tx_mode-v1-1-3a402fe1f...@linutronix.de
---
 drivers/net/ethernet/intel/igc/igc.h  |  4 +---
 drivers/net/ethernet/intel/igc/igc_main.c | 18 +-
 drivers/net/ethernet/intel/igc/igc_tsn.c  | 40 ++-
 3 files changed, 20 insertions(+), 42 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc.h 
b/drivers/net/ethernet/intel/igc/igc.h
index 
cd1d7b6c1782352094f6867a31b6958c929bbbf4..16d85bdf55a7e9c412c47acf727bca6bc7154c61
 100644
--- a/drivers/net/ethernet/intel/igc/igc.h
+++ b/drivers/net/ethernet/intel/igc/igc.h
@@ -388,11 +388,9 @@ extern char igc_driver_name[];
 #define IGC_FLAG_RX_LEGACY BIT(16)
 #define IGC_FLAG_TSN_QBV_ENABLED   BIT(17)
 #define IGC_FLAG_TSN_QAV_ENABLED   BIT(18)
-#define IGC_FLAG_TSN_LEGACY_ENABLEDBIT(19)
 
 #define IGC_FLAG_TSN_ANY_ENABLED   \
-   (IGC_FLAG_TSN_QBV_ENABLED | IGC_FLAG_TSN_QAV_ENABLED |  \
-IGC_FLAG_TSN_LEGACY_ENABLED)
+   (IGC_FLAG_TSN_QBV_ENABLED | IGC_FLAG_TSN_QAV_ENABLED)
 
 #define IGC_FLAG_RSS_FIELD_IPV4_UDPBIT(6)
 #define IGC_FLAG_RSS_FIELD_IPV6_UDPBIT(7)
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c 
b/drivers/net/ethernet/intel/igc/igc_main.c
index 
472f009630c98e60c7166ceb8d05cb094f6c837b..240b6075197fb1e61077a736ddf8f9e67c1ed5cd
 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -6679,13 +6679,14 @@ static int igc_tsn_enable_mqprio(struct igc_adapter 
*adapter,
 struct tc_mqprio_qopt_offload *mqprio)
 {
struct igc_hw *hw = &adapter->hw;
-   int i;
+   int err, i;
 
if (hw->mac.type != igc_i225)
return -EOPNOTSUPP;
 
if (!mqprio->qopt.num_tc) {
adapter->strict_priority_enable = false;
+   netdev_reset_tc(adapter->netdev);
goto apply;
}
 
@@ -6716,6 +6717,21 @@ static int igc_tsn_enable_mqprio(struct igc_adapter 
*adapter,
igc_save_mqprio_params(adapter, mqprio->qopt.num_tc,
   mqprio->qopt.offset);
 
+   err = netdev_set_num_tc(adapter->netdev, adapter->num_tc);
+   if (err)
+   return err;
+
+   for (i = 0; i < adapter->num_tc; i++) {
+   err = netdev_set_tc_queue(adapter->netdev, i, 1,
+ adapter->queue_per_tc[i]);
+   if (err)
+   return err;
+   }
+
+   /* In case the card is configured with less than four queues. */
+   for (; i < IGC_MAX_TX_QUEUES; i++)
+   adapter->queue_per_tc[i] = i;
+
mqprio->qopt.hw = TC_MQPRIO_HW_OFFLOAD_TCS;
 
 apply:
diff --git a/drivers/net/ethernet/intel/igc/igc_tsn.c 
b/drivers/net/ethernet/intel/igc/igc_tsn.c
index 
1e44374ca1ffbb86e9893266c590f318984ef574..7c28f3e7bb576f0e6a21c883e934ede4d53096f4
 100644
--- a/drivers/net/ethernet/intel/igc/igc_tsn.c
+++ b/drivers/net/ethernet/intel/igc/igc_tsn.c
@@ -37,18 +37,13 @@ static unsigned int igc_tsn_new_flags(struct igc_adapter 
*adapter)
 {
unsigned int new_flags = adapter->flags & ~IGC_FLAG_TSN_ANY_ENABLED;
 
-   if (adapter->taprio_offload_enable)
-   new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
-
-   if (is_any_launchtime(adapter))
+   if (adapter->taprio_offload_enable || is_any_launchtime(adapter) ||
+   adapter->strict_priority_enable)
new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
 
if (is_cbs_enabled(adapter))
new_flags |= IGC_FLAG_TSN_QAV_ENABLED;
 
-   if (adapter->strict_priority_enable)
-   new_flags |= IGC_FLAG_TSN_LEGACY_ENABLED;
-
return new_flags;
 }
 
@@ -157,16 +152,12 @@ static int igc_tsn_disable_offload(struct igc_adapter 
*adapter)
wr32(IGC_QBVCYCLET_S, 0);
wr32(IGC_QBVCYC

[Intel-wired-lan] [PATCH iwl-next v7 2/9] igc: Rename xdp_get_tx_ring() for non-xdp usage

2025-03-03 Thread Faizal Rahim
Renamed xdp_get_tx_ring() function to a more generic name for use in
upcoming frame preemption patches.

Signed-off-by: Faizal Rahim 
---
 drivers/net/ethernet/intel/igc/igc.h  | 2 +-
 drivers/net/ethernet/intel/igc/igc_main.c | 9 -
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc.h 
b/drivers/net/ethernet/intel/igc/igc.h
index b8111ad9a9a8..22ecdac26cf4 100644
--- a/drivers/net/ethernet/intel/igc/igc.h
+++ b/drivers/net/ethernet/intel/igc/igc.h
@@ -736,7 +736,7 @@ struct igc_nfc_rule *igc_get_nfc_rule(struct igc_adapter 
*adapter,
  u32 location);
 int igc_add_nfc_rule(struct igc_adapter *adapter, struct igc_nfc_rule *rule);
 void igc_del_nfc_rule(struct igc_adapter *adapter, struct igc_nfc_rule *rule);
-
+struct igc_ring *igc_get_tx_ring(struct igc_adapter *adapter, int cpu);
 void igc_ptp_init(struct igc_adapter *adapter);
 void igc_ptp_reset(struct igc_adapter *adapter);
 void igc_ptp_suspend(struct igc_adapter *adapter);
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c 
b/drivers/net/ethernet/intel/igc/igc_main.c
index 56a35d58e7a6..db4a36afcec6 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -2444,8 +2444,7 @@ static int igc_xdp_init_tx_descriptor(struct igc_ring 
*ring,
return -ENOMEM;
 }
 
-static struct igc_ring *igc_xdp_get_tx_ring(struct igc_adapter *adapter,
-   int cpu)
+struct igc_ring *igc_get_tx_ring(struct igc_adapter *adapter, int cpu)
 {
int index = cpu;
 
@@ -2469,7 +2468,7 @@ static int igc_xdp_xmit_back(struct igc_adapter *adapter, 
struct xdp_buff *xdp)
if (unlikely(!xdpf))
return -EFAULT;
 
-   ring = igc_xdp_get_tx_ring(adapter, cpu);
+   ring = igc_get_tx_ring(adapter, cpu);
nq = txring_txq(ring);
 
__netif_tx_lock(nq, cpu);
@@ -2546,7 +2545,7 @@ static void igc_finalize_xdp(struct igc_adapter *adapter, 
int status)
struct igc_ring *ring;
 
if (status & IGC_XDP_TX) {
-   ring = igc_xdp_get_tx_ring(adapter, cpu);
+   ring = igc_get_tx_ring(adapter, cpu);
nq = txring_txq(ring);
 
__netif_tx_lock(nq, cpu);
@@ -6699,7 +6698,7 @@ static int igc_xdp_xmit(struct net_device *dev, int 
num_frames,
if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
return -EINVAL;
 
-   ring = igc_xdp_get_tx_ring(adapter, cpu);
+   ring = igc_get_tx_ring(adapter, cpu);
nq = txring_txq(ring);
 
__netif_tx_lock(nq, cpu);
-- 
2.34.1



Re: [Intel-wired-lan] [PATCH iwl-next v5 07/15] ixgbe: read the netlist version information

2025-03-03 Thread R, Bharath
> -Original Message-
> From: Intel-wired-lan  On Behalf Of
> Jedrzej Jagielski
> Sent: Friday, February 21, 2025 5:21 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: Nguyen, Anthony L ;
> net...@vger.kernel.org; ho...@kernel.org; j...@nvidia.com; Mrozowicz,
> SlawomirX ; Polchlopek, Mateusz
> ; Kwapulinski, Piotr
> ; Jagielski, Jedrzej 
> 
> Subject: [Intel-wired-lan] [PATCH iwl-next v5 07/15] ixgbe: read the netlist
> version information
> 
> From: Slawomir Mrozowicz 
> 
> Add functions reading the netlist version info and use them as a part of the
> setting NVM info procedure.
> 
> Reviewed-by: Mateusz Polchlopek 
> Signed-off-by: Slawomir Mrozowicz 
> Co-developed-by: Piotr Kwapulinski 
> Signed-off-by: Piotr Kwapulinski 
> Signed-off-by: Jedrzej Jagielski 
> ---
>  drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c | 112 ++
>  .../ethernet/intel/ixgbe/ixgbe_type_e610.h|  33 ++
>  2 files changed, 145 insertions(+)
> 

Tested-by: Bharath R 


Re: [Intel-wired-lan] [PATCH iwl-next v3] igc: Change Tx mode for MQPRIO offloading

2025-03-03 Thread Abdul Rahim, Faizal




On 3/3/2025 5:16 pm, Kurt Kanzenbach wrote:

The current MQPRIO offload implementation uses the legacy TSN Tx mode. In
this mode the hardware uses four packet buffers and considers queue
priorities.

In order to harmonize the TAPRIO implementation with MQPRIO, switch to the
regular TSN Tx mode. This mode also uses four packet buffers and considers
queue priorities. In addition to the legacy mode, transmission is always
coupled to Qbv. The driver already has mechanisms to use a dummy schedule
of 1 second with all gates open for ETF. Simply use this for MQPRIO too.

This reduces code and makes it easier to add support for frame preemption
later.

While at it limit the netdev_tc calls to MQPRIO only.

Tested on i225 with real time application using high priority queue, iperf3
using low priority queue and network TAP device.

Signed-off-by: Kurt Kanzenbach 
---
Changes in v3:
- Commit message (Paul)
- Link to v2: 
https://lore.kernel.org/r/20250224-igc_mqprio_tx_mode-v2-1-9666da13c...@linutronix.de

Changes in v2:
- Add comma to commit message (Faizal)
- Simplify if condition (Faizal)
- Link to v1: 
https://lore.kernel.org/r/20250217-igc_mqprio_tx_mode-v1-1-3a402fe1f...@linutronix.de
---
  drivers/net/ethernet/intel/igc/igc.h  |  4 +---
  drivers/net/ethernet/intel/igc/igc_main.c | 18 +-
  drivers/net/ethernet/intel/igc/igc_tsn.c  | 40 ++-
  3 files changed, 20 insertions(+), 42 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc.h 
b/drivers/net/ethernet/intel/igc/igc.h
index 
cd1d7b6c1782352094f6867a31b6958c929bbbf4..16d85bdf55a7e9c412c47acf727bca6bc7154c61
 100644
--- a/drivers/net/ethernet/intel/igc/igc.h
+++ b/drivers/net/ethernet/intel/igc/igc.h
@@ -388,11 +388,9 @@ extern char igc_driver_name[];
  #define IGC_FLAG_RX_LEGACYBIT(16)
  #define IGC_FLAG_TSN_QBV_ENABLED  BIT(17)
  #define IGC_FLAG_TSN_QAV_ENABLED  BIT(18)
-#define IGC_FLAG_TSN_LEGACY_ENABLEDBIT(19)
  
  #define IGC_FLAG_TSN_ANY_ENABLED\

-   (IGC_FLAG_TSN_QBV_ENABLED | IGC_FLAG_TSN_QAV_ENABLED |  \
-IGC_FLAG_TSN_LEGACY_ENABLED)
+   (IGC_FLAG_TSN_QBV_ENABLED | IGC_FLAG_TSN_QAV_ENABLED)
  
  #define IGC_FLAG_RSS_FIELD_IPV4_UDP	BIT(6)

  #define IGC_FLAG_RSS_FIELD_IPV6_UDP   BIT(7)
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c 
b/drivers/net/ethernet/intel/igc/igc_main.c
index 
472f009630c98e60c7166ceb8d05cb094f6c837b..240b6075197fb1e61077a736ddf8f9e67c1ed5cd
 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -6679,13 +6679,14 @@ static int igc_tsn_enable_mqprio(struct igc_adapter 
*adapter,
 struct tc_mqprio_qopt_offload *mqprio)
  {
struct igc_hw *hw = &adapter->hw;
-   int i;
+   int err, i;
  
  	if (hw->mac.type != igc_i225)

return -EOPNOTSUPP;
  
  	if (!mqprio->qopt.num_tc) {

adapter->strict_priority_enable = false;
+   netdev_reset_tc(adapter->netdev);
goto apply;
}
  
@@ -6716,6 +6717,21 @@ static int igc_tsn_enable_mqprio(struct igc_adapter *adapter,

igc_save_mqprio_params(adapter, mqprio->qopt.num_tc,
   mqprio->qopt.offset);
  
+	err = netdev_set_num_tc(adapter->netdev, adapter->num_tc);

+   if (err)
+   return err;
+
+   for (i = 0; i < adapter->num_tc; i++) {
+   err = netdev_set_tc_queue(adapter->netdev, i, 1,
+ adapter->queue_per_tc[i]);
+   if (err)
+   return err;
+   }
+
+   /* In case the card is configured with less than four queues. */
+   for (; i < IGC_MAX_TX_QUEUES; i++)
+   adapter->queue_per_tc[i] = i;
+
mqprio->qopt.hw = TC_MQPRIO_HW_OFFLOAD_TCS;
  
  apply:

diff --git a/drivers/net/ethernet/intel/igc/igc_tsn.c 
b/drivers/net/ethernet/intel/igc/igc_tsn.c
index 
1e44374ca1ffbb86e9893266c590f318984ef574..7c28f3e7bb576f0e6a21c883e934ede4d53096f4
 100644
--- a/drivers/net/ethernet/intel/igc/igc_tsn.c
+++ b/drivers/net/ethernet/intel/igc/igc_tsn.c
@@ -37,18 +37,13 @@ static unsigned int igc_tsn_new_flags(struct igc_adapter 
*adapter)
  {
unsigned int new_flags = adapter->flags & ~IGC_FLAG_TSN_ANY_ENABLED;
  
-	if (adapter->taprio_offload_enable)

-   new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
-
-   if (is_any_launchtime(adapter))
+   if (adapter->taprio_offload_enable || is_any_launchtime(adapter) ||
+   adapter->strict_priority_enable)
new_flags |= IGC_FLAG_TSN_QBV_ENABLED;
  
  	if (is_cbs_enabled(adapter))

new_flags |= IGC_FLAG_TSN_QAV_ENABLED;
  
-	if (adapter->strict_priority_enable)

-   new_flags |= IGC_FLAG_TSN_LEGACY_ENABLED;
-
return new_flags;
  }
  
@@ -157,16 +152,12 @@ static int igc_tsn_disable_offload(struct igc_adapter *adapter)

wr32(IGC_QBVCYCLET_S, 0);
   

Re: [Intel-wired-lan] [PATCH iwl-next v5 03/15] ixgbe: add initial devlink support

2025-03-03 Thread R, Bharath
> -Original Message-
> From: Intel-wired-lan  On Behalf Of
> Jedrzej Jagielski
> Sent: Friday, February 21, 2025 5:21 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: Nguyen, Anthony L ;
> net...@vger.kernel.org; ho...@kernel.org; j...@nvidia.com; Jagielski, Jedrzej
> ; Polchlopek, Mateusz
> ; Kitszel, Przemyslaw
> 
> Subject: [Intel-wired-lan] [PATCH iwl-next v5 03/15] ixgbe: add initial 
> devlink
> support
> 
> Add an initial support for devlink interface to ixgbe driver.
> 
> Similarly to i40e driver the implementation doesn't enable devlink to manage
> device-wide configuration. Devlink instance is created for each physical
> function of PCIe device.
> 
> Create separate directory for devlink related ixgbe files and use naming 
> scheme
> similar to the one used in the ice driver.
> 
> Add a stub for Documentation, to be extended by further patches.
> 
> Change struct ixgbe_adapter allocation to be done by devlink (Przemek), as
> suggested by Jiri.
> 
> Reviewed-by: Mateusz Polchlopek 
> Co-developed-by: Przemek Kitszel 
> Signed-off-by: Przemek Kitszel 
> Signed-off-by: Jedrzej Jagielski 
> ---
> v2: fix error patch in probe; minor tweaks
> v4: alloc ixgbe_adapter by devlink
> ---
>  Documentation/networking/devlink/index.rst|  1 +
>  Documentation/networking/devlink/ixgbe.rst|  8 ++
>  drivers/net/ethernet/intel/Kconfig|  1 +
>  drivers/net/ethernet/intel/ixgbe/Makefile |  3 +-
>  .../ethernet/intel/ixgbe/devlink/devlink.c| 77 +++
>  .../ethernet/intel/ixgbe/devlink/devlink.h| 10 +++
>  drivers/net/ethernet/intel/ixgbe/ixgbe.h  | 12 ++-
>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 30 +++-
>  8 files changed, 138 insertions(+), 4 deletions(-)  create mode 100644
> 

Tested-by: Bharath R 



Re: [Intel-wired-lan] [PATCH iwl-next v5 11/15] ixgbe: add device flash update via devlink

2025-03-03 Thread R, Bharath
> -Original Message-
> From: Intel-wired-lan  On Behalf Of
> Jedrzej Jagielski
> Sent: Friday, February 21, 2025 5:21 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: Nguyen, Anthony L ;
> net...@vger.kernel.org; ho...@kernel.org; j...@nvidia.com; Jagielski, Jedrzej
> ; Keller, Jacob E ;
> Mrozowicz, SlawomirX ; Kwapulinski, Piotr
> ; Wegrzyn, Stefan 
> Subject: [Intel-wired-lan] [PATCH iwl-next v5 11/15] ixgbe: add device flash
> update via devlink
> 
> Use the pldmfw library to implement device flash update for the Intel ixgbe
> networking device driver specifically for E610 devices.
> This support uses the devlink flash update interface.
> 
> Using the pldmfw library, the provided firmware file will be scanned for the
> three major components, "fw.undi" for the Option ROM, "fw.mgmt" for the
> main NVM module containing the primary device firmware, and "fw.netlist"
> containing the netlist module.
> 
> The flash is separated into two banks, the active bank containing the running
> firmware, and the inactive bank which we use for update. Each module is
> updated in a staged process. First, the inactive bank is erased, preparing the
> device for update. Second, the contents of the component are copied to the
> inactive portion of the flash. After all components are updated, the driver
> signals the device to switch the active bank during the next EMP reset.
> 
> With this implementation, basic flash update for the E610 hardware is
> supported.
> 
> Reviewed-by: Jacob Keller 
> Co-developed-by: Slawomir Mrozowicz 
> Signed-off-by: Slawomir Mrozowicz 
> Co-developed-by: Piotr Kwapulinski 
> Signed-off-by: Piotr Kwapulinski 
> Co-developed-by: Stefan Wegrzyn 
> Signed-off-by: Stefan Wegrzyn 
> Signed-off-by: Jedrzej Jagielski 
> ---
> v5: fix caps->nvm_unified_update assignment
> ---
>  Documentation/networking/devlink/ixgbe.rst|  24 +
>  drivers/net/ethernet/intel/Kconfig|   1 +
>  drivers/net/ethernet/intel/ixgbe/Makefile |   2 +-
>  .../ethernet/intel/ixgbe/devlink/devlink.c|   4 +
>  drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c | 210 ++
> drivers/net/ethernet/intel/ixgbe/ixgbe_e610.h |  11 +
>  .../ethernet/intel/ixgbe/ixgbe_fw_update.c| 668 ++
>  .../ethernet/intel/ixgbe/ixgbe_fw_update.h|  12 +
>  .../ethernet/intel/ixgbe/ixgbe_type_e610.h|  64 ++
>  9 files changed, 995 insertions(+), 1 deletion(-)  create mode 100644
> 

Tested-by: Bharath R 




Re: [Intel-wired-lan] [PATCH iwl-next v5 12/15] ixgbe: add support for devlink reload

2025-03-03 Thread R, Bharath
> -Original Message-
> From: Intel-wired-lan  On Behalf Of
> Jedrzej Jagielski
> Sent: Friday, February 21, 2025 5:21 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: Nguyen, Anthony L ;
> net...@vger.kernel.org; ho...@kernel.org; j...@nvidia.com; Jagielski, Jedrzej
> ; Polchlopek, Mateusz
> ; Mrozowicz, SlawomirX
> ; Kwapulinski, Piotr
> ; Wegrzyn, Stefan 
> Subject: [Intel-wired-lan] [PATCH iwl-next v5 12/15] ixgbe: add support for
> devlink reload
> 
> The E610 adapters contain an embedded chip with firmware which can be
> updated using devlink flash. The firmware which runs on this chip is referred
> to as the Embedded Management Processor firmware (EMP firmware).
> 
> Activating the new firmware image currently requires that the system be
> rebooted. This is not ideal as rebooting the system can cause unwanted
> downtime.
> 
> The EMP firmware itself can be reloaded by issuing a special update to the
> device called an Embedded Management Processor reset (EMP reset). This
> reset causes the device to reset and reload the EMP firmware.
> 
> Implement support for devlink reload with the "fw_activate" flag. This allows
> user space to request the firmware be activated immediately.
> 
> Reviewed-by: Mateusz Polchlopek 
> Co-developed-by: Slawomir Mrozowicz 
> Signed-off-by: Slawomir Mrozowicz 
> Co-developed-by: Piotr Kwapulinski 
> Signed-off-by: Piotr Kwapulinski 
> Co-developed-by: Stefan Wegrzyn 
> Signed-off-by: Stefan Wegrzyn 
> Signed-off-by: Jedrzej Jagielski 
> ---
>  Documentation/networking/devlink/ixgbe.rst|  15 +++
>  .../ethernet/intel/ixgbe/devlink/devlink.c| 112 ++
>  drivers/net/ethernet/intel/ixgbe/ixgbe.h  |   4 +
>  drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c |  18 +++
>  drivers/net/ethernet/intel/ixgbe/ixgbe_e610.h |   1 +
>  .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c  |  12 ++
>  .../ethernet/intel/ixgbe/ixgbe_fw_update.c|  37 +-
>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |   5 +-
>  8 files changed, 197 insertions(+), 7 deletions(-)
> 

Tested-by: Bharath R 


Re: [Intel-wired-lan] [PATCH iwl-next v1] ice: refactor the Tx scheduler feature

2025-03-03 Thread Simon Horman
On Wed, Feb 26, 2025 at 12:33:56PM +0100, Mateusz Polchlopek wrote:
> Embed ice_get_tx_topo_user_sel() inside the only caller:
> ice_devlink_tx_sched_layers_get().
> Instead of jump from the wrapper to the function that does "get" operation
> it does "get" itself.
> 
> Remove unnecessary comment and make usage of str_enabled_disabled()
> in ice_init_tx_topology().

Hi Mateusz,

These changes seem reasonable to me.
But I wonder if they could be motivated in the commit message.

What I mean is, the commit message explains what has been done.
But I think it should explain why it has been done.

> Suggested-by: Marcin Szycik 
> Reviewed-by: Michal Swiatkowski 
> Reviewed-by: Jedrzej Jagielski 
> Reviewed-by: Przemek Kitszel 
> Reviewed-by: Aleksandr Loktionov 
> Signed-off-by: Mateusz Polchlopek 

...


Re: [Intel-wired-lan] [iwl-net v2 5/5] ice: fix using untrusted value of pkt_len in ice_vc_fdir_parse_raw()

2025-03-03 Thread Przemek Kitszel

On 2/28/25 18:17, Simon Horman wrote:

On Tue, Feb 25, 2025 at 10:08:49AM +0100, Martyna Szapar-Mudlaw wrote:

From: Mateusz Polchlopek 

Fix using the untrusted value of proto->raw.pkt_len in function
ice_vc_fdir_parse_raw() by verifying if it does not exceed the
VIRTCHNL_MAX_SIZE_RAW_PACKET value.

Fixes: 99f419df8a5c ("ice: enable FDIR filters from raw binary patterns for 
VFs")
Signed-off-by: Mateusz Polchlopek 
Signed-off-by: Martyna Szapar-Mudlaw 
---
  .../ethernet/intel/ice/ice_virtchnl_fdir.c| 25 +--
  1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c 
b/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c
index 14e3f0f89c78..6250629ee8f9 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c
@@ -835,18 +835,27 @@ ice_vc_fdir_parse_raw(struct ice_vf *vf,
u8 *pkt_buf, *msk_buf __free(kfree);
struct ice_parser_result rslt;
struct ice_pf *pf = vf->pf;
+   u16 pkt_len, udp_port = 0;
struct ice_parser *psr;
int status = -ENOMEM;
struct ice_hw *hw;
-   u16 udp_port = 0;
  
-	pkt_buf = kzalloc(proto->raw.pkt_len, GFP_KERNEL);

-   msk_buf = kzalloc(proto->raw.pkt_len, GFP_KERNEL);
+   if (!proto->raw.pkt_len)
+   return -EINVAL;


Hi Martyna,

It seems to me that the use of __free() above will result in
kfree(msk_buf) being called here. But msk_buf is not initialised at this
point.

My suggest would be to drop the use of __free().
But if not, I think that in order to be safe it would be best to do this
(completely untested;

u8 *pkt_buf, *msk_buf __free(kfree) = NULL;


Oh yeah!, thank you Simon for catching that.

I would say "naked __free()" was harmful here.


[Intel-wired-lan] [PATCH iwl-next v7 0/9] igc: Add support for Frame Preemption feature in IGC

2025-03-03 Thread Faizal Rahim
Introduces support for the FPE feature in the IGC driver.

The patches aligns with the upstream FPE API:
https://patchwork.kernel.org/project/netdevbpf/cover/20230220122343.1156614-1-vladimir.olt...@nxp.com/
https://patchwork.kernel.org/project/netdevbpf/cover/20230119122705.73054-1-vladimir.olt...@nxp.com/

It builds upon earlier work:
https://patchwork.kernel.org/project/netdevbpf/cover/20220520011538.109-1-vinicius.go...@intel.com/

The patch series adds the following functionalities to the IGC driver:
a) Configure FPE using `ethtool --set-mm`.
b) Display FPE settings via `ethtool --show-mm`.
c) View FPE statistics using `ethtool --include-statistics --show-mm'.
e) Block setting preemptible tc in taprio since it is not supported yet.
   Existing code already blocks it in mqprio.

Tested:
Enabled CONFIG_PROVE_LOCKING, CONFIG_DEBUG_ATOMIC_SLEEP, CONFIG_DMA_API_DEBUG, 
and CONFIG_KASAN
1) selftests
2) netdev down/up cycles
3) suspend/resume cycles
4) fpe verification

No bugs or unusual dmesg logs were observed.
Ran 1), 2) and 3) with and without the patch series, compared dmesg and 
selftest logs — no differences found.

Change Log:
v6 -> v7:
- Squash the cpu param to the prev line (Przemek Kitszel)
- Use igc_ prefix for fpe_t (Przemek Kitszel)
- Move new ops to different line in igc_ethtool_ops (Przemek Kitszel)
- Documentation for igc_enable_empty_addr_recv (): rx -> Rx (Przemek Kitszel)
- Documentation for igc_enable_empty_addr_recv (): s/IGC/the driver/ (Przemek 
Kitszel)
- Change preferred style of init, from { }, to {} (Przemek Kitszel)
- Remove inclusion of umbrella header  in igc_tsn.c (Przemek 
Kitszel)
- End enum with "," in igc_txd_popts_type (Przemek Kitszel)
- Remove unnecessary braces in igc_fpe_is_verify_or_response() (Przemek Kitszel)

v5 -> v6:
- Added Tested-by: Furong Xu for patch 1/9 (Vladimir, Furong Xu)
- Updated logic in ethtool_mmsv_link_state_handle() (Vladimir, Furong Xu)
- Swap sequence of function call in stmmac_set_mm() (Furong Xu)
- Log an error if igc_enable_empty_addr_recv() fails (Vladimir)
- Move the patch ".. Block setting preemptible traffic .." before ".. Add 
support to get MAC Merge data .." (Vladimir)
- Move mmsv function kernel-doc from .h to .c file (Vladimir)

v4 -> v5:
- Remove "igc: Add support for preemptible traffic class in taprio" patch 
(Vladimir)
- Add a new patch "igc: Block setting preemptible traffic classes in taprio" 
(Vladimir)
- Add kernel-doc for mmsv api (Vladimir)
- olininfo_status to use host byte order (Simon)
- status_error should host byte type (Simon)
- Some code was misplaced in the wrong patch (Vladimir)
- Mix of tabs and spaces in patch description (Vladimir)
- Created igc_is_pmac_enabled() to reduce code repetition (Vladimir)

v3 -> v4:
- Fix compilation warnings introduced by this patch series

v2 -> v3:
- Implement configure_tx() mmsv callback (Vladimir)
- Use static_branch_inc() and static_branch_dec() (Vladimir)
- Add adapter->fpe.mmsv.pmac_enabled as extra check (Vladimir)
- Remove unnecessary error check in igc_fpe_init_tx_descriptor() (Vladimir)
- Additional places to use FIELD_PREP() instead of manual bit manipulation 
(Vladimir)
- IGC_TXD_POPTS_SMD_V and IGC_TXD_POPTS_SMD_R type change to enum (Vladimir)
- Remove unnecessary netif_running() check in igc_fpe_xmit_frame (Vladimir)
- Rate limit print in igc_fpe_send_mpacket (Vladimir)

v1 -> v2:
- Extract the stmmac verification logic into a common library (Vladimir)
- igc to use common library for verification (Vladimir)
- Fix syntax for kernel-doc to use "Return:" (Vladimir)
- Use FIELD_GET instead of manual bit masking (Vladimir)
- Don't assign 0 to statistics counter in igc_ethtool_get_mm_stats() (Vladimir)
- Use pmac-enabled as a condition to allow MAC address value 0 (Vladimir)
- Define macro register value in increasing value order (Vladimir)
- Fix tx-min-frag-size handling for igc (Vladimir)
- Handle link state changes with verification in igc (Vladimir)
- Add static key for fast path code (Vladimir)
- rx_min_frag_size get from constant (Vladimir)

v1: 
https://patchwork.kernel.org/project/netdevbpf/cover/20241216064720.931522-1-faizal.abdul.ra...@linux.intel.com/
v2: 
https://patchwork.kernel.org/project/netdevbpf/cover/20250205100524.1138523-1-faizal.abdul.ra...@linux.intel.com/
v3: 
https://patchwork.kernel.org/project/netdevbpf/cover/20250207165649.2245320-1-faizal.abdul.ra...@linux.intel.com/
v4: 
https://patchwork.kernel.org/project/netdevbpf/cover/20250210070207.2615418-1-faizal.abdul.ra...@linux.intel.com/
v5: 
https://patchwork.kernel.org/project/netdevbpf/cover/20250220025349.3007793-1-faizal.abdul.ra...@linux.intel.com/
v6: 
https://patchwork.kernel.org/project/netdevbpf/cover/20250227140158.2129988-1-faizal.abdul.ra...@linux.intel.com/

Faizal Rahim (8):
  igc: Rename xdp_get_tx_ring() for non-xdp usage
  igc: Optimize the TX packet buffer utilization
  igc: Set the RX packet buffer size for TSN mode
  igc: Add support for frame preemption verification
  ig

[Intel-wired-lan] [PATCH iwl-next v7 3/9] igc: Optimize the TX packet buffer utilization

2025-03-03 Thread Faizal Rahim
Packet buffers (RX + TX) total 64KB. Neither RX or TX buffers can be
larger than 34KB. So divide the buffer equally, 32KB for each.

Co-developed-by: Vinicius Costa Gomes 
Signed-off-by: Vinicius Costa Gomes 
Signed-off-by: Faizal Rahim 
---
 drivers/net/ethernet/intel/igc/igc_defines.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/igc/igc_defines.h 
b/drivers/net/ethernet/intel/igc/igc_defines.h
index 8e449904aa7d..516ef70c98e9 100644
--- a/drivers/net/ethernet/intel/igc/igc_defines.h
+++ b/drivers/net/ethernet/intel/igc/igc_defines.h
@@ -400,7 +400,8 @@
 #define I225_TXPBSIZE_DEFAULT  0x0414 /* TXPBSIZE default */
 #define IGC_RXPBS_CFG_TS_EN0x8000 /* Timestamp in Rx buffer */
 
-#define IGC_TXPBSIZE_TSN   0x04145145 /* 5k bytes buffer for each queue */
+ /* 7KB bytes buffer for each tx queue (total 4 queues) + 4KB for BMC*/
+#define IGC_TXPBSIZE_TSN   0x041c71c7
 
 #define IGC_DTXMXPKTSZ_TSN 0x19 /* 1600 bytes of max TX DMA packet size */
 #define IGC_DTXMXPKTSZ_DEFAULT 0x98 /* 9728-byte Jumbo frames */
-- 
2.34.1



[Intel-wired-lan] [PATCH iwl-next v7 6/9] igc: Add support to set tx-min-frag-size

2025-03-03 Thread Faizal Rahim
Add support to set tx-min-frag-size via set_mm callback in igc.
Increase the max limit of tx-ming-frag-size in ethtool from 252 to 256
since i225/6 value range is 64, 128, 192 and 256.

Co-developed-by: Vinicius Costa Gomes 
Signed-off-by: Vinicius Costa Gomes 
Signed-off-by: Faizal Rahim 
---
 drivers/net/ethernet/intel/igc/igc.h |  1 +
 drivers/net/ethernet/intel/igc/igc_defines.h |  1 +
 drivers/net/ethernet/intel/igc/igc_ethtool.c |  5 +++
 drivers/net/ethernet/intel/igc/igc_tsn.c | 37 ++--
 drivers/net/ethernet/intel/igc/igc_tsn.h |  2 +-
 net/ethtool/mm.c |  2 +-
 6 files changed, 43 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc.h 
b/drivers/net/ethernet/intel/igc/igc.h
index d9ecb7cf80c9..4dfd133b4d6f 100644
--- a/drivers/net/ethernet/intel/igc/igc.h
+++ b/drivers/net/ethernet/intel/igc/igc.h
@@ -42,6 +42,7 @@ void igc_ethtool_set_ops(struct net_device *);
 
 struct igc_fpe_t {
struct ethtool_mmsv mmsv;
+   u32 tx_min_frag_size;
 };
 
 enum igc_mac_filter_type {
diff --git a/drivers/net/ethernet/intel/igc/igc_defines.h 
b/drivers/net/ethernet/intel/igc/igc_defines.h
index 22db1de02964..038ee89f1e08 100644
--- a/drivers/net/ethernet/intel/igc/igc_defines.h
+++ b/drivers/net/ethernet/intel/igc/igc_defines.h
@@ -551,6 +551,7 @@
 #define IGC_TQAVCTRL_PREEMPT_ENA   0x0002
 #define IGC_TQAVCTRL_ENHANCED_QAV  0x0008
 #define IGC_TQAVCTRL_FUTSCDDIS 0x0080
+#define IGC_TQAVCTRL_MIN_FRAG_MASK 0xC000
 
 #define IGC_TXQCTL_QUEUE_MODE_LAUNCHT  0x0001
 #define IGC_TXQCTL_STRICT_CYCLE0x0002
diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c 
b/drivers/net/ethernet/intel/igc/igc_ethtool.c
index b64d5c6c1d20..529654ccd83f 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -1789,6 +1789,11 @@ static int igc_ethtool_set_mm(struct net_device *netdev,
struct igc_adapter *adapter = netdev_priv(netdev);
struct igc_fpe_t *fpe = &adapter->fpe;
 
+   fpe->tx_min_frag_size = 
igc_fpe_get_supported_frag_size(cmd->tx_min_frag_size);
+   if (fpe->tx_min_frag_size != cmd->tx_min_frag_size)
+   NL_SET_ERR_MSG_MOD(extack,
+  "tx-min-frag-size value set is unsupported. 
Rounded up to supported value (64, 128, 192, 256)");
+
if (fpe->mmsv.pmac_enabled != cmd->pmac_enabled) {
if (cmd->pmac_enabled)
static_branch_inc(&igc_fpe_enabled);
diff --git a/drivers/net/ethernet/intel/igc/igc_tsn.c 
b/drivers/net/ethernet/intel/igc/igc_tsn.c
index 0a2c747fde2d..2ec5909bf8b0 100644
--- a/drivers/net/ethernet/intel/igc/igc_tsn.c
+++ b/drivers/net/ethernet/intel/igc/igc_tsn.c
@@ -6,6 +6,12 @@
 #include "igc_hw.h"
 #include "igc_tsn.h"
 
+#define MIN_MULTPLIER_TX_MIN_FRAG  0
+#define MAX_MULTPLIER_TX_MIN_FRAG  3
+/* Frag size is based on the Section 8.12.2 of the SW User Manual */
+#define TX_MIN_FRAG_SIZE   64
+#define TX_MAX_FRAG_SIZE   (TX_MIN_FRAG_SIZE * (MAX_MULTPLIER_TX_MIN_FRAG 
+ 1))
+
 DEFINE_STATIC_KEY_FALSE(igc_fpe_enabled);
 
 static int igc_fpe_init_smd_frame(struct igc_ring *ring,
@@ -128,6 +134,7 @@ static const struct ethtool_mmsv_ops igc_mmsv_ops = {
 
 void igc_fpe_init(struct igc_adapter *adapter)
 {
+   adapter->fpe.tx_min_frag_size = TX_MIN_FRAG_SIZE;
ethtool_mmsv_init(&adapter->fpe.mmsv, adapter->netdev, &igc_mmsv_ops);
 }
 
@@ -278,7 +285,7 @@ static int igc_tsn_disable_offload(struct igc_adapter 
*adapter)
tqavctrl = rd32(IGC_TQAVCTRL);
tqavctrl &= ~(IGC_TQAVCTRL_TRANSMIT_MODE_TSN |
  IGC_TQAVCTRL_ENHANCED_QAV | IGC_TQAVCTRL_FUTSCDDIS |
- IGC_TQAVCTRL_PREEMPT_ENA);
+ IGC_TQAVCTRL_PREEMPT_ENA | IGC_TQAVCTRL_MIN_FRAG_MASK);
 
wr32(IGC_TQAVCTRL, tqavctrl);
 
@@ -324,12 +331,34 @@ static void igc_tsn_set_retx_qbvfullthreshold(struct 
igc_adapter *adapter)
wr32(IGC_RETX_CTL, retxctl);
 }
 
+static u8 igc_fpe_get_frag_size_mult(const struct igc_fpe_t *fpe)
+{
+   u8 mult = (fpe->tx_min_frag_size / TX_MIN_FRAG_SIZE) - 1;
+
+   return clamp_t(u8, mult, MIN_MULTPLIER_TX_MIN_FRAG,
+  MAX_MULTPLIER_TX_MIN_FRAG);
+}
+
+u32 igc_fpe_get_supported_frag_size(u32 frag_size)
+{
+   const u32 supported_sizes[] = {64, 128, 192, 256};
+
+   /* Find the smallest supported size that is >= frag_size */
+   for (int i = 0; i < ARRAY_SIZE(supported_sizes); i++) {
+   if (frag_size <= supported_sizes[i])
+   return supported_sizes[i];
+   }
+
+   return TX_MAX_FRAG_SIZE; /* Should not happen, value > 256 is blocked 
by ethtool */
+}
+
 static int igc_tsn_enable_offload(struct igc_adapter *adapter)
 {
struct igc_hw *hw = &adapter->hw;
u32 tqavctrl, baset_l, baset_h;
u32 sec, nsec, cy

[Intel-wired-lan] [PATCH iwl-next v7 8/9] igc: Add support to get MAC Merge data via ethtool

2025-03-03 Thread Faizal Rahim
Implement "ethtool --show-mm" callback for IGC.

Tested with command:
$ ethtool --show-mm enp1s0.
  MAC Merge layer state for enp1s0:
  pMAC enabled: on
  TX enabled: on
  TX active: on
  TX minimum fragment size: 64
  RX minimum fragment size: 60
  Verify enabled: on
  Verify time: 128
  Max verify time: 128
  Verification status: SUCCEEDED

Verified that the fields value are retrieved correctly.

Signed-off-by: Faizal Rahim 
---
 drivers/net/ethernet/intel/igc/igc_ethtool.c | 14 ++
 drivers/net/ethernet/intel/igc/igc_tsn.h |  1 +
 2 files changed, 15 insertions(+)

diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c 
b/drivers/net/ethernet/intel/igc/igc_ethtool.c
index 529654ccd83f..fd4b4b332309 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -1782,6 +1782,19 @@ static int igc_ethtool_set_eee(struct net_device *netdev,
return 0;
 }
 
+static int igc_ethtool_get_mm(struct net_device *netdev,
+ struct ethtool_mm_state *cmd)
+{
+   struct igc_adapter *adapter = netdev_priv(netdev);
+   struct igc_fpe_t *fpe = &adapter->fpe;
+
+   ethtool_mmsv_get_mm(&fpe->mmsv, cmd);
+   cmd->tx_min_frag_size = fpe->tx_min_frag_size;
+   cmd->rx_min_frag_size = IGC_RX_MIN_FRAG_SIZE;
+
+   return 0;
+}
+
 static int igc_ethtool_set_mm(struct net_device *netdev,
  struct ethtool_mm_cfg *cmd,
  struct netlink_ext_ack *extack)
@@ -2101,6 +2114,7 @@ static const struct ethtool_ops igc_ethtool_ops = {
.get_link_ksettings = igc_ethtool_get_link_ksettings,
.set_link_ksettings = igc_ethtool_set_link_ksettings,
.self_test  = igc_ethtool_diag_test,
+   .get_mm = igc_ethtool_get_mm,
.set_mm = igc_ethtool_set_mm,
 };
 
diff --git a/drivers/net/ethernet/intel/igc/igc_tsn.h 
b/drivers/net/ethernet/intel/igc/igc_tsn.h
index 6b48e0ed4341..a00dc1d80e12 100644
--- a/drivers/net/ethernet/intel/igc/igc_tsn.h
+++ b/drivers/net/ethernet/intel/igc/igc_tsn.h
@@ -4,6 +4,7 @@
 #ifndef _IGC_TSN_H_
 #define _IGC_TSN_H_
 
+#define IGC_RX_MIN_FRAG_SIZE   60
 #define SMD_FRAME_SIZE 60
 
 enum igc_txd_popts_type {
-- 
2.34.1



[Intel-wired-lan] [PATCH iwl-next v7 4/9] igc: Set the RX packet buffer size for TSN mode

2025-03-03 Thread Faizal Rahim
In preparation for supporting frame preemption, when entering TSN mode
set the receive packet buffer to 16KB for the Express MAC, 16KB for
the Preemptible MAC and 2KB for the BMC, according to the datasheet
section 7.1.3.2.

Co-developed-by: Vinicius Costa Gomes 
Signed-off-by: Vinicius Costa Gomes 
Signed-off-by: Faizal Rahim 
---
 drivers/net/ethernet/intel/igc/igc_defines.h |  3 +++
 drivers/net/ethernet/intel/igc/igc_tsn.c | 13 +++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc_defines.h 
b/drivers/net/ethernet/intel/igc/igc_defines.h
index 516ef70c98e9..b19ac6f30dac 100644
--- a/drivers/net/ethernet/intel/igc/igc_defines.h
+++ b/drivers/net/ethernet/intel/igc/igc_defines.h
@@ -402,6 +402,9 @@
 
  /* 7KB bytes buffer for each tx queue (total 4 queues) + 4KB for BMC*/
 #define IGC_TXPBSIZE_TSN   0x041c71c7
+/* 15KB for EXP + 15KB for BE + 2KB for BMC */
+#define IGC_RXPBSIZE_TSN   0xf08f
+#define IGC_RXPBSIZE_SIZE_MASK 0x0001
 
 #define IGC_DTXMXPKTSZ_TSN 0x19 /* 1600 bytes of max TX DMA packet size */
 #define IGC_DTXMXPKTSZ_DEFAULT 0x98 /* 9728-byte Jumbo frames */
diff --git a/drivers/net/ethernet/intel/igc/igc_tsn.c 
b/drivers/net/ethernet/intel/igc/igc_tsn.c
index 1e44374ca1ff..f0213cfce07d 100644
--- a/drivers/net/ethernet/intel/igc/igc_tsn.c
+++ b/drivers/net/ethernet/intel/igc/igc_tsn.c
@@ -132,13 +132,17 @@ static int igc_tsn_disable_offload(struct igc_adapter 
*adapter)
 {
u16 queue_per_tc[4] = { 3, 2, 1, 0 };
struct igc_hw *hw = &adapter->hw;
-   u32 tqavctrl;
+   u32 tqavctrl, rxpbs;
int i;
 
wr32(IGC_GTXOFFSET, 0);
wr32(IGC_TXPBS, I225_TXPBSIZE_DEFAULT);
wr32(IGC_DTXMXPKTSZ, IGC_DTXMXPKTSZ_DEFAULT);
 
+   rxpbs = rd32(IGC_RXPBS) & ~IGC_RXPBSIZE_SIZE_MASK;
+   rxpbs |= I225_RXPBSIZE_DEFAULT;
+   wr32(IGC_RXPBS, rxpbs);
+
if (igc_is_device_id_i226(hw))
igc_tsn_restore_retx_default(adapter);
 
@@ -194,7 +198,7 @@ static int igc_tsn_enable_offload(struct igc_adapter 
*adapter)
 {
struct igc_hw *hw = &adapter->hw;
u32 tqavctrl, baset_l, baset_h;
-   u32 sec, nsec, cycle;
+   u32 sec, nsec, cycle, rxpbs;
ktime_t base_time, systim;
int i;
 
@@ -202,6 +206,11 @@ static int igc_tsn_enable_offload(struct igc_adapter 
*adapter)
wr32(IGC_DTXMXPKTSZ, IGC_DTXMXPKTSZ_TSN);
wr32(IGC_TXPBS, IGC_TXPBSIZE_TSN);
 
+   rxpbs = rd32(IGC_RXPBS) & ~IGC_RXPBSIZE_SIZE_MASK;
+   rxpbs |= IGC_RXPBSIZE_TSN;
+
+   wr32(IGC_RXPBS, rxpbs);
+
if (igc_is_device_id_i226(hw))
igc_tsn_set_retx_qbvfullthreshold(adapter);
 
-- 
2.34.1



[Intel-wired-lan] [PATCH iwl-next v7 9/9] igc: Add support to get frame preemption statistics via ethtool

2025-03-03 Thread Faizal Rahim
Implemented "ethtool --include-statistics --show-mm" callback for IGC.

Tested preemption scenario to check preemption statistics:
1) Trigger verification handshake on both boards:
$ sudo ethtool --set-mm enp1s0 pmac-enabled on
$ sudo ethtool --set-mm enp1s0 tx-enabled on
$ sudo ethtool --set-mm enp1s0 verify-enabled on
2) Set preemptible or express queue in taprio for tx board:
$ sudo tc qdisc replace dev enp1s0 parent root handle 100 taprio \
  num_tc 4 map 3 2 1 0 3 3 3 3 3 3 3 3 3 3 3 3 \
  queues 1@0 1@1 1@2 1@3 base-time 0 sched-entry S F 10 \
  fp E E P P
3) Send large size packets on preemptible queue
4) Send small size packets on express queue to preempt packets in
   preemptible queue
5) Show preemption statistics on the receiving board:
   $ ethtool --include-statistics --show-mm enp1s0
 MAC Merge layer state for enp1s0:
 pMAC enabled: on
 TX enabled: on
 TX active: on
 TX minimum fragment size: 64
 RX minimum fragment size: 60
 Verify enabled: on
 Verify time: 128
 Max verify time: 128
 Verification status: SUCCEEDED
 Statistics:
  MACMergeFrameAssErrorCount: 0
  MACMergeFrameSmdErrorCount: 0
  MACMergeFrameAssOkCount: 511
  MACMergeFragCountRx: 764
  MACMergeFragCountTx: 0
  MACMergeHoldCount: 0

Co-developed-by: Vinicius Costa Gomes 
Signed-off-by: Vinicius Costa Gomes 
Signed-off-by: Faizal Rahim 
---
 drivers/net/ethernet/intel/igc/igc_ethtool.c | 36 
 drivers/net/ethernet/intel/igc/igc_regs.h| 16 +
 2 files changed, 52 insertions(+)

diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c 
b/drivers/net/ethernet/intel/igc/igc_ethtool.c
index fd4b4b332309..a5f7512a7806 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -1819,6 +1819,41 @@ static int igc_ethtool_set_mm(struct net_device *netdev,
return igc_tsn_offload_apply(adapter);
 }
 
+/**
+ * igc_ethtool_get_frame_ass_error - Get the frame assembly error count.
+ * @dev: Pointer to the net_device structure.
+ * Return: The count of frame assembly errors.
+ */
+static u64 igc_ethtool_get_frame_ass_error(struct net_device *dev)
+{
+   struct igc_adapter *adapter = netdev_priv(dev);
+   u32 ooo_smdc, ooo_frame_cnt, ooo_frag_cnt; /* Out of order statistics */
+   struct igc_hw *hw = &adapter->hw;
+   u32 miss_frame_frag_cnt;
+   u32 reg_value;
+
+   reg_value = rd32(IGC_PRMEXPRCNT);
+   ooo_smdc = FIELD_GET(IGC_PRMEXPRCNT_OOO_SMDC, reg_value);
+   ooo_frame_cnt = FIELD_GET(IGC_PRMEXPRCNT_OOO_FRAME_CNT, reg_value);
+   ooo_frag_cnt = FIELD_GET(IGC_PRMEXPRCNT_OOO_FRAG_CNT, reg_value);
+   miss_frame_frag_cnt = FIELD_GET(IGC_PRMEXPRCNT_MISS_FRAME_FRAG_CNT,
+   reg_value);
+
+   return ooo_smdc + ooo_frame_cnt + ooo_frag_cnt + miss_frame_frag_cnt;
+}
+
+static void igc_ethtool_get_mm_stats(struct net_device *dev,
+struct ethtool_mm_stats *stats)
+{
+   struct igc_adapter *adapter = netdev_priv(dev);
+   struct igc_hw *hw = &adapter->hw;
+
+   stats->MACMergeFrameAssErrorCount = 
igc_ethtool_get_frame_ass_error(dev);
+   stats->MACMergeFrameAssOkCount = rd32(IGC_PRMPTDRCNT);
+   stats->MACMergeFragCountRx =  rd32(IGC_PRMEVNTRCNT);
+   stats->MACMergeFragCountTx = rd32(IGC_PRMEVNTTCNT);
+}
+
 static int igc_ethtool_get_link_ksettings(struct net_device *netdev,
  struct ethtool_link_ksettings *cmd)
 {
@@ -2116,6 +2151,7 @@ static const struct ethtool_ops igc_ethtool_ops = {
.self_test  = igc_ethtool_diag_test,
.get_mm = igc_ethtool_get_mm,
.set_mm = igc_ethtool_set_mm,
+   .get_mm_stats   = igc_ethtool_get_mm_stats,
 };
 
 void igc_ethtool_set_ops(struct net_device *netdev)
diff --git a/drivers/net/ethernet/intel/igc/igc_regs.h 
b/drivers/net/ethernet/intel/igc/igc_regs.h
index 12ddc5793651..41dbfb07eb2f 100644
--- a/drivers/net/ethernet/intel/igc/igc_regs.h
+++ b/drivers/net/ethernet/intel/igc/igc_regs.h
@@ -222,6 +222,22 @@
 
 #define IGC_FTQF(_n)   (0x059E0 + (4 * (_n)))  /* 5-tuple Queue Fltr */
 
+/* Time sync registers - preemption statistics */
+#define IGC_PRMPTDRCNT 0x04284 /* Good RX Preempted Packets */
+#define IGC_PRMEVNTTCNT0x04298 /* TX Preemption event counter 
*/
+#define IGC_PRMEVNTRCNT0x0429C /* RX Preemption event counter 
*/
+
+ /* Preemption Exception Counter */
+#define IGC_PRMEXPRCNT 0x42A0
+/* Received out of order packets with SMD-C */
+#define IGC_PRMEXPRCNT_OOO_SMDC0x00FF
+/* Received out of order packets with SMD-C and wrong Frame CNT */
+#define IGC_PRMEXPRCNT_OOO_FRAME_CNT   0xFF00
+/* Received out of order packets with SMD-C and wrong F

[Intel-wired-lan] [PATCH iwl-next v7 7/9] igc: Block setting preemptible traffic class in taprio

2025-03-03 Thread Faizal Rahim
Since preemptible tc implementation is not ready yet, block it from being
set in taprio. The existing code already blocks it in mqprio.

Signed-off-by: Faizal Rahim 
---
 drivers/net/ethernet/intel/igc/igc_main.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/intel/igc/igc_main.c 
b/drivers/net/ethernet/intel/igc/igc_main.c
index fc086919387c..319eeb5b0a54 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -6407,6 +6407,10 @@ static int igc_save_qbv_schedule(struct igc_adapter 
*adapter,
if (!validate_schedule(adapter, qopt))
return -EINVAL;
 
+   /* preemptible isn't supported yet */
+   if (qopt->mqprio.preemptible_tcs)
+   return -EOPNOTSUPP;
+
igc_ptp_read(adapter, &now);
 
if (igc_tsn_is_taprio_activated_by_user(adapter) &&
-- 
2.34.1



[Intel-wired-lan] [PATCH iwl-next v7 1/9] net: ethtool: mm: extract stmmac verification logic into common library

2025-03-03 Thread Faizal Rahim
From: Vladimir Oltean 

It appears that stmmac is not the only hardware which requires a
software-driven verification state machine for the MAC Merge layer.

While on the one hand it's good to encourage hardware implementations,
on the other hand it's quite difficult to tolerate multiple drivers
implementing independently fairly non-trivial logic.

Extract the hardware-independent logic from stmmac into library code and
put it in ethtool. Name the state structure "mmsv" for MAC Merge
Software Verification. Let this expose an operations structure for
executing the hardware stuff: sync hardware with the tx_active boolean
(result of verification process), enable/disable the pMAC, send mPackets,
notify library of external events (reception of mPackets), as well as
link state changes.

Note that it is assumed that the external events are received in hardirq
context. If they are not, it is probably a good idea to disable hardirqs
when calling ethtool_mmsv_event_handle(), because the library does not
do so.

Also, the MM software verification process has no business with the
tx_min_frag_size, that is all the driver's to handle.

Signed-off-by: Vladimir Oltean 
Co-developed-by: Choong Yong Liang 
Signed-off-by: Choong Yong Liang 
Co-developed-by: Faizal Rahim 
Signed-off-by: Faizal Rahim 
Tested-by: Choong Yong Liang 
Tested-by: Furong Xu <0x1...@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac.h  |  16 +-
 .../ethernet/stmicro/stmmac/stmmac_ethtool.c  |  41 +--
 .../net/ethernet/stmicro/stmmac/stmmac_fpe.c  | 174 +++
 .../net/ethernet/stmicro/stmmac/stmmac_fpe.h  |   5 -
 .../net/ethernet/stmicro/stmmac/stmmac_main.c |   8 +-
 include/linux/ethtool.h   |  73 +
 net/ethtool/mm.c  | 279 +-
 7 files changed, 395 insertions(+), 201 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h 
b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index f05cae103d83..c9cc41af258a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -147,21 +147,9 @@ struct stmmac_channel {
 };
 
 struct stmmac_fpe_cfg {
-   /* Serialize access to MAC Merge state between ethtool requests
-* and link state updates.
-*/
-   spinlock_t lock;
-
+   struct ethtool_mmsv mmsv;
const struct stmmac_fpe_reg *reg;
-   u32 fpe_csr;/* MAC_FPE_CTRL_STS reg cache */
-
-   enum ethtool_mm_verify_status status;
-   struct timer_list verify_timer;
-   bool verify_enabled;
-   int verify_retries;
-   bool pmac_enabled;
-   u32 verify_time;
-   bool tx_enabled;
+   u32 fpe_csr;/* MAC_FPE_CTRL_STS reg cache */
 };
 
 struct stmmac_tc_entry {
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
index 918a32f8fda8..25533d6a3175 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -1210,37 +1210,17 @@ static int stmmac_get_mm(struct net_device *ndev,
 struct ethtool_mm_state *state)
 {
struct stmmac_priv *priv = netdev_priv(ndev);
-   unsigned long flags;
u32 frag_size;
 
if (!stmmac_fpe_supported(priv))
return -EOPNOTSUPP;
 
-   spin_lock_irqsave(&priv->fpe_cfg.lock, flags);
+   ethtool_mmsv_get_mm(&priv->fpe_cfg.mmsv, state);
 
-   state->max_verify_time = STMMAC_FPE_MM_MAX_VERIFY_TIME_MS;
-   state->verify_enabled = priv->fpe_cfg.verify_enabled;
-   state->pmac_enabled = priv->fpe_cfg.pmac_enabled;
-   state->verify_time = priv->fpe_cfg.verify_time;
-   state->tx_enabled = priv->fpe_cfg.tx_enabled;
-   state->verify_status = priv->fpe_cfg.status;
state->rx_min_frag_size = ETH_ZLEN;
-
-   /* FPE active if common tx_enabled and
-* (verification success or disabled(forced))
-*/
-   if (state->tx_enabled &&
-   (state->verify_status == ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED ||
-state->verify_status == ETHTOOL_MM_VERIFY_STATUS_DISABLED))
-   state->tx_active = true;
-   else
-   state->tx_active = false;
-
frag_size = stmmac_fpe_get_add_frag_size(priv);
state->tx_min_frag_size = ethtool_mm_frag_size_add_to_min(frag_size);
 
-   spin_unlock_irqrestore(&priv->fpe_cfg.lock, flags);
-
return 0;
 }
 
@@ -1248,8 +1228,6 @@ static int stmmac_set_mm(struct net_device *ndev, struct 
ethtool_mm_cfg *cfg,
 struct netlink_ext_ack *extack)
 {
struct stmmac_priv *priv = netdev_priv(ndev);
-   struct stmmac_fpe_cfg *fpe_cfg = &priv->fpe_cfg;
-   unsigned long flags;
u32 frag_size;
int err;
 
@@ -1258,23 +1236,8 @@ static int stmmac_set_mm(struct net_device *ndev, struct 
ethtool_mm_cfg *cfg,
if (err)
return e

Re: [Intel-wired-lan] [PATCH iwl-next v5 01/15] devlink: add value check to devlink_info_version_put()

2025-03-03 Thread R, Bharath
> -Original Message-
> From: Intel-wired-lan  On Behalf Of
> Jedrzej Jagielski
> Sent: Friday, February 21, 2025 5:21 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: Nguyen, Anthony L ;
> net...@vger.kernel.org; ho...@kernel.org; j...@nvidia.com; Jagielski, Jedrzej
> ; Kitszel, Przemyslaw
> 
> Subject: [Intel-wired-lan] [PATCH iwl-next v5 01/15] devlink: add value check
> to devlink_info_version_put()
> 
> Prevent from proceeding if there's nothing to print.
> 
> Suggested-by: Przemek Kitszel 
> Reviewed-by: Jiri Pirko 
> Signed-off-by: Jedrzej Jagielski 
> ---
>  net/devlink/dev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Tested-by: Bharath R 


Re: [Intel-wired-lan] [PATCH iwl-next v5 05/15] ixgbe: add E610 functions for acquiring flash data

2025-03-03 Thread R, Bharath
> -Original Message-
> From: Intel-wired-lan  On Behalf Of
> Jedrzej Jagielski
> Sent: Friday, February 21, 2025 5:21 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: Nguyen, Anthony L ;
> net...@vger.kernel.org; ho...@kernel.org; j...@nvidia.com; Mrozowicz,
> SlawomirX ; Kitszel, Przemyslaw
> ; Polchlopek, Mateusz
> ; Kwapulinski, Piotr
> ; Jagielski, Jedrzej 
> 
> Subject: [Intel-wired-lan] [PATCH iwl-next v5 05/15] ixgbe: add E610
> functions for acquiring flash data
> 
> From: Slawomir Mrozowicz 
> 
> Read NVM related info from the flash.
> 
> Add several helper functions used to access the flash data, find memory
> banks, calculate offsets, calculate the flash size.
> 
> Reviewed-by: Przemek Kitszel 
> Reviewed-by: Mateusz Polchlopek 
> Signed-off-by: Slawomir Mrozowicz 
> Co-developed-by: Piotr Kwapulinski 
> Signed-off-by: Piotr Kwapulinski 
> Co-developed-by: Jedrzej Jagielski 
> Signed-off-by: Jedrzej Jagielski 
> ---
>  drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c | 509 +-
>  drivers/net/ethernet/intel/ixgbe/ixgbe_e610.h |   1 +
>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |   4 +
>  .../ethernet/intel/ixgbe/ixgbe_type_e610.h|  40 +-
>  4 files changed, 552 insertions(+), 2 deletions(-)
> 

Tested-by: Bharath R 


Re: [Intel-wired-lan] [PATCH iwl-next v2 1/4] ixgbe: create E610 specific ethtool_ops structure

2025-03-03 Thread Jagielski, Jedrzej
From: Paul Menzel  
Sent: Friday, February 28, 2025 11:17 AM

>Dear Jedrzej,
>
>
>Thank you for your patch.
>
>Am 28.02.25 um 09:37 schrieb Jedrzej Jagielski:
>> E610's implementation of various ethtool ops is different than
>> the ones corresponding to ixgbe legacy products. Therefore create
>> separate E610 ethtool_ops struct which will be filled out in the
>> forthcoming patches.
>> 
>> Assing adequate ops struct basing on mac type. This step requires
>
>1.  A*dd*ing
>2.  Maybe even imperative mood: Add.
>3.  … based on MAC type.

Hello Paul
that's really unfortunate mistake, i don't know how i could pass it by
thank you for pointing it out! :)

Regards
Jedrek

>
>> changing a bit the flow of probing by placing ixgbe_set_ethtool_ops
>> after mac type is assigned. So move the whole netdev assignment
>> block after mac_type is known. This step doesn't have any additional
>> impact on probing sequence.
>> 
>> Suggested-by: Aleksandr Loktionov 
>> Reviewed-by: Aleksandr Loktionov 
>> Signed-off-by: Jedrzej Jagielski 
>> ---


[Intel-wired-lan] [PATCH iwl-next v3 1/4] ixgbe: create E610 specific ethtool_ops structure

2025-03-03 Thread Jedrzej Jagielski
E610's implementation of various ethtool ops is different than
the ones corresponding to ixgbe legacy products. Therefore create
separate E610 ethtool_ops struct which will be filled out in the
forthcoming patches.

Add adequate ops struct basing on MAC type. This step requires
changing a bit the flow of probing by placing ixgbe_set_ethtool_ops
after hw.mac.type is assigned. So move the whole netdev assignment
block after hw.mac.type is known. This step doesn't have any additional
impact on probing sequence.

Suggested-by: Aleksandr Loktionov 
Reviewed-by: Aleksandr Loktionov 
Signed-off-by: Jedrzej Jagielski 
---
v3: correct the commit msg
---
 .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c  | 52 ++-
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 10 ++--
 2 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index c86103eccc8a..83d9ee3941e5 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -3650,7 +3650,57 @@ static const struct ethtool_ops ixgbe_ethtool_ops = {
.set_link_ksettings = ixgbe_set_link_ksettings,
 };
 
+static const struct ethtool_ops ixgbe_ethtool_ops_e610 = {
+   .supported_coalesce_params = ETHTOOL_COALESCE_USECS,
+   .get_drvinfo= ixgbe_get_drvinfo,
+   .get_regs_len   = ixgbe_get_regs_len,
+   .get_regs   = ixgbe_get_regs,
+   .get_wol= ixgbe_get_wol,
+   .set_wol= ixgbe_set_wol,
+   .nway_reset = ixgbe_nway_reset,
+   .get_link   = ethtool_op_get_link,
+   .get_eeprom_len = ixgbe_get_eeprom_len,
+   .get_eeprom = ixgbe_get_eeprom,
+   .set_eeprom = ixgbe_set_eeprom,
+   .get_ringparam  = ixgbe_get_ringparam,
+   .set_ringparam  = ixgbe_set_ringparam,
+   .get_pause_stats= ixgbe_get_pause_stats,
+   .get_pauseparam = ixgbe_get_pauseparam,
+   .set_pauseparam = ixgbe_set_pauseparam,
+   .get_msglevel   = ixgbe_get_msglevel,
+   .set_msglevel   = ixgbe_set_msglevel,
+   .self_test  = ixgbe_diag_test,
+   .get_strings= ixgbe_get_strings,
+   .set_phys_id= ixgbe_set_phys_id,
+   .get_sset_count = ixgbe_get_sset_count,
+   .get_ethtool_stats  = ixgbe_get_ethtool_stats,
+   .get_coalesce   = ixgbe_get_coalesce,
+   .set_coalesce   = ixgbe_set_coalesce,
+   .get_rxnfc  = ixgbe_get_rxnfc,
+   .set_rxnfc  = ixgbe_set_rxnfc,
+   .get_rxfh_indir_size= ixgbe_rss_indir_size,
+   .get_rxfh_key_size  = ixgbe_get_rxfh_key_size,
+   .get_rxfh   = ixgbe_get_rxfh,
+   .set_rxfh   = ixgbe_set_rxfh,
+   .get_eee= ixgbe_get_eee,
+   .set_eee= ixgbe_set_eee,
+   .get_channels   = ixgbe_get_channels,
+   .set_channels   = ixgbe_set_channels,
+   .get_priv_flags = ixgbe_get_priv_flags,
+   .set_priv_flags = ixgbe_set_priv_flags,
+   .get_ts_info= ixgbe_get_ts_info,
+   .get_module_info= ixgbe_get_module_info,
+   .get_module_eeprom  = ixgbe_get_module_eeprom,
+   .get_link_ksettings = ixgbe_get_link_ksettings,
+   .set_link_ksettings = ixgbe_set_link_ksettings,
+};
+
 void ixgbe_set_ethtool_ops(struct net_device *netdev)
 {
-   netdev->ethtool_ops = &ixgbe_ethtool_ops;
+   struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev);
+
+   if (adapter->hw.mac.type == ixgbe_mac_e610)
+   netdev->ethtool_ops = &ixgbe_ethtool_ops_e610;
+   else
+   netdev->ethtool_ops = &ixgbe_ethtool_ops;
 }
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 90cffa50221c..b6ce1017bf13 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -11610,11 +11610,6 @@ static int ixgbe_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
goto err_ioremap;
}
 
-   netdev->netdev_ops = &ixgbe_netdev_ops;
-   ixgbe_set_ethtool_ops(netdev);
-   netdev->watchdog_timeo = 5 * HZ;
-   strscpy(netdev->name, pci_name(pdev), sizeof(netdev->name));
-
/* Setup hw api */
hw->mac.ops   = *ii->mac_ops;
hw->mac.type  = ii->mac;
@@ -11644,6 +11639,11 @@ static int ixgbe_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
hw->phy.mdio.mdio_read = ixgbe_mdio_read;
hw->phy.mdio.mdio_write = ixgbe_mdio_write;
 
+   netdev->netdev_ops = &ixgbe_netdev_ops;
+   ixgbe_set_ethtool_ops(netdev);
+   netdev->watchdog_timeo = 5 * HZ;
+   strscpy(n

[Intel-wired-lan] [PATCH iwl-next v3 4/4] ixgbe: add E610 .set_phys_id() callback implementation

2025-03-03 Thread Jedrzej Jagielski
Legacy implementation of .set_phys_id() ethtool callback is not
applicable for E610 device.

Add new implementation which uses 0x06E9 command by calling
ixgbe_aci_set_port_id_led().

Reviewed-by: Aleksandr Loktionov 
Reviewed-by: Michal Swiatkowski 
Signed-off-by: Jedrzej Jagielski 
---
v3: move the #defines related to ixgbe_aci_cmd_set_port_id_led out of the
struct definition
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c | 29 +++
 drivers/net/ethernet/intel/ixgbe/ixgbe_e610.h |  1 +
 .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c  | 22 +-
 .../ethernet/intel/ixgbe/ixgbe_type_e610.h| 14 +
 4 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c
index 7b0a405a305e..f11cd13c18f4 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c
@@ -1485,6 +1485,35 @@ static int ixgbe_start_hw_e610(struct ixgbe_hw *hw)
return err;
 }
 
+/**
+ * ixgbe_aci_set_port_id_led - set LED value for the given port
+ * @hw: pointer to the HW struct
+ * @orig_mode: set LED original mode
+ *
+ * Set LED value for the given port (0x06E9)
+ *
+ * Return: the exit code of the operation.
+ */
+int ixgbe_aci_set_port_id_led(struct ixgbe_hw *hw, bool orig_mode)
+{
+   struct ixgbe_aci_cmd_set_port_id_led *cmd;
+   struct ixgbe_aci_desc desc;
+
+   cmd = &desc.params.set_port_id_led;
+
+   ixgbe_fill_dflt_direct_cmd_desc(&desc, ixgbe_aci_opc_set_port_id_led);
+
+   cmd->lport_num = (u8)hw->bus.func;
+   cmd->lport_num_valid = IXGBE_ACI_PORT_ID_PORT_NUM_VALID;
+
+   if (orig_mode)
+   cmd->ident_mode = IXGBE_ACI_PORT_IDENT_LED_ORIG;
+   else
+   cmd->ident_mode = IXGBE_ACI_PORT_IDENT_LED_BLINK;
+
+   return ixgbe_aci_send_cmd(hw, &desc, NULL, 0);
+}
+
 /**
  * ixgbe_get_media_type_e610 - Gets media type
  * @hw: pointer to the HW struct
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_e610.h 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_e610.h
index b668ff0ae2e5..c97623fb10ac 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_e610.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_e610.h
@@ -36,6 +36,7 @@ int ixgbe_aci_get_link_info(struct ixgbe_hw *hw, bool ena_lse,
struct ixgbe_link_status *link);
 int ixgbe_aci_set_event_mask(struct ixgbe_hw *hw, u8 port_num, u16 mask);
 int ixgbe_configure_lse(struct ixgbe_hw *hw, bool activate, u16 mask);
+int ixgbe_aci_set_port_id_led(struct ixgbe_hw *hw, bool orig_mode);
 enum ixgbe_media_type ixgbe_get_media_type_e610(struct ixgbe_hw *hw);
 int ixgbe_setup_link_e610(struct ixgbe_hw *hw, ixgbe_link_speed speed,
  bool autoneg_wait);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 17d937f672dc..49ced536d679 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -2491,6 +2491,26 @@ static int ixgbe_set_phys_id(struct net_device *netdev,
return 0;
 }
 
+static int ixgbe_set_phys_id_e610(struct net_device *netdev,
+ enum ethtool_phys_id_state state)
+{
+   struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev);
+   bool led_active;
+
+   switch (state) {
+   case ETHTOOL_ID_ACTIVE:
+   led_active = true;
+   break;
+   case ETHTOOL_ID_INACTIVE:
+   led_active = false;
+   break;
+   default:
+   return -EOPNOTSUPP;
+   }
+
+   return ixgbe_aci_set_port_id_led(&adapter->hw, !led_active);
+}
+
 static int ixgbe_get_coalesce(struct net_device *netdev,
  struct ethtool_coalesce *ec,
  struct kernel_ethtool_coalesce *kernel_coal,
@@ -3756,7 +3776,7 @@ static const struct ethtool_ops ixgbe_ethtool_ops_e610 = {
.set_msglevel   = ixgbe_set_msglevel,
.self_test  = ixgbe_diag_test,
.get_strings= ixgbe_get_strings,
-   .set_phys_id= ixgbe_set_phys_id,
+   .set_phys_id= ixgbe_set_phys_id_e610,
.get_sset_count = ixgbe_get_sset_count,
.get_ethtool_stats  = ixgbe_get_ethtool_stats,
.get_coalesce   = ixgbe_get_coalesce,
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type_e610.h 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_type_e610.h
index bea94e5ccb73..09df67f03cf4 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type_e610.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type_e610.h
@@ -223,6 +223,7 @@ enum ixgbe_aci_opc {
ixgbe_aci_opc_write_mdio= 0x06E5,
ixgbe_aci_opc_set_gpio_by_func  = 0x06E6,
ixgbe_aci_opc_get_gpio_by_func  = 0x06E7,
+   ixgbe_aci_opc_set_port_id_led 

[Intel-wired-lan] [PATCH iwl-next v3 0/4] ixgbe: add ethtool support for E610

2025-03-03 Thread Jedrzej Jagielski
As E610 adapter introduces different approach to communicate with FW than
the previous adapters using the ixgbe driver, there is a need to adjust
some of the ethtool callbacks implementations to the new pattern. Some of
the features are now set using Admin Command Interface (eg. controlling
LEDs) which among the ixgbe supported device is specific for E610 only.
That means ethtool callbacks related to these features need to be handled
specifically in case of E610 adapter. E610 introduces also different rules
(eg. setting FC, setting WoL) for some of the features what also needs to
be adjusted.

This series is based on the series introducing initial E610 device
support:
https://lore.kernel.org/intel-wired-lan/20241205084450.4651-1-piotr.kwapulin...@intel.com/


Jedrzej Jagielski (4):
  ixgbe: create E610 specific ethtool_ops structure
  ixgbe: add support for ACPI WOL for E610
  ixgbe: apply different rules for setting FC on E610
  ixgbe: add E610 .set_phys_id() callback implementation

 drivers/net/ethernet/intel/ixgbe/ixgbe_e610.c |  29 +++
 drivers/net/ethernet/intel/ixgbe/ixgbe_e610.h |   1 +
 .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c  | 171 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |  10 +-
 .../ethernet/intel/ixgbe/ixgbe_type_e610.h|  14 ++
 5 files changed, 212 insertions(+), 13 deletions(-)
---
NOTE: initial version of the series has been sent as V2 - it had been
tagged by mistake. Sorry for messing out.
So this revision is in fact V2.
link to the initial version:
https://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=446487
---


base-commit: 35c698223836714535e5413753b5899ca2a05d0a
-- 
2.31.1



[Intel-wired-lan] [PATCH iwl-next v3 2/4] ixgbe: add support for ACPI WOL for E610

2025-03-03 Thread Jedrzej Jagielski
Currently only APM (Advanced Power Management) is supported by
the ixgbe driver. It works for magic packets only, as for different
sources of wake-up E610 adapter utilizes different feature.

Add E610 specific implementation of ixgbe_set_wol() callback. When
any of broadcast/multicast/unicast wake-up is set, disable APM and
configure ACPI (Advanced Configuration and Power Interface).

Reviewed-by: Michal Swiatkowski 
Reviewed-by: Aleksandr Loktionov 
Signed-off-by: Jedrzej Jagielski 
---
 .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c  | 46 ++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 83d9ee3941e5..abc8c279192a 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -2365,6 +2365,50 @@ static int ixgbe_set_wol(struct net_device *netdev, 
struct ethtool_wolinfo *wol)
return 0;
 }
 
+static int ixgbe_set_wol_acpi(struct net_device *netdev,
+ struct ethtool_wolinfo *wol)
+{
+   struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev);
+   struct ixgbe_hw *hw = &adapter->hw;
+   u32 grc;
+
+   if (ixgbe_wol_exclusion(adapter, wol))
+   return wol->wolopts ? -EOPNOTSUPP : 0;
+
+   /* disable APM wakeup */
+   grc = IXGBE_READ_REG(hw, IXGBE_GRC_X550EM_a);
+   grc &= ~IXGBE_GRC_APME;
+   IXGBE_WRITE_REG(hw, IXGBE_GRC_X550EM_a, grc);
+
+   /* erase existing filters */
+   IXGBE_WRITE_REG(hw, IXGBE_WUFC, 0);
+   adapter->wol = 0;
+
+   if (wol->wolopts & WAKE_UCAST)
+   adapter->wol |= IXGBE_WUFC_EX;
+   if (wol->wolopts & WAKE_MCAST)
+   adapter->wol |= IXGBE_WUFC_MC;
+   if (wol->wolopts & WAKE_BCAST)
+   adapter->wol |= IXGBE_WUFC_BC;
+
+   IXGBE_WRITE_REG(hw, IXGBE_WUC, IXGBE_WUC_PME_EN);
+   IXGBE_WRITE_REG(hw, IXGBE_WUFC, adapter->wol);
+
+   hw->wol_enabled = adapter->wol;
+   device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
+
+   return 0;
+}
+
+static int ixgbe_set_wol_e610(struct net_device *netdev,
+ struct ethtool_wolinfo *wol)
+{
+   if (wol->wolopts & (WAKE_UCAST | WAKE_MCAST | WAKE_BCAST))
+   return ixgbe_set_wol_acpi(netdev, wol);
+   else
+   return ixgbe_set_wol(netdev, wol);
+}
+
 static int ixgbe_nway_reset(struct net_device *netdev)
 {
struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev);
@@ -3656,7 +3700,7 @@ static const struct ethtool_ops ixgbe_ethtool_ops_e610 = {
.get_regs_len   = ixgbe_get_regs_len,
.get_regs   = ixgbe_get_regs,
.get_wol= ixgbe_get_wol,
-   .set_wol= ixgbe_set_wol,
+   .set_wol= ixgbe_set_wol_e610,
.nway_reset = ixgbe_nway_reset,
.get_link   = ethtool_op_get_link,
.get_eeprom_len = ixgbe_get_eeprom_len,
-- 
2.31.1



Re: [Intel-wired-lan] [PATCH] e1000: Adicionado const para melhorar a segurança do código

2025-03-03 Thread Andrew Lunn
On Mon, Mar 03, 2025 at 10:11:55AM -0300, joaomboni wrote:
> Signed-off-by: joaomboni 

Sorry, but the Subject: line needs to be in English.

And the name in Signed-off-by: needs to be a real name.

The code change itself looks sensible.

Andrew

---
pw-bot: cr


[Intel-wired-lan] [PATCH iwl-next v3 3/4] ixgbe: apply different rules for setting FC on E610

2025-03-03 Thread Jedrzej Jagielski
E610 device doesn't support disabling FC autonegotiation.

Create dedicated E610 .set_pauseparam() implementation and assign
it to ixgbe_ethtool_ops_e610.

Reviewed-by: Aleksandr Loktionov 
Signed-off-by: Jedrzej Jagielski 
---
 .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c  | 57 ---
 1 file changed, 49 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index abc8c279192a..17d937f672dc 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -564,6 +564,22 @@ static void ixgbe_get_pauseparam(struct net_device *netdev,
}
 }
 
+static void ixgbe_set_pauseparam_finalize(struct net_device *netdev,
+ struct ixgbe_fc_info *fc)
+{
+   struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev);
+   struct ixgbe_hw *hw = &adapter->hw;
+
+   /* If the thing changed then we'll update and use new autoneg. */
+   if (memcmp(fc, &hw->fc, sizeof(*fc))) {
+   hw->fc = *fc;
+   if (netif_running(netdev))
+   ixgbe_reinit_locked(adapter);
+   else
+   ixgbe_reset(adapter);
+   }
+}
+
 static int ixgbe_set_pauseparam(struct net_device *netdev,
struct ethtool_pauseparam *pause)
 {
@@ -592,15 +608,40 @@ static int ixgbe_set_pauseparam(struct net_device *netdev,
else
fc.requested_mode = ixgbe_fc_none;
 
-   /* if the thing changed then we'll update and use new autoneg */
-   if (memcmp(&fc, &hw->fc, sizeof(struct ixgbe_fc_info))) {
-   hw->fc = fc;
-   if (netif_running(netdev))
-   ixgbe_reinit_locked(adapter);
-   else
-   ixgbe_reset(adapter);
+   ixgbe_set_pauseparam_finalize(netdev, &fc);
+
+   return 0;
+}
+
+static int ixgbe_set_pauseparam_e610(struct net_device *netdev,
+struct ethtool_pauseparam *pause)
+{
+   struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev);
+   struct ixgbe_hw *hw = &adapter->hw;
+   struct ixgbe_fc_info fc = hw->fc;
+
+   if (!ixgbe_device_supports_autoneg_fc(hw))
+   return -EOPNOTSUPP;
+
+   if (pause->autoneg == AUTONEG_DISABLE) {
+   netdev_info(netdev,
+   "Cannot disable autonegotiation on this device.\n");
+   return -EOPNOTSUPP;
}
 
+   fc.disable_fc_autoneg = false;
+
+   if (pause->rx_pause && pause->tx_pause)
+   fc.requested_mode = ixgbe_fc_full;
+   else if (pause->rx_pause)
+   fc.requested_mode = ixgbe_fc_rx_pause;
+   else if (pause->tx_pause)
+   fc.requested_mode = ixgbe_fc_tx_pause;
+   else
+   fc.requested_mode = ixgbe_fc_none;
+
+   ixgbe_set_pauseparam_finalize(netdev, &fc);
+
return 0;
 }
 
@@ -3710,7 +3751,7 @@ static const struct ethtool_ops ixgbe_ethtool_ops_e610 = {
.set_ringparam  = ixgbe_set_ringparam,
.get_pause_stats= ixgbe_get_pause_stats,
.get_pauseparam = ixgbe_get_pauseparam,
-   .set_pauseparam = ixgbe_set_pauseparam,
+   .set_pauseparam = ixgbe_set_pauseparam_e610,
.get_msglevel   = ixgbe_get_msglevel,
.set_msglevel   = ixgbe_set_msglevel,
.self_test  = ixgbe_diag_test,
-- 
2.31.1



[Intel-wired-lan] [PATCH v2] e1000: The 'const' qualifier has been added where applicable to enhance code safety and prevent unintended modifications.

2025-03-03 Thread joaomboni
Signed-off-by: Joao Bonifacio 
---
 drivers/net/ethernet/intel/e1000/e1000_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c 
b/drivers/net/ethernet/intel/e1000/e1000_main.c
index 3f089c3d47b2..96bc85f09aaf 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -9,7 +9,7 @@
 #include 
 
 char e1000_driver_name[] = "e1000";
-static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
+static const char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
 static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel 
Corporation.";
 
 /* e1000_pci_tbl - PCI Device ID Table
-- 
2.48.1



[Intel-wired-lan] MMIO write access to an invalid page in i40e_clear_hw()

2025-03-03 Thread Kyungwook Boo
Hello,

It seems that there are invalid page MMIO write access in i40e_clear_hw()
due to an integer underflow from num_pf_int(also num_vf_int seems possible).

The following is a sample code in i40e_clear_hw():

val = rd32(hw, I40E_GLPCI_CNF2); // (1)
num_pf_int = FIELD_GET(I40E_GLPCI_CNF2_MSI_X_PF_N_MASK, val); // (2)
num_vf_int = FIELD_GET(I40E_GLPCI_CNF2_MSI_X_VF_N_MASK, val);
...
for (i = 0; i < num_pf_int - 2; i++)  // (3)
wr32(hw, I40E_PFINT_DYN_CTLN(i), val);  // (4)
...
for (i = 0; i < num_pf_int - 2; i++)// (5)
wr32(hw, I40E_PFINT_LNKLSTN(i), val);
...
for (i = 0; i < num_vf_int - 2; i++)// (6)
wr32(hw, I40E_VPINT_LNKLSTN(i), val);

An example scenario for num_pf_int:
(1) val = 0 (if MMIO read value was 0)
(2) num_pf_int = 0 (also zero after bit field extraction from val)
(3) An integer underflow occurs (num_pf_int - 2 == 0xfffe)
(4) Out-of-bounds MMIO write access if access address exceeds the expected
range.

>From above example scenario, the maximum access offset value can be around
0x4000347f8(=172G) which seems like this underflow is not intended(also there
are masking operations like (2) for num_pf_int), so I report this issue.

I think similar issue also could happen at (5) and (6).

The following is the patch method I propose:

diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c 
b/drivers/net/ethernet/intel/i40e/i40e_common.c
index 370b4bddee44..97ef79be39b3 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_common.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_common.c
@@ -848,19 +848,25 @@ void i40e_clear_hw(struct i40e_hw *hw)
/* stop all the interrupts */
wr32(hw, I40E_PFINT_ICR0_ENA, 0);
val = 0x3 << I40E_PFINT_DYN_CTLN_ITR_INDX_SHIFT;
-   for (i = 0; i < num_pf_int - 2; i++)
-   wr32(hw, I40E_PFINT_DYN_CTLN(i), val);
+   if (num_pf_int > 1) {
+   for (i = 0; i < num_pf_int - 2; i++)
+   wr32(hw, I40E_PFINT_DYN_CTLN(i), val);
+   }
 
/* Set the FIRSTQ_INDX field to 0x7FF in PFINT_LNKLSTx */
val = eol << I40E_PFINT_LNKLST0_FIRSTQ_INDX_SHIFT;
wr32(hw, I40E_PFINT_LNKLST0, val);
-   for (i = 0; i < num_pf_int - 2; i++)
-   wr32(hw, I40E_PFINT_LNKLSTN(i), val);
+   if (num_pf_int > 1) {
+   for (i = 0; i < num_pf_int - 2; i++)
+   wr32(hw, I40E_PFINT_LNKLSTN(i), val);
+   }
val = eol << I40E_VPINT_LNKLST0_FIRSTQ_INDX_SHIFT;
for (i = 0; i < num_vfs; i++)
wr32(hw, I40E_VPINT_LNKLST0(i), val);
-   for (i = 0; i < num_vf_int - 2; i++)
-   wr32(hw, I40E_VPINT_LNKLSTN(i), val);
+   if (num_vf_int > 1) {
+   for (i = 0; i < num_vf_int - 2; i++)
+   wr32(hw, I40E_VPINT_LNKLSTN(i), val);
+   }
 
/* warn the HW of the coming Tx disables */
for (i = 0; i < num_queues; i++) {


Could you check this?

Best regards,
Kyungwook Boo


Re: [Intel-wired-lan] [PATCH net-next v9 2/6] net: ena: use napi's aRFS rmap notifers

2025-03-03 Thread Ahmed Zaki




On 2025-03-03 10:11 a.m., Arinzon, David wrote:

Use the core's rmap notifiers and delete our own.

Acked-by: David Arinzon 
Signed-off-by: Ahmed Zaki 
---
  drivers/net/ethernet/amazon/ena/ena_netdev.c | 43 +---
  1 file changed, 1 insertion(+), 42 deletions(-)

diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c
b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index c1295dfad0d0..6aab85a7c60a 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -5,9 +5,6 @@

  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

-#ifdef CONFIG_RFS_ACCEL
-#include 
-#endif /* CONFIG_RFS_ACCEL */
  #include 
  #include 
  #include 
@@ -162,30 +159,6 @@ int ena_xmit_common(struct ena_adapter
*adapter,
 return 0;
  }

-static int ena_init_rx_cpu_rmap(struct ena_adapter *adapter) -{ -#ifdef
CONFIG_RFS_ACCEL
-   u32 i;
-   int rc;
-
-   adapter->netdev->rx_cpu_rmap = alloc_irq_cpu_rmap(adapter-

num_io_queues);

-   if (!adapter->netdev->rx_cpu_rmap)
-   return -ENOMEM;
-   for (i = 0; i < adapter->num_io_queues; i++) {
-   int irq_idx = ENA_IO_IRQ_IDX(i);
-
-   rc = irq_cpu_rmap_add(adapter->netdev->rx_cpu_rmap,
- pci_irq_vector(adapter->pdev, irq_idx));
-   if (rc) {
-   free_irq_cpu_rmap(adapter->netdev->rx_cpu_rmap);
-   adapter->netdev->rx_cpu_rmap = NULL;
-   return rc;
-   }
-   }
-#endif /* CONFIG_RFS_ACCEL */
-   return 0;
-}
-
  static void ena_init_io_rings_common(struct ena_adapter *adapter,
  struct ena_ring *ring, u16 qid)  { @@ 
-1596,7 +1569,7 @@
static int ena_enable_msix(struct ena_adapter *adapter)
 adapter->num_io_queues = irq_cnt - ENA_ADMIN_MSIX_VEC;
 }

-   if (ena_init_rx_cpu_rmap(adapter))
+   if (netif_enable_cpu_rmap(adapter->netdev,
+ adapter->num_io_queues))
 netif_warn(adapter, probe, adapter->netdev,
"Failed to map IRQs to CPUs\n");

@@ -1742,13 +1715,6 @@ static void ena_free_io_irq(struct ena_adapter
*adapter)
 struct ena_irq *irq;
 int i;

-#ifdef CONFIG_RFS_ACCEL
-   if (adapter->msix_vecs >= 1) {
-   free_irq_cpu_rmap(adapter->netdev->rx_cpu_rmap);
-   adapter->netdev->rx_cpu_rmap = NULL;
-   }
-#endif /* CONFIG_RFS_ACCEL */
-
 for (i = ENA_IO_IRQ_FIRST_IDX; i <
ENA_MAX_MSIX_VEC(io_queue_count); i++) {
 irq = &adapter->irq_tbl[i];
 irq_set_affinity_hint(irq->vector, NULL); @@ -4131,13 +4097,6 
@@
static void __ena_shutoff(struct pci_dev *pdev, bool shutdown)
 ena_dev = adapter->ena_dev;
 netdev = adapter->netdev;

-#ifdef CONFIG_RFS_ACCEL
-   if ((adapter->msix_vecs >= 1) && (netdev->rx_cpu_rmap)) {
-   free_irq_cpu_rmap(netdev->rx_cpu_rmap);
-   netdev->rx_cpu_rmap = NULL;
-   }
-
-#endif /* CONFIG_RFS_ACCEL */
 /* Make sure timer and reset routine won't be called after
  * freeing device resources.
  */
--
2.43.0


Hi Ahmed,

After the merging of this patch, I see the below stack trace when the IRQs are 
freed.
It can be reproduced by unloading and loading the driver using `modprobe -r 
ena; modprobe ena` (happens during unload)

Based on the patchset and the changes to other drivers, I think there's a 
missing call to the function
that releases the affinity notifier (The warn is in 
https://web.git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/tree/kernel/irq/manage.c#n2031)

I saw in the intel code in the patchset that ` netif_napi_set_irq(, -1);` 
is added?

After adding the code snippet I don't see this anymore, but I want to 
understand whether it's the right call by design.


Yes, in ena_down() the IRQs are freed before napis are deleted (where 
IRQ notifiers are released). The code below is fine (and is better IMO) 
but you can also delete napis then free IRQs.




@@ -1716,8 +1716,11 @@ static void ena_free_io_irq(struct ena_adapter *adapter)
 int i;

 for (i = ENA_IO_IRQ_FIRST_IDX; i < ENA_MAX_MSIX_VEC(io_queue_count); 
i++) {
+   struct ena_napi *ena_napi;
+
 irq = &adapter->irq_tbl[i];
 irq_set_affinity_hint(irq->vector, NULL);
+   ena_napi = (struct ena_napi *)irq->data;
+   netif_napi_set_irq(&ena_napi->napi, -1);
 free_irq(irq->vector, irq->data);
 }
  }

[  484.544586]  ? __warn+0x84/0x130
[  484.544843]  ? free_irq+0x5c/0x70
[  484.545105]  ? report_bug+0x18a/0x1a0
[  484.545390]  ? handle_bug+0x53/0x90
[  484.545664]  ? exc_invalid_op+0x14/0x70
[  484.545959]  ? asm_exc_invalid_op+0x16/0x20
[  484.546279]  ? free_irq+0x5c/0x70
[  484.546545]  ? free_irq+0x10/0x70
[  484.546807]  ena_free_io_irq+0x5f/0x70 [ena]
[  484.547138]  en

Re: [Intel-wired-lan] [PATCH] e1000: Adicionado const para melhorar a segurança do código

2025-03-03 Thread Jakub Kicinski
On Mon, 3 Mar 2025 14:48:46 +0100 Andrew Lunn wrote:
> Sorry, but the Subject: line needs to be in English.
> 
> And the name in Signed-off-by: needs to be a real name.
> 
> The code change itself looks sensible.

If only we were also LLMs, not just humans, we could read commits 
in any language!


Re: [Intel-wired-lan] [PATCH net-next v9 2/6] net: ena: use napi's aRFS rmap notifers

2025-03-03 Thread Arinzon, David
> Use the core's rmap notifiers and delete our own.
> 
> Acked-by: David Arinzon 
> Signed-off-by: Ahmed Zaki 
> ---
>  drivers/net/ethernet/amazon/ena/ena_netdev.c | 43 +---
>  1 file changed, 1 insertion(+), 42 deletions(-)
> 
> diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c
> b/drivers/net/ethernet/amazon/ena/ena_netdev.c
> index c1295dfad0d0..6aab85a7c60a 100644
> --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
> +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
> @@ -5,9 +5,6 @@
> 
>  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> 
> -#ifdef CONFIG_RFS_ACCEL
> -#include 
> -#endif /* CONFIG_RFS_ACCEL */
>  #include 
>  #include 
>  #include 
> @@ -162,30 +159,6 @@ int ena_xmit_common(struct ena_adapter
> *adapter,
> return 0;
>  }
> 
> -static int ena_init_rx_cpu_rmap(struct ena_adapter *adapter) -{ -#ifdef
> CONFIG_RFS_ACCEL
> -   u32 i;
> -   int rc;
> -
> -   adapter->netdev->rx_cpu_rmap = alloc_irq_cpu_rmap(adapter-
> >num_io_queues);
> -   if (!adapter->netdev->rx_cpu_rmap)
> -   return -ENOMEM;
> -   for (i = 0; i < adapter->num_io_queues; i++) {
> -   int irq_idx = ENA_IO_IRQ_IDX(i);
> -
> -   rc = irq_cpu_rmap_add(adapter->netdev->rx_cpu_rmap,
> - pci_irq_vector(adapter->pdev, irq_idx));
> -   if (rc) {
> -   free_irq_cpu_rmap(adapter->netdev->rx_cpu_rmap);
> -   adapter->netdev->rx_cpu_rmap = NULL;
> -   return rc;
> -   }
> -   }
> -#endif /* CONFIG_RFS_ACCEL */
> -   return 0;
> -}
> -
>  static void ena_init_io_rings_common(struct ena_adapter *adapter,
>  struct ena_ring *ring, u16 qid)  { @@ 
> -1596,7 +1569,7 @@
> static int ena_enable_msix(struct ena_adapter *adapter)
> adapter->num_io_queues = irq_cnt - ENA_ADMIN_MSIX_VEC;
> }
> 
> -   if (ena_init_rx_cpu_rmap(adapter))
> +   if (netif_enable_cpu_rmap(adapter->netdev,
> + adapter->num_io_queues))
> netif_warn(adapter, probe, adapter->netdev,
>"Failed to map IRQs to CPUs\n");
> 
> @@ -1742,13 +1715,6 @@ static void ena_free_io_irq(struct ena_adapter
> *adapter)
> struct ena_irq *irq;
> int i;
> 
> -#ifdef CONFIG_RFS_ACCEL
> -   if (adapter->msix_vecs >= 1) {
> -   free_irq_cpu_rmap(adapter->netdev->rx_cpu_rmap);
> -   adapter->netdev->rx_cpu_rmap = NULL;
> -   }
> -#endif /* CONFIG_RFS_ACCEL */
> -
> for (i = ENA_IO_IRQ_FIRST_IDX; i <
> ENA_MAX_MSIX_VEC(io_queue_count); i++) {
> irq = &adapter->irq_tbl[i];
> irq_set_affinity_hint(irq->vector, NULL); @@ -4131,13 +4097,6 
> @@
> static void __ena_shutoff(struct pci_dev *pdev, bool shutdown)
> ena_dev = adapter->ena_dev;
> netdev = adapter->netdev;
> 
> -#ifdef CONFIG_RFS_ACCEL
> -   if ((adapter->msix_vecs >= 1) && (netdev->rx_cpu_rmap)) {
> -   free_irq_cpu_rmap(netdev->rx_cpu_rmap);
> -   netdev->rx_cpu_rmap = NULL;
> -   }
> -
> -#endif /* CONFIG_RFS_ACCEL */
> /* Make sure timer and reset routine won't be called after
>  * freeing device resources.
>  */
> --
> 2.43.0

Hi Ahmed,

After the merging of this patch, I see the below stack trace when the IRQs are 
freed.
It can be reproduced by unloading and loading the driver using `modprobe -r 
ena; modprobe ena` (happens during unload)

Based on the patchset and the changes to other drivers, I think there's a 
missing call to the function
that releases the affinity notifier (The warn is in 
https://web.git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/tree/kernel/irq/manage.c#n2031)

I saw in the intel code in the patchset that ` netif_napi_set_irq(, -1);` 
is added?

After adding the code snippet I don't see this anymore, but I want to 
understand whether it's the right call by design.

@@ -1716,8 +1716,11 @@ static void ena_free_io_irq(struct ena_adapter *adapter)
int i;

for (i = ENA_IO_IRQ_FIRST_IDX; i < ENA_MAX_MSIX_VEC(io_queue_count); 
i++) {
+   struct ena_napi *ena_napi;
+
irq = &adapter->irq_tbl[i];
irq_set_affinity_hint(irq->vector, NULL);
+   ena_napi = (struct ena_napi *)irq->data;
+   netif_napi_set_irq(&ena_napi->napi, -1);
free_irq(irq->vector, irq->data);
}
 }

[  484.544586]  ? __warn+0x84/0x130
[  484.544843]  ? free_irq+0x5c/0x70
[  484.545105]  ? report_bug+0x18a/0x1a0
[  484.545390]  ? handle_bug+0x53/0x90
[  484.545664]  ? exc_invalid_op+0x14/0x70
[  484.545959]  ? asm_exc_invalid_op+0x16/0x20
[  484.546279]  ? free_irq+0x5c/0x70
[  484.546545]  ? free_irq+0x10/0x70
[  484.546807]  ena_free_io_irq+0x5f/0x70 [ena]
[  484.547138]  ena_down+0x250/0x3e0 [ena]
[  484.547435]  ena_destroy_device+0x118/0x150 [ena]
[  484.