Re: [Intel-wired-lan] [PATCH iwl-net] i40e: Fix trying to free already-freed IRQ

2024-09-04 Thread Loktionov, Aleksandr



> -Original Message-
> From: Intel-wired-lan  On Behalf
> Of Kamal Heib
> Sent: Tuesday, September 3, 2024 8:26 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: ivecera ; YangHang Liu ;
> net...@vger.kernel.org; Kamal Heib ; Nguyen, Anthony
> L ; Kitszel, Przemyslaw
> ; Jakub Kicinski ;
> Paolo Abeni ; David S . Miller
> 
> Subject: [Intel-wired-lan] [PATCH iwl-net] i40e: Fix trying to free
> already-freed IRQ
> 
> Avoid the following warning when trying to free an already freed IRQ,
> The issue happens when trying to call i40e_remove() twice from two
> different contexts which will lead to calling i40e_vsi_free_irq()
> twice, Fix the issue by using a flag to mark that the IRQ has already
> been freed.
> 
> i40e :07:00.0: i40e_ptp_stop: removed PHC on enp7s0 [
> cut here ] Trying to free already-free IRQ 0
> WARNING: CPU: 2 PID: 12 at kernel/irq/manage.c:1868
> __free_irq+0x1e3/0x350 Modules linked in: nft_fib_inet nft_fib_ipv4
> nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6
> nft_reject nft_ct nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6
> nf_defrag_ipv4 rfkill ip_set nf_tables nfnetlink vfat fat
> intel_rapl_msr intel_rapl_common kvm_amd ccp iTCO_wdt
> iTCO_vendor_support kvm i2c_i801 pcspkr i40e lpc_ich virtio_gpu
> i2c_smbus virtio_dma_buf drm_shmem_helper drm_kms_helper
> virtio_balloon joydev drm fuse xfs libcrc32c ahci crct10dif_pclmul
> libahci crc32_pclmul crc32c_intel virtio_net libata virtio_blk
> ghash_clmulni_intel net_failover virtio_console failover serio_raw
> dm_mirror dm_region_hash dm_log dm_mod
> CPU: 2 PID: 12 Comm: kworker/u16:1 Kdump: loaded Not tainted 5.14.0-
> 478.el9.x86_64 #1 Hardware name: Red Hat KVM/RHEL, BIOS edk2-20240524-
> 1.el9 05/24/2024
> Workqueue: kacpi_hotplug acpi_hotplug_work_fn
> RIP: 0010:__free_irq+0x1e3/0x350
> Code: 00 00 48 8b bb a8 01 00 00 e8 09 74 02 00 49 8b 7c 24 30 e8 8f
> 7c 1d 00 eb 35 8b 74 24 04 48 c7 c7 50 a3 61 92 e8 cd 99 f6 ff <0f> 0b
> 4c 89 fe 48 89 ef e8 30 aa b3 00 48 8b 43 40 48 8b 40 78 48
> RSP: 0018:b971c0077ac8 EFLAGS: 00010086
> RAX:  RBX: 8b594193ee00 RCX: 0027
> RDX: 0027 RSI: 7fff RDI: 8b59bcf208c8
> RBP: 8b594193eec4 R08:  R09: b971c0077970
> R10: b971c0077968 R11: 931e7c28 R12: 8b5944946000
> R13: 8b594193ef80 R14: 8b5944946000 R15: 0246
> FS:  () GS:8b59bcf0()
> knlGS:
> CS:  0010 DS:  ES:  CR0: 80050033
> CR2: 7f11eb064000 CR3: 0ad40004 CR4: 00770ef0
> PKRU: 5554
> Call Trace:
>  
>  ? srso_alias_return_thunk+0x5/0xfbef5
>  ? show_trace_log_lvl+0x26e/0x2df
>  ? show_trace_log_lvl+0x26e/0x2df
>  ? free_irq+0x33/0x70
>  ? __free_irq+0x1e3/0x350
>  ? __warn+0x7e/0xd0
>  ? __free_irq+0x1e3/0x350
>  ? report_bug+0x100/0x140
>  ? srso_alias_return_thunk+0x5/0xfbef5
>  ? handle_bug+0x3c/0x70
>  ? exc_invalid_op+0x14/0x70
>  ? asm_exc_invalid_op+0x16/0x20
>  ? __free_irq+0x1e3/0x350
>  ? __free_irq+0x1e3/0x350
>  free_irq+0x33/0x70
>  i40e_vsi_free_irq+0x19e/0x220 [i40e]
>  i40e_vsi_close+0x2b/0xc0 [i40e]
>  i40e_close+0x11/0x20 [i40e]
>  __dev_close_many+0x9e/0x110
>  dev_close_many+0x8b/0x140
>  ? srso_alias_return_thunk+0x5/0xfbef5
>  ? free_pcppages_bulk+0xee/0x290
>  unregister_netdevice_many_notify+0x162/0x690
>  ? srso_alias_return_thunk+0x5/0xfbef5
>  ? free_unref_page_commit+0x19a/0x310
>  unregister_netdevice_queue+0xd3/0x110
>  unregister_netdev+0x18/0x20
>  i40e_vsi_release+0x84/0x2e0 [i40e]
>  ? srso_alias_return_thunk+0x5/0xfbef5
>  i40e_remove+0x15c/0x430 [i40e]
>  pci_device_remove+0x3e/0xb0
>  device_release_driver_internal+0x193/0x200
>  pci_stop_bus_device+0x6c/0x90
>  pci_stop_and_remove_bus_device+0xe/0x20
>  disable_slot+0x49/0x90
>  acpiphp_disable_and_eject_slot+0x15/0x90
>  hotplug_event+0xea/0x210
>  ? __pfx_acpiphp_hotplug_notify+0x10/0x10
>  acpiphp_hotplug_notify+0x22/0x80
>  ? __pfx_acpiphp_hotplug_notify+0x10/0x10
>  acpi_device_hotplug+0xb8/0x210
>  acpi_hotplug_work_fn+0x1a/0x30
>  process_one_work+0x197/0x380
>  worker_thread+0x2fe/0x410
>  ? __pfx_worker_thread+0x10/0x10
>  kthread+0xe0/0x100
>  ? __pfx_kthread+0x10/0x10
>  ret_from_fork+0x2c/0x50
>  
> ---[ end trace  ]---
> 
> Fixes: 41c445ff0f48 ("i40e: main driver core")
> Tested-by: YangHang Liu 
> Signed-off-by: Kamal Heib 
> ---
>  drivers/net/ethernet/intel/i40e/i40e.h  | 1 +
>  drivers/net/ethernet/intel/i40e/i40e_main.c | 8 
>  2 files changed, 9 insertions(+)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e.h
> b/drivers/net/ethernet/intel/i40e/i40e.h
> index d546567e0286..910415116995 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e.h
> +++ b/drivers/net/ethernet/intel/i40e/i40e.h
> @@ -865,6 +865,7 @@ struct i40e_vsi {
>   int num_q_vectors;
>   int base_vector;
>   bool irqs_ready;
> + bool legacy_msi_irq_ready;
I'm

Re: [Intel-wired-lan] [PATCH v4 iwl-next 6/7] ice: Read SDP section from NVM for pin definitions

2024-09-04 Thread Pucha, HimasekharX Reddy
> -Original Message-
> From: Intel-wired-lan  On Behalf Of Karol 
> Kolacinski
> Sent: Friday, August 30, 2024 4:37 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: net...@vger.kernel.org; Kubalewski, Arkadiusz 
> ; Kolacinski, Karol 
> ; Nguyen, Anthony L ; 
> Hagvi, Yochai ; Simon Horman ; 
> Kitszel, Przemyslaw 
> Subject: [Intel-wired-lan] [PATCH v4 iwl-next 6/7] ice: Read SDP section from 
> NVM for pin definitions
>
> From: Yochai Hagvi 
>
> PTP pins assignment and their related SDPs (Software Definable Pins) are 
> currently hardcoded.
> Fix that by reading NVM section instead on products supporting this, which 
> are E810 products.
> If SDP section is not defined in NVM, the driver continues to use the 
> hardcoded table.
>
> Reviewed-by: Arkadiusz Kubalewski 
> Signed-off-by: Yochai Hagvi 
> Co-developed-by: Karol Kolacinski 
> Signed-off-by: Karol Kolacinski 
> Reviewed-by: Simon Horman 
> ---
>  .../net/ethernet/intel/ice/ice_adminq_cmd.h   |   9 ++
>  drivers/net/ethernet/intel/ice/ice_ptp.c  | 138 ++
>  drivers/net/ethernet/intel/ice/ice_ptp.h  |   6 +-
>  drivers/net/ethernet/intel/ice/ice_ptp_hw.c   |  60 
>  drivers/net/ethernet/intel/ice/ice_ptp_hw.h   |   1 +
>  5 files changed, 186 insertions(+), 28 deletions(-)
>

Tested-by: Pucha Himasekhar Reddy  (A 
Contingent worker at Intel)




Re: [Intel-wired-lan] [PATCH v4 iwl-next 2/7] ice: Add SDPs support for E825C

2024-09-04 Thread Pucha, HimasekharX Reddy
> -Original Message-
> From: Intel-wired-lan  On Behalf Of Karol 
> Kolacinski
> Sent: Friday, August 30, 2024 4:37 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: net...@vger.kernel.org; Kubalewski, Arkadiusz 
> ; Kolacinski, Karol 
> ; Nguyen, Anthony L ; 
> Simon Horman ; Kitszel, Przemyslaw 
> 
> Subject: [Intel-wired-lan] [PATCH v4 iwl-next 2/7] ice: Add SDPs support for 
> E825C
>
> Add support of PTP SDPs (Software Definable Pins) for E825C products.
>
> Reviewed-by: Arkadiusz Kubalewski 
> Signed-off-by: Karol Kolacinski 
> Reviewed-by: Simon Horman 
> ---
> V1 -> V2: Removed redundant n_pins assignment and enable and verify move
>
>  drivers/net/ethernet/intel/ice/ice_ptp.c | 20 ++--
>  1 file changed, 18 insertions(+), 2 deletions(-)
>

Tested-by: Pucha Himasekhar Reddy  (A 
Contingent worker at Intel)




Re: [Intel-wired-lan] [PATCH v4 iwl-next 4/7] ice: Cache perout/extts requests and check flags

2024-09-04 Thread Pucha, HimasekharX Reddy
> -Original Message-
> From: Intel-wired-lan  On Behalf Of Karol 
> Kolacinski
> Sent: Friday, August 30, 2024 4:37 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: net...@vger.kernel.org; Kubalewski, Arkadiusz 
> ; Kolacinski, Karol 
> ; Nguyen, Anthony L ; 
> Simon Horman ; Kitszel, Przemyslaw 
> 
> Subject: [Intel-wired-lan] [PATCH v4 iwl-next 4/7] ice: Cache perout/extts 
> requests and check flags
>
> Cache original PTP GPIO requests instead of saving each parameter in internal 
> structures for periodic output or external timestamp request.
>
> Factor out all periodic output register writes from ice_ptp_cfg_clkout to a 
> separate function to improve readability.
>
> Reviewed-by: Arkadiusz Kubalewski 
> Signed-off-by: Karol Kolacinski 
> Reviewed-by: Simon Horman 
> ---
> V1 -> V2: Fixed unresolved merge conflict
>
>  drivers/net/ethernet/intel/ice/ice_ptp.c  | 360 +-
>  drivers/net/ethernet/intel/ice/ice_ptp.h  |  27 +-
>  .../net/ethernet/intel/ice/ice_ptp_consts.h   |   2 +-
>  drivers/net/ethernet/intel/ice/ice_ptp_hw.h   |  27 +-
>  4 files changed, 212 insertions(+), 204 deletions(-)
>

Tested-by: Pucha Himasekhar Reddy  (A 
Contingent worker at Intel)



Re: [Intel-wired-lan] [PATCH v4 iwl-next 1/7] ice: Implement ice_ptp_pin_desc

2024-09-04 Thread Pucha, HimasekharX Reddy
> -Original Message-
> From: Intel-wired-lan  On Behalf Of Karol 
> Kolacinski
> Sent: Friday, August 30, 2024 4:37 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: net...@vger.kernel.org; Kubalewski, Arkadiusz 
> ; Kolacinski, Karol 
> ; Nguyen, Anthony L ; 
> Simon Horman ; Kitszel, Przemyslaw 
> 
> Subject: [Intel-wired-lan] [PATCH v4 iwl-next 1/7] ice: Implement 
> ice_ptp_pin_desc
>
> Add a new internal structure describing PTP pins.
> Use the new structure for all non-E810T products.
>
> Reviewed-by: Arkadiusz Kubalewski 
> Signed-off-by: Karol Kolacinski 
> Reviewed-by: Simon Horman 
> ---
> V1 -> V2: Removed unused err variable
>
>  drivers/net/ethernet/intel/ice/ice_ptp.c | 256 +++  
> drivers/net/ethernet/intel/ice/ice_ptp.h |  65 --
>  2 files changed, 214 insertions(+), 107 deletions(-)
>

Tested-by: Pucha Himasekhar Reddy  (A 
Contingent worker at Intel)




Re: [Intel-wired-lan] [PATCH v4 iwl-next 5/7] ice: Disable shared pin on E810 on setfunc

2024-09-04 Thread Pucha, HimasekharX Reddy
> -Original Message-
> From: Intel-wired-lan  On Behalf Of Karol 
> Kolacinski
> Sent: Friday, August 30, 2024 4:37 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: net...@vger.kernel.org; Kubalewski, Arkadiusz 
> ; Kolacinski, Karol 
> ; Nguyen, Anthony L ; 
> Simon Horman ; Kitszel, Przemyslaw 
> 
> Subject: [Intel-wired-lan] [PATCH v4 iwl-next 5/7] ice: Disable shared pin on 
> E810 on setfunc
>
> When setting a new supported function for a pin on E810, disable other 
> enabled pin that shares the same GPIO.
>
> Reviewed-by: Arkadiusz Kubalewski 
> Signed-off-by: Karol Kolacinski 
> Reviewed-by: Simon Horman 
> ---
> V1 -> V2: Fixed incorrect call to ice_ptp_set_sma_cfg_e810t()
>
>  drivers/net/ethernet/intel/ice/ice_ptp.c | 65 
>  1 file changed, 65 insertions(+)
>

Tested-by: Pucha Himasekhar Reddy  (A 
Contingent worker at Intel)




Re: [Intel-wired-lan] [PATCH iwl-next v6 5/5] ice: Drop auxbus use for PTP to finalize ice_adapter move

2024-09-04 Thread Pucha, HimasekharX Reddy
> -Original Message-
> From: Intel-wired-lan  On Behalf Of 
> Sergey Temerkhanov
> Sent: Wednesday, August 21, 2024 6:40 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: Temerkhanov, Sergey ; 
> net...@vger.kernel.org; Simon Horman ; Kitszel, Przemyslaw 
> 
> Subject: [Intel-wired-lan] [PATCH iwl-next v6 5/5] ice: Drop auxbus use for 
> PTP to finalize ice_adapter move
>
> Drop unused auxbus/auxdev support from the PTP code due to move to the 
> ice_adapter.
>
> Signed-off-by: Sergey Temerkhanov 
> Reviewed-by: Przemek Kitszel 
> Reviewed-by: Simon Horman 
> ---
>  drivers/net/ethernet/intel/ice/ice_ptp.c | 252 ---  
> drivers/net/ethernet/intel/ice/ice_ptp.h |  21 --
>  2 files changed, 273 deletions(-)
>

Tested-by: Pucha Himasekhar Reddy  (A 
Contingent worker at Intel)




Re: [Intel-wired-lan] [PATCH v4 iwl-next 3/7] ice: Align E810T GPIO to other products

2024-09-04 Thread Pucha, HimasekharX Reddy
> -Original Message-
> From: Intel-wired-lan  On Behalf Of Karol 
> Kolacinski
> Sent: Friday, August 30, 2024 4:37 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: net...@vger.kernel.org; Kubalewski, Arkadiusz 
> ; Kolacinski, Karol 
> ; Nguyen, Anthony L ; 
> Simon Horman ; Kitszel, Przemyslaw 
> 
> Subject: [Intel-wired-lan] [PATCH v4 iwl-next 3/7] ice: Align E810T GPIO to 
> other products
>
> Instead of having separate PTP GPIO implementation for E810T, use existing 
> one from all other products.
>
> Reviewed-by: Arkadiusz Kubalewski 
> Signed-off-by: Karol Kolacinski 
> Reviewed-by: Simon Horman 
> ---
> V1 -> V2: restored blank line and moved enable and verify assignment
>
>  drivers/net/ethernet/intel/ice/ice_gnss.c   |   4 +-
>  drivers/net/ethernet/intel/ice/ice_ptp.c| 464 +---
>  drivers/net/ethernet/intel/ice/ice_ptp.h|  29 +-
>  drivers/net/ethernet/intel/ice/ice_ptp_hw.c |  20 +-  
> drivers/net/ethernet/intel/ice/ice_ptp_hw.h |  43 +-
>  5 files changed, 155 insertions(+), 405 deletions(-)
>

Tested-by: Pucha Himasekhar Reddy  (A 
Contingent worker at Intel)



Re: [Intel-wired-lan] [PATCH iwl-next v6 4/5] ice: Use ice_adapter for PTP shared data instead of auxdev

2024-09-04 Thread Pucha, HimasekharX Reddy
> -Original Message-
> From: Intel-wired-lan  On Behalf Of 
> Sergey Temerkhanov
> Sent: Wednesday, August 21, 2024 6:40 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: Temerkhanov, Sergey ; 
> net...@vger.kernel.org; Simon Horman ; Kitszel, Przemyslaw 
> 
> Subject: [Intel-wired-lan] [PATCH iwl-next v6 4/5] ice: Use ice_adapter for 
> PTP shared data instead of auxdev
>
> Use struct ice_adapter to hold shared PTP data and control PTP related 
> actions instead of auxbus. This allows significant code simplification and 
> faster access to the container fields used in the PTP support code.
>
> Move the PTP port list to the ice_adapter container to simplify the code and 
> avoid race conditions which could occur due to the synchronous nature of the 
> initialization/access and certain memory saving can be achieved by moving PTP 
> data into the ice_adapter itself.
>
> Signed-off-by: Sergey Temerkhanov 
> Reviewed-by: Przemek Kitszel 
> Reviewed-by: Simon Horman 
> ---
>  drivers/net/ethernet/intel/ice/ice_adapter.c |   6 +
>  drivers/net/ethernet/intel/ice/ice_adapter.h |  17 +++
>  drivers/net/ethernet/intel/ice/ice_ptp.c | 115 ---
>  drivers/net/ethernet/intel/ice/ice_ptp.h |   5 +-
>  drivers/net/ethernet/intel/ice/ice_ptp_hw.h  |   5 +
>  5 files changed, 105 insertions(+), 43 deletions(-)
>

Tested-by: Pucha Himasekhar Reddy  (A 
Contingent worker at Intel)




Re: [Intel-wired-lan] [PATCH iwl-next v6 3/5] ice: Initial support for E825C hardware in ice_adapter

2024-09-04 Thread Pucha, HimasekharX Reddy
> -Original Message-
> From: Intel-wired-lan  On Behalf Of 
> Sergey Temerkhanov
> Sent: Wednesday, August 21, 2024 6:40 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: Temerkhanov, Sergey ; 
> net...@vger.kernel.org; Simon Horman 
> Subject: [Intel-wired-lan] [PATCH iwl-next v6 3/5] ice: Initial support for 
> E825C hardware in ice_adapter
>
> Address E825C devices by PCI ID since dual IP core configurations need 1 
> ice_adapter for both devices.
>
> Signed-off-by: Sergey Temerkhanov 
> Reviewed-by: Simon Horman 
> ---
>  drivers/net/ethernet/intel/ice/ice_adapter.c | 16 +---
>  1 file changed, 13 insertions(+), 3 deletions(-)
>

Tested-by: Pucha Himasekhar Reddy  (A 
Contingent worker at Intel)




Re: [Intel-wired-lan] [PATCH iwl-next v6 2/5] ice: Add ice_get_ctrl_ptp() wrapper to simplify the code

2024-09-04 Thread Pucha, HimasekharX Reddy
> -Original Message-
> From: Intel-wired-lan  On Behalf Of 
> Sergey Temerkhanov
> Sent: Wednesday, August 21, 2024 6:40 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: Temerkhanov, Sergey ; 
> net...@vger.kernel.org; Simon Horman ; Kitszel, Przemyslaw 
> 
> Subject: [Intel-wired-lan] [PATCH iwl-next v6 2/5] ice: Add 
> ice_get_ctrl_ptp() wrapper to simplify the code
>
> Add ice_get_ctrl_ptp() wrapper to simplify the PTP support code in the 
> functions that do not use ctrl_pf directly.
> Add the control PF pointer to struct ice_adapter Rearrange fields in struct 
> ice_adapter
>
> Signed-off-by: Sergey Temerkhanov 
> Reviewed-by: Przemek Kitszel 
> Reviewed-by: Simon Horman 
> ---
>  drivers/net/ethernet/intel/ice/ice_adapter.h |  5 -
>  drivers/net/ethernet/intel/ice/ice_ptp.c | 12 
>  2 files changed, 16 insertions(+), 1 deletion(-)
>

Tested-by: Pucha Himasekhar Reddy  (A 
Contingent worker at Intel)




Re: [Intel-wired-lan] [PATCH iwl-next v6 1/5] ice: Introduce ice_get_phy_model() wrapper

2024-09-04 Thread Pucha, HimasekharX Reddy
> -Original Message-
> From: Intel-wired-lan  On Behalf Of 
> Sergey Temerkhanov
> Sent: Wednesday, August 21, 2024 6:40 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: Temerkhanov, Sergey ; 
> net...@vger.kernel.org; Simon Horman ; Kitszel, Przemyslaw 
> 
> Subject: [Intel-wired-lan] [PATCH iwl-next v6 1/5] ice: Introduce 
> ice_get_phy_model() wrapper
>
> Introduce ice_get_phy_model() to improve code readability
>
> Signed-off-by: Sergey Temerkhanov 
> Reviewed-by: Przemek Kitszel 
> Reviewed-by: Simon Horman 
> ---
>  drivers/net/ethernet/intel/ice/ice.h|  5 +
>  drivers/net/ethernet/intel/ice/ice_ptp.c| 19 +-
>  drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 22 ++---
>  3 files changed, 25 insertions(+), 21 deletions(-)
>

Tested-by: Pucha Himasekhar Reddy  (A 
Contingent worker at Intel)




[Intel-wired-lan] [PATCH iwl-next] ice: make ice_cfg_tx_topo() almost const-correct

2024-09-04 Thread Przemek Kitszel
Constify ice_cfg_tx_topo() @buf parameter.
This cascades further down to few more functions.

I set the boundary on ice_get_set_tx_topo(), which could not be easily
constified as it is get-or-set, but it's set variant does not change
provided data, the same holds for ice_aqc_opc_set_tx_topo() in particular.
That's why there is (u8 *) cast to loose const prior to entering into AQ
world of const-obliviousness.

Reviewed-by: Larysa Zaremba 
Signed-off-by: Przemek Kitszel 
---
 drivers/net/ethernet/intel/ice/ice_ddp.h |  4 +-
 drivers/net/ethernet/intel/ice/ice_ddp.c | 48 
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_ddp.h 
b/drivers/net/ethernet/intel/ice/ice_ddp.h
index 97f272317475..79551da2a4b0 100644
--- a/drivers/net/ethernet/intel/ice/ice_ddp.h
+++ b/drivers/net/ethernet/intel/ice/ice_ddp.h
@@ -438,7 +438,7 @@ struct ice_pkg_enum {
u32 buf_idx;
 
u32 type;
-   struct ice_buf_hdr *buf;
+   const struct ice_buf_hdr *buf;
u32 sect_idx;
void *sect;
u32 sect_type;
@@ -467,6 +467,6 @@ ice_pkg_enum_entry(struct ice_seg *ice_seg, struct 
ice_pkg_enum *state,
 void *ice_pkg_enum_section(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
   u32 sect_type);
 
-int ice_cfg_tx_topo(struct ice_hw *hw, u8 *buf, u32 len);
+int ice_cfg_tx_topo(struct ice_hw *hw, const void *buf, u32 len);
 
 #endif
diff --git a/drivers/net/ethernet/intel/ice/ice_ddp.c 
b/drivers/net/ethernet/intel/ice/ice_ddp.c
index 953262b88a58..f2ac1d265510 100644
--- a/drivers/net/ethernet/intel/ice/ice_ddp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ddp.c
@@ -31,7 +31,7 @@ static const struct ice_tunnel_type_scan tnls[] = {
  * Verifies various attributes of the package file, including length, format
  * version, and the requirement of at least one segment.
  */
-static enum ice_ddp_state ice_verify_pkg(struct ice_pkg_hdr *pkg, u32 len)
+static enum ice_ddp_state ice_verify_pkg(const struct ice_pkg_hdr *pkg, u32 
len)
 {
u32 seg_count;
u32 i;
@@ -57,13 +57,13 @@ static enum ice_ddp_state ice_verify_pkg(struct ice_pkg_hdr 
*pkg, u32 len)
/* all segments must fit within length */
for (i = 0; i < seg_count; i++) {
u32 off = le32_to_cpu(pkg->seg_offset[i]);
-   struct ice_generic_seg_hdr *seg;
+   const struct ice_generic_seg_hdr *seg;
 
/* segment header must fit */
if (len < off + sizeof(*seg))
return ICE_DDP_PKG_INVALID_FILE;
 
-   seg = (struct ice_generic_seg_hdr *)((u8 *)pkg + off);
+   seg = (void *)pkg + off;
 
/* segment body must fit */
if (len < off + le32_to_cpu(seg->seg_size))
@@ -119,13 +119,13 @@ static enum ice_ddp_state ice_chk_pkg_version(struct 
ice_pkg_ver *pkg_ver)
  *
  * This helper function validates a buffer's header.
  */
-static struct ice_buf_hdr *ice_pkg_val_buf(struct ice_buf *buf)
+static const struct ice_buf_hdr *ice_pkg_val_buf(const struct ice_buf *buf)
 {
-   struct ice_buf_hdr *hdr;
+   const struct ice_buf_hdr *hdr;
u16 section_count;
u16 data_end;
 
-   hdr = (struct ice_buf_hdr *)buf->buf;
+   hdr = (const struct ice_buf_hdr *)buf->buf;
/* verify data */
section_count = le16_to_cpu(hdr->section_count);
if (section_count < ICE_MIN_S_COUNT || section_count > ICE_MAX_S_COUNT)
@@ -165,8 +165,8 @@ static struct ice_buf_table *ice_find_buf_table(struct 
ice_seg *ice_seg)
  * unexpected value has been detected (for example an invalid section count or
  * an invalid buffer end value).
  */
-static struct ice_buf_hdr *ice_pkg_enum_buf(struct ice_seg *ice_seg,
-   struct ice_pkg_enum *state)
+static const struct ice_buf_hdr *ice_pkg_enum_buf(struct ice_seg *ice_seg,
+ struct ice_pkg_enum *state)
 {
if (ice_seg) {
state->buf_table = ice_find_buf_table(ice_seg);
@@ -1800,9 +1800,9 @@ int ice_update_pkg(struct ice_hw *hw, struct ice_buf 
*bufs, u32 count)
  * success it returns a pointer to the segment header, otherwise it will
  * return NULL.
  */
-static struct ice_generic_seg_hdr *
+static const struct ice_generic_seg_hdr *
 ice_find_seg_in_pkg(struct ice_hw *hw, u32 seg_type,
-   struct ice_pkg_hdr *pkg_hdr)
+   const struct ice_pkg_hdr *pkg_hdr)
 {
u32 i;
 
@@ -1813,11 +1813,9 @@ ice_find_seg_in_pkg(struct ice_hw *hw, u32 seg_type,
 
/* Search all package segments for the requested segment type */
for (i = 0; i < le32_to_cpu(pkg_hdr->seg_count); i++) {
-   struct ice_generic_seg_hdr *seg;
+   const struct ice_generic_seg_hdr *seg;
 
-   seg = (struct ice_generic_seg_hdr
-  *)((u8 *)pkg_hdr +
-   

[Intel-wired-lan] [PATCH iwl-net v2] ice: fix VSI lists confusion when adding VLANs

2024-09-04 Thread Michal Schmidt
The description of function ice_find_vsi_list_entry says:
  Search VSI list map with VSI count 1

However, since the blamed commit (see Fixes below), the function no
longer checks vsi_count. This causes a problem in ice_add_vlan_internal,
where the decision to share VSI lists between filter rules relies on the
vsi_count of the found existing VSI list being 1.

The reproducing steps:
1. Have a PF and two VFs.
   There will be a filter rule for VLAN 0, referring to a VSI list
   containing VSIs: 0 (PF), 2 (VF#0), 3 (VF#1).
2. Add VLAN 1234 to VF#0.
   ice will make the wrong decision to share the VSI list with the new
   rule. The wrong behavior may not be immediately apparent, but it can
   be observed with debug prints.
3. Add VLAN 1234 to VF#1.
   ice will unshare the VSI list for the VLAN 1234 rule. Due to the
   earlier bad decision, the newly created VSI list will contain
   VSIs 0 (PF) and 3 (VF#1), instead of expected 2 (VF#0) and 3 (VF#1).
4. Try pinging a network peer over the VLAN interface on VF#0.
   This fails.

Reproducer script at:
https://gitlab.com/mschmidt2/repro/-/blob/master/RHEL-46814/test-vlan-vsi-list-confusion.sh
Commented debug trace:
https://gitlab.com/mschmidt2/repro/-/blob/master/RHEL-46814/ice-vlan-vsi-lists-debug.txt
Patch adding the debug prints:
https://gitlab.com/mschmidt2/linux/-/commit/f8a8814623944a45091a77c6094c40bfe726bfdb
(Unsafe, by the way. Lacks rule_lock when dumping in ice_remove_vlan.)

Michal Swiatkowski added to the explanation that the bug is caused by
reusing a VSI list created for VLAN 0. All created VFs' VSIs are added
to VLAN 0 filter. When a non-zero VLAN is created on a VF which is already
in VLAN 0 (normal case), the VSI list from VLAN 0 is reused.
It leads to a problem because all VFs (VSIs to be specific) that are
subscribed to VLAN 0 will now receive a new VLAN tag traffic. This is
one bug, another is the bug described above. Removing filters from
one VF will remove VLAN filter from the previous VF. It happens a VF is
reset. Example:
- creation of 3 VFs
- we have VSI list (used for VLAN 0) [0 (pf), 2 (vf1), 3 (vf2), 4 (vf3)]
- we are adding VLAN 100 on VF1, we are reusing the previous list
  because 2 is there
- VLAN traffic works fine, but VLAN 100 tagged traffic can be received
  on all VSIs from the list (for example broadcast or unicast)
- trust is turning on on VF2, VF2 is resetting, all filters from VF2 are
  removed; the VLAN 100 filter is also removed because 3 is on the list
- VLAN traffic to VF1 isn't working anymore, there is a need to recreate
  VLAN interface to readd VLAN filter

One thing I'm not certain about is the implications for the LAG feature,
which is another caller of ice_find_vsi_list_entry. I don't have a
LAG-capable card at hand to test.

Fixes: 23ccae5ce15f ("ice: changes to the interface with the HW and FW for 
SRIOV_VF+LAG")
Reviewed-by: Michal Swiatkowski 
Signed-off-by: Michal Schmidt 
---
v2: Corrected the Fixes commit ID (the ID in v1 was of a centos-stream-9
backport accidentally).
Added the extended explanation from Michal Swiatkowski.
Fixed some typos.
---
 drivers/net/ethernet/intel/ice/ice_switch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c 
b/drivers/net/ethernet/intel/ice/ice_switch.c
index fe8847184cb1..4e6e7af962bd 100644
--- a/drivers/net/ethernet/intel/ice/ice_switch.c
+++ b/drivers/net/ethernet/intel/ice/ice_switch.c
@@ -3264,7 +3264,7 @@ ice_find_vsi_list_entry(struct ice_hw *hw, u8 recp_id, 
u16 vsi_handle,
 
list_head = &sw->recp_list[recp_id].filt_rules;
list_for_each_entry(list_itr, list_head, list_entry) {
-   if (list_itr->vsi_list_info) {
+   if (list_itr->vsi_count == 1 && list_itr->vsi_list_info) {
map_info = list_itr->vsi_list_info;
if (test_bit(vsi_handle, map_info->vsi_map)) {
*vsi_list_id = map_info->vsi_list_id;
-- 
2.45.2



[Intel-wired-lan] [PATCH iwl-net] idpf: deinit virtchnl transaction manager after vport and vectors

2024-09-04 Thread Larysa Zaremba
When the device is removed, idpf is supposed to make certain virtchnl
requests e.g. VIRTCHNL2_OP_DEALLOC_VECTORS and VIRTCHNL2_OP_DESTROY_VPORT.

However, this does not happen due to the referenced commit introducing
virtchnl transaction manager and placing its deinitialization before those
messages are sent. Then the sending is impossible due to no transactions
being available.

Lack of cleanup can lead to the FW becoming unresponsive from e.g.
unloading-loading the driver and creating-destroying VFs afterwards.

Move transaction manager deinitialization to after other virtchnl-related
cleanup is done.

Fixes: 34c21fa894a1 ("idpf: implement virtchnl transaction manager")
Reviewed-by: Przemek Kitszel 
Signed-off-by: Larysa Zaremba 
---
 drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c 
b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
index a5f9b7a5effe..f18f490dafd8 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
@@ -3040,9 +3040,9 @@ void idpf_vc_core_deinit(struct idpf_adapter *adapter)
if (!test_bit(IDPF_VC_CORE_INIT, adapter->flags))
return;
 
-   idpf_vc_xn_shutdown(adapter->vcxn_mngr);
idpf_deinit_task(adapter);
idpf_intr_rel(adapter);
+   idpf_vc_xn_shutdown(adapter->vcxn_mngr);
 
cancel_delayed_work_sync(&adapter->serv_task);
cancel_delayed_work_sync(&adapter->mbx_task);
-- 
2.45.0



[Intel-wired-lan] [tnguy-net-queue:200GbE] BUILD SUCCESS cfd433cecef929b4d92685f570f1a480762ec260

2024-09-04 Thread kernel test robot
tree/branch: 
https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue.git 200GbE
branch HEAD: cfd433cecef929b4d92685f570f1a480762ec260  Merge branch 
'ptp-ocp-fix-serial-port-information-export'

elapsed time: 1293m

configs tested: 110
configs skipped: 4

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

tested configs:
alpha allnoconfig   gcc-14.1.0
alphaallyesconfig   clang-20
alpha   defconfig   gcc-14.1.0
arc  allmodconfig   clang-20
arc   allnoconfig   gcc-14.1.0
arc  allyesconfig   clang-20
arc defconfig   gcc-14.1.0
arm  allmodconfig   clang-20
arm   allnoconfig   gcc-14.1.0
arm  allyesconfig   clang-20
arm defconfig   gcc-14.1.0
armneponset_defconfig   gcc-14.1.0
arm socfpga_defconfig   gcc-14.1.0
arm64allmodconfig   clang-20
arm64 allnoconfig   gcc-14.1.0
arm64   defconfig   gcc-14.1.0
csky alldefconfig   gcc-14.1.0
csky  allnoconfig   gcc-14.1.0
cskydefconfig   gcc-14.1.0
hexagon  allmodconfig   clang-20
hexagon   allnoconfig   gcc-14.1.0
hexagon  allyesconfig   clang-20
hexagon defconfig   gcc-14.1.0
i386 allmodconfig   clang-18
i386  allnoconfig   clang-18
i386 allyesconfig   clang-18
i386 buildonly-randconfig-001-20240904   gcc-12
i386 buildonly-randconfig-002-20240904   gcc-12
i386 buildonly-randconfig-003-20240904   gcc-12
i386 buildonly-randconfig-004-20240904   gcc-12
i386 buildonly-randconfig-005-20240904   gcc-12
i386 buildonly-randconfig-006-20240904   gcc-12
i386defconfig   clang-18
i386  randconfig-001-20240904   gcc-12
i386  randconfig-002-20240904   gcc-12
i386  randconfig-004-20240904   gcc-12
i386  randconfig-005-20240904   gcc-12
i386  randconfig-006-20240904   gcc-12
i386  randconfig-011-20240904   gcc-12
i386  randconfig-012-20240904   gcc-12
i386  randconfig-013-20240904   gcc-12
i386  randconfig-014-20240904   gcc-12
i386  randconfig-015-20240904   gcc-12
i386  randconfig-016-20240904   gcc-12
loongarchallmodconfig   gcc-14.1.0
loongarch allnoconfig   gcc-14.1.0
loongarch   defconfig   gcc-14.1.0
m68k allmodconfig   gcc-14.1.0
m68k  allnoconfig   gcc-14.1.0
m68k allyesconfig   gcc-14.1.0
m68kdefconfig   gcc-14.1.0
m68k  multi_defconfig   gcc-14.1.0
microblaze   allmodconfig   gcc-14.1.0
microblazeallnoconfig   gcc-14.1.0
microblaze   allyesconfig   gcc-14.1.0
microblaze  defconfig   gcc-14.1.0
mips  allnoconfig   gcc-14.1.0
mips   gcw0_defconfig   gcc-14.1.0
mips   ip28_defconfig   gcc-14.1.0
mips   jazz_defconfig   gcc-14.1.0
nios2 allnoconfig   gcc-14.1.0
nios2   defconfig   gcc-14.1.0
openrisc  allnoconfig   clang-20
openrisc allyesconfig   gcc-14.1.0
openriscdefconfig   gcc-12
openrisc simple_smp_defconfig   gcc-14.1.0
parisc   allmodconfig   gcc-14.1.0
pariscallnoconfig   clang-20
parisc   allyesconfig   gcc-14.1.0
parisc  defconfig   gcc-12
parisc64defconfig   gcc-14.1.0
powerpc akebono_defconfig   gcc-14.1.0
powerpc  allmodconfig   gcc-14.1.0
powerpc   allnoconfig   clang-20
powerpc  allyesconfig   gcc-14.1.0
powerpc  ep88xc_defconfig   gcc-14.1.0
powerpc  g5_defconfig   gcc-14.1.0
powerpcge_imp3a_defconfig   gcc-14.1.0
powerpc xes_mpc85xx_defconfig   gcc-14.1.0
riscvallmodco

[Intel-wired-lan] [iwl-net v1] iavf: allow changing VLAN state without calling PF

2024-09-04 Thread Michal Swiatkowski
First case:
> ip l a l $VF name vlanx type vlan id 100
> ip l d vlanx
> ip l a l $VF name vlanx type vlan id 100

As workqueue can be execute after sometime, there is a window to have
call trace like that:
- iavf_del_vlan
- iavf_add_vlan
- iavf_del_vlans (wq)

It means that our VLAN 100 will change the state from IAVF_VLAN_ACTIVE
to IAVF_VLAN_REMOVE (iavf_del_vlan). After that in iavf_add_vlan state
won't be changed because VLAN 100 is on the filter list. The final
result is that the VLAN 100 filter isn't added in hardware (no
iavf_add_vlans call).

To fix that change the state if the filter wasn't removed yet directly
to active. It is save as IAVF_VLAN_REMOVE means that virtchnl message
wasn't sent yet.

Second case:
> ip l a l $VF name vlanx type vlan id 100
Any type of VF reset ex. change trust
> ip l s $PF vf $VF_NUM trust on
> ip l d vlanx
> ip l a l $VF name vlanx type vlan id 100

In case of reset iavf driver is responsible for readding all filters
that are being used. To do that all VLAN filters state are changed to
IAVF_VLAN_ADD. Here is even longer window for changing VLAN state from
kernel side, as workqueue isn't called immediately. We can have call
trace like that:

- changing to IAVF_VLAN_ADD (after reset)
- iavf_del_vlan (called from kernel ops)
- iavf_del_vlans (wq)

Not exsisitng VLAN filters will be removed from hardware. It isn't a
bug, ice driver will handle it fine. However, we can have call trace
like that:

- changing to IAVF_VLAN_ADD (after reset)
- iavf_del_vlan (called from kernel ops)
- iavf_add_vlan (called from kernel ops)
- iavf_del_vlans (wq)

With fix for previous case we end up with no VLAN filters in hardware.
We have to remove VLAN filters if the state is IAVF_VLAN_ADD and delete
VLAN was called. It is save as IAVF_VLAN_ADD means that virtchnl message
wasn't sent yet.

Fixes: 0c0da0e95105 ("iavf: refactor VLAN filter states")
Signed-off-by: Michal Swiatkowski 
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c 
b/drivers/net/ethernet/intel/iavf/iavf_main.c
index ff11bafb3b4f..ae5e37eac761 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -773,6 +773,11 @@ iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter 
*adapter,
f->state = IAVF_VLAN_ADD;
adapter->num_vlan_filters++;
iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_ADD_VLAN_FILTER);
+   } else if (f->state == IAVF_VLAN_REMOVE) {
+   /* IAVF_VLAN_REMOVE means that VLAN wasn't yet removed.
+* We can safely only change the state here.
+*/
+   f->state = IAVF_VLAN_ACTIVE;
}
 
 clearout:
@@ -793,8 +798,17 @@ static void iavf_del_vlan(struct iavf_adapter *adapter, 
struct iavf_vlan vlan)
 
f = iavf_find_vlan(adapter, vlan);
if (f) {
-   f->state = IAVF_VLAN_REMOVE;
-   iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_DEL_VLAN_FILTER);
+   /* IAVF_ADD_VLAN means that VLAN wasn't even added yet.
+* Remove it from the list.
+*/
+   if (f->state == IAVF_VLAN_ADD) {
+   list_del(&f->list);
+   kfree(f);
+   adapter->num_vlan_filters--;
+   } else {
+   iavf_schedule_aq_request(adapter,
+IAVF_FLAG_AQ_DEL_VLAN_FILTER);
+   }
}
 
spin_unlock_bh(&adapter->mac_vlan_list_lock);
-- 
2.42.0



Re: [Intel-wired-lan] [PATCH v1 net-next] e1000e: Remove duplicated writel() in e1000_configure_tx/rx()

2024-09-04 Thread Andrew Lunn
On Wed, Sep 04, 2024 at 02:56:46PM +0900, Takamitsu Iwai wrote:
> > So you have confirmed with the datsheet that the write is not needed?
> >
> > As i said, this is a hardware register, not memory. Writes are not
> > always idempotent. It might be necessary to write it twice.
> 
> I have checked following datasheets and I can not find that we need to write
> RDH, RDT, TDH, TDT registers twice at initialization.
> 
> https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/82577-gbe-phy-datasheet.pdf
> https://www.intel.com/content/www/us/en/content-details/613460/intel-82583v-gbe-controller-datasheet.html
> 
> Write happened once before commit 0845d45e900c, so just out of curiosity,
> have you seen such a device?

This is just risk minimisation. I don't want e1000e to be broken
because you removed a write. I'm trying to ensure you fully understand
what you are changing, and have verified it is a safe change. I don't
have this hardware, so i cannot test it.

> My colleague, Kohei, tested the patch with a real hardware and will provide 
> his
> Tested-by shortly.

Please resend the patch, adding his Tested-by: and update the commit
message to summarise this discussion. Explain how you determined this
is safe.

Thanks
Andrew


[Intel-wired-lan] [PATCH iwl-net] ice: fix memleak in ice_init_tx_topology()

2024-09-04 Thread Przemek Kitszel
Fix leak of the FW blob, by not copying it.
ice_cfg_tx_topo() is not changing the passed buffer, but constification
of it is not a -net material, constification patch is mentioned by Link.

This was found by kmemleak, with the following trace for each PF:
[] kmemdup_noprof+0x1d/0x50
[] ice_init_ddp_config+0x100/0x220 [ice]
[] ice_init_dev+0x6f/0x200 [ice]
[] ice_init+0x29/0x560 [ice]
[] ice_probe+0x21d/0x310 [ice]

Link: 
https://lore.kernel.org/intel-wired-lan/20240904093135.8795-2-przemyslaw.kits...@intel.com
Fixes: cc5776fe1832 ("ice: Enable switching default Tx scheduler topology")
Reviewed-by: Larysa Zaremba 
Signed-off-by: Przemek Kitszel 
---
 drivers/net/ethernet/intel/ice/ice_main.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_main.c 
b/drivers/net/ethernet/intel/ice/ice_main.c
index 6f97ed471fe9..71f592dda156 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -4535,16 +4535,10 @@ ice_init_tx_topology(struct ice_hw *hw, const struct 
firmware *firmware)
u8 num_tx_sched_layers = hw->num_tx_sched_layers;
struct ice_pf *pf = hw->back;
struct device *dev;
-   u8 *buf_copy;
int err;
 
dev = ice_pf_to_dev(pf);
-   /* ice_cfg_tx_topo buf argument is not a constant,
-* so we have to make a copy
-*/
-   buf_copy = kmemdup(firmware->data, firmware->size, GFP_KERNEL);
-
-   err = ice_cfg_tx_topo(hw, buf_copy, firmware->size);
+   err = ice_cfg_tx_topo(hw, (void *)firmware->data, firmware->size);
if (!err) {
if (hw->num_tx_sched_layers > num_tx_sched_layers)
dev_info(dev, "Tx scheduling layers switching feature 
disabled\n");

base-commit: 4186c8d9e6af57bab0687b299df10ebd47534a0a
-- 
2.46.0



[Intel-wired-lan] [tnguy-net-queue:100GbE] BUILD SUCCESS 04c7e14e5b0b6227e7b00d7a96ca2f2426ab9171

2024-09-04 Thread kernel test robot
tree/branch: 
https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue.git 100GbE
branch HEAD: 04c7e14e5b0b6227e7b00d7a96ca2f2426ab9171  ice: do not bring the 
VSI up, if it was down before the XDP setup

elapsed time: 1038m

configs tested: 93
configs skipped: 3

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

tested configs:
alpha allnoconfig   gcc-14.1.0
alphaallyesconfig   clang-20
alpha   defconfig   gcc-14.1.0
arc  allmodconfig   clang-20
arc   allnoconfig   gcc-14.1.0
arc  allyesconfig   clang-20
arc defconfig   gcc-14.1.0
arm  allmodconfig   clang-20
arm   allnoconfig   gcc-14.1.0
arm  allyesconfig   clang-20
arm defconfig   gcc-14.1.0
armneponset_defconfig   gcc-14.1.0
arm socfpga_defconfig   gcc-14.1.0
arm64allmodconfig   clang-20
arm64 allnoconfig   gcc-14.1.0
arm64   defconfig   gcc-14.1.0
csky alldefconfig   gcc-14.1.0
csky  allnoconfig   gcc-14.1.0
cskydefconfig   gcc-14.1.0
hexagon  allmodconfig   clang-20
hexagon   allnoconfig   gcc-14.1.0
hexagon  allyesconfig   clang-20
hexagon defconfig   gcc-14.1.0
i386 allmodconfig   clang-18
i386  allnoconfig   clang-18
i386 allyesconfig   clang-18
i386defconfig   clang-18
loongarchallmodconfig   gcc-14.1.0
loongarch allnoconfig   gcc-14.1.0
loongarch   defconfig   gcc-14.1.0
m68k allmodconfig   gcc-14.1.0
m68k  allnoconfig   gcc-14.1.0
m68k allyesconfig   gcc-14.1.0
m68kdefconfig   gcc-14.1.0
m68k  multi_defconfig   gcc-14.1.0
microblaze   allmodconfig   gcc-14.1.0
microblazeallnoconfig   gcc-14.1.0
microblaze   allyesconfig   gcc-14.1.0
microblaze  defconfig   gcc-14.1.0
mips  allnoconfig   gcc-14.1.0
mips   gcw0_defconfig   gcc-14.1.0
mips   ip28_defconfig   gcc-14.1.0
mips   jazz_defconfig   gcc-14.1.0
nios2 allnoconfig   gcc-14.1.0
nios2   defconfig   gcc-14.1.0
openrisc  allnoconfig   clang-20
openrisc allyesconfig   gcc-14.1.0
openriscdefconfig   gcc-12
openrisc simple_smp_defconfig   gcc-14.1.0
parisc   allmodconfig   gcc-14.1.0
pariscallnoconfig   clang-20
parisc   allyesconfig   gcc-14.1.0
parisc  defconfig   gcc-12
parisc64defconfig   gcc-14.1.0
powerpc akebono_defconfig   gcc-14.1.0
powerpc  allmodconfig   gcc-14.1.0
powerpc   allnoconfig   clang-20
powerpc  allyesconfig   gcc-14.1.0
powerpc  ep88xc_defconfig   gcc-14.1.0
powerpc  g5_defconfig   gcc-14.1.0
powerpcge_imp3a_defconfig   gcc-14.1.0
powerpc xes_mpc85xx_defconfig   gcc-14.1.0
riscvallmodconfig   gcc-14.1.0
riscv allnoconfig   clang-20
riscvallyesconfig   gcc-14.1.0
riscv   defconfig   gcc-12
s390 allmodconfig   gcc-14.1.0
s390  allnoconfig   clang-20
s390 allyesconfig   gcc-14.1.0
s390defconfig   gcc-12
s390defconfig   gcc-14.1.0
sh   allmodconfig   gcc-14.1.0
shallnoconfig   gcc-14.1.0
sh   allyesconfig   gcc-14.1.0
sh  defconfig   gcc-12
sh  sdk7786_defconfig   gcc-14.1.0
sh   se7724_defconfig   gcc-14.1.0
sparcallmodconfig   gcc-14.1.0
sparc   sparc32_defconfig   gcc-14.1.0
spar

Re: [Intel-wired-lan] [PATCH iwl-next v5] ice: add E830 HW VF mailbox message limit support

2024-09-04 Thread Romanowski, Rafal
> -Original Message-
> From: Intel-wired-lan  On Behalf Of
> Alexander Lobakin
> Sent: Wednesday, August 21, 2024 3:21 PM
> To: Greenwalt, Paul 
> Cc: pmen...@molgen.mpg.de; intel-wired-...@lists.osuosl.org
> Subject: Re: [Intel-wired-lan] [PATCH iwl-next v5] ice: add E830 HW VF mailbox
> message limit support
> 
> From: Paul Greenwalt 
> Date: Tue, 20 Aug 2024 17:26:16 -0400
> 
> > E830 adds hardware support to prevent the VF from overflowing the PF
> > mailbox with VIRTCHNL messages. E830 will use the hardware feature
> > (ICE_F_MBX_LIMIT) instead of the software solution ice_is_malicious_vf().
> >
> > To prevent a VF from overflowing the PF, the PF sets the number of
> > messages per VF that can be in the PF's mailbox queue
> > (ICE_MBX_OVERFLOW_WATERMARK). When the PF processes a message from
> a
> > VF, the PF decrements the per VF message count using the
> > E830_MBX_VF_DEC_TRIG register.
> >
> > Signed-off-by: Paul Greenwalt 
> 
> Reviewed-by: Alexander Lobakin 
> 
> Thanks,
> Olek


Tested-by: Rafal Romanowski 




Re: [Intel-wired-lan] [PATCH v1 net-next] e1000e: Remove duplicated writel() in e1000_configure_tx/rx()

2024-09-04 Thread Vitaly Lifshits



On 9/4/2024 3:13 PM, Andrew Lunn wrote:

On Wed, Sep 04, 2024 at 02:56:46PM +0900, Takamitsu Iwai wrote:

So you have confirmed with the datsheet that the write is not needed?

As i said, this is a hardware register, not memory. Writes are not
always idempotent. It might be necessary to write it twice.

I have checked following datasheets and I can not find that we need to write
RDH, RDT, TDH, TDT registers twice at initialization.

https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/82577-gbe-phy-datasheet.pdf
https://www.intel.com/content/www/us/en/content-details/613460/intel-82583v-gbe-controller-datasheet.html

Write happened once before commit 0845d45e900c, so just out of curiosity,
have you seen such a device?

This is just risk minimisation. I don't want e1000e to be broken
because you removed a write. I'm trying to ensure you fully understand
what you are changing, and have verified it is a safe change. I don't
have this hardware, so i cannot test it.


My colleague, Kohei, tested the patch with a real hardware and will provide his
Tested-by shortly.

Please resend the patch, adding his Tested-by: and update the commit
message to summarise this discussion. Explain how you determined this
is safe.

Thanks
Andrew



I believe that this patch should not cause any damage, even on old 
hardware, but I would like to test it internally first.




Re: [Intel-wired-lan] [PATCH iwl-next] ice: make ice_cfg_tx_topo() almost const-correct

2024-09-04 Thread Przemek Kitszel

On 9/4/24 11:31, Przemek Kitszel wrote:

Constify ice_cfg_tx_topo() @buf parameter.
This cascades further down to few more functions.

I set the boundary on ice_get_set_tx_topo(), which could not be easily
constified as it is get-or-set, but it's set variant does not change
provided data, the same holds for ice_aqc_opc_set_tx_topo() in particular.
That's why there is (u8 *) cast to loose const prior to entering into AQ
world of const-obliviousness.

Reviewed-by: Larysa Zaremba 
Signed-off-by: Przemek Kitszel 


I've forgot to CC netdev, sorry :F
I think there is no need to repost though.
Original URL (content is quoted entriely here) if it is more helpful
https://lore.kernel.org/intel-wired-lan/20240904093135.8795-2-przemyslaw.kits...@intel.com/

I will make an alias for my git-sent-email invocations ;)


---
  drivers/net/ethernet/intel/ice/ice_ddp.h |  4 +-
  drivers/net/ethernet/intel/ice/ice_ddp.c | 48 
  2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_ddp.h 
b/drivers/net/ethernet/intel/ice/ice_ddp.h
index 97f272317475..79551da2a4b0 100644
--- a/drivers/net/ethernet/intel/ice/ice_ddp.h
+++ b/drivers/net/ethernet/intel/ice/ice_ddp.h
@@ -438,7 +438,7 @@ struct ice_pkg_enum {
u32 buf_idx;
  
  	u32 type;

-   struct ice_buf_hdr *buf;
+   const struct ice_buf_hdr *buf;
u32 sect_idx;
void *sect;
u32 sect_type;
@@ -467,6 +467,6 @@ ice_pkg_enum_entry(struct ice_seg *ice_seg, struct 
ice_pkg_enum *state,
  void *ice_pkg_enum_section(struct ice_seg *ice_seg, struct ice_pkg_enum 
*state,
   u32 sect_type);
  
-int ice_cfg_tx_topo(struct ice_hw *hw, u8 *buf, u32 len);

+int ice_cfg_tx_topo(struct ice_hw *hw, const void *buf, u32 len);
  
  #endif

diff --git a/drivers/net/ethernet/intel/ice/ice_ddp.c 
b/drivers/net/ethernet/intel/ice/ice_ddp.c
index 953262b88a58..f2ac1d265510 100644
--- a/drivers/net/ethernet/intel/ice/ice_ddp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ddp.c
@@ -31,7 +31,7 @@ static const struct ice_tunnel_type_scan tnls[] = {
   * Verifies various attributes of the package file, including length, format
   * version, and the requirement of at least one segment.
   */
-static enum ice_ddp_state ice_verify_pkg(struct ice_pkg_hdr *pkg, u32 len)
+static enum ice_ddp_state ice_verify_pkg(const struct ice_pkg_hdr *pkg, u32 
len)
  {
u32 seg_count;
u32 i;
@@ -57,13 +57,13 @@ static enum ice_ddp_state ice_verify_pkg(struct ice_pkg_hdr 
*pkg, u32 len)
/* all segments must fit within length */
for (i = 0; i < seg_count; i++) {
u32 off = le32_to_cpu(pkg->seg_offset[i]);
-   struct ice_generic_seg_hdr *seg;
+   const struct ice_generic_seg_hdr *seg;
  
  		/* segment header must fit */

if (len < off + sizeof(*seg))
return ICE_DDP_PKG_INVALID_FILE;
  
-		seg = (struct ice_generic_seg_hdr *)((u8 *)pkg + off);

+   seg = (void *)pkg + off;
  
  		/* segment body must fit */

if (len < off + le32_to_cpu(seg->seg_size))
@@ -119,13 +119,13 @@ static enum ice_ddp_state ice_chk_pkg_version(struct 
ice_pkg_ver *pkg_ver)
   *
   * This helper function validates a buffer's header.
   */
-static struct ice_buf_hdr *ice_pkg_val_buf(struct ice_buf *buf)
+static const struct ice_buf_hdr *ice_pkg_val_buf(const struct ice_buf *buf)
  {
-   struct ice_buf_hdr *hdr;
+   const struct ice_buf_hdr *hdr;
u16 section_count;
u16 data_end;
  
-	hdr = (struct ice_buf_hdr *)buf->buf;

+   hdr = (const struct ice_buf_hdr *)buf->buf;
/* verify data */
section_count = le16_to_cpu(hdr->section_count);
if (section_count < ICE_MIN_S_COUNT || section_count > ICE_MAX_S_COUNT)
@@ -165,8 +165,8 @@ static struct ice_buf_table *ice_find_buf_table(struct 
ice_seg *ice_seg)
   * unexpected value has been detected (for example an invalid section count or
   * an invalid buffer end value).
   */
-static struct ice_buf_hdr *ice_pkg_enum_buf(struct ice_seg *ice_seg,
-   struct ice_pkg_enum *state)
+static const struct ice_buf_hdr *ice_pkg_enum_buf(struct ice_seg *ice_seg,
+ struct ice_pkg_enum *state)
  {
if (ice_seg) {
state->buf_table = ice_find_buf_table(ice_seg);
@@ -1800,9 +1800,9 @@ int ice_update_pkg(struct ice_hw *hw, struct ice_buf 
*bufs, u32 count)
   * success it returns a pointer to the segment header, otherwise it will
   * return NULL.
   */
-static struct ice_generic_seg_hdr *
+static const struct ice_generic_seg_hdr *
  ice_find_seg_in_pkg(struct ice_hw *hw, u32 seg_type,
-   struct ice_pkg_hdr *pkg_hdr)
+   const struct ice_pkg_hdr *pkg_hdr)
  {
u32 i;
  
@@ -1813,11 +1813,9 @@ ice_find_seg_in_pkg(struct ice_hw *hw, u32 seg_type,
  
  	/* Search all package

Re: [Intel-wired-lan] [PATCH v4 iwl-next 7/7] ice: Enable 1PPS out from CGU for E825C products

2024-09-04 Thread Pucha, HimasekharX Reddy
> -Original Message-
> From: Intel-wired-lan  On Behalf Of Karol 
> Kolacinski
> Sent: Friday, August 30, 2024 4:37 PM
> To: intel-wired-...@lists.osuosl.org
> Cc: Temerkhanov, Sergey ; 
> net...@vger.kernel.org; Kubalewski, Arkadiusz 
> ; Kolacinski, Karol 
> ; Nguyen, Anthony L ; 
> Simon Horman ; Kitszel, Przemyslaw 
> 
> Subject: [Intel-wired-lan] [PATCH v4 iwl-next 7/7] ice: Enable 1PPS out from 
> CGU for E825C products
>
> From: Sergey Temerkhanov 
>
> Implement configuring 1PPS signal output from CGU. Use maximal amplitude 
> because Linux PTP pin API does not have any way for user to set signal level.
>
> This change is necessary for E825C products to properly output any signal 
> from 1PPS pin.
>
> Reviewed-by: Arkadiusz Kubalewski 
> Signed-off-by: Sergey Temerkhanov 
> Co-developed-by: Karol Kolacinski 
> Signed-off-by: Karol Kolacinski 
> Reviewed-by: Simon Horman 
> ---
> V1 -> V2: Added return value description, renamed the function and
>  enable parameter. Reworded commit message.
>
>  drivers/net/ethernet/intel/ice/ice_ptp.c| 10 +
>  drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 23 +  
> drivers/net/ethernet/intel/ice/ice_ptp_hw.h |  1 +
>  3 files changed, 34 insertions(+)
>

Tested-by: Pucha Himasekhar Reddy  (A 
Contingent worker at Intel)




[Intel-wired-lan] [PATCH v6 net-next 00/15] net: introduce TX H/W shaping API

2024-09-04 Thread Paolo Abeni
We have a plurality of shaping-related drivers API, but none flexible
enough to meet existing demand from vendors[1].

This series introduces new device APIs to configure in a flexible way
TX H/W shaping. The new functionalities are exposed via a newly
defined generic netlink interface and include introspection
capabilities. Some self-tests are included, on top of a dummy
netdevsim implementation. Finally a basic implementation for the iavf
driver is provided.

Some usage examples:

* Configure shaping on a given queue:

./tools/net/ynl/cli.py --spec Documentation/netlink/specs/shaper.yaml \
--do set --json '{"ifindex": '$IFINDEX',
  "shaper": {"handle":
 {"scope": "queue", "id":'$QUEUEID'},
  "bw-max": 200}}'

* Container B/W sharing

The orchestration infrastructure wants to group the 
container-related queues under a RR scheduling and limit the aggregate
bandwidth:

./tools/net/ynl/cli.py --spec Documentation/netlink/specs/shaper.yaml \
--do group --json '{"ifindex": '$IFINDEX',
"leaves": [
  {"handle": {"scope": "queue", "id":'$QID1'},
   "weight": '$W1'}, 
  {"handle": {"scope": "queue", "id":'$QID2'},
   "weight": '$W2'}], 
  {"handle": {"scope": "queue", "id":'$QID3'},
   "weight": '$W3'}], 
"node": {"handle": {"scope":"node"},
 "bw-max": 1000}}'
{'ifindex': $IFINDEX, 'handle': {'scope': 'node', 'id': 0}}

Q1 \
\
Q2 -- node 0 ---  netdev
/ (bw-max: 10M)
Q3 / 

* Delegation

A containers wants to limit the aggregate B/W bandwidth of 2 of the 3
queues it owns - the starting configuration is the one from the
previous point:

SPEC=Documentation/netlink/specs/net_shaper.yaml
./tools/net/ynl/cli.py --spec $SPEC \
--do group --json '{"ifindex": '$IFINDEX',
"leaves": [ 
  {"handle": {"scope": "queue", "id":'$QID1'},
   "weight": '$W1'}, 
  {"handle": {"scope": "queue", "id":'$QID2'},
   "weight": '$W2'}], 
"node": {"handle": {"scope": "node"},
 "bw-max": 500 }}'
{'ifindex': $IFINDEX, 'handle': {'scope': 'node', 'id': 1}}

Q1 -- node 1 \
/ (bw-max: 5M)\
Q2 /   node 0 ---  netdev
  /  (bw-max: 10M)
Q3 --

* Cleanup:

To delete a single queue shaper:

./tools/net/ynl/cli.py --spec $SPEC --do delete --json \
'{"ifindex": '$IFINDEX',
  "handle": {"scope": "queue", "id":'$QID3'}}'

Q1 -- node 1 \
/ (bw-max: 5M)\
Q2 /   node 0 ---  netdev
   (bw-max: 10M)

Deleting a node shaper relinks all its leaves to the node's parent:

./tools/net/ynl/cli.py --spec $SPEC --do delete --json \
'{"ifindex": '$IFINDEX',
  "handle": {"scope": "node", "id":1}}'

Q1 --\
  \
  node 0 ---  netdev
 /  (bw-max: 10M)
Q2 -

Deleting the last shaper under a node shaper deletes the node, too:

./tools/net/ynl/cli.py --spec $SPEC --do delete --json \
'{"ifindex": '$IFINDEX',
  "handle": {"scope": "queue", "id":'$QID1'}}'
./tools/net/ynl/cli.py --spec $SPEC --do delete --json \
'{"ifindex": '$IFINDEX',
  "handle": {"scope": "queue", "id":'$QID2'}}'
./tools/net/ynl/cli.py --spec $SPEC --do get --json \
'{"ifindex": '$IFINDEX',
  "handle": {"scope": "node", "id": 0}}'
Netlink error: No such file or directory
nl_len = 44 (28) nl_flags = 0x300 nl_type = 2
error: -2
extack: {'bad-attr': '.handle'}

[1] https://lore.kernel.org/netdev/20240405102313.ga310...@kernel.org/
---
Changes from v5:
 - handle/shaper unsplit
 - removed 'binding' from NL api
 - several helper renames
 - added rcu protection to shaper pointer
 - implemented value checking into the core
 - handle device channels reconf
 - consolidate NL ctx handling
 - dropped idr allocator, leverage the existing xarray
 - caps names shrinking
 - group() op is optional
 - cap callback can't fail
 - more self-tests

v5: https://lore.kernel.org/netdev/cover.1724944116.git.pab...@redhat.com/

Changes from v4:
 - ops operate on struct binding
 - 'root' -> 'node' rename
 - most core function/helpers operate on 'binding'
 - use NL_SET_BAD_ATTR where possible
 - some code deduplication

v4: https://lore.kernel.org/netdev/cover.1724165948.git.pab...@redhat.com/

Changes from v3:
 - rename
 - locking
 - delete operates on node, too

v3: https://lore.kernel.org/netdev/cover.1722357745.git.pab...@redhat.com/

Changes from RFC v2:
 - added patch 1
 - fixed deprecated API usage

RFC v2: https://lore.kernel.org/netdev/cover.17218519

[Intel-wired-lan] [PATCH v6 net-next 01/15] genetlink: extend info user-storage to match NL cb ctx

2024-09-04 Thread Paolo Abeni
This allows a more uniform implementation of non-dump and dump
operations, and will be used later in the series to avoid some
per-operation allocation.

Additionally rename the NL_ASSERT_DUMP_CTX_FITS macro, to
fit a more extended usage.

Suggested-by: Jakub Kicinski 
Signed-off-by: Paolo Abeni 
---
 drivers/net/vxlan/vxlan_mdb.c| 2 +-
 include/linux/netlink.h  | 5 +++--
 include/net/genetlink.h  | 8 ++--
 net/core/netdev-genl.c   | 2 +-
 net/core/rtnetlink.c | 2 +-
 net/devlink/devl_internal.h  | 2 +-
 net/ethtool/rss.c| 2 +-
 net/netfilter/nf_conntrack_netlink.c | 2 +-
 net/netlink/genetlink.c  | 4 ++--
 9 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/net/vxlan/vxlan_mdb.c b/drivers/net/vxlan/vxlan_mdb.c
index 60eb95a06d55..ebed05a2804c 100644
--- a/drivers/net/vxlan/vxlan_mdb.c
+++ b/drivers/net/vxlan/vxlan_mdb.c
@@ -284,7 +284,7 @@ int vxlan_mdb_dump(struct net_device *dev, struct sk_buff 
*skb,
 
ASSERT_RTNL();
 
-   NL_ASSERT_DUMP_CTX_FITS(struct vxlan_mdb_dump_ctx);
+   NL_ASSERT_CTX_FITS(struct vxlan_mdb_dump_ctx);
 
nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, RTM_NEWMDB, sizeof(*bpm),
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index b332c2048c75..a3ca198a3a9e 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -34,6 +34,7 @@ struct netlink_skb_parms {
 
 #define NETLINK_CB(skb)(*(struct 
netlink_skb_parms*)&((skb)->cb))
 #define NETLINK_CREDS(skb) (&NETLINK_CB((skb)).creds)
+#define NETLINK_CTX_SIZE   48
 
 
 void netlink_table_grab(void);
@@ -293,7 +294,7 @@ struct netlink_callback {
int flags;
boolstrict_check;
union {
-   u8  ctx[48];
+   u8  ctx[NETLINK_CTX_SIZE];
 
/* args is deprecated. Cast a struct over ctx instead
 * for proper type safety.
@@ -302,7 +303,7 @@ struct netlink_callback {
};
 };
 
-#define NL_ASSERT_DUMP_CTX_FITS(type_name) \
+#define NL_ASSERT_CTX_FITS(type_name)  \
BUILD_BUG_ON(sizeof(type_name) >\
 sizeof_field(struct netlink_callback, ctx))
 
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index 9ab49bfeae78..9d3726e8f90e 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -124,7 +124,8 @@ struct genl_family {
  * @genlhdr: generic netlink message header
  * @attrs: netlink attributes
  * @_net: network namespace
- * @user_ptr: user pointers
+ * @ctx: storage space for the use by the family
+ * @user_ptr: user pointers (deprecated, use ctx instead)
  * @extack: extended ACK report struct
  */
 struct genl_info {
@@ -135,7 +136,10 @@ struct genl_info {
struct genlmsghdr * genlhdr;
struct nlattr **attrs;
possible_net_t  _net;
-   void *  user_ptr[2];
+   union {
+   u8  ctx[NETLINK_CTX_SIZE];
+   void *  user_ptr[2];
+   };
struct netlink_ext_ack *extack;
 };
 
diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
index a17d7eaeb001..bb2b9f53ef6b 100644
--- a/net/core/netdev-genl.c
+++ b/net/core/netdev-genl.c
@@ -23,7 +23,7 @@ struct netdev_nl_dump_ctx {
 
 static struct netdev_nl_dump_ctx *netdev_dump_ctx(struct netlink_callback *cb)
 {
-   NL_ASSERT_DUMP_CTX_FITS(struct netdev_nl_dump_ctx);
+   NL_ASSERT_CTX_FITS(struct netdev_nl_dump_ctx);
 
return (struct netdev_nl_dump_ctx *)cb->ctx;
 }
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index f0a520987085..472d1a27cdf8 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -6169,7 +6169,7 @@ static int rtnl_mdb_dump(struct sk_buff *skb, struct 
netlink_callback *cb)
int idx, s_idx;
int err;
 
-   NL_ASSERT_DUMP_CTX_FITS(struct rtnl_mdb_dump_ctx);
+   NL_ASSERT_CTX_FITS(struct rtnl_mdb_dump_ctx);
 
if (cb->strict_check) {
err = rtnl_mdb_valid_dump_req(cb->nlh, cb->extack);
diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h
index c7a8e13f917c..a9f064ab9ed9 100644
--- a/net/devlink/devl_internal.h
+++ b/net/devlink/devl_internal.h
@@ -166,7 +166,7 @@ int devlink_nl_dumpit(struct sk_buff *msg, struct 
netlink_callback *cb,
 static inline struct devlink_nl_dump_state *
 devlink_dump_state(struct netlink_callback *cb)
 {
-   NL_ASSERT_DUMP_CTX_FITS(struct devlink_nl_dump_state);
+   NL_ASSERT_CTX_FITS(struct devlink_nl_dump_state);
 
return (struct devlink_nl_dump_state *)cb->ctx;
 }
diff --git a/net/ethtool/rss.c b/net/ethtool/rss.c
index e07386275e14..7cb106b590ab 100644
--- a/net/ethtool/rss.c
+++ b/net/ethtool/rss.c
@@ 

[Intel-wired-lan] [PATCH v6 net-next 02/15] netlink: spec: add shaper YAML spec

2024-09-04 Thread Paolo Abeni
Define the user-space visible interface to query, configure and delete
network shapers via yaml definition.

Add dummy implementations for the relevant NL callbacks.

set() and delete() operations touch a single shaper creating/updating or
deleting it.
The group() operation creates a shaper's group, nesting multiple input
shapers under the specified output shaper.

Signed-off-by: Paolo Abeni 
---
v5 -> v6:
 - moved back ifindex out of binding attr, drop the latter
 - restrict leaves attributes to scheduling-related ones
v4 -> v5:
 - moved ifindex under the binding attr
 - moved id, scope to new attr set
 - rename 'root' as 'node'
 - deleted unused 'info' subset
 - a lot of doc update and fixup
 - removed empty black line at MAKEFILE eof
v3 -> v4:
 - spec file rename
 - always use '@' for references
 - detached scope -> node scope
 - inputs/output -> leaves/root
 - deduplicate leaves/root policy
 - get/dump/group return ifindex, too
 - added some general introduction to the doc
RFC v1 -> RFC v2:
 - u64 -> uint
 - net_shapers -> net-shapers
 - documented all the attributes
 - dropped [ admin-perm ] for get() op
 - group op
 - set/delete touch a single shaper
---
 Documentation/netlink/specs/net_shaper.yaml | 313 
 MAINTAINERS |   1 +
 include/uapi/linux/net_shaper.h |  80 +
 net/Kconfig |   3 +
 net/Makefile|   1 +
 net/shaper/Makefile |   8 +
 net/shaper/shaper.c |  55 
 net/shaper/shaper_nl_gen.c  | 133 +
 net/shaper/shaper_nl_gen.h  |  36 +++
 9 files changed, 630 insertions(+)
 create mode 100644 Documentation/netlink/specs/net_shaper.yaml
 create mode 100644 include/uapi/linux/net_shaper.h
 create mode 100644 net/shaper/Makefile
 create mode 100644 net/shaper/shaper.c
 create mode 100644 net/shaper/shaper_nl_gen.c
 create mode 100644 net/shaper/shaper_nl_gen.h

diff --git a/Documentation/netlink/specs/net_shaper.yaml 
b/Documentation/netlink/specs/net_shaper.yaml
new file mode 100644
index ..1820578743c1
--- /dev/null
+++ b/Documentation/netlink/specs/net_shaper.yaml
@@ -0,0 +1,313 @@
+# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
+
+name: net-shaper
+
+doc: |
+  Networking HW rate limiting configuration.
+
+  This API allows configuring HW shapers available on the network
+  devices at different levels (queues, network device) and allows
+  arbitrary manipulation of the scheduling tree of the involved
+  shapers.
+
+  Each @shaper is identified within the given device, by an @handle,
+  comprising both a @scope and an @id.
+
+  Depending on the @scope value, the shapers are attached to specific
+  HW objects (queues, devices) or, for @node scope, represent a
+  scheduling group, that can be placed in an arbitrary location of
+  the scheduling tree.
+
+  Shapers can be created with two different operations: the @set
+  operation, to create and update a single "attached" shaper, and
+  the @group operation, to create and update a scheduling
+  group. Only the @group operation can create @node scope shapers
+
+  Existing shapers can be deleted /reset via the @delete operation.
+
+  The user can query the running configuration via the @get operation.
+
+definitions:
+  -
+type: enum
+name: scope
+doc: Defines the shaper @id interpretation.
+render-max: true
+entries:
+  - name: unspec
+doc: The scope is not specified.
+  -
+name: netdev
+doc: The main shaper for the given network device.
+  -
+name: queue
+doc: |
+The shaper is attached to the given device queue,
+the @id represents the queue number.
+  -
+name: node
+doc: |
+ The shaper allows grouping of queues or other
+ node shapers; can be nested in either @netdev
+ shapers or other @node shapers, allowing placement
+ in any location of the scheduling tree, except
+ leaves and root.
+  -
+type: enum
+name: metric
+doc: Different metric supported by the shaper.
+entries:
+  -
+name: bps
+doc: Shaper operates on a bits per second basis.
+  -
+name: pps
+doc: Shaper operates on a packets per second basis.
+
+attribute-sets:
+  -
+name: net-shaper
+attributes:
+  -
+name: handle
+type: nest
+nested-attributes: handle
+doc: Unique identifier for the given shaper inside the owning device.
+  -
+name: metric
+type: u32
+enum: metric
+doc: Metric used by the given shaper for bw-min, bw-max and burst.
+  -
+name: bw-min
+type: uint
+doc: Minimum Guaranteed bandwidth for the given shaper.
+  -
+name: bw-max
+type: uint
+doc: Maximum ban

[Intel-wired-lan] [PATCH v6 net-next 03/15] net-shapers: implement NL get operation

2024-09-04 Thread Paolo Abeni
Introduce the basic infrastructure to implement the net-shaper
core functionality. Each network devices carries a net-shaper cache,
the NL get() operation fetches the data from such cache.

The cache is initially empty, will be fill by the set()/group()
operation implemented later and is destroyed at device cleanup time.

The net_shaper_fill_handle(), net_shaper_ctx_init(), and
net_shaper_generic_pre() implementations handle generic index type
attributes, despite the current caller always pass a constant value
to avoid more noise in later patches using them with different
attributes.

Signed-off-by: Paolo Abeni 
---
v5 -> v6:
 - move shaper lock into dev
 - add rcu protection to shaper get/dump
 - net_shaper_cache_lookup -> net_shaper_lookup
 - net_shaper_ctx_init -> net_shaper_ctx_setup
 - net_shaper_info -> net_shaper
 - net_shaper_data -> net_shaper_hierarcy
 - use NL_REQ_ATTR_CHECK where possible
 - nla_nest_start_noflag -> nla_parse_nested
 - consolidate ctx usage
 - capabilities() op returns void

v4 -> v5:
 - ops operate on struct binding
 - replace net_device * with binding* in most helpers
 - include 'ifindex' in get/dump output
 - use dev_tracker for real
 - user pre/post for dump op, too
 - use NL_SET_BAD_ATTR where applicable
 - drop redundant/useless kdoc documentation
 - add type arg to net_shaper_ctx_init() (moved from later patch)
 - factor out generic pre/post helper for later usage in the series
 - remove unneeded forward declaration from netdevice.h
 - dropped 'inline' modifier in .c file
 - dropped black line at net_shaper.h EoF

v3 -> v4:
 - add scope prefix
 - use forward declaration in the include
 - move the handle out of shaper_info

RFC v2 -> RFC v3:
 - dev_put() -> netdev_put()
---
 Documentation/networking/kapi.rst |   3 +
 include/linux/netdevice.h |  21 ++
 include/net/net_shaper.h  | 120 +++
 net/core/dev.c|   6 +
 net/core/dev.h|   6 +
 net/shaper/shaper.c   | 341 +-
 6 files changed, 490 insertions(+), 7 deletions(-)
 create mode 100644 include/net/net_shaper.h

diff --git a/Documentation/networking/kapi.rst 
b/Documentation/networking/kapi.rst
index ea55f462cefa..98682b9a13ee 100644
--- a/Documentation/networking/kapi.rst
+++ b/Documentation/networking/kapi.rst
@@ -104,6 +104,9 @@ Driver Support
 .. kernel-doc:: include/linux/netdevice.h
:internal:
 
+.. kernel-doc:: include/net/net_shaper.h
+   :internal:
+
 PHY Support
 ---
 
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index ca5f0dda733b..9168449a51bd 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1603,6 +1603,14 @@ struct net_device_ops {
int (*ndo_hwtstamp_set)(struct net_device *dev,
struct 
kernel_hwtstamp_config *kernel_config,
struct netlink_ext_ack 
*extack);
+
+#if IS_ENABLED(CONFIG_NET_SHAPER)
+   /**
+* @net_shaper_ops: Device shaping offload operations
+* see include/net/net_shapers.h
+*/
+   const struct net_shaper_ops *net_shaper_ops;
+#endif
 };
 
 /**
@@ -2399,6 +2407,19 @@ struct net_device {
/** @irq_moder: dim parameters used if IS_ENABLED(CONFIG_DIMLIB). */
struct dim_irq_moder*irq_moder;
 
+   /**
+* @lock: protects @net_shaper_hierarchy, feel free to use for other
+* netdev-scope protection. Ordering: take after rtnl_lock.
+*/
+   struct mutexlock;
+
+#if IS_ENABLED(CONFIG_NET_SHAPER)
+   /**
+* @net_shaper_hierarchy: data tracking the current shaper status
+*  see include/net/net_shapers.h
+*/
+   struct net_shaper_hierarchy *net_shaper_hierarchy;
+#endif
u8  priv[] cacheline_aligned
   __counted_by(priv_len);
 } cacheline_aligned;
diff --git a/include/net/net_shaper.h b/include/net/net_shaper.h
new file mode 100644
index ..5c3f49b52fe9
--- /dev/null
+++ b/include/net/net_shaper.h
@@ -0,0 +1,120 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef _NET_SHAPER_H_
+#define _NET_SHAPER_H_
+
+#include 
+
+#include 
+
+struct net_device;
+struct devlink;
+struct netlink_ext_ack;
+
+enum net_shaper_binding_type {
+   NET_SHAPER_BINDING_TYPE_NETDEV,
+   /* NET_SHAPER_BINDING_TYPE_DEVLINK_PORT */
+};
+
+struct net_shaper_binding {
+   enum net_shaper_binding_type type;
+   union {
+   struct net_device *netdev;
+   struct devlink *devlink;
+   };
+};
+
+struct net_shaper_handle {
+   enum net_shaper_scope scope;
+   u32 id;
+};
+
+/**
+ * struct net_shaper - represents a shaping node on the NIC H/W
+ * zeroed field are considered not set.
+ * @parent: Unique identifier for the shaper parent, usually implied
+ * @handle: Unique identifier for thi

[Intel-wired-lan] [PATCH v6 net-next 04/15] net-shapers: implement NL set and delete operations

2024-09-04 Thread Paolo Abeni
Both NL operations directly map on the homonymous device shaper
callbacks, update accordingly the shapers cache and are serialized
via a per device lock.
Implement the cache modification helpers to additionally deal with
NODE scope shaper. That will be needed by the group() operation
implemented in the next patch.
The delete implementation is partial: does not handle NODE scope
shaper yet. Such support will require infrastructure from
the next patch and will be implemented later in the series.

Signed-off-by: Paolo Abeni 
---
v5 -> v6:
 - use xa_alloc() instead idr
 - rcu protection on shaper free
 - drop NL_SET_ERR_MSG() on allocation failures
 - net_shaper_cache_init() -> net_shaper_hierarchy_setup()
 - net_shaper_cache_{pre_insert,commit} -> net_shaper_{pre_insert,commit}
 - fix BAD_ADDR handle in net_shaper_parse_info()

v4 -> v5:
 - replace net_device * with binding* in most helpers
 - move check for scope NONE handle at parse time and leverage
   NL_SET_BAD_ATTR()
 - move the default parent initialization to net_shaper_parse_info_nest()

v3 -> v4:
 - add locking
 - helper rename

RFC v2 -> RFC v3:
 - dev_put() -> netdev_put()
---
 net/shaper/shaper.c | 403 +++-
 1 file changed, 401 insertions(+), 2 deletions(-)

diff --git a/net/shaper/shaper.c b/net/shaper/shaper.c
index 2d72f9112f23..8d6f3c5829b0 100644
--- a/net/shaper/shaper.c
+++ b/net/shaper/shaper.c
@@ -36,6 +36,24 @@ static struct net_shaper_binding 
*net_shaper_binding_from_ctx(void *ctx)
return &((struct net_shaper_nl_ctx *)ctx)->binding;
 }
 
+static void net_shaper_lock(struct net_shaper_binding *binding)
+{
+   switch (binding->type) {
+   case NET_SHAPER_BINDING_TYPE_NETDEV:
+   mutex_lock(&binding->netdev->lock);
+   break;
+   }
+}
+
+static void net_shaper_unlock(struct net_shaper_binding *binding)
+{
+   switch (binding->type) {
+   case NET_SHAPER_BINDING_TYPE_NETDEV:
+   mutex_unlock(&binding->netdev->lock);
+   break;
+   }
+}
+
 static struct net_shaper_hierarchy *
 net_shaper_hierarchy(struct net_shaper_binding *binding)
 {
@@ -47,6 +65,16 @@ net_shaper_hierarchy(struct net_shaper_binding *binding)
return NULL;
 }
 
+static const struct net_shaper_ops *
+net_shaper_ops(struct net_shaper_binding *binding)
+{
+   if (binding->type == NET_SHAPER_BINDING_TYPE_NETDEV)
+   return binding->netdev->netdev_ops->net_shaper_ops;
+
+   /* No other type supported yet. */
+   return NULL;
+}
+
 static int net_shaper_fill_binding(struct sk_buff *msg,
   const struct net_shaper_binding *binding,
   u32 type)
@@ -171,6 +199,37 @@ static u32 net_shaper_handle_to_index(const struct 
net_shaper_handle *handle)
FIELD_PREP(NET_SHAPER_ID_MASK, handle->id);
 }
 
+static void net_shaper_index_to_handle(u32 index,
+  struct net_shaper_handle *handle)
+{
+   handle->scope = FIELD_GET(NET_SHAPER_SCOPE_MASK, index);
+   handle->id = FIELD_GET(NET_SHAPER_ID_MASK, index);
+}
+
+static void net_shaper_default_parent(const struct net_shaper_handle *handle,
+ struct net_shaper_handle *parent)
+{
+   switch (handle->scope) {
+   case NET_SHAPER_SCOPE_UNSPEC:
+   case NET_SHAPER_SCOPE_NETDEV:
+   case __NET_SHAPER_SCOPE_MAX:
+   parent->scope = NET_SHAPER_SCOPE_UNSPEC;
+   break;
+
+   case NET_SHAPER_SCOPE_QUEUE:
+   case NET_SHAPER_SCOPE_NODE:
+   parent->scope = NET_SHAPER_SCOPE_NETDEV;
+   break;
+   }
+   parent->id = 0;
+}
+
+/*
+ * MARK_0 is already in use due to XA_FLAGS_ALLOC, can't reuse such flag as
+ * it's cleared by xa_store().
+ */
+#define NET_SHAPER_NOT_VALID XA_MARK_1
+
 static struct net_shaper *
 net_shaper_lookup(struct net_shaper_binding *binding,
  const struct net_shaper_handle *handle)
@@ -179,6 +238,135 @@ net_shaper_lookup(struct net_shaper_binding *binding,
u32 index = net_shaper_handle_to_index(handle);
 
return hierarchy ? xa_load(&hierarchy->shapers, index) : NULL;
+   if (!hierarchy || xa_get_mark(&hierarchy->shapers, index,
+ NET_SHAPER_NOT_VALID))
+   return NULL;
+
+   return xa_load(&hierarchy->shapers, index);
+}
+
+/* Allocate on demand the per device shaper's hierarchy container.
+ * Called under the net shaper lock
+ */
+static struct net_shaper_hierarchy *
+net_shaper_hierarchy_setup(struct net_shaper_binding *binding)
+{
+   struct net_shaper_hierarchy *hierarchy = net_shaper_hierarchy(binding);
+
+   if (hierarchy)
+   return hierarchy;
+
+   hierarchy = kmalloc(sizeof(*hierarchy), GFP_KERNEL);
+   if (!hierarchy)
+   return NULL;
+
+   /* The flag is required for ID allocation */
+   xa_init_flags(&hie

[Intel-wired-lan] [PATCH v6 net-next 05/15] net-shapers: implement NL group operation

2024-09-04 Thread Paolo Abeni
Allow grouping multiple leaves shaper under the given root.
The node and the leaves shapers are created, if needed, otherwise
the existing shapers are re-linked as requested.

Try hard to pre-allocated the needed resources, to avoid non
trivial H/W configuration rollbacks in case of any failure.

Signed-off-by: Paolo Abeni 
---
v5 -> v6:
 - pre-allocate msg in net_shaper_nl_group_doit()
 - factor out handle_cmp() and parent_from_leaves() helpers
 - driver group() implementation is optional
 - move the 0 leaves check earlier
 - net_shaper_cache_rollback ->net_shaper_rollback
 - report the failure on reply generation error (no rollback)
 - several net_shaper_group_send_reply() fixup

v4 -> v5:
 - replace net_device* with binding* in most helpers
 - factor out net_shaper_fill_binding() helper for re-use in later patch
 - move most sanity check at parse time and use NL_SET_BAD_ATTR
 - reused net_shaper_fill_handle() in net_shaper_group_send_reply()
   instead of open-coding it.

v3 -> v4:
 - cleanup left-over scope node shaper after re-link, as needed
 - add locking
 - separate arguments for shaper handle

RFC v2 -> RFC v3:
 - dev_put() -> netdev_put()
---
 net/shaper/shaper.c | 367 +++-
 1 file changed, 366 insertions(+), 1 deletion(-)

diff --git a/net/shaper/shaper.c b/net/shaper/shaper.c
index 8d6f3c5829b0..c409acbe768c 100644
--- a/net/shaper/shaper.c
+++ b/net/shaper/shaper.c
@@ -75,6 +75,24 @@ net_shaper_ops(struct net_shaper_binding *binding)
return NULL;
 }
 
+/* Count the number of [multi] attributes of the given type. */
+static int net_shaper_list_len(struct genl_info *info, int type)
+{
+   struct nlattr *attr;
+   int rem, cnt = 0;
+
+   nla_for_each_attr_type(attr, type, genlmsg_data(info->genlhdr),
+  genlmsg_len(info->genlhdr), rem)
+   cnt++;
+   return cnt;
+}
+
+static int net_shaper_handle_size(void)
+{
+   return nla_total_size(nla_total_size(sizeof(u32)) +
+ nla_total_size(sizeof(u32)));
+}
+
 static int net_shaper_fill_binding(struct sk_buff *msg,
   const struct net_shaper_binding *binding,
   u32 type)
@@ -369,6 +387,25 @@ static void net_shaper_commit(struct net_shaper_binding 
*binding,
xa_unlock(&hierarchy->shapers);
 }
 
+/* Rollback all the tentative inserts from the data container. */
+static void net_shaper_rollback(struct net_shaper_binding *binding)
+{
+   struct net_shaper_hierarchy *hierarchy = net_shaper_hierarchy(binding);
+   struct net_shaper *cur;
+   unsigned long index;
+
+   if (!hierarchy)
+   return;
+
+   xa_lock(&hierarchy->shapers);
+   xa_for_each_marked(&hierarchy->shapers, index, cur,
+  NET_SHAPER_NOT_VALID) {
+   __xa_erase(&hierarchy->shapers, index);
+   kfree(cur);
+   }
+   xa_unlock(&hierarchy->shapers);
+}
+
 static int net_shaper_parse_handle(const struct nlattr *attr,
   const struct genl_info *info,
   struct net_shaper_handle *handle)
@@ -463,6 +500,7 @@ static int net_shaper_parse_info(struct net_shaper_binding 
*binding,
 static int net_shaper_parse_info_nest(struct net_shaper_binding *binding,
  const struct nlattr *attr,
  const struct genl_info *info,
+ const struct net_shaper *node,
  struct net_shaper *shaper)
 {
struct nlattr *tb[NET_SHAPER_A_WEIGHT + 1];
@@ -478,11 +516,59 @@ static int net_shaper_parse_info_nest(struct 
net_shaper_binding *binding,
if (ret < 0)
return ret;
 
+   if (node && shaper->handle.scope != NET_SHAPER_SCOPE_QUEUE) {
+   NL_SET_BAD_ATTR(info->extack, tb[NET_SHAPER_A_HANDLE]);
+   return -EINVAL;
+   }
+
if (!exists)
net_shaper_default_parent(&shaper->handle, &shaper->parent);
return 0;
 }
 
+/* Alike net_parse_shaper_info(), but additionally allow the user specifying
+ * the shaper's parent handle.
+ */
+static int net_shaper_parse_node(struct net_shaper_binding *binding,
+const struct nlattr *attr,
+const struct genl_info *info,
+struct net_shaper *shaper)
+{
+   struct nlattr *tb[NET_SHAPER_A_PARENT + 1];
+   bool exists;
+   int ret;
+
+   ret = nla_parse_nested(tb, NET_SHAPER_A_PARENT, attr,
+  net_shaper_node_info_nl_policy,
+  info->extack);
+   if (ret < 0)
+   return ret;
+
+   ret = net_shaper_parse_info(binding, tb, info, shaper, &exists);
+   if (ret)
+   return ret;
+
+   if (shaper->handle.scope != NET_SH

[Intel-wired-lan] [PATCH v6 net-next 06/15] net-shapers: implement delete support for NODE scope shaper

2024-09-04 Thread Paolo Abeni
Leverage the previously introduced group operation to implement
the removal of NODE scope shaper, re-linking its leaves under the
the parent node before actually deleting the specified NODE scope
shaper.

Signed-off-by: Paolo Abeni 
---
v4 -> v5:
 - replace net_device* with binding* in most helpers
---
 net/shaper/shaper.c | 87 ++---
 1 file changed, 75 insertions(+), 12 deletions(-)

diff --git a/net/shaper/shaper.c b/net/shaper/shaper.c
index c409acbe768c..1255d532b36a 100644
--- a/net/shaper/shaper.c
+++ b/net/shaper/shaper.c
@@ -804,7 +804,8 @@ static int net_shaper_parent_from_leaves(int leaves_count,
 }
 
 static int __net_shaper_group(struct net_shaper_binding *binding,
- int leaves_count, struct net_shaper *leaves,
+ bool update_node, int leaves_count,
+ struct net_shaper *leaves,
  struct net_shaper *node,
  struct netlink_ext_ack *extack)
 {
@@ -848,12 +849,14 @@ static int __net_shaper_group(struct net_shaper_binding 
*binding,
}
}
 
-   /* For newly created node scope shaper, the following will update
-* the handle, due to id allocation.
-*/
-   ret = net_shaper_pre_insert(binding, &node->handle, extack);
-   if (ret)
-   return ret;
+   if (update_node) {
+   /* For newly created node scope shaper, the following will
+* update the handle, due to id allocation.
+*/
+   ret = net_shaper_pre_insert(binding, &node->handle, extack);
+   if (ret)
+   return ret;
+   }
 
for (i = 0; i < leaves_count; ++i) {
leaf_handle = leaves[i].handle;
@@ -878,7 +881,8 @@ static int __net_shaper_group(struct net_shaper_binding 
*binding,
 
if (parent)
parent->leaves++;
-   net_shaper_commit(binding, 1, node);
+   if (update_node)
+   net_shaper_commit(binding, 1, node);
net_shaper_commit(binding, leaves_count, leaves);
return 0;
 
@@ -887,6 +891,64 @@ static int __net_shaper_group(struct net_shaper_binding 
*binding,
return ret;
 }
 
+static int net_shaper_pre_del_node(struct net_shaper_binding *binding,
+  const struct net_shaper *shaper,
+  struct netlink_ext_ack *extack)
+{
+   struct net_shaper_hierarchy *hierarchy = net_shaper_hierarchy(binding);
+   struct net_shaper *cur, *leaves, node = {};
+   int ret, leaves_count = 0;
+   unsigned long index;
+   bool update_node;
+
+   if (!shaper->leaves)
+   return 0;
+
+   /* Fetch the new node information. */
+   node.handle = shaper->parent;
+   cur = net_shaper_lookup(binding, &node.handle);
+   if (cur) {
+   node = *cur;
+   } else {
+   /* A scope NODE shaper can be nested only to the NETDEV scope
+* shaper without creating the latter, this check may fail only
+* if the data is in inconsistent status.
+*/
+   if (WARN_ON_ONCE(node.handle.scope != NET_SHAPER_SCOPE_NETDEV))
+   return -EINVAL;
+   }
+
+   leaves = kcalloc(shaper->leaves, sizeof(struct net_shaper),
+GFP_KERNEL);
+   if (!leaves)
+   return -ENOMEM;
+
+   /* Build the leaves arrays. */
+   xa_for_each(&hierarchy->shapers, index, cur) {
+   if (net_shaper_handle_cmp(&cur->parent, &shaper->handle))
+   continue;
+
+   if (WARN_ON_ONCE(leaves_count == shaper->leaves)) {
+   ret = -EINVAL;
+   goto free;
+   }
+
+   leaves[leaves_count++] = *cur;
+   }
+
+   /* When re-linking to the netdev shaper, avoid the eventual, implicit,
+* creation of the new node, would be surprising since the user is
+* doing a delete operation.
+*/
+   update_node = node.handle.scope != NET_SHAPER_SCOPE_NETDEV;
+   ret = __net_shaper_group(binding, update_node, leaves_count,
+leaves, &node, extack);
+
+free:
+   kfree(leaves);
+   return ret;
+}
+
 static int net_shaper_delete(struct net_shaper_binding *binding,
 const struct net_shaper_handle *handle,
 struct netlink_ext_ack *extack)
@@ -910,9 +972,9 @@ static int net_shaper_delete(struct net_shaper_binding 
*binding,
}
 
if (handle->scope == NET_SHAPER_SCOPE_NODE) {
-   /* TODO: implement support for scope NODE delete. */
-   ret = -EINVAL;
-   goto unlock;
+   ret = net_shaper_pre_del_node(binding, shaper, extack);
+   if (ret)
+   goto un

[Intel-wired-lan] [PATCH v6 net-next 07/15] net-shapers: implement shaper cleanup on queue deletion

2024-09-04 Thread Paolo Abeni
hook into netif_set_real_num_tx_queues() to cleanup any shaper
configured on top of the to-be-destroyed TX queues.

Signed-off-by: Paolo Abeni 
---
 net/core/dev.c  |  2 ++
 net/core/dev.h  |  4 
 net/shaper/shaper.c | 31 +++
 3 files changed, 37 insertions(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index 8615f16e8456..33629a9d0661 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2948,6 +2948,8 @@ int netif_set_real_num_tx_queues(struct net_device *dev, 
unsigned int txq)
if (dev->num_tc)
netif_setup_tc(dev, txq);
 
+   net_shaper_set_real_num_tx_queues(dev, txq);
+
dev_qdisc_change_real_num_tx(dev, txq);
 
dev->real_num_tx_queues = txq;
diff --git a/net/core/dev.h b/net/core/dev.h
index 13c558874af3..d3ea92949ff3 100644
--- a/net/core/dev.h
+++ b/net/core/dev.h
@@ -37,8 +37,12 @@ void dev_addr_check(struct net_device *dev);
 
 #if IS_ENABLED(CONFIG_NET_SHAPER)
 void net_shaper_flush_netdev(struct net_device *dev);
+void net_shaper_set_real_num_tx_queues(struct net_device *dev,
+  unsigned int txq);
 #else
 static inline void net_shaper_flush_netdev(struct net_device *dev) {}
+static inline void net_shaper_set_real_num_tx_queues(struct net_device *dev,
+unsigned int txq) {}
 #endif
 
 /* sysctls not referred to from outside net/core/ */
diff --git a/net/shaper/shaper.c b/net/shaper/shaper.c
index 1255d532b36a..f6f5712d7b3c 100644
--- a/net/shaper/shaper.c
+++ b/net/shaper/shaper.c
@@ -1201,6 +1201,37 @@ void net_shaper_flush_netdev(struct net_device *dev)
net_shaper_flush(&binding);
 }
 
+void net_shaper_set_real_num_tx_queues(struct net_device *dev,
+  unsigned int txq)
+{
+   struct net_shaper_hierarchy *hierarchy;
+   struct net_shaper_binding binding;
+   int i;
+
+   binding.type = NET_SHAPER_BINDING_TYPE_NETDEV;
+   binding.netdev = dev;
+   hierarchy = net_shaper_hierarchy(&binding);
+   if (!hierarchy)
+   return;
+
+   net_shaper_lock(&binding);
+
+   /* Take action only when decreasing the tx queue number. */
+   for (i = txq; i < dev->real_num_tx_queues; ++i) {
+   struct net_shaper_handle handle;
+   struct net_shaper *shaper;
+
+   handle.scope = NET_SHAPER_SCOPE_QUEUE;
+   handle.id = i;
+   shaper = net_shaper_lookup(&binding, &handle);
+   if (!shaper)
+   continue;
+
+   __net_shaper_delete(&binding, shaper, NULL);
+   }
+   net_shaper_unlock(&binding);
+}
+
 static int __init shaper_init(void)
 {
return genl_register_family(&net_shaper_nl_family);
-- 
2.45.2



[Intel-wired-lan] [PATCH v6 net-next 08/15] netlink: spec: add shaper introspection support

2024-09-04 Thread Paolo Abeni
Allow the user-space to fine-grain query the shaping features
supported by the NIC on each domain.

Signed-off-by: Paolo Abeni 
---
v5 -> v6:
 - shorter cap-related names

v4 -> v5:
 - added pre/post helpers for dump op
---
 Documentation/netlink/specs/net_shaper.yaml | 88 +
 include/uapi/linux/net_shaper.h | 17 
 net/shaper/shaper.c | 32 
 net/shaper/shaper_nl_gen.c  | 29 +++
 net/shaper/shaper_nl_gen.h  | 10 +++
 5 files changed, 176 insertions(+)

diff --git a/Documentation/netlink/specs/net_shaper.yaml 
b/Documentation/netlink/specs/net_shaper.yaml
index 1820578743c1..b93cf1fa3928 100644
--- a/Documentation/netlink/specs/net_shaper.yaml
+++ b/Documentation/netlink/specs/net_shaper.yaml
@@ -27,6 +27,11 @@ doc: |
 
   The user can query the running configuration via the @get operation.
 
+  Different devices can provide different feature sets, e.g. with no
+  support for complex scheduling hierarchy, or for some shaping
+  parameters. The user can introspect the HW capabilities via the
+  @cap-get operation.
+
 definitions:
   -
 type: enum
@@ -201,6 +206,53 @@ attribute-sets:
 name: priority
   -
 name: weight
+  -
+name: caps
+attributes:
+  -
+name: ifindex
+type: u32
+doc: Interface index queried for shapers capabilities.
+  -
+name: scope
+type: u32
+enum: scope
+doc: The scope to which the queried capabilities apply.
+  -
+name: support-metric-bps
+type: flag
+doc: The device accepts 'bps' metric for bw-min, bw-max and burst.
+  -
+name: support-metric-pps
+type: flag
+doc: The device accepts 'pps' metric for bw-min, bw-max and burst.
+  -
+name: support-nesting
+type: flag
+doc: |
+  The device supports nesting shaper belonging to this scope
+  below 'node' scoped shapers. Only 'queue' and 'node'
+  scope can have flag 'support-nesting'.
+  -
+name: support-bw-min
+type: flag
+doc: The device supports a minimum guaranteed B/W.
+  -
+name: support-bw-max
+type: flag
+doc: The device supports maximum B/W shaping.
+  -
+name: support-burst
+type: flag
+doc: The device supports a maximum burst size.
+  -
+name: support-priority
+type: flag
+doc: The device supports priority scheduling.
+  -
+name: support-weight
+type: flag
+doc: The device supports weighted round robin scheduling.
 
 operations:
   list:
@@ -311,3 +363,39 @@ operations:
 - node
 reply:
   attributes: *ns-binding
+
+-
+  name: cap-get
+  doc: |
+Get the shaper capabilities supported by the given device
+for the specified scope.
+  attribute-set: caps
+
+  do:
+pre: net-shaper-nl-cap-pre-doit
+post: net-shaper-nl-cap-post-doit
+request:
+  attributes:
+- ifindex
+- scope
+reply:
+  attributes: &cap-attrs
+- ifindex
+- scope
+- support-metric-bps
+- support-metric-pps
+- support-nesting
+- support-bw-min
+- support-bw-max
+- support-burst
+- support-priority
+- support-weight
+
+  dump:
+pre: net-shaper-nl-cap-pre-dumpit
+post: net-shaper-nl-cap-post-dumpit
+request:
+  attributes:
+- ifindex
+reply:
+  attributes: *cap-attrs
diff --git a/include/uapi/linux/net_shaper.h b/include/uapi/linux/net_shaper.h
index 03c774a2bec1..ff82c00bc305 100644
--- a/include/uapi/linux/net_shaper.h
+++ b/include/uapi/linux/net_shaper.h
@@ -67,11 +67,28 @@ enum {
NET_SHAPER_A_HANDLE_MAX = (__NET_SHAPER_A_HANDLE_MAX - 1)
 };
 
+enum {
+   NET_SHAPER_A_CAPS_IFINDEX = 1,
+   NET_SHAPER_A_CAPS_SCOPE,
+   NET_SHAPER_A_CAPS_SUPPORT_METRIC_BPS,
+   NET_SHAPER_A_CAPS_SUPPORT_METRIC_PPS,
+   NET_SHAPER_A_CAPS_SUPPORT_NESTING,
+   NET_SHAPER_A_CAPS_SUPPORT_BW_MIN,
+   NET_SHAPER_A_CAPS_SUPPORT_BW_MAX,
+   NET_SHAPER_A_CAPS_SUPPORT_BURST,
+   NET_SHAPER_A_CAPS_SUPPORT_PRIORITY,
+   NET_SHAPER_A_CAPS_SUPPORT_WEIGHT,
+
+   __NET_SHAPER_A_CAPS_MAX,
+   NET_SHAPER_A_CAPS_MAX = (__NET_SHAPER_A_CAPS_MAX - 1)
+};
+
 enum {
NET_SHAPER_CMD_GET = 1,
NET_SHAPER_CMD_SET,
NET_SHAPER_CMD_DELETE,
NET_SHAPER_CMD_GROUP,
+   NET_SHAPER_CMD_CAP_GET,
 
__NET_SHAPER_CMD_MAX,
NET_SHAPER_CMD_MAX = (__NET_SHAPER_CMD_MAX - 1)
diff --git a/net/shaper/shaper.c b/net/shaper/shaper.c
index f6f5712d7b3c..67d38b691bb8 100644
--- a/net/shaper/shaper.c
+++ b/net/shaper/shaper.c
@@ -614,6 +614,27 @@ int net_shaper_nl_post_dumpit(struct netli

[Intel-wired-lan] [PATCH v6 net-next 10/15] net-shapers: implement cap validation in the core

2024-09-04 Thread Paolo Abeni
Use the device capabilities to reject invalid attribute values before
pushing them to the H/W.

Note that validating the metric explicitly avoids NL_SET_BAD_ATTR()
usage, to provide unambiguous error messages to the user.

Validating the nesting requires the knowledge of the new parent for
the given shaper; as such is a chicken-egg problem: to validate the
leaf nesting we need to know the node scope, to validate the node
nesting we need to know the leafs parent scope.

To break the circular dependency, place the leafs nesting validation
after the parsing.

Suggested-by: Jakub Kicinski 
Signed-off-by: Paolo Abeni 
---
 net/shaper/shaper.c | 102 ++--
 1 file changed, 99 insertions(+), 3 deletions(-)

diff --git a/net/shaper/shaper.c b/net/shaper/shaper.c
index bc55dd53a5d7..2302faf9ee45 100644
--- a/net/shaper/shaper.c
+++ b/net/shaper/shaper.c
@@ -441,6 +441,64 @@ static int net_shaper_parse_handle(const struct nlattr 
*attr,
return 0;
 }
 
+static int net_shaper_validate_caps(struct net_shaper_binding *binding,
+   struct nlattr **tb,
+   const struct genl_info *info,
+   struct net_shaper *shaper)
+{
+   const struct net_shaper_ops *ops = net_shaper_ops(binding);
+   struct nlattr *bad = NULL;
+   unsigned long caps = 0;
+
+   ops->capabilities(binding, shaper->handle.scope, &caps);
+
+   if (tb[NET_SHAPER_A_PRIORITY] &&
+   !(caps & BIT(NET_SHAPER_A_CAPS_SUPPORT_PRIORITY)))
+   bad = tb[NET_SHAPER_A_PRIORITY];
+   if (tb[NET_SHAPER_A_WEIGHT] &&
+   !(caps & BIT(NET_SHAPER_A_CAPS_SUPPORT_WEIGHT)))
+   bad = tb[NET_SHAPER_A_WEIGHT];
+   if (tb[NET_SHAPER_A_BW_MIN] &&
+   !(caps & BIT(NET_SHAPER_A_CAPS_SUPPORT_BW_MIN)))
+   bad = tb[NET_SHAPER_A_BW_MIN];
+   if (tb[NET_SHAPER_A_BW_MAX] &&
+   !(caps & BIT(NET_SHAPER_A_CAPS_SUPPORT_BW_MAX)))
+   bad = tb[NET_SHAPER_A_BW_MAX];
+   if (tb[NET_SHAPER_A_BURST] &&
+   !(caps & BIT(NET_SHAPER_A_CAPS_SUPPORT_BURST)))
+   bad = tb[NET_SHAPER_A_BURST];
+
+   if (!caps)
+   bad = tb[NET_SHAPER_A_HANDLE];
+
+   if (bad) {
+   NL_SET_BAD_ATTR(info->extack, bad);
+   return -EOPNOTSUPP;
+   }
+
+   /* The metric is really used only if there is *any* rate-related
+* setting, either in current attributes set or in pre-existing
+* values.
+*/
+   if (shaper->burst || shaper->bw_min || shaper->bw_max) {
+   u32 metric_cap = NET_SHAPER_A_CAPS_SUPPORT_METRIC_BPS +
+shaper->metric;
+
+   /* The metric test can fail even when the user did not
+* specify the METRIC attribute. Pointing to rate related
+* attribute will be confusing, as the attribute itself
+* could be indeed supported, with a different metric.
+* Be more specific.
+*/
+   if (!(caps & BIT(metric_cap))) {
+   NL_SET_ERR_MSG_FMT(info->extack, "Bad metric %d",
+  shaper->metric);
+   return -EOPNOTSUPP;
+   }
+   }
+   return 0;
+}
+
 static int net_shaper_parse_info(struct net_shaper_binding *binding,
 struct nlattr **tb,
 const struct genl_info *info,
@@ -491,6 +549,28 @@ static int net_shaper_parse_info(struct net_shaper_binding 
*binding,
 
if (tb[NET_SHAPER_A_WEIGHT])
shaper->weight = nla_get_u32(tb[NET_SHAPER_A_WEIGHT]);
+
+   ret = net_shaper_validate_caps(binding, tb, info, shaper);
+   if (ret < 0)
+   return ret;
+
+   return 0;
+}
+
+static int net_shaper_validate_nesting(struct net_shaper_binding *binding,
+  const struct net_shaper *shaper,
+  struct netlink_ext_ack *extack)
+{
+   const struct net_shaper_ops *ops = net_shaper_ops(binding);
+   unsigned long caps = 0;
+
+   ops->capabilities(binding, shaper->handle.scope, &caps);
+   if (!(caps & BIT(NET_SHAPER_A_CAPS_SUPPORT_NESTING))) {
+   NL_SET_ERR_MSG_FMT(extack,
+  "Nesting not supported for scope %d",
+  shaper->handle.scope);
+   return -EOPNOTSUPP;
+   }
return 0;
 }
 
@@ -516,9 +596,21 @@ static int net_shaper_parse_info_nest(struct 
net_shaper_binding *binding,
if (ret < 0)
return ret;
 
-   if (node && shaper->handle.scope != NET_SHAPER_SCOPE_QUEUE) {
-   NL_SET_BAD_ATTR(info->extack, tb[NET_SHAPER_A_HANDLE]);
-   return -EINVAL;
+   /* When node is specified, the shaper is actually a leaf for a

[Intel-wired-lan] [PATCH v6 net-next 11/15] testing: net-drv: add basic shaper test

2024-09-04 Thread Paolo Abeni
Leverage a basic/dummy netdevsim implementation to do functional
coverage for NL interface.

Signed-off-by: Paolo Abeni 
---
v5 -> v6:
  - additional test-cases for delegation and queue reconf

v4 -> v5:
  - updated to new driver API
  - more consistent indentation

rfc v1 -> v2:
  - added more test-cases WRT nesting and grouping
---
 drivers/net/Kconfig   |   1 +
 drivers/net/netdevsim/netdev.c|  39 ++
 tools/testing/selftests/drivers/net/Makefile  |   1 +
 tools/testing/selftests/drivers/net/shaper.py | 458 ++
 .../testing/selftests/net/lib/py/__init__.py  |   1 +
 tools/testing/selftests/net/lib/py/ynl.py |   5 +
 6 files changed, 505 insertions(+)
 create mode 100755 tools/testing/selftests/drivers/net/shaper.py

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 9920b3a68ed1..1fd5acdc73c6 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -641,6 +641,7 @@ config NETDEVSIM
depends on PTP_1588_CLOCK_MOCK || PTP_1588_CLOCK_MOCK=n
select NET_DEVLINK
select PAGE_POOL
+   select NET_SHAPER
help
  This driver is a developer testing tool and software model that can
  be used to test various control path networking APIs, especially
diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
index 017a6102be0a..cad85bb0cf54 100644
--- a/drivers/net/netdevsim/netdev.c
+++ b/drivers/net/netdevsim/netdev.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -475,6 +476,43 @@ static int nsim_stop(struct net_device *dev)
return 0;
 }
 
+static int nsim_shaper_set(struct net_shaper_binding *binding,
+  const struct net_shaper *shaper,
+  struct netlink_ext_ack *extack)
+{
+   return 0;
+}
+
+static int nsim_shaper_del(struct net_shaper_binding *binding,
+  const struct net_shaper_handle *handle,
+  struct netlink_ext_ack *extack)
+{
+   return 0;
+}
+
+static int nsim_shaper_group(struct net_shaper_binding *binding,
+int leaves_count,
+const struct net_shaper *leaves,
+const struct net_shaper *root,
+struct netlink_ext_ack *extack)
+{
+   return 0;
+}
+
+static void nsim_shaper_cap(struct net_shaper_binding *binding,
+   enum net_shaper_scope scope,
+   unsigned long *flags)
+{
+   *flags = ULONG_MAX;
+}
+
+static const struct net_shaper_ops nsim_shaper_ops = {
+   .set= nsim_shaper_set,
+   .delete = nsim_shaper_del,
+   .group  = nsim_shaper_group,
+   .capabilities   = nsim_shaper_cap,
+};
+
 static const struct net_device_ops nsim_netdev_ops = {
.ndo_start_xmit = nsim_start_xmit,
.ndo_set_rx_mode= nsim_set_rx_mode,
@@ -496,6 +534,7 @@ static const struct net_device_ops nsim_netdev_ops = {
.ndo_bpf= nsim_bpf,
.ndo_open   = nsim_open,
.ndo_stop   = nsim_stop,
+   .net_shaper_ops = &nsim_shaper_ops,
 };
 
 static const struct net_device_ops nsim_vf_netdev_ops = {
diff --git a/tools/testing/selftests/drivers/net/Makefile 
b/tools/testing/selftests/drivers/net/Makefile
index 39fb97a8c1df..25aec5c081df 100644
--- a/tools/testing/selftests/drivers/net/Makefile
+++ b/tools/testing/selftests/drivers/net/Makefile
@@ -9,6 +9,7 @@ TEST_PROGS := \
ping.py \
queues.py \
stats.py \
+   shaper.py
 # end of TEST_PROGS
 
 include ../../lib.mk
diff --git a/tools/testing/selftests/drivers/net/shaper.py 
b/tools/testing/selftests/drivers/net/shaper.py
new file mode 100755
index ..7bb83f8a2583
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/shaper.py
@@ -0,0 +1,458 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+
+from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_true, KsftSkipEx
+from lib.py import EthtoolFamily, NetshaperFamily
+from lib.py import NetDrvEnv
+from lib.py import NlError
+from lib.py import cmd
+
+def get_shapers(cfg, nl_shaper) -> None:
+try:
+shapers = nl_shaper.get({'ifindex': cfg.ifindex}, dump=True)
+except NlError as e:
+if e.error == 95:
+raise KsftSkipEx("shapers not supported by the device")
+raise
+
+# Default configuration: no shapers configured.
+ksft_eq(len(shapers), 0)
+
+def get_caps(cfg, nl_shaper) -> None:
+try:
+caps = nl_shaper.cap_get({'ifindex': cfg.ifindex}, dump=True)
+except NlError as e:
+if e.error == 95:
+raise KsftSkipEx("shapers not supported by the device")
+raise
+
+# Each device implementing shaper support must support some
+# features in at least a scope.
+ksft_true(

[Intel-wired-lan] [PATCH v6 net-next 12/15] virtchnl: support queue rate limit and quanta size configuration

2024-09-04 Thread Paolo Abeni
From: Wenjun Wu 

This patch adds new virtchnl opcodes and structures for rate limit
and quanta size configuration, which include:
1. VIRTCHNL_OP_CONFIG_QUEUE_BW, to configure max bandwidth for each
VF per queue.
2. VIRTCHNL_OP_CONFIG_QUANTA, to configure quanta size per queue.
3. VIRTCHNL_OP_GET_QOS_CAPS, VF queries current QoS configuration, such
as enabled TCs, arbiter type, up2tc and bandwidth of VSI node. The
configuration is previously set by DCB and PF, and now is the potential
QoS capability of VF. VF can take it as reference to configure queue TC
mapping.

Signed-off-by: Wenjun Wu 
---
 include/linux/avf/virtchnl.h | 119 +++
 1 file changed, 119 insertions(+)

diff --git a/include/linux/avf/virtchnl.h b/include/linux/avf/virtchnl.h
index f41395264dca..223e433c39fe 100644
--- a/include/linux/avf/virtchnl.h
+++ b/include/linux/avf/virtchnl.h
@@ -89,6 +89,9 @@ enum virtchnl_rx_hsplit {
VIRTCHNL_RX_HSPLIT_SPLIT_SCTP= 8,
 };
 
+enum virtchnl_bw_limit_type {
+   VIRTCHNL_BW_SHAPER = 0,
+};
 /* END GENERIC DEFINES */
 
 /* Opcodes for VF-PF communication. These are placed in the v_opcode field
@@ -151,6 +154,11 @@ enum virtchnl_ops {
VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 = 55,
VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 = 56,
VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 = 57,
+   /* opcode 57 - 65 are reserved */
+   VIRTCHNL_OP_GET_QOS_CAPS = 66,
+   /* opcode 68 through 111 are reserved */
+   VIRTCHNL_OP_CONFIG_QUEUE_BW = 112,
+   VIRTCHNL_OP_CONFIG_QUANTA = 113,
VIRTCHNL_OP_MAX,
 };
 
@@ -261,6 +269,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
 #define VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC   BIT(26)
 #define VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF BIT(27)
 #define VIRTCHNL_VF_OFFLOAD_FDIR_PFBIT(28)
+#define VIRTCHNL_VF_OFFLOAD_QOSBIT(29)
 
 #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
   VIRTCHNL_VF_OFFLOAD_VLAN | \
@@ -1416,6 +1425,85 @@ struct virtchnl_fdir_del {
 
 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
 
+struct virtchnl_shaper_bw {
+   /* Unit is Kbps */
+   u32 committed;
+   u32 peak;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_shaper_bw);
+
+/* VIRTCHNL_OP_GET_QOS_CAPS
+ * VF sends this message to get its QoS Caps, such as
+ * TC number, Arbiter and Bandwidth.
+ */
+struct virtchnl_qos_cap_elem {
+   u8 tc_num;
+   u8 tc_prio;
+#define VIRTCHNL_ABITER_STRICT  0
+#define VIRTCHNL_ABITER_ETS 2
+   u8 arbiter;
+#define VIRTCHNL_STRICT_WEIGHT  1
+   u8 weight;
+   enum virtchnl_bw_limit_type type;
+   union {
+   struct virtchnl_shaper_bw shaper;
+   u8 pad2[32];
+   };
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(40, virtchnl_qos_cap_elem);
+
+struct virtchnl_qos_cap_list {
+   u16 vsi_id;
+   u16 num_elem;
+   struct virtchnl_qos_cap_elem cap[];
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_qos_cap_list);
+#define virtchnl_qos_cap_list_LEGACY_SIZEOF44
+
+/* VIRTCHNL_OP_CONFIG_QUEUE_BW */
+struct virtchnl_queue_bw {
+   u16 queue_id;
+   u8 tc;
+   u8 pad;
+   struct virtchnl_shaper_bw shaper;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_bw);
+
+struct virtchnl_queues_bw_cfg {
+   u16 vsi_id;
+   u16 num_queues;
+   struct virtchnl_queue_bw cfg[];
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_queues_bw_cfg);
+#define virtchnl_queues_bw_cfg_LEGACY_SIZEOF   16
+
+enum virtchnl_queue_type {
+   VIRTCHNL_QUEUE_TYPE_TX  = 0,
+   VIRTCHNL_QUEUE_TYPE_RX  = 1,
+};
+
+/* structure to specify a chunk of contiguous queues */
+struct virtchnl_queue_chunk {
+   /* see enum virtchnl_queue_type */
+   s32 type;
+   u16 start_queue_id;
+   u16 num_queues;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_queue_chunk);
+
+struct virtchnl_quanta_cfg {
+   u16 quanta_size;
+   struct virtchnl_queue_chunk queue_select;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_quanta_cfg);
+
 #define __vss_byone(p, member, count, old)   \
(struct_size(p, member, count) + (old - 1 - struct_size(p, member, 0)))
 
@@ -1438,6 +1526,8 @@ VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
 __vss(virtchnl_vlan_filter_list_v2, __vss_byelem, p, m, c),  \
 __vss(virtchnl_tc_info, __vss_byelem, p, m, c),  \
 __vss(virtchnl_rdma_qvlist_info, __vss_byelem, p, m, c), \
+__vss(virtchnl_qos_cap_list, __vss_byelem, p, m, c), \
+__vss(virtchnl_queues_bw_cfg, __vss_byelem, p, m, c),\
 __vss(virtchnl_rss_key, __vss_byone, p, m, c),   \
 __vss(virtchnl_rss_lut, __vss_byone, p, m, c))
 
@@ -1637,6 +1727,35 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info 
*ver, u32 v_opcode,
case VIR

[Intel-wired-lan] [PATCH v6 net-next 09/15] net: shaper: implement introspection support

2024-09-04 Thread Paolo Abeni
The netlink op is a simple wrapper around the device callback.

Extend the existing fetch_dev() helper adding an attribute argument
for the requested device. Reuse such helper in the newly implemented
operation.

Signed-off-by: Paolo Abeni 
---
v5 -> v6:
 - update to new API

v4 -> v5:
 - replace net_device* with binding* in most functions
 - de-deplicate some code thanks to more generic helpers in previous
   patches

v3 -> v4:
 - another dev_put() -> netdev_put() conversion, missed in previous
   iteration

RFC v2 -> v3:
 - dev_put() -> netdev_put()
---
 net/shaper/shaper.c | 98 +++--
 1 file changed, 95 insertions(+), 3 deletions(-)

diff --git a/net/shaper/shaper.c b/net/shaper/shaper.c
index 67d38b691bb8..bc55dd53a5d7 100644
--- a/net/shaper/shaper.c
+++ b/net/shaper/shaper.c
@@ -617,22 +617,29 @@ int net_shaper_nl_post_dumpit(struct netlink_callback *cb)
 int net_shaper_nl_cap_pre_doit(const struct genl_split_ops *ops,
   struct sk_buff *skb, struct genl_info *info)
 {
-   return -EOPNOTSUPP;
+   return net_shaper_generic_pre(info, NET_SHAPER_A_CAPS_IFINDEX);
 }
 
 void net_shaper_nl_cap_post_doit(const struct genl_split_ops *ops,
 struct sk_buff *skb, struct genl_info *info)
 {
+   net_shaper_generic_post(info);
 }
 
 int net_shaper_nl_cap_pre_dumpit(struct netlink_callback *cb)
 {
-   return -EOPNOTSUPP;
+   struct net_shaper_nl_ctx *ctx = (struct net_shaper_nl_ctx *)cb->ctx;
+
+   return net_shaper_ctx_setup(genl_info_dump(cb),
+   NET_SHAPER_A_CAPS_IFINDEX, ctx);
 }
 
 int net_shaper_nl_cap_post_dumpit(struct netlink_callback *cb)
 {
-   return -EOPNOTSUPP;
+   struct net_shaper_nl_ctx *ctx = (struct net_shaper_nl_ctx *)cb->ctx;
+
+   net_shaper_ctx_cleanup(ctx);
+   return 0;
 }
 
 int net_shaper_nl_get_doit(struct sk_buff *skb, struct genl_info *info)
@@ -1191,14 +1198,99 @@ int net_shaper_nl_group_doit(struct sk_buff *skb, 
struct genl_info *info)
goto free_shapers;
 }
 
+static int
+net_shaper_cap_fill_one(struct sk_buff *msg,
+   struct net_shaper_binding *binding,
+   enum net_shaper_scope scope, unsigned long flags,
+   const struct genl_info *info)
+{
+   unsigned long cur;
+   void *hdr;
+
+   hdr = genlmsg_iput(msg, info);
+   if (!hdr)
+   return -EMSGSIZE;
+
+   if (net_shaper_fill_binding(msg, binding, NET_SHAPER_A_CAPS_IFINDEX) ||
+   nla_put_u32(msg, NET_SHAPER_A_CAPS_SCOPE, scope))
+   goto nla_put_failure;
+
+   for (cur = NET_SHAPER_A_CAPS_SUPPORT_METRIC_BPS;
+cur <= NET_SHAPER_A_CAPS_MAX; ++cur) {
+   if (flags & BIT(cur) && nla_put_flag(msg, cur))
+   goto nla_put_failure;
+   }
+
+   genlmsg_end(msg, hdr);
+
+   return 0;
+
+nla_put_failure:
+   genlmsg_cancel(msg, hdr);
+   return -EMSGSIZE;
+}
+
 int net_shaper_nl_cap_get_doit(struct sk_buff *skb, struct genl_info *info)
 {
+   struct net_shaper_binding *binding;
+   const struct net_shaper_ops *ops;
+   enum net_shaper_scope scope;
+   unsigned long flags = 0;
+   struct sk_buff *msg;
+   int ret;
+
+   if (GENL_REQ_ATTR_CHECK(info, NET_SHAPER_A_CAPS_SCOPE))
+   return -EINVAL;
+
+   binding = net_shaper_binding_from_ctx(info->ctx);
+   scope = nla_get_u32(info->attrs[NET_SHAPER_A_CAPS_SCOPE]);
+   ops = net_shaper_ops(binding);
+   ops->capabilities(binding, scope, &flags);
+   if (!flags)
+   return -EOPNOTSUPP;
+
+   msg = genlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+   if (!msg)
+   return -ENOMEM;
+
+   ret = net_shaper_cap_fill_one(msg, binding, scope, flags, info);
+   if (ret)
+   goto free_msg;
+
+   ret =  genlmsg_reply(msg, info);
+   if (ret)
+   goto free_msg;
return 0;
+
+free_msg:
+   nlmsg_free(msg);
+   return ret;
 }
 
 int net_shaper_nl_cap_get_dumpit(struct sk_buff *skb,
 struct netlink_callback *cb)
 {
+   const struct genl_info *info = genl_info_dump(cb);
+   struct net_shaper_binding *binding;
+   const struct net_shaper_ops *ops;
+   enum net_shaper_scope scope;
+   int ret;
+
+   binding = net_shaper_binding_from_ctx(cb->ctx);
+   ops = net_shaper_ops(binding);
+   for (scope = 0; scope <= NET_SHAPER_SCOPE_MAX; ++scope) {
+   unsigned long flags = 0;
+
+   ops->capabilities(binding, scope, &flags);
+   if (!flags)
+   continue;
+
+   ret = net_shaper_cap_fill_one(skb, binding, scope, flags,
+ info);
+   if (ret)
+   return ret;
+   }
+
return 0;
 }
 
-- 
2.45.2



[Intel-wired-lan] [PATCH v6 net-next 13/15] ice: Support VF queue rate limit and quanta size configuration

2024-09-04 Thread Paolo Abeni
From: Wenjun Wu 

Add support to configure VF queue rate limit and quanta size.

For quanta size configuration, the quanta profiles are divided evenly
by PF numbers. For each port, the first quanta profile is reserved for
default. When VF is asked to set queue quanta size, PF will search for
an available profile, change the fields and assigned this profile to the
queue.

Signed-off-by: Wenjun Wu 
---
 drivers/net/ethernet/intel/ice/ice.h  |   2 +
 drivers/net/ethernet/intel/ice/ice_base.c |   2 +
 drivers/net/ethernet/intel/ice/ice_common.c   |  21 ++
 .../net/ethernet/intel/ice/ice_hw_autogen.h   |   8 +
 drivers/net/ethernet/intel/ice/ice_txrx.h |   1 +
 drivers/net/ethernet/intel/ice/ice_type.h |   1 +
 drivers/net/ethernet/intel/ice/ice_vf_lib.h   |   8 +
 drivers/net/ethernet/intel/ice/ice_virtchnl.c | 335 ++
 drivers/net/ethernet/intel/ice/ice_virtchnl.h |  11 +
 .../intel/ice/ice_virtchnl_allowlist.c|   6 +
 10 files changed, 395 insertions(+)

diff --git a/drivers/net/ethernet/intel/ice/ice.h 
b/drivers/net/ethernet/intel/ice/ice.h
index caaa10157909..35ace1907a62 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -659,6 +659,8 @@ struct ice_pf {
struct ice_agg_node vf_agg_node[ICE_MAX_VF_AGG_NODES];
struct ice_dplls dplls;
struct device *hwmon_dev;
+
+   u8 num_quanta_prof_used;
 };
 
 extern struct workqueue_struct *ice_lag_wq;
diff --git a/drivers/net/ethernet/intel/ice/ice_base.c 
b/drivers/net/ethernet/intel/ice/ice_base.c
index f448d3a84564..c238d440a623 100644
--- a/drivers/net/ethernet/intel/ice/ice_base.c
+++ b/drivers/net/ethernet/intel/ice/ice_base.c
@@ -349,6 +349,8 @@ ice_setup_tx_ctx(struct ice_tx_ring *ring, struct 
ice_tlan_ctx *tlan_ctx, u16 pf
break;
}
 
+   tlan_ctx->quanta_prof_idx = ring->quanta_prof_id;
+
tlan_ctx->tso_ena = ICE_TX_LEGACY;
tlan_ctx->tso_qnum = pf_q;
 
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c 
b/drivers/net/ethernet/intel/ice/ice_common.c
index 009716a12a26..b22e71dc59d4 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -2436,6 +2436,25 @@ ice_parse_func_caps(struct ice_hw *hw, struct 
ice_hw_func_caps *func_p,
ice_recalc_port_limited_caps(hw, &func_p->common_cap);
 }
 
+/**
+ * ice_func_id_to_logical_id - map from function id to logical pf id
+ * @active_function_bitmap: active function bitmap
+ * @pf_id: function number of device
+ *
+ * Return: logical PF ID.
+ */
+static int ice_func_id_to_logical_id(u32 active_function_bitmap, u8 pf_id)
+{
+   u8 logical_id = 0;
+   u8 i;
+
+   for (i = 0; i < pf_id; i++)
+   if (active_function_bitmap & BIT(i))
+   logical_id++;
+
+   return logical_id;
+}
+
 /**
  * ice_parse_valid_functions_cap - Parse ICE_AQC_CAPS_VALID_FUNCTIONS caps
  * @hw: pointer to the HW struct
@@ -2453,6 +2472,8 @@ ice_parse_valid_functions_cap(struct ice_hw *hw, struct 
ice_hw_dev_caps *dev_p,
dev_p->num_funcs = hweight32(number);
ice_debug(hw, ICE_DBG_INIT, "dev caps: num_funcs = %d\n",
  dev_p->num_funcs);
+
+   hw->logical_pf_id = ice_func_id_to_logical_id(number, hw->pf_id);
 }
 
 /**
diff --git a/drivers/net/ethernet/intel/ice/ice_hw_autogen.h 
b/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
index 91cbae1eec89..af9302f0e376 100644
--- a/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
+++ b/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
@@ -6,6 +6,14 @@
 #ifndef _ICE_HW_AUTOGEN_H_
 #define _ICE_HW_AUTOGEN_H_
 
+#define GLCOMM_QUANTA_PROF(_i) (0x002D2D68 + ((_i) * 4))
+#define GLCOMM_QUANTA_PROF_MAX_INDEX   15
+#define GLCOMM_QUANTA_PROF_QUANTA_SIZE_S   0
+#define GLCOMM_QUANTA_PROF_QUANTA_SIZE_M   ICE_M(0x3FFF, 0)
+#define GLCOMM_QUANTA_PROF_MAX_CMD_S   16
+#define GLCOMM_QUANTA_PROF_MAX_CMD_M   ICE_M(0xFF, 16)
+#define GLCOMM_QUANTA_PROF_MAX_DESC_S  24
+#define GLCOMM_QUANTA_PROF_MAX_DESC_M  ICE_M(0x3F, 24)
 #define QTX_COMM_DBELL(_DBQM)  (0x002C + ((_DBQM) * 4))
 #define QTX_COMM_HEAD(_DBQM)   (0x000E + ((_DBQM) * 4))
 #define QTX_COMM_HEAD_HEAD_S   0
diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.h 
b/drivers/net/ethernet/intel/ice/ice_txrx.h
index feba314a3fe4..ea2fae9035b5 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx.h
+++ b/drivers/net/ethernet/intel/ice/ice_txrx.h
@@ -406,6 +406,7 @@ struct ice_tx_ring {
 #define ICE_TX_FLAGS_RING_VLAN_L2TAG2  BIT(2)
u8 flags;
u8 dcb_tc;  /* Traffic class of ring */
+   u16 quanta_prof_id;
 } cacheline_internodealigned_in_smp;
 
 static inline bool ice_ring_uses_build_skb(struct ice_rx_ring *ring)
diff --git a/drivers/net/ethernet/intel/ice/ice_type.h 
b/drivers/net/ethernet/intel/ice/ice_type.h
ind

[Intel-wired-lan] [PATCH v6 net-next 14/15] iavf: Add net_shaper_ops support

2024-09-04 Thread Paolo Abeni
From: Sudheer Mogilappagari 

Implement net_shaper_ops support for IAVF. This enables configuration
of rate limiting on per queue basis. Customer intends to enforce
bandwidth limit on Tx traffic steered to the queue by configuring
rate limits on the queue.

To set rate limiting for a queue, update shaper object of given queues
in driver and send VIRTCHNL_OP_CONFIG_QUEUE_BW to PF to update HW
configuration.

Deleting shaper configured for queue is nothing but configuring shaper
with bw_max 0. The PF restores the default rate limiting config
when bw_max is zero.

Signed-off-by: Sudheer Mogilappagari 
---
v5 -> v6:
 - adapted to new API
 - dropped scope-related checks (moved into the core)

v4 -> v5:
 - fix kdoc
---
 drivers/net/ethernet/intel/Kconfig|   1 +
 drivers/net/ethernet/intel/iavf/iavf.h|   3 +
 drivers/net/ethernet/intel/iavf/iavf_main.c   | 110 ++
 drivers/net/ethernet/intel/iavf/iavf_txrx.h   |   2 +
 .../net/ethernet/intel/iavf/iavf_virtchnl.c   |  65 +++
 5 files changed, 181 insertions(+)

diff --git a/drivers/net/ethernet/intel/Kconfig 
b/drivers/net/ethernet/intel/Kconfig
index 0375c7448a57..20bc40eec487 100644
--- a/drivers/net/ethernet/intel/Kconfig
+++ b/drivers/net/ethernet/intel/Kconfig
@@ -258,6 +258,7 @@ config I40E_DCB
 config IAVF
tristate
select LIBIE
+   select NET_SHAPER
 
 config I40EVF
tristate "Intel(R) Ethernet Adaptive Virtual Function support"
diff --git a/drivers/net/ethernet/intel/iavf/iavf.h 
b/drivers/net/ethernet/intel/iavf/iavf.h
index 48cd1d06761c..a84bdbfbb0f7 100644
--- a/drivers/net/ethernet/intel/iavf/iavf.h
+++ b/drivers/net/ethernet/intel/iavf/iavf.h
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "iavf_type.h"
 #include 
@@ -336,6 +337,7 @@ struct iavf_adapter {
 #define IAVF_FLAG_AQ_DISABLE_CTAG_VLAN_INSERTION   BIT_ULL(36)
 #define IAVF_FLAG_AQ_ENABLE_STAG_VLAN_INSERTIONBIT_ULL(37)
 #define IAVF_FLAG_AQ_DISABLE_STAG_VLAN_INSERTION   BIT_ULL(38)
+#define IAVF_FLAG_AQ_CONFIGURE_QUEUES_BW   BIT_ULL(39)
 
/* flags for processing extended capability messages during
 * __IAVF_INIT_EXTENDED_CAPS. Each capability exchange requires
@@ -581,6 +583,7 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
 int iavf_config_rss(struct iavf_adapter *adapter);
 int iavf_lan_add_device(struct iavf_adapter *adapter);
 int iavf_lan_del_device(struct iavf_adapter *adapter);
+void iavf_cfg_queues_bw(struct iavf_adapter *adapter);
 void iavf_enable_channels(struct iavf_adapter *adapter);
 void iavf_disable_channels(struct iavf_adapter *adapter);
 void iavf_add_cloud_filter(struct iavf_adapter *adapter);
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c 
b/drivers/net/ethernet/intel/iavf/iavf_main.c
index f782402cd789..532c4b8f3fa0 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -2085,6 +2085,11 @@ static int iavf_process_aq_command(struct iavf_adapter 
*adapter)
return 0;
}
 
+   if (adapter->aq_required & IAVF_FLAG_AQ_CONFIGURE_QUEUES_BW) {
+   iavf_cfg_queues_bw(adapter);
+   return 0;
+   }
+
if (adapter->aq_required & IAVF_FLAG_AQ_CONFIGURE_QUEUES) {
iavf_configure_queues(adapter);
return 0;
@@ -2918,6 +2923,30 @@ static void iavf_disable_vf(struct iavf_adapter *adapter)
dev_info(&adapter->pdev->dev, "Reset task did not complete, VF 
disabled\n");
 }
 
+/**
+ * iavf_reconfig_qs_bw - Call-back task to handle hardware reset
+ * @adapter: board private structure
+ *
+ * After a reset, the shaper parameters of queues need to be replayed again.
+ * Since the net_shaper object inside TX rings persists across reset,
+ * set the update flag for all queues so that the virtchnl message is triggered
+ * for all queues.
+ **/
+static void iavf_reconfig_qs_bw(struct iavf_adapter *adapter)
+{
+   int i, num = 0;
+
+   for (i = 0; i < adapter->num_active_queues; i++)
+   if (adapter->tx_rings[i].q_shaper.bw_min ||
+   adapter->tx_rings[i].q_shaper.bw_max) {
+   adapter->tx_rings[i].q_shaper_update = true;
+   num++;
+   }
+
+   if (num)
+   adapter->aq_required |= IAVF_FLAG_AQ_CONFIGURE_QUEUES_BW;
+}
+
 /**
  * iavf_reset_task - Call-back task to handle hardware reset
  * @work: pointer to work_struct
@@ -3124,6 +3153,8 @@ static void iavf_reset_task(struct work_struct *work)
iavf_up_complete(adapter);
 
iavf_irq_enable(adapter, true);
+
+   iavf_reconfig_qs_bw(adapter);
} else {
iavf_change_state(adapter, __IAVF_DOWN);
wake_up(&adapter->down_waitqueue);
@@ -4893,6 +4924,84 @@ static netdev_features_t iavf_fix_features(struct 
net_device *netdev,
return iavf_fix_strip_featu

[Intel-wired-lan] [PATCH v6 net-next 15/15] iavf: add support to exchange qos capabilities

2024-09-04 Thread Paolo Abeni
From: Sudheer Mogilappagari 

During driver initialization VF determines QOS capability is allowed
by PF and receives QOS parameters. After which quanta size for queues
is configured which is not configurable and is set to 1KB currently.

Signed-off-by: Sudheer Mogilappagari 
---
v5 -> v6:
 - error out on bad rate
---
 drivers/net/ethernet/intel/iavf/iavf.h| 10 ++
 drivers/net/ethernet/intel/iavf/iavf_main.c   | 51 +-
 .../net/ethernet/intel/iavf/iavf_virtchnl.c   | 92 ++-
 3 files changed, 150 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf.h 
b/drivers/net/ethernet/intel/iavf/iavf.h
index a84bdbfbb0f7..75ac69670789 100644
--- a/drivers/net/ethernet/intel/iavf/iavf.h
+++ b/drivers/net/ethernet/intel/iavf/iavf.h
@@ -251,6 +251,9 @@ struct iavf_cloud_filter {
 #define IAVF_RESET_WAIT_DETECTED_COUNT 500
 #define IAVF_RESET_WAIT_COMPLETE_COUNT 2000
 
+#define IAVF_MAX_QOS_TC_NUM8
+#define IAVF_DEFAULT_QUANTA_SIZE   1024
+
 /* board specific private data structure */
 struct iavf_adapter {
struct workqueue_struct *wq;
@@ -338,6 +341,8 @@ struct iavf_adapter {
 #define IAVF_FLAG_AQ_ENABLE_STAG_VLAN_INSERTIONBIT_ULL(37)
 #define IAVF_FLAG_AQ_DISABLE_STAG_VLAN_INSERTION   BIT_ULL(38)
 #define IAVF_FLAG_AQ_CONFIGURE_QUEUES_BW   BIT_ULL(39)
+#define IAVF_FLAG_AQ_CFG_QUEUES_QUANTA_SIZEBIT_ULL(40)
+#define IAVF_FLAG_AQ_GET_QOS_CAPS  BIT_ULL(41)
 
/* flags for processing extended capability messages during
 * __IAVF_INIT_EXTENDED_CAPS. Each capability exchange requires
@@ -410,6 +415,8 @@ struct iavf_adapter {
   VIRTCHNL_VF_OFFLOAD_FDIR_PF)
 #define ADV_RSS_SUPPORT(_a) ((_a)->vf_res->vf_cap_flags & \
 VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF)
+#define QOS_ALLOWED(_a) ((_a)->vf_res->vf_cap_flags & \
+VIRTCHNL_VF_OFFLOAD_QOS)
struct virtchnl_vf_resource *vf_res; /* incl. all VSIs */
struct virtchnl_vsi_resource *vsi_res; /* our LAN VSI */
struct virtchnl_version_info pf_version;
@@ -418,6 +425,7 @@ struct iavf_adapter {
struct virtchnl_vlan_caps vlan_v2_caps;
u16 msg_enable;
struct iavf_eth_stats current_stats;
+   struct virtchnl_qos_cap_list *qos_caps;
struct iavf_vsi vsi;
u32 aq_wait_count;
/* RSS stuff */
@@ -584,6 +592,8 @@ int iavf_config_rss(struct iavf_adapter *adapter);
 int iavf_lan_add_device(struct iavf_adapter *adapter);
 int iavf_lan_del_device(struct iavf_adapter *adapter);
 void iavf_cfg_queues_bw(struct iavf_adapter *adapter);
+void iavf_cfg_queues_quanta_size(struct iavf_adapter *adapter);
+void iavf_get_qos_caps(struct iavf_adapter *adapter);
 void iavf_enable_channels(struct iavf_adapter *adapter);
 void iavf_disable_channels(struct iavf_adapter *adapter);
 void iavf_add_cloud_filter(struct iavf_adapter *adapter);
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c 
b/drivers/net/ethernet/intel/iavf/iavf_main.c
index 532c4b8f3fa0..27509e418e98 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -2090,6 +2090,16 @@ static int iavf_process_aq_command(struct iavf_adapter 
*adapter)
return 0;
}
 
+   if (adapter->aq_required & IAVF_FLAG_AQ_GET_QOS_CAPS) {
+   iavf_get_qos_caps(adapter);
+   return 0;
+   }
+
+   if (adapter->aq_required & IAVF_FLAG_AQ_CFG_QUEUES_QUANTA_SIZE) {
+   iavf_cfg_queues_quanta_size(adapter);
+   return 0;
+   }
+
if (adapter->aq_required & IAVF_FLAG_AQ_CONFIGURE_QUEUES) {
iavf_configure_queues(adapter);
return 0;
@@ -2675,6 +2685,9 @@ static void iavf_init_config_adapter(struct iavf_adapter 
*adapter)
/* request initial VLAN offload settings */
iavf_set_vlan_offload_features(adapter, 0, netdev->features);
 
+   if (QOS_ALLOWED(adapter))
+   adapter->aq_required |= IAVF_FLAG_AQ_GET_QOS_CAPS;
+
iavf_schedule_finish_config(adapter);
return;
 
@@ -4939,6 +4952,31 @@ static int iavf_verify_handle(struct net_shaper_binding 
*binding,
return 0;
 }
 
+static int
+iavf_verify_shaper(struct net_shaper_binding *binding,
+  const struct net_shaper *shaper,
+  struct netlink_ext_ack *extack)
+{
+   struct iavf_adapter *adapter = netdev_priv(binding->netdev);
+   u64 vf_max;
+   int ret;
+
+   ret = iavf_verify_handle(binding, &shaper->handle, extack);
+   if (ret)
+   return ret;
+
+   if (shaper->handle.scope == NET_SHAPER_SCOPE_QUEUE) {
+   vf_max = adapter->qos_caps->cap[0].shaper.peak;
+   if (vf_max && shaper->bw_max > vf_max) {
+   NL_SET_ERR_MSG_FMT(extack, "Max rate (%llu) of queue %d 
can't exceed max TX

[Intel-wired-lan] [tnguy-net-queue:main] BUILD SUCCESS 33f339a1ba54e56bba57ee9a77c71e385ab4825c

2024-09-04 Thread kernel test robot
tree/branch: 
https://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue.git main
branch HEAD: 33f339a1ba54e56bba57ee9a77c71e385ab4825c  bpf, net: Fix a 
potential race in do_sock_getsockopt()

elapsed time: 1057m

configs tested: 110
configs skipped: 4

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

tested configs:
alpha allnoconfig   gcc-14.1.0
alphaallyesconfig   clang-20
alpha   defconfig   gcc-14.1.0
arc  allmodconfig   clang-20
arc   allnoconfig   gcc-14.1.0
arc  allyesconfig   clang-20
arc defconfig   gcc-14.1.0
arm  allmodconfig   clang-20
arm   allnoconfig   gcc-14.1.0
arm  allyesconfig   clang-20
arm defconfig   gcc-14.1.0
armneponset_defconfig   gcc-14.1.0
arm socfpga_defconfig   gcc-14.1.0
arm64allmodconfig   clang-20
arm64 allnoconfig   gcc-14.1.0
arm64   defconfig   gcc-14.1.0
csky alldefconfig   gcc-14.1.0
csky  allnoconfig   gcc-14.1.0
cskydefconfig   gcc-14.1.0
hexagon  allmodconfig   clang-20
hexagon   allnoconfig   gcc-14.1.0
hexagon  allyesconfig   clang-20
hexagon defconfig   gcc-14.1.0
i386 allmodconfig   clang-18
i386  allnoconfig   clang-18
i386 allyesconfig   clang-18
i386 buildonly-randconfig-001-20240904   gcc-12
i386 buildonly-randconfig-002-20240904   gcc-12
i386 buildonly-randconfig-003-20240904   gcc-12
i386 buildonly-randconfig-004-20240904   gcc-12
i386 buildonly-randconfig-005-20240904   gcc-12
i386 buildonly-randconfig-006-20240904   gcc-12
i386defconfig   clang-18
i386  randconfig-001-20240904   gcc-12
i386  randconfig-002-20240904   gcc-12
i386  randconfig-004-20240904   gcc-12
i386  randconfig-005-20240904   gcc-12
i386  randconfig-006-20240904   gcc-12
i386  randconfig-011-20240904   gcc-12
i386  randconfig-012-20240904   gcc-12
i386  randconfig-013-20240904   gcc-12
i386  randconfig-014-20240904   gcc-12
i386  randconfig-015-20240904   gcc-12
i386  randconfig-016-20240904   gcc-12
loongarchallmodconfig   gcc-14.1.0
loongarch allnoconfig   gcc-14.1.0
loongarch   defconfig   gcc-14.1.0
m68k allmodconfig   gcc-14.1.0
m68k  allnoconfig   gcc-14.1.0
m68k allyesconfig   gcc-14.1.0
m68kdefconfig   gcc-14.1.0
m68k  multi_defconfig   gcc-14.1.0
microblaze   allmodconfig   gcc-14.1.0
microblazeallnoconfig   gcc-14.1.0
microblaze   allyesconfig   gcc-14.1.0
microblaze  defconfig   gcc-14.1.0
mips  allnoconfig   gcc-14.1.0
mips   gcw0_defconfig   gcc-14.1.0
mips   ip28_defconfig   gcc-14.1.0
mips   jazz_defconfig   gcc-14.1.0
nios2 allnoconfig   gcc-14.1.0
nios2   defconfig   gcc-14.1.0
openrisc  allnoconfig   clang-20
openrisc allyesconfig   gcc-14.1.0
openriscdefconfig   gcc-12
openrisc simple_smp_defconfig   gcc-14.1.0
parisc   allmodconfig   gcc-14.1.0
pariscallnoconfig   clang-20
parisc   allyesconfig   gcc-14.1.0
parisc  defconfig   gcc-12
parisc64defconfig   gcc-14.1.0
powerpc akebono_defconfig   gcc-14.1.0
powerpc  allmodconfig   gcc-14.1.0
powerpc   allnoconfig   clang-20
powerpc  allyesconfig   gcc-14.1.0
powerpc  ep88xc_defconfig   gcc-14.1.0
powerpc  g5_defconfig   gcc-14.1.0
powerpcge_imp3a_defconfig   gcc-14.1.0
powerpc xes_mpc85xx_defconfig   gcc-14.1.0
riscvallmodconfig   gcc-14.1.0

Re: [Intel-wired-lan] [PATCH iwl-net] i40e: Fix trying to free already-freed IRQ

2024-09-04 Thread YangHang Liu
This issue can be reproduced by hot-unplugging the INTx i40e PF.

The Call Trace will disappear after using Kamal's fix.

Tested-by: Yanghang Liu



On Wed, Sep 4, 2024 at 2:26 AM Kamal Heib  wrote:
>
> Avoid the following warning when trying to free an already freed IRQ,
> The issue happens when trying to call i40e_remove() twice from two
> different contexts which will lead to calling i40e_vsi_free_irq() twice,
> Fix the issue by using a flag to mark that the IRQ has already been freed.
>
> i40e :07:00.0: i40e_ptp_stop: removed PHC on enp7s0
> [ cut here ]
> Trying to free already-free IRQ 0
> WARNING: CPU: 2 PID: 12 at kernel/irq/manage.c:1868 __free_irq+0x1e3/0x350
> Modules linked in: nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib 
> nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nft_chain_nat 
> nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 rfkill ip_set nf_tables 
> nfnetlink vfat fat intel_rapl_msr intel_rapl_common kvm_amd ccp iTCO_wdt 
> iTCO_vendor_support kvm i2c_i801 pcspkr i40e lpc_ich virtio_gpu i2c_smbus 
> virtio_dma_buf drm_shmem_helper drm_kms_helper virtio_balloon joydev drm fuse 
> xfs libcrc32c ahci crct10dif_pclmul libahci crc32_pclmul crc32c_intel 
> virtio_net libata virtio_blk ghash_clmulni_intel net_failover virtio_console 
> failover serio_raw dm_mirror dm_region_hash dm_log dm_mod
> CPU: 2 PID: 12 Comm: kworker/u16:1 Kdump: loaded Not tainted 
> 5.14.0-478.el9.x86_64 #1
> Hardware name: Red Hat KVM/RHEL, BIOS edk2-20240524-1.el9 05/24/2024
> Workqueue: kacpi_hotplug acpi_hotplug_work_fn
> RIP: 0010:__free_irq+0x1e3/0x350
> Code: 00 00 48 8b bb a8 01 00 00 e8 09 74 02 00 49 8b 7c 24 30 e8 8f 7c 1d 00 
> eb 35 8b 74 24 04 48 c7 c7 50 a3 61 92 e8 cd 99 f6 ff <0f> 0b 4c 89 fe 48 89 
> ef e8 30 aa b3 00 48 8b 43 40 48 8b 40 78 48
> RSP: 0018:b971c0077ac8 EFLAGS: 00010086
> RAX:  RBX: 8b594193ee00 RCX: 0027
> RDX: 0027 RSI: 7fff RDI: 8b59bcf208c8
> RBP: 8b594193eec4 R08:  R09: b971c0077970
> R10: b971c0077968 R11: 931e7c28 R12: 8b5944946000
> R13: 8b594193ef80 R14: 8b5944946000 R15: 0246
> FS:  () GS:8b59bcf0() knlGS:
> CS:  0010 DS:  ES:  CR0: 80050033
> CR2: 7f11eb064000 CR3: 0ad40004 CR4: 00770ef0
> PKRU: 5554
> Call Trace:
>  
>  ? srso_alias_return_thunk+0x5/0xfbef5
>  ? show_trace_log_lvl+0x26e/0x2df
>  ? show_trace_log_lvl+0x26e/0x2df
>  ? free_irq+0x33/0x70
>  ? __free_irq+0x1e3/0x350
>  ? __warn+0x7e/0xd0
>  ? __free_irq+0x1e3/0x350
>  ? report_bug+0x100/0x140
>  ? srso_alias_return_thunk+0x5/0xfbef5
>  ? handle_bug+0x3c/0x70
>  ? exc_invalid_op+0x14/0x70
>  ? asm_exc_invalid_op+0x16/0x20
>  ? __free_irq+0x1e3/0x350
>  ? __free_irq+0x1e3/0x350
>  free_irq+0x33/0x70
>  i40e_vsi_free_irq+0x19e/0x220 [i40e]
>  i40e_vsi_close+0x2b/0xc0 [i40e]
>  i40e_close+0x11/0x20 [i40e]
>  __dev_close_many+0x9e/0x110
>  dev_close_many+0x8b/0x140
>  ? srso_alias_return_thunk+0x5/0xfbef5
>  ? free_pcppages_bulk+0xee/0x290
>  unregister_netdevice_many_notify+0x162/0x690
>  ? srso_alias_return_thunk+0x5/0xfbef5
>  ? free_unref_page_commit+0x19a/0x310
>  unregister_netdevice_queue+0xd3/0x110
>  unregister_netdev+0x18/0x20
>  i40e_vsi_release+0x84/0x2e0 [i40e]
>  ? srso_alias_return_thunk+0x5/0xfbef5
>  i40e_remove+0x15c/0x430 [i40e]
>  pci_device_remove+0x3e/0xb0
>  device_release_driver_internal+0x193/0x200
>  pci_stop_bus_device+0x6c/0x90
>  pci_stop_and_remove_bus_device+0xe/0x20
>  disable_slot+0x49/0x90
>  acpiphp_disable_and_eject_slot+0x15/0x90
>  hotplug_event+0xea/0x210
>  ? __pfx_acpiphp_hotplug_notify+0x10/0x10
>  acpiphp_hotplug_notify+0x22/0x80
>  ? __pfx_acpiphp_hotplug_notify+0x10/0x10
>  acpi_device_hotplug+0xb8/0x210
>  acpi_hotplug_work_fn+0x1a/0x30
>  process_one_work+0x197/0x380
>  worker_thread+0x2fe/0x410
>  ? __pfx_worker_thread+0x10/0x10
>  kthread+0xe0/0x100
>  ? __pfx_kthread+0x10/0x10
>  ret_from_fork+0x2c/0x50
>  
> ---[ end trace  ]---
>
> Fixes: 41c445ff0f48 ("i40e: main driver core")
> Tested-by: YangHang Liu 
> Signed-off-by: Kamal Heib 
> ---
>  drivers/net/ethernet/intel/i40e/i40e.h  | 1 +
>  drivers/net/ethernet/intel/i40e/i40e_main.c | 8 
>  2 files changed, 9 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/i40e/i40e.h 
> b/drivers/net/ethernet/intel/i40e/i40e.h
> index d546567e0286..910415116995 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e.h
> +++ b/drivers/net/ethernet/intel/i40e/i40e.h
> @@ -865,6 +865,7 @@ struct i40e_vsi {
> int num_q_vectors;
> int base_vector;
> bool irqs_ready;
> +   bool legacy_msi_irq_ready;
>
> u16 seid;   /* HW index of this VSI (absolute index) */
> u16 id; /* VSI number */
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c 
> b/drivers/net/ethernet/inte

Re: [Intel-wired-lan] [PATCH v1 net-next] e1000e: Remove duplicated writel() in e1000_configure_tx/rx()

2024-09-04 Thread Kohei Enju
> My colleague, Kohei, tested the patch with a real hardware and will provide 
> his
> Tested-by shortly.

I have tested the patch using my physical hardware, an Intel Ethernet 
controller I219-V. The device was properly attached by the e1000e driver and 
functioned correctly. The test was performed on a custom kernel based on 
kernel-core-6.10.6-200.fc40.x86_64.

The PCI device is identified as an Intel Corporation Ethernet Connection (17) 
I219-V (rev 11), with vendor ID 0x8086 and device ID 0x1a1d. This device ID 
matches the E1000_DEV_ID_PCH_ADP_I219_V17 definition in the e1000e driver code.
```
$ lspci | grep -i ethernet
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (17) I219-V 
(rev 11)

$ cat /sys/bus/pci/devices/:00:1f.6/{vendor,device}
0x8086
0x1a1d

$ grep -ri 0x1a1d 
~/ghq/github.com/torvalds/linux/drivers/net/ethernet/intel/e1000e
/home/kohei/ghq/github.com/torvalds/linux/drivers/net/ethernet/intel/e1000e/hw.h:#define
 E1000_DEV_ID_PCH_ADP_I219_V17  0x1A1D
```

So this testing confirms that the patch does not introduce any regressions for 
this specific hardware configuration.

Tested-by: Kohei Enju 
Thanks!


[Intel-wired-lan] [PATCH iwl-next v2 0/6] idpf: XDP chapter II: convert Tx completion to libeth

2024-09-04 Thread Alexander Lobakin
XDP for idpf is currently 5 chapters:
* convert Rx to libeth;
* convert Tx completion to libeth (this);
* generic XDP and XSk code changes;
* actual XDP for idpf via libeth_xdp;
* XSk for idpf (^).

Part II does the following:
* adds generic libeth Tx completion routines;
* converts idpf to use generic libeth Tx comp routines;
* fixes Tx queue timeouts and robustifies Tx completion in general;
* fixes Tx event/descriptor flushes (writebacks).

Most idpf patches again remove more lines than adds.
Generic Tx completion helpers and structs are needed as libeth_xdp
(Ch. III) makes use of them. WB_ON_ITR is needed since XDPSQs don't
want to work without it at all. Tx queue timeouts fixes are needed
since without them, it's way easier to catch a Tx timeout event when
WB_ON_ITR is enabled.

Alexander Lobakin (3):
  libeth: add Tx buffer completion helpers
  idpf: convert to libeth Tx buffer completion
  netdevice: add netdev_tx_reset_subqueue() shorthand

Joshua Hay (2):
  idpf: refactor Tx completion routines
  idpf: enable WB_ON_ITR

Michal Kubiak (1):
  idpf: fix netdev Tx queue stop/wake

 include/net/libeth/types.h|  25 ++
 drivers/net/ethernet/intel/idpf/idpf_txrx.h   |  92 ++--
 include/linux/netdevice.h |  13 +-
 include/net/libeth/tx.h   | 129 ++
 drivers/net/ethernet/intel/idpf/idpf_dev.c|   2 +
 .../ethernet/intel/idpf/idpf_singleq_txrx.c   | 110 +++--
 drivers/net/ethernet/intel/idpf/idpf_txrx.c   | 394 --
 drivers/net/ethernet/intel/idpf/idpf_vf_dev.c |   2 +
 8 files changed, 441 insertions(+), 326 deletions(-)
 create mode 100644 include/net/libeth/types.h
 create mode 100644 include/net/libeth/tx.h

---
>From v1[0]:
* drop the stats implementation. It's not generic, uses old Ethtool
  interfaces and is written using macro templates which made it barely
  readable (Kuba).
  I'll be rewriting it separately.
* replace `/* ` with `/*\n * `
  since the special rule for netdev was removed.

[0] 
https://lore.kernel.org/netdev/20240819223442.48013-1-anthony.l.ngu...@intel.com
-- 
2.46.0



[Intel-wired-lan] [PATCH iwl-next v2 1/6] libeth: add Tx buffer completion helpers

2024-09-04 Thread Alexander Lobakin
Software-side Tx buffers for storing DMA, frame size, skb pointers etc.
are pretty much generic and every driver defines them the same way. The
same can be said for software Tx completions -- same napi_consume_skb()s
and all that...
Add a couple simple wrappers for doing that to stop repeating the old
tale at least within the Intel code. Drivers are free to use 'priv'
member at the end of the structure.

Reviewed-by: Przemek Kitszel 
Signed-off-by: Alexander Lobakin 
---
 include/net/libeth/types.h |  25 +++
 include/net/libeth/tx.h| 129 +
 2 files changed, 154 insertions(+)
 create mode 100644 include/net/libeth/types.h
 create mode 100644 include/net/libeth/tx.h

diff --git a/include/net/libeth/types.h b/include/net/libeth/types.h
new file mode 100644
index ..603825e45133
--- /dev/null
+++ b/include/net/libeth/types.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (C) 2024 Intel Corporation */
+
+#ifndef __LIBETH_TYPES_H
+#define __LIBETH_TYPES_H
+
+#include 
+
+/**
+ * struct libeth_sq_napi_stats - "hot" counters to update in Tx completion loop
+ * @packets: completed frames counter
+ * @bytes: sum of bytes of completed frames above
+ * @raw: alias to access all the fields as an array
+ */
+struct libeth_sq_napi_stats {
+   union {
+   struct {
+   u32 packets;
+   u32 bytes;
+   };
+   DECLARE_FLEX_ARRAY(u32, raw);
+   };
+};
+
+#endif /* __LIBETH_TYPES_H */
diff --git a/include/net/libeth/tx.h b/include/net/libeth/tx.h
new file mode 100644
index ..35614f9523f6
--- /dev/null
+++ b/include/net/libeth/tx.h
@@ -0,0 +1,129 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (C) 2024 Intel Corporation */
+
+#ifndef __LIBETH_TX_H
+#define __LIBETH_TX_H
+
+#include 
+
+#include 
+
+/* Tx buffer completion */
+
+/**
+ * enum libeth_sqe_type - type of &libeth_sqe to act on Tx completion
+ * @LIBETH_SQE_EMPTY: unused/empty, no action required
+ * @LIBETH_SQE_CTX: context descriptor with empty SQE, no action required
+ * @LIBETH_SQE_SLAB: kmalloc-allocated buffer, unmap and kfree()
+ * @LIBETH_SQE_FRAG: mapped skb frag, only unmap DMA
+ * @LIBETH_SQE_SKB: &sk_buff, unmap and napi_consume_skb(), update stats
+ */
+enum libeth_sqe_type {
+   LIBETH_SQE_EMPTY= 0U,
+   LIBETH_SQE_CTX,
+   LIBETH_SQE_SLAB,
+   LIBETH_SQE_FRAG,
+   LIBETH_SQE_SKB,
+};
+
+/**
+ * struct libeth_sqe - represents a Send Queue Element / Tx buffer
+ * @type: type of the buffer, see the enum above
+ * @rs_idx: index of the last buffer from the batch this one was sent in
+ * @raw: slab buffer to free via kfree()
+ * @skb: &sk_buff to consume
+ * @dma: DMA address to unmap
+ * @len: length of the mapped region to unmap
+ * @nr_frags: number of frags in the frame this buffer belongs to
+ * @packets: number of physical packets sent for this frame
+ * @bytes: number of physical bytes sent for this frame
+ * @priv: driver-private scratchpad
+ */
+struct libeth_sqe {
+   enum libeth_sqe_typetype:32;
+   u32 rs_idx;
+
+   union {
+   void*raw;
+   struct sk_buff  *skb;
+   };
+
+   DEFINE_DMA_UNMAP_ADDR(dma);
+   DEFINE_DMA_UNMAP_LEN(len);
+
+   u32 nr_frags;
+   u32 packets;
+   u32 bytes;
+
+   unsigned long   priv;
+} __aligned_largest;
+
+/**
+ * LIBETH_SQE_CHECK_PRIV - check the driver's private SQE data
+ * @p: type or name of the object the driver wants to fit into &libeth_sqe
+ *
+ * Make sure the driver's private data fits into libeth_sqe::priv. To be used
+ * right after its declaration.
+ */
+#define LIBETH_SQE_CHECK_PRIV(p) \
+   static_assert(sizeof(p) <= sizeof_field(struct libeth_sqe, priv))
+
+/**
+ * struct libeth_cq_pp - completion queue poll params
+ * @dev: &device to perform DMA unmapping
+ * @ss: onstack NAPI stats to fill
+ * @napi: whether it's called from the NAPI context
+ *
+ * libeth uses this structure to access objects needed for performing full
+ * Tx complete operation without passing lots of arguments and change the
+ * prototypes each time a new one is added.
+ */
+struct libeth_cq_pp {
+   struct device   *dev;
+   struct libeth_sq_napi_stats *ss;
+
+   boolnapi;
+};
+
+/**
+ * libeth_tx_complete - perform Tx completion for one SQE
+ * @sqe: SQE to complete
+ * @cp: poll params
+ *
+ * Do Tx complete for all the types of buffers, incl. freeing, unmapping,
+ * updating the stats etc.
+ */
+static inline void libeth_tx_complete(struct libeth_sqe *sqe,
+   

[Intel-wired-lan] [PATCH iwl-next v2 2/6] idpf: convert to libeth Tx buffer completion

2024-09-04 Thread Alexander Lobakin
&idpf_tx_buffer is almost identical to the previous generations, as well
as the way it's handled. Moreover, relying on dma_unmap_addr() and
!!buf->skb instead of explicit defining of buffer's type was never good.
Use the newly added libeth helpers to do it properly and reduce the
copy-paste around the Tx code.

Reviewed-by: Przemek Kitszel 
Signed-off-by: Alexander Lobakin 
---
 drivers/net/ethernet/intel/idpf/idpf_txrx.h   |  50 +
 .../ethernet/intel/idpf/idpf_singleq_txrx.c   |  82 +++
 drivers/net/ethernet/intel/idpf/idpf_txrx.c   | 205 +++---
 3 files changed, 105 insertions(+), 232 deletions(-)

diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.h 
b/drivers/net/ethernet/intel/idpf/idpf_txrx.h
index 6215dbee5546..1b20cd96c613 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.h
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.h
@@ -131,7 +131,6 @@ do {
\
(txq)->num_completions_pending - (txq)->complq->num_completions)
 
 #define IDPF_TX_SPLITQ_COMPL_TAG_WIDTH 16
-#define IDPF_SPLITQ_TX_INVAL_COMPL_TAG -1
 /* Adjust the generation for the completion tag and wrap if necessary */
 #define IDPF_TX_ADJ_COMPL_TAG_GEN(txq) \
((++(txq)->compl_tag_cur_gen) >= (txq)->compl_tag_gen_max ? \
@@ -149,47 +148,7 @@ union idpf_tx_flex_desc {
struct idpf_flex_tx_sched_desc flow; /* flow based scheduling */
 };
 
-/**
- * struct idpf_tx_buf
- * @next_to_watch: Next descriptor to clean
- * @skb: Pointer to the skb
- * @dma: DMA address
- * @len: DMA length
- * @bytecount: Number of bytes
- * @gso_segs: Number of GSO segments
- * @compl_tag: Splitq only, unique identifier for a buffer. Used to compare
- *with completion tag returned in buffer completion event.
- *Because the completion tag is expected to be the same in all
- *data descriptors for a given packet, and a single packet can
- *span multiple buffers, we need this field to track all
- *buffers associated with this completion tag independently of
- *the buf_id. The tag consists of a N bit buf_id and M upper
- *order "generation bits". See compl_tag_bufid_m and
- *compl_tag_gen_s in struct idpf_queue. We'll use a value of -1
- *to indicate the tag is not valid.
- * @ctx_entry: Singleq only. Used to indicate the corresponding entry
- *in the descriptor ring was used for a context descriptor and
- *this buffer entry should be skipped.
- */
-struct idpf_tx_buf {
-   void *next_to_watch;
-   struct sk_buff *skb;
-   DEFINE_DMA_UNMAP_ADDR(dma);
-   DEFINE_DMA_UNMAP_LEN(len);
-   unsigned int bytecount;
-   unsigned short gso_segs;
-
-   union {
-   int compl_tag;
-
-   bool ctx_entry;
-   };
-};
-
-struct idpf_tx_stash {
-   struct hlist_node hlist;
-   struct idpf_tx_buf buf;
-};
+#define idpf_tx_buf libeth_sqe
 
 /**
  * struct idpf_buf_lifo - LIFO for managing OOO completions
@@ -496,11 +455,6 @@ struct idpf_tx_queue_stats {
u64_stats_t dma_map_errs;
 };
 
-struct idpf_cleaned_stats {
-   u32 packets;
-   u32 bytes;
-};
-
 #define IDPF_ITR_DYNAMIC   1
 #define IDPF_ITR_MAX   0x1FE0
 #define IDPF_ITR_20K   0x0032
@@ -688,7 +642,7 @@ struct idpf_tx_queue {
 
void *desc_ring;
};
-   struct idpf_tx_buf *tx_buf;
+   struct libeth_sqe *tx_buf;
struct idpf_txq_group *txq_grp;
struct device *dev;
void __iomem *tail;
diff --git a/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c 
b/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
index fe64febf7436..98f26a4b835f 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
@@ -2,6 +2,7 @@
 /* Copyright (C) 2023 Intel Corporation */
 
 #include 
+#include 
 
 #include "idpf.h"
 
@@ -224,6 +225,7 @@ static void idpf_tx_singleq_map(struct idpf_tx_queue *tx_q,
/* record length, and DMA address */
dma_unmap_len_set(tx_buf, len, size);
dma_unmap_addr_set(tx_buf, dma, dma);
+   tx_buf->type = LIBETH_SQE_FRAG;
 
/* align size to end of page */
max_data += -dma & (IDPF_TX_MAX_READ_REQ_SIZE - 1);
@@ -245,6 +247,8 @@ static void idpf_tx_singleq_map(struct idpf_tx_queue *tx_q,
i = 0;
}
 
+   tx_q->tx_buf[i].type = LIBETH_SQE_EMPTY;
+
dma += max_data;
size -= max_data;
 
@@ -282,13 +286,13 @@ static void idpf_tx_singleq_map(struct idpf_tx_queue 
*tx_q,
tx_desc->qw1 = idpf_tx_singleq_build_ctob(td_cmd, offsets,
  size, td_tag);
 
-   IDPF_SINGLEQ_BUMP_RING_IDX(tx_q, i);
+   first->type = LIBETH_SQE_SKB;

[Intel-wired-lan] [PATCH iwl-next v2 3/6] netdevice: add netdev_tx_reset_subqueue() shorthand

2024-09-04 Thread Alexander Lobakin
Add a shorthand similar to other net*_subqueue() helpers for resetting
the queue by its index w/o obtaining &netdev_tx_queue beforehand
manually.

Reviewed-by: Przemek Kitszel 
Signed-off-by: Alexander Lobakin 
---
 include/linux/netdevice.h | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 4d6fb0ccdea1..4f37b01b3d5a 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3599,6 +3599,17 @@ static inline void netdev_tx_reset_queue(struct 
netdev_queue *q)
 #endif
 }
 
+/**
+ * netdev_tx_reset_subqueue - reset the BQL stats and state of a netdev queue
+ * @dev: network device
+ * @qid: stack index of the queue to reset
+ */
+static inline void netdev_tx_reset_subqueue(const struct net_device *dev,
+   u32 qid)
+{
+   netdev_tx_reset_queue(netdev_get_tx_queue(dev, qid));
+}
+
 /**
  * netdev_reset_queue - reset the packets and bytes count of a network 
device
  * @dev_queue: network device
@@ -3608,7 +3619,7 @@ static inline void netdev_tx_reset_queue(struct 
netdev_queue *q)
  */
 static inline void netdev_reset_queue(struct net_device *dev_queue)
 {
-   netdev_tx_reset_queue(netdev_get_tx_queue(dev_queue, 0));
+   netdev_tx_reset_subqueue(dev_queue, 0);
 }
 
 /**
-- 
2.46.0



[Intel-wired-lan] [PATCH iwl-next v2 4/6] idpf: refactor Tx completion routines

2024-09-04 Thread Alexander Lobakin
From: Joshua Hay 

Add a mechanism to guard against stashing partial packets into the hash
table to make the driver more robust, with more efficient decision
making when cleaning.

Don't stash partial packets. This can happen when an RE (Report Event)
completion is received in flow scheduling mode, or when an out of order
RS (Report Status) completion is received. The first buffer with the skb
is stashed, but some or all of its frags are not because the stack is
out of reserve buffers. This leaves the ring in a weird state since
the frags are still on the ring.

Use the field libeth_sqe::nr_frags to track the number of
fragments/tx_bufs representing the packet. The clean routines check to
make sure there are enough reserve buffers on the stack before stashing
any part of the packet. If there are not, next_to_clean is left pointing
to the first buffer of the packet that failed to be stashed. This leaves
the whole packet on the ring, and the next time around, cleaning will
start from this packet.

An RS completion is still expected for this packet in either case. So
instead of being cleaned from the hash table, it will be cleaned from
the ring directly. This should all still be fine since the DESC_UNUSED
and BUFS_UNUSED will reflect the state of the ring. If we ever fall
below the thresholds, the TxQ will still be stopped, giving the
completion queue time to catch up. This may lead to stopping the queue
more frequently, but it guarantees the Tx ring will always be in a good
state.

Also, always use the idpf_tx_splitq_clean function to clean descriptors,
i.e. use it from clean_buf_ring as well. This way we avoid duplicating
the logic and make sure we're using the same reserve buffers guard rail.

This does require a switch from the s16 next_to_clean overflow
descriptor ring wrap calculation to u16 and the normal ring size check.

Signed-off-by: Joshua Hay 
Reviewed-by: Przemek Kitszel 
Signed-off-by: Alexander Lobakin 
---
 drivers/net/ethernet/intel/idpf/idpf_txrx.h   |   6 +-
 .../ethernet/intel/idpf/idpf_singleq_txrx.c   |  24 +--
 drivers/net/ethernet/intel/idpf/idpf_txrx.c   | 167 +++---
 3 files changed, 121 insertions(+), 76 deletions(-)

diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.h 
b/drivers/net/ethernet/intel/idpf/idpf_txrx.h
index 1b20cd96c613..3a2a92e79e60 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.h
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.h
@@ -127,7 +127,7 @@ do {
\
  */
 #define IDPF_TX_COMPLQ_PENDING(txq)\
(((txq)->num_completions_pending >= (txq)->complq->num_completions ? \
-   0 : U64_MAX) + \
+   0 : U32_MAX) + \
(txq)->num_completions_pending - (txq)->complq->num_completions)
 
 #define IDPF_TX_SPLITQ_COMPL_TAG_WIDTH 16
@@ -785,7 +785,7 @@ struct idpf_compl_queue {
u32 next_to_use;
u32 next_to_clean;
 
-   u32 num_completions;
+   aligned_u64 num_completions;
__cacheline_group_end_aligned(read_write);
 
__cacheline_group_begin_aligned(cold);
@@ -917,7 +917,7 @@ struct idpf_txq_group {
 
struct idpf_compl_queue *complq;
 
-   u32 num_completions_pending;
+   aligned_u64 num_completions_pending;
 };
 
 static inline int idpf_q_vector_to_mem(const struct idpf_q_vector *q_vector)
diff --git a/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c 
b/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
index 98f26a4b835f..947d3ff9677c 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
@@ -239,15 +239,16 @@ static void idpf_tx_singleq_map(struct idpf_tx_queue 
*tx_q,
  offsets,
  max_data,
  td_tag);
-   tx_desc++;
-   i++;
-
-   if (i == tx_q->desc_count) {
+   if (unlikely(++i == tx_q->desc_count)) {
+   tx_buf = &tx_q->tx_buf[0];
tx_desc = &tx_q->base_tx[0];
i = 0;
+   } else {
+   tx_buf++;
+   tx_desc++;
}
 
-   tx_q->tx_buf[i].type = LIBETH_SQE_EMPTY;
+   tx_buf->type = LIBETH_SQE_EMPTY;
 
dma += max_data;
size -= max_data;
@@ -261,12 +262,14 @@ static void idpf_tx_singleq_map(struct idpf_tx_queue 
*tx_q,
 
tx_desc->qw1 = idpf_tx_singleq_build_ctob(td_cmd, offsets,
  size, td_tag);
-   tx_desc++;
-   i++;
 
-   if (i == tx_q->desc_count) {
+   if (unlikely(++i == tx_q->desc_

[Intel-wired-lan] [PATCH iwl-next v2 5/6] idpf: fix netdev Tx queue stop/wake

2024-09-04 Thread Alexander Lobakin
From: Michal Kubiak 

netif_txq_maybe_stop() returns -1, 0, or 1, while
idpf_tx_maybe_stop_common() says it returns 0 or -EBUSY. As a result,
there sometimes are Tx queue timeout warnings despite that the queue
is empty or there is at least enough space to restart it.
Make idpf_tx_maybe_stop_common() inline and returning true or false,
handling the return of netif_txq_maybe_stop() properly. Use a correct
goto in idpf_tx_maybe_stop_splitq() to avoid stopping the queue or
incrementing the stops counter twice.

Fixes: 6818c4d5b3c2 ("idpf: add splitq start_xmit")
Fixes: a5ab9ee0df0b ("idpf: add singleq start_xmit and napi poll")
Cc: sta...@vger.kernel.org # 6.7+
Signed-off-by: Michal Kubiak 
Reviewed-by: Przemek Kitszel 
Signed-off-by: Alexander Lobakin 
---
 drivers/net/ethernet/intel/idpf/idpf_txrx.h   |  9 -
 .../ethernet/intel/idpf/idpf_singleq_txrx.c   |  4 +++
 drivers/net/ethernet/intel/idpf/idpf_txrx.c   | 35 +--
 3 files changed, 21 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.h 
b/drivers/net/ethernet/intel/idpf/idpf_txrx.h
index 3a2a92e79e60..33305de06975 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.h
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.h
@@ -1018,7 +1018,6 @@ void idpf_tx_dma_map_error(struct idpf_tx_queue *txq, 
struct sk_buff *skb,
   struct idpf_tx_buf *first, u16 ring_idx);
 unsigned int idpf_tx_desc_count_required(struct idpf_tx_queue *txq,
 struct sk_buff *skb);
-int idpf_tx_maybe_stop_common(struct idpf_tx_queue *tx_q, unsigned int size);
 void idpf_tx_timeout(struct net_device *netdev, unsigned int txqueue);
 netdev_tx_t idpf_tx_singleq_frame(struct sk_buff *skb,
  struct idpf_tx_queue *tx_q);
@@ -1027,4 +1026,12 @@ bool idpf_rx_singleq_buf_hw_alloc_all(struct 
idpf_rx_queue *rxq,
  u16 cleaned_count);
 int idpf_tso(struct sk_buff *skb, struct idpf_tx_offload_params *off);
 
+static inline bool idpf_tx_maybe_stop_common(struct idpf_tx_queue *tx_q,
+u32 needed)
+{
+   return !netif_subqueue_maybe_stop(tx_q->netdev, tx_q->idx,
+ IDPF_DESC_UNUSED(tx_q),
+ needed, needed);
+}
+
 #endif /* !_IDPF_TXRX_H_ */
diff --git a/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c 
b/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
index 947d3ff9677c..5ba360abbe66 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
@@ -375,6 +375,10 @@ netdev_tx_t idpf_tx_singleq_frame(struct sk_buff *skb,
  IDPF_TX_DESCS_FOR_CTX)) {
idpf_tx_buf_hw_update(tx_q, tx_q->next_to_use, false);
 
+   u64_stats_update_begin(&tx_q->stats_sync);
+   u64_stats_inc(&tx_q->q_stats.q_busy);
+   u64_stats_update_end(&tx_q->stats_sync);
+
return NETDEV_TX_BUSY;
}
 
diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c 
b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
index a7f7efc61caf..0303e097 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
@@ -2131,29 +2131,6 @@ void idpf_tx_splitq_build_flow_desc(union 
idpf_tx_flex_desc *desc,
desc->flow.qw1.compl_tag = cpu_to_le16(params->compl_tag);
 }
 
-/**
- * idpf_tx_maybe_stop_common - 1st level check for common Tx stop conditions
- * @tx_q: the queue to be checked
- * @size: number of descriptors we want to assure is available
- *
- * Returns 0 if stop is not needed
- */
-int idpf_tx_maybe_stop_common(struct idpf_tx_queue *tx_q, unsigned int size)
-{
-   struct netdev_queue *nq;
-
-   if (likely(IDPF_DESC_UNUSED(tx_q) >= size))
-   return 0;
-
-   u64_stats_update_begin(&tx_q->stats_sync);
-   u64_stats_inc(&tx_q->q_stats.q_busy);
-   u64_stats_update_end(&tx_q->stats_sync);
-
-   nq = netdev_get_tx_queue(tx_q->netdev, tx_q->idx);
-
-   return netif_txq_maybe_stop(nq, IDPF_DESC_UNUSED(tx_q), size, size);
-}
-
 /**
  * idpf_tx_maybe_stop_splitq - 1st level check for Tx splitq stop conditions
  * @tx_q: the queue to be checked
@@ -2165,7 +2142,7 @@ static int idpf_tx_maybe_stop_splitq(struct idpf_tx_queue 
*tx_q,
 unsigned int descs_needed)
 {
if (idpf_tx_maybe_stop_common(tx_q, descs_needed))
-   goto splitq_stop;
+   goto out;
 
/* If there are too many outstanding completions expected on the
 * completion queue, stop the TX queue to give the device some time to
@@ -2184,10 +2161,12 @@ static int idpf_tx_maybe_stop_splitq(struct 
idpf_tx_queue *tx_q,
return 0;
 
 splitq_stop:
+   netif_stop_subqueue(tx_q->netdev, tx_q->idx);
+
+out:
u64_stats_update_begin(&tx_q

[Intel-wired-lan] [PATCH iwl-next v2 6/6] idpf: enable WB_ON_ITR

2024-09-04 Thread Alexander Lobakin
From: Joshua Hay 

Tell hardware to write back completed descriptors even when interrupts
are disabled. Otherwise, descriptors might not be written back until
the hardware can flush a full cacheline of descriptors. This can cause
unnecessary delays when traffic is light (or even trigger Tx queue
timeout).

The example scenario to reproduce the Tx timeout if the fix is not
applied:
  - configure at least 2 Tx queues to be assigned to the same q_vector,
  - generate a huge Tx traffic on the first Tx queue
  - try to send a few packets using the second Tx queue.
In such a case Tx timeout will appear on the second Tx queue because no
completion descriptors are written back for that queue while interrupts
are disabled due to NAPI polling.

Fixes: c2d548cad150 ("idpf: add TX splitq napi poll support")
Fixes: a5ab9ee0df0b ("idpf: add singleq start_xmit and napi poll")
Signed-off-by: Joshua Hay 
Co-developed-by: Michal Kubiak 
Signed-off-by: Michal Kubiak 
Reviewed-by: Przemek Kitszel 
Signed-off-by: Alexander Lobakin 
---
 drivers/net/ethernet/intel/idpf/idpf_txrx.h   | 27 ++-
 drivers/net/ethernet/intel/idpf/idpf_dev.c|  2 ++
 .../ethernet/intel/idpf/idpf_singleq_txrx.c   |  6 -
 drivers/net/ethernet/intel/idpf/idpf_txrx.c   |  7 -
 drivers/net/ethernet/intel/idpf/idpf_vf_dev.c |  2 ++
 5 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.h 
b/drivers/net/ethernet/intel/idpf/idpf_txrx.h
index 33305de06975..f0537826f840 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.h
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.h
@@ -349,9 +349,11 @@ struct idpf_vec_regs {
  * struct idpf_intr_reg
  * @dyn_ctl: Dynamic control interrupt register
  * @dyn_ctl_intena_m: Mask for dyn_ctl interrupt enable
+ * @dyn_ctl_intena_msk_m: Mask for dyn_ctl interrupt enable mask
  * @dyn_ctl_itridx_s: Register bit offset for ITR index
  * @dyn_ctl_itridx_m: Mask for ITR index
  * @dyn_ctl_intrvl_s: Register bit offset for ITR interval
+ * @dyn_ctl_wb_on_itr_m: Mask for WB on ITR feature
  * @rx_itr: RX ITR register
  * @tx_itr: TX ITR register
  * @icr_ena: Interrupt cause register offset
@@ -360,9 +362,11 @@ struct idpf_vec_regs {
 struct idpf_intr_reg {
void __iomem *dyn_ctl;
u32 dyn_ctl_intena_m;
+   u32 dyn_ctl_intena_msk_m;
u32 dyn_ctl_itridx_s;
u32 dyn_ctl_itridx_m;
u32 dyn_ctl_intrvl_s;
+   u32 dyn_ctl_wb_on_itr_m;
void __iomem *rx_itr;
void __iomem *tx_itr;
void __iomem *icr_ena;
@@ -383,6 +387,7 @@ struct idpf_intr_reg {
  * @intr_reg: See struct idpf_intr_reg
  * @napi: napi handler
  * @total_events: Number of interrupts processed
+ * @wb_on_itr: whether WB on ITR is enabled
  * @tx_dim: Data for TX net_dim algorithm
  * @tx_itr_value: TX interrupt throttling rate
  * @tx_intr_mode: Dynamic ITR or not
@@ -413,6 +418,7 @@ struct idpf_q_vector {
__cacheline_group_begin_aligned(read_write);
struct napi_struct napi;
u16 total_events;
+   bool wb_on_itr;
 
struct dim tx_dim;
u16 tx_itr_value;
@@ -431,7 +437,7 @@ struct idpf_q_vector {
cpumask_var_t affinity_mask;
__cacheline_group_end_aligned(cold);
 };
-libeth_cacheline_set_assert(struct idpf_q_vector, 104,
+libeth_cacheline_set_assert(struct idpf_q_vector, 112,
424 + 2 * sizeof(struct dim),
8 + sizeof(cpumask_var_t));
 
@@ -987,6 +993,25 @@ static inline void idpf_tx_splitq_build_desc(union 
idpf_tx_flex_desc *desc,
idpf_tx_splitq_build_flow_desc(desc, params, td_cmd, size);
 }
 
+/**
+ * idpf_vport_intr_set_wb_on_itr - enable descriptor writeback on disabled 
interrupts
+ * @q_vector: pointer to queue vector struct
+ */
+static inline void idpf_vport_intr_set_wb_on_itr(struct idpf_q_vector 
*q_vector)
+{
+   struct idpf_intr_reg *reg;
+
+   if (q_vector->wb_on_itr)
+   return;
+
+   q_vector->wb_on_itr = true;
+   reg = &q_vector->intr_reg;
+
+   writel(reg->dyn_ctl_wb_on_itr_m | reg->dyn_ctl_intena_msk_m |
+  (IDPF_NO_ITR_UPDATE_IDX << reg->dyn_ctl_itridx_s),
+  reg->dyn_ctl);
+}
+
 int idpf_vport_singleq_napi_poll(struct napi_struct *napi, int budget);
 void idpf_vport_init_num_qs(struct idpf_vport *vport,
struct virtchnl2_create_vport *vport_msg);
diff --git a/drivers/net/ethernet/intel/idpf/idpf_dev.c 
b/drivers/net/ethernet/intel/idpf/idpf_dev.c
index 3df9935685e9..6c913a703df6 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_dev.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_dev.c
@@ -97,8 +97,10 @@ static int idpf_intr_reg_init(struct idpf_vport *vport)
intr->dyn_ctl = idpf_get_reg_addr(adapter,
  reg_vals[vec_id].dyn_ctl_reg);
intr->dyn_ctl_intena_m = PF_GLINT_DYN_CTL_INTENA_M;
+   intr->dyn_ctl_intena_msk_m = PF

Re: [Intel-wired-lan] [PATCH net-next] ice: Make use of assign_bit() API

2024-09-04 Thread Gerhard Engleder

On 02.09.24 15:14, Hongbo Li wrote:

We have for some time the assign_bit() API to replace open coded

 if (foo)
 set_bit(n, bar);
 else
 clear_bit(n, bar);

Use this API to clean the code. No functional change intended.

Signed-off-by: Hongbo Li 
---
  drivers/net/ethernet/intel/ice/ice_main.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_main.c 
b/drivers/net/ethernet/intel/ice/ice_main.c
index 46d3c5a34d6a..e3ad91b3ba77 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -6522,8 +6522,7 @@ ice_set_features(struct net_device *netdev, 
netdev_features_t features)
if (changed & NETIF_F_HW_TC) {
bool ena = !!(features & NETIF_F_HW_TC);
  
-		ena ? set_bit(ICE_FLAG_CLS_FLOWER, pf->flags) :

- clear_bit(ICE_FLAG_CLS_FLOWER, pf->flags);
+   assign_bit(ICE_FLAG_CLS_FLOWER, pf->flags, ena);
}
  
  	if (changed & NETIF_F_LOOPBACK)


Reviewed-by: Gerhard Engleder 


Re: [Intel-wired-lan] [PATCH iwl-net] ice: fix memleak in ice_init_tx_topology()

2024-09-04 Thread Jacob Keller



On 9/4/2024 5:32 AM, Przemek Kitszel wrote:
>   dev = ice_pf_to_dev(pf);
> - /* ice_cfg_tx_topo buf argument is not a constant,
> -  * so we have to make a copy
> -  */
> - buf_copy = kmemdup(firmware->data, firmware->size, GFP_KERNEL);
> -
> - err = ice_cfg_tx_topo(hw, buf_copy, firmware->size);
> + err = ice_cfg_tx_topo(hw, (void *)firmware->data, firmware->size);
>   if (!err) {

Yea, just casting away the const is sufficient here, the function
doesn't modify this buffer.

Reviewed-by: Jacob Keller 


Re: [Intel-wired-lan] [PATCH iwl-net] i40e: Fix trying to free already-freed IRQ

2024-09-04 Thread Loktionov, Aleksandr


> -Original Message-
> From: Intel-wired-lan  On Behalf
> Of YangHang Liu
> Sent: Wednesday, September 4, 2024 4:37 AM
> To: Kamal Heib ; Chao Yang 
> Cc: ivecera ; net...@vger.kernel.org; Jakub
> Kicinski ; Nguyen, Anthony L
> ; Kitszel, Przemyslaw
> ; intel-wired-...@lists.osuosl.org;
> Paolo Abeni ; David S . Miller
> 
> Subject: Re: [Intel-wired-lan] [PATCH iwl-net] i40e: Fix trying to
> free already-freed IRQ
> 
> This issue can be reproduced by hot-unplugging the INTx i40e PF.
> 
> The Call Trace will disappear after using Kamal's fix.
> 
> Tested-by: Yanghang Liu
> 
> 
> 
> On Wed, Sep 4, 2024 at 2:26 AM Kamal Heib  wrote:
> >
> > Avoid the following warning when trying to free an already freed
> IRQ,
> > The issue happens when trying to call i40e_remove() twice from two
> > different contexts which will lead to calling i40e_vsi_free_irq()
> > twice, Fix the issue by using a flag to mark that the IRQ has
> already been freed.
> >
> > i40e :07:00.0: i40e_ptp_stop: removed PHC on enp7s0 
> [
> > cut here ] Trying to free already-free IRQ 0
> > WARNING: CPU: 2 PID: 12 at kernel/irq/manage.c:1868
> > __free_irq+0x1e3/0x350 Modules linked in: nft_fib_inet nft_fib_ipv4
> > nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6
> > nft_reject nft_ct nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6
> > nf_defrag_ipv4 rfkill ip_set nf_tables nfnetlink vfat fat
> > intel_rapl_msr intel_rapl_common kvm_amd ccp iTCO_wdt
> > iTCO_vendor_support kvm i2c_i801 pcspkr i40e lpc_ich virtio_gpu
> > i2c_smbus virtio_dma_buf drm_shmem_helper drm_kms_helper
> > virtio_balloon joydev drm fuse xfs libcrc32c ahci crct10dif_pclmul
> > libahci crc32_pclmul crc32c_intel virtio_net libata virtio_blk
> > ghash_clmulni_intel net_failover virtio_console failover serio_raw
> > dm_mirror dm_region_hash dm_log dm_mod
> > CPU: 2 PID: 12 Comm: kworker/u16:1 Kdump: loaded Not tainted
> > 5.14.0-478.el9.x86_64 #1 Hardware name: Red Hat KVM/RHEL, BIOS
> > edk2-20240524-1.el9 05/24/2024
> > Workqueue: kacpi_hotplug acpi_hotplug_work_fn
> > RIP: 0010:__free_irq+0x1e3/0x350
> > Code: 00 00 48 8b bb a8 01 00 00 e8 09 74 02 00 49 8b 7c 24 30 e8 8f
> > 7c 1d 00 eb 35 8b 74 24 04 48 c7 c7 50 a3 61 92 e8 cd 99 f6 ff <0f>
> 0b
> > 4c 89 fe 48 89 ef e8 30 aa b3 00 48 8b 43 40 48 8b 40 78 48
> > RSP: 0018:b971c0077ac8 EFLAGS: 00010086
> > RAX:  RBX: 8b594193ee00 RCX: 0027
> > RDX: 0027 RSI: 7fff RDI: 8b59bcf208c8
> > RBP: 8b594193eec4 R08:  R09: b971c0077970
> > R10: b971c0077968 R11: 931e7c28 R12: 8b5944946000
> > R13: 8b594193ef80 R14: 8b5944946000 R15: 0246
> > FS:  () GS:8b59bcf0()
> > knlGS:
> > CS:  0010 DS:  ES:  CR0: 80050033
> > CR2: 7f11eb064000 CR3: 0ad40004 CR4: 00770ef0
> > PKRU: 5554
> > Call Trace:
> >  
> >  ? srso_alias_return_thunk+0x5/0xfbef5
> >  ? show_trace_log_lvl+0x26e/0x2df
> >  ? show_trace_log_lvl+0x26e/0x2df
> >  ? free_irq+0x33/0x70
> >  ? __free_irq+0x1e3/0x350
> >  ? __warn+0x7e/0xd0
> >  ? __free_irq+0x1e3/0x350
> >  ? report_bug+0x100/0x140
> >  ? srso_alias_return_thunk+0x5/0xfbef5
> >  ? handle_bug+0x3c/0x70
> >  ? exc_invalid_op+0x14/0x70
> >  ? asm_exc_invalid_op+0x16/0x20
> >  ? __free_irq+0x1e3/0x350
> >  ? __free_irq+0x1e3/0x350
> >  free_irq+0x33/0x70
> >  i40e_vsi_free_irq+0x19e/0x220 [i40e]
> >  i40e_vsi_close+0x2b/0xc0 [i40e]
> >  i40e_close+0x11/0x20 [i40e]
> >  __dev_close_many+0x9e/0x110
> >  dev_close_many+0x8b/0x140
> >  ? srso_alias_return_thunk+0x5/0xfbef5
> >  ? free_pcppages_bulk+0xee/0x290
> >  unregister_netdevice_many_notify+0x162/0x690
> >  ? srso_alias_return_thunk+0x5/0xfbef5
> >  ? free_unref_page_commit+0x19a/0x310
> >  unregister_netdevice_queue+0xd3/0x110
> >  unregister_netdev+0x18/0x20
> >  i40e_vsi_release+0x84/0x2e0 [i40e]
> >  ? srso_alias_return_thunk+0x5/0xfbef5
> >  i40e_remove+0x15c/0x430 [i40e]
> >  pci_device_remove+0x3e/0xb0
> >  device_release_driver_internal+0x193/0x200
> >  pci_stop_bus_device+0x6c/0x90
> >  pci_stop_and_remove_bus_device+0xe/0x20
> >  disable_slot+0x49/0x90
> >  acpiphp_disable_and_eject_slot+0x15/0x90
> >  hotplug_event+0xea/0x210
> >  ? __pfx_acpiphp_hotplug_notify+0x10/0x10
> >  acpiphp_hotplug_notify+0x22/0x80
> >  ? __pfx_acpiphp_hotplug_notify+0x10/0x10
> >  acpi_device_hotplug+0xb8/0x210
> >  acpi_hotplug_work_fn+0x1a/0x30
> >  process_one_work+0x197/0x380
> >  worker_thread+0x2fe/0x410
> >  ? __pfx_worker_thread+0x10/0x10
> >  kthread+0xe0/0x100
> >  ? __pfx_kthread+0x10/0x10
> >  ret_from_fork+0x2c/0x50
> >  
> > ---[ end trace  ]---
> >
> > Fixes: 41c445ff0f48 ("i40e: main driver core")
> > Tested-by: YangHang Liu 
> > Signed-off-by: Kamal Heib 
> > ---
> >  drivers/net/ethernet/intel/i40e/i40e.h  | 1 +
> >  drivers/net/ethernet/intel/i40e/i40e_main.c | 8 
> >  

[Intel-wired-lan] [tnguy-net-queue:dev-queue] BUILD SUCCESS 75b303206b000ac23ee0e63f377c2a25f9bb5134

2024-09-04 Thread kernel test robot
allnoconfig   clang-18
x86_64   allyesconfig   clang-18
x86_64   buildonly-randconfig-001-20240904   clang-18
x86_64   buildonly-randconfig-002-20240904   clang-18
x86_64   buildonly-randconfig-003-20240904   clang-18
x86_64   buildonly-randconfig-004-20240904   clang-18
x86_64   buildonly-randconfig-005-20240904   clang-18
x86_64   buildonly-randconfig-006-20240904   clang-18
x86_64  defconfig   clang-18
x86_64  kexec   gcc-12
x86_64randconfig-001-20240904   clang-18
x86_64randconfig-002-20240904   clang-18
x86_64randconfig-003-20240904   clang-18
x86_64randconfig-004-20240904   clang-18
x86_64randconfig-005-20240904   clang-18
x86_64randconfig-006-20240904   clang-18
x86_64randconfig-011-20240904   clang-18
x86_64randconfig-012-20240904   clang-18
x86_64randconfig-013-20240904   clang-18
x86_64randconfig-014-20240904   clang-18
x86_64randconfig-015-20240904   clang-18
x86_64randconfig-016-20240904   clang-18
x86_64randconfig-071-20240904   clang-18
x86_64randconfig-072-20240904   clang-18
x86_64randconfig-073-20240904   clang-18
x86_64randconfig-074-20240904   clang-18
x86_64randconfig-075-20240904   clang-18
x86_64randconfig-076-20240904   clang-18
x86_64  rhel-8.3-rust   clang-18
x86_64   rhel-8.3   gcc-12
xtensaallnoconfig   gcc-14.1.0
xtensa  audio_kc705_defconfig   gcc-14.1.0
xtensa virt_defconfig   gcc-14.1.0

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


Re: [Intel-wired-lan] [PATCH iwl-net] i40e: Fix trying to free already-freed IRQ

2024-09-04 Thread Kamal Heib
On Wed, Sep 04, 2024 at 09:00:32PM +, Loktionov, Aleksandr wrote:
> 
> 
> > -Original Message-
> > From: Intel-wired-lan  On Behalf
> > Of YangHang Liu
> > Sent: Wednesday, September 4, 2024 4:37 AM
> > To: Kamal Heib ; Chao Yang 
> > Cc: ivecera ; net...@vger.kernel.org; Jakub
> > Kicinski ; Nguyen, Anthony L
> > ; Kitszel, Przemyslaw
> > ; intel-wired-...@lists.osuosl.org;
> > Paolo Abeni ; David S . Miller
> > 
> > Subject: Re: [Intel-wired-lan] [PATCH iwl-net] i40e: Fix trying to
> > free already-freed IRQ
> > 
> > This issue can be reproduced by hot-unplugging the INTx i40e PF.
> > 
> > The Call Trace will disappear after using Kamal's fix.
> > 
> > Tested-by: Yanghang Liu
> > 
> > 
> > 
> > On Wed, Sep 4, 2024 at 2:26 AM Kamal Heib  wrote:
> > >
> > > Avoid the following warning when trying to free an already freed
> > IRQ,
> > > The issue happens when trying to call i40e_remove() twice from two
> > > different contexts which will lead to calling i40e_vsi_free_irq()
> > > twice, Fix the issue by using a flag to mark that the IRQ has
> > already been freed.
> > >
> > > i40e :07:00.0: i40e_ptp_stop: removed PHC on enp7s0 
> > [
> > > cut here ] Trying to free already-free IRQ 0
> > > WARNING: CPU: 2 PID: 12 at kernel/irq/manage.c:1868
> > > __free_irq+0x1e3/0x350 Modules linked in: nft_fib_inet nft_fib_ipv4
> > > nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6
> > > nft_reject nft_ct nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6
> > > nf_defrag_ipv4 rfkill ip_set nf_tables nfnetlink vfat fat
> > > intel_rapl_msr intel_rapl_common kvm_amd ccp iTCO_wdt
> > > iTCO_vendor_support kvm i2c_i801 pcspkr i40e lpc_ich virtio_gpu
> > > i2c_smbus virtio_dma_buf drm_shmem_helper drm_kms_helper
> > > virtio_balloon joydev drm fuse xfs libcrc32c ahci crct10dif_pclmul
> > > libahci crc32_pclmul crc32c_intel virtio_net libata virtio_blk
> > > ghash_clmulni_intel net_failover virtio_console failover serio_raw
> > > dm_mirror dm_region_hash dm_log dm_mod
> > > CPU: 2 PID: 12 Comm: kworker/u16:1 Kdump: loaded Not tainted
> > > 5.14.0-478.el9.x86_64 #1 Hardware name: Red Hat KVM/RHEL, BIOS
> > > edk2-20240524-1.el9 05/24/2024
> > > Workqueue: kacpi_hotplug acpi_hotplug_work_fn
> > > RIP: 0010:__free_irq+0x1e3/0x350
> > > Code: 00 00 48 8b bb a8 01 00 00 e8 09 74 02 00 49 8b 7c 24 30 e8 8f
> > > 7c 1d 00 eb 35 8b 74 24 04 48 c7 c7 50 a3 61 92 e8 cd 99 f6 ff <0f>
> > 0b
> > > 4c 89 fe 48 89 ef e8 30 aa b3 00 48 8b 43 40 48 8b 40 78 48
> > > RSP: 0018:b971c0077ac8 EFLAGS: 00010086
> > > RAX:  RBX: 8b594193ee00 RCX: 0027
> > > RDX: 0027 RSI: 7fff RDI: 8b59bcf208c8
> > > RBP: 8b594193eec4 R08:  R09: b971c0077970
> > > R10: b971c0077968 R11: 931e7c28 R12: 8b5944946000
> > > R13: 8b594193ef80 R14: 8b5944946000 R15: 0246
> > > FS:  () GS:8b59bcf0()
> > > knlGS:
> > > CS:  0010 DS:  ES:  CR0: 80050033
> > > CR2: 7f11eb064000 CR3: 0ad40004 CR4: 00770ef0
> > > PKRU: 5554
> > > Call Trace:
> > >  
> > >  ? srso_alias_return_thunk+0x5/0xfbef5
> > >  ? show_trace_log_lvl+0x26e/0x2df
> > >  ? show_trace_log_lvl+0x26e/0x2df
> > >  ? free_irq+0x33/0x70
> > >  ? __free_irq+0x1e3/0x350
> > >  ? __warn+0x7e/0xd0
> > >  ? __free_irq+0x1e3/0x350
> > >  ? report_bug+0x100/0x140
> > >  ? srso_alias_return_thunk+0x5/0xfbef5
> > >  ? handle_bug+0x3c/0x70
> > >  ? exc_invalid_op+0x14/0x70
> > >  ? asm_exc_invalid_op+0x16/0x20
> > >  ? __free_irq+0x1e3/0x350
> > >  ? __free_irq+0x1e3/0x350
> > >  free_irq+0x33/0x70
> > >  i40e_vsi_free_irq+0x19e/0x220 [i40e]
> > >  i40e_vsi_close+0x2b/0xc0 [i40e]
> > >  i40e_close+0x11/0x20 [i40e]
> > >  __dev_close_many+0x9e/0x110
> > >  dev_close_many+0x8b/0x140
> > >  ? srso_alias_return_thunk+0x5/0xfbef5
> > >  ? free_pcppages_bulk+0xee/0x290
> > >  unregister_netdevice_many_notify+0x162/0x690
> > >  ? srso_alias_return_thunk+0x5/0xfbef5
> > >  ? free_unref_page_commit+0x19a/0x310
> > >  unregister_netdevice_queue+0xd3/0x110
> > >  unregister_netdev+0x18/0x20
> > >  i40e_vsi_release+0x84/0x2e0 [i40e]
> > >  ? srso_alias_return_thunk+0x5/0xfbef5
> > >  i40e_remove+0x15c/0x430 [i40e]
> > >  pci_device_remove+0x3e/0xb0
> > >  device_release_driver_internal+0x193/0x200
> > >  pci_stop_bus_device+0x6c/0x90
> > >  pci_stop_and_remove_bus_device+0xe/0x20
> > >  disable_slot+0x49/0x90
> > >  acpiphp_disable_and_eject_slot+0x15/0x90
> > >  hotplug_event+0xea/0x210
> > >  ? __pfx_acpiphp_hotplug_notify+0x10/0x10
> > >  acpiphp_hotplug_notify+0x22/0x80
> > >  ? __pfx_acpiphp_hotplug_notify+0x10/0x10
> > >  acpi_device_hotplug+0xb8/0x210
> > >  acpi_hotplug_work_fn+0x1a/0x30
> > >  process_one_work+0x197/0x380
> > >  worker_thread+0x2fe/0x410
> > >  ? __pfx_worker_thread+0x10/0x10
> > >  kthread+0xe0/0x100
> > >  ? __pfx_kthread+0x10/0x10
> > >  ret_from_f

Re: [Intel-wired-lan] [PATCH v6 net-next 01/15] genetlink: extend info user-storage to match NL cb ctx

2024-09-04 Thread Jakub Kicinski
On Wed,  4 Sep 2024 15:53:33 +0200 Paolo Abeni wrote:
> This allows a more uniform implementation of non-dump and dump
> operations, and will be used later in the series to avoid some
> per-operation allocation.
> 
> Additionally rename the NL_ASSERT_DUMP_CTX_FITS macro, to
> fit a more extended usage.
> 
> Suggested-by: Jakub Kicinski 
> Signed-off-by: Paolo Abeni 

Reviewed-by: Jakub Kicinski 

Thank you!


Re: [Intel-wired-lan] [PATCH v6 net-next 03/15] net-shapers: implement NL get operation

2024-09-04 Thread Jakub Kicinski
On Wed,  4 Sep 2024 15:53:35 +0200 Paolo Abeni wrote:
> +static int net_shaper_ctx_setup(const struct genl_info *info, int type,
> + struct net_shaper_nl_ctx *ctx)
> +{
> + struct net *ns = genl_info_net(info);
> + struct net_device *dev;
> + int ifindex;
> +
> + memset(ctx, 0, sizeof(*ctx));

Don't think you need to memset() this?
Patch 1 touches the relevant memset()s in the core.

> +static int net_shaper_generic_pre(struct genl_info *info, int type)
> +{
> + struct net_shaper_nl_ctx *ctx = (struct net_shaper_nl_ctx *)info->ctx;
> + int ret;
> +
> + BUILD_BUG_ON(sizeof(*ctx) > sizeof(info->ctx));
> +
> + ret = net_shaper_ctx_setup(info, type, ctx);
> + if (ret)
> + return ret;
> +
> + return 0;

There seems to be no extra code here at the end of the series so:

return net_shaper_ctx_setup(info, type, ctx);

With those nits addressed:

Reviewed-by: Jakub Kicinski 


Re: [Intel-wired-lan] [PATCH v6 net-next 02/15] netlink: spec: add shaper YAML spec

2024-09-04 Thread Jakub Kicinski
On Wed,  4 Sep 2024 15:53:34 +0200 Paolo Abeni wrote:
> +doc: |
> +  Networking HW rate limiting configuration.
> +
> +  This API allows configuring HW shapers available on the network
> +  devices at different levels (queues, network device) and allows
> +  arbitrary manipulation of the scheduling tree of the involved
> +  shapers.
> +
> +  Each @shaper is identified within the given device, by an @handle,
> +  comprising both a @scope and an @id.
> +
> +  Depending on the @scope value, the shapers are attached to specific
> +  HW objects (queues, devices) or, for @node scope, represent a
> +  scheduling group, that can be placed in an arbitrary location of
> +  the scheduling tree.
> +
> +  Shapers can be created with two different operations: the @set
> +  operation, to create and update a single "attached" shaper, and
> +  the @group operation, to create and update a scheduling
> +  group. Only the @group operation can create @node scope shapers
> +
> +  Existing shapers can be deleted /reset via the @delete operation.

nit: space before the / ?

> +name: bw-min
> +type: uint
> +doc: Minimum Guaranteed bandwidth for the given shaper.

I think I asked to remove "Minimum"? Both "guaranteed" and "minimum"
express the fact that we can't go lower, so it's a bit of a pleonasm.

> +  -
> +name: node
> +type: nest
> +nested-attributes: node-info
> +doc: |
> +   Describes the node shaper for a @group operation.
> +   Differently from @leaves and @shaper allow specifying
> +   the shaper parent handle, too.

Parent handle is inside node scope? Why are leaves outside and parent
inside? Both should be at the same scope, preferably main scope.

> +  -
> +name: shaper
> +type: nest
> +nested-attributes: info
> +doc: |
> +   Describes a single shaper for a @set operation.

Why does this level of nesting exist? With the exception of ifindex 
all attributes for SET are nested inside this..


Re: [Intel-wired-lan] [PATCH v6 net-next 07/15] net-shapers: implement shaper cleanup on queue deletion

2024-09-04 Thread Jakub Kicinski
On Wed,  4 Sep 2024 15:53:39 +0200 Paolo Abeni wrote:
> + net_shaper_set_real_num_tx_queues(dev, txq);
> +
>   dev_qdisc_change_real_num_tx(dev, txq);
>  
>   dev->real_num_tx_queues = txq;

The dev->lock has to be taken here, around those three lines,
and then set / group must check QUEUE ids against 
dev->real_num_tx_queues, no? Otherwise the work 
net_shaper_set_real_num_tx_queues() does is prone to races?


Re: [Intel-wired-lan] [PATCH v6 net-next 10/15] net-shapers: implement cap validation in the core

2024-09-04 Thread Jakub Kicinski
On Wed,  4 Sep 2024 15:53:42 +0200 Paolo Abeni wrote:
> Use the device capabilities to reject invalid attribute values before
> pushing them to the H/W.
> 
> Note that validating the metric explicitly avoids NL_SET_BAD_ATTR()
> usage, to provide unambiguous error messages to the user.
> 
> Validating the nesting requires the knowledge of the new parent for
> the given shaper; as such is a chicken-egg problem: to validate the
> leaf nesting we need to know the node scope, to validate the node
> nesting we need to know the leafs parent scope.
> 
> To break the circular dependency, place the leafs nesting validation
> after the parsing.
> 
> Suggested-by: Jakub Kicinski 
> Signed-off-by: Paolo Abeni 

Reviewed-by: Jakub Kicinski 


Re: [Intel-wired-lan] [PATCH v6 net-next 14/15] iavf: Add net_shaper_ops support

2024-09-04 Thread Jakub Kicinski
On Wed,  4 Sep 2024 15:53:46 +0200 Paolo Abeni wrote:
> +static int iavf_verify_handle(struct net_shaper_binding *binding,
> +   const struct net_shaper_handle *handle,
> +   struct netlink_ext_ack *extack)
> +{
> + struct iavf_adapter *adapter = netdev_priv(binding->netdev);
> + int qid = handle->id;
> +
> + if (qid >= adapter->num_active_queues) {
> + NL_SET_ERR_MSG_FMT(extack, "Invalid shaper handle, queued id %d 
> max %d",
> +qid, adapter->num_active_queues);
> + return -EINVAL;
> + }
> + return 0;
> +}

This can go once we have the real_num validation in the core?
Otherwise LGTM!


Re: [Intel-wired-lan] [PATCH iwl-next v1] ice: Add E830 checksum support

2024-09-04 Thread Greenwalt, Paul



On 9/3/2024 8:29 PM, Greenwalt, Paul wrote:

>>>  
>>> @@ -6237,6 +6243,7 @@ ice_fix_features(struct net_device *netdev, 
>>> netdev_features_t features)
>>> struct ice_netdev_priv *np = netdev_priv(netdev);
>>> netdev_features_t req_vlan_fltr, cur_vlan_fltr;
>>> bool cur_ctag, cur_stag, req_ctag, req_stag;
>>> +   netdev_features_t changed;
>>>  
>>> cur_vlan_fltr = netdev->features & NETIF_VLAN_FILTERING_FEATURES;
>>> cur_ctag = cur_vlan_fltr & NETIF_F_HW_VLAN_CTAG_FILTER;
>>> @@ -6285,6 +6292,29 @@ ice_fix_features(struct net_device *netdev, 
>>> netdev_features_t features)
>>> features &= ~NETIF_VLAN_STRIPPING_FEATURES;
>>> }
>>>  
>>> +   if (!ice_is_feature_supported(np->vsi->back, ICE_F_GCS) ||
>>> +   !(features & NETIF_F_HW_CSUM))
>>> +   return features;
>>> +
>>> +   changed = netdev->features ^ features;
>>> +
>>> +   /* HW checksum feature is supported and set, so enforce mutual
>>> +* exclusivity of TSO and GCS.
>>> +*/
>>> +   if (features & NETIF_F_ALL_TSO) {
>>
>>  if (!(features & ALL_TSO))
>>  return features;
>>
>> to reduce indent level and avoid huge `if` blocks.
>>

Hi Olek and Tony, you both had feedback related to the change to
ice_fix_features().

Olek: to reduce indent level and avoid huge `if` blocks.

Tony: This prevents adding any other feature checks below this in the
future.
Seems like we should rework this into the feature being checked so that
we don't have this restriction.

Would using two helper functions for fixing DVM, and another for GCS and
TSO address your feedback? By adding feature checks are the top of the
helper functions and returning early, this could reduce the indent level
and avoid the huge 'if' block, while removing the restriction of adding
feature checks below these in the future.

Thanks,
Paul

>>> +   if (changed & NETIF_F_HW_CSUM && changed & NETIF_F_ALL_TSO) {
>>> +   netdev_warn(netdev, "Dropping TSO and HW checksum. TSO 
>>> and HW checksum are mutually exclusive.\n");
>>> +   features &= ~NETIF_F_HW_CSUM;
>>> +   features &= ~((features & changed) & NETIF_F_ALL_TSO);



Re: [Intel-wired-lan] [iwl-net v1] iavf: allow changing VLAN state without calling PF

2024-09-04 Thread Przemek Kitszel

On 9/4/24 14:00, Michal Swiatkowski wrote:

First case:


[...]


Second case:


[...]


With fix for previous case we end up with no VLAN filters in hardware.
We have to remove VLAN filters if the state is IAVF_VLAN_ADD and delete
VLAN was called. It is save as IAVF_VLAN_ADD means that virtchnl message
wasn't sent yet.


I'm fine with combining the two cases into one commit as that is related



Fixes: 0c0da0e95105 ("iavf: refactor VLAN filter states")
Signed-off-by: Michal Swiatkowski 
---
  drivers/net/ethernet/intel/iavf/iavf_main.c | 18 --
  1 file changed, 16 insertions(+), 2 deletions(-)


[...]


@@ -793,8 +798,17 @@ static void iavf_del_vlan(struct iavf_adapter *adapter, 
struct iavf_vlan vlan)
  
  	f = iavf_find_vlan(adapter, vlan);

if (f) {
-   f->state = IAVF_VLAN_REMOVE;


you forgot to put this line in else case below


-   iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_DEL_VLAN_FILTER);
+   /* IAVF_ADD_VLAN means that VLAN wasn't even added yet.
+* Remove it from the list.
+*/
+   if (f->state == IAVF_VLAN_ADD) {
+   list_del(&f->list);
+   kfree(f);
+   adapter->num_vlan_filters--;
+   } else {
+   iavf_schedule_aq_request(adapter,
+IAVF_FLAG_AQ_DEL_VLAN_FILTER);
+   }
}
  
  	spin_unlock_bh(&adapter->mac_vlan_list_lock);