ice: reorganize virtualization code
Subsystems (2)
cover ice: reorganize virtualization code
The ice_virtchnl_pf.c file has become a single place for a lot of virtualization functionality. This includes most of the virtchnl message handling, integration with kernel hooks like the .ndo operations, reset logic, and more.
We are planning in the future to implement and support Scalable IOV in the ice driver. To do this, much (but not all) of the code in ice_virtchnl_pf.c will want to be reused.
Rather than dump all of the Scalable IOV implementation into ice_virtchnl_pf.c it makes sense to house it in a separate file. But that still leaves all of the Single Root IOV code littered among more generic logic.
This series reorganizes code to make the non-implementation specific bits into new files with the following general guidelines:
* ice_vf_lib.[ch]
Basic VF structures and accessors. This is where scheme-independent code will reside.
* ice_virtchnl.[ch]
Virtchnl message handling. This is where the bulk of the logic for processing messages from VFs using the virtchnl messaging scheme will reside. This is separated from ice_vf_lib.c because it is distinct and has a bulk of the processing code.
* ice_sriov.[ch]
Single Root IOV implementation, including initialization and the routines for interacting with SR-IOV based netdev operations.
* (future) ice_siov.[ch]
Scalable IOV implementation.
The goal is to make it easier to re-use parts of the virtualization logic while separating concerns such as Single Root specific implementation details.
In addition, this series has several minor cleanups and refactors we've accumulated during this development cycle which help prepare the ice driver for the Scalable IOV implementation.
This series builds on top of the recent hash table refactor work.
Jacob Keller (25):
ice: rename ice_sriov.c to ice_vf_mbx.c
ice: rename ice_virtchnl_pf.c to ice_sriov.c
ice: remove circular header dependencies on ice.h
ice: convert vf->vc_ops to a const pointer
ice: remmove unused definitions from ice_sriov.h
ice: rename ICE_MAX_VF_COUNT to avoid confusion
ice: refactor spoofchk control code in ice_sriov.c
ice: move ice_set_vf_port_vlan near other .ndo ops
ice: cleanup error logging for ice_ena_vfs
ice: log an error message when eswitch fails to configure
ice: use ice_is_vf_trusted helper function
ice: introduce ice_vf_lib.c, ice_vf_lib.h, and ice_vf_lib_private.h
ice: fix incorrect dev_dbg print mistaking 'i' for vf->vf_id
ice: introduce VF operations structure for reset flows
ice: fix a long line warning in ice_reset_vf
ice: move reset functionality into ice_vf_lib.c
ice: drop is_vflr parameter from ice_reset_all_vfs
ice: make ice_reset_all_vfs void
ice: convert ice_reset_vf to standard error codes
ice: convert ice_reset_vf to take flags
ice: introduce ICE_VF_RESET_NOTIFY flag
ice: introduce ICE_VF_RESET_LOCK flag
ice: cleanup long longs in ice_sriov.c
ice: introduce ice_virtchnl.c and ice_virtchnl.h
ice: remove PF pointer from ice_check_vf_init
drivers/net/ethernet/intel/ice/Makefile | 6 +-
drivers/net/ethernet/intel/ice/ice.h | 5 +-
drivers/net/ethernet/intel/ice/ice_arfs.h | 3 +
drivers/net/ethernet/intel/ice/ice_base.c | 2 +-
drivers/net/ethernet/intel/ice/ice_common.h | 4 +-
drivers/net/ethernet/intel/ice/ice_dcb.h | 1 +
.../net/ethernet/intel/ice/ice_flex_pipe.c | 1 +
drivers/net/ethernet/intel/ice/ice_flow.c | 1 +
drivers/net/ethernet/intel/ice/ice_flow.h | 2 +
drivers/net/ethernet/intel/ice/ice_idc_int.h | 1 -
drivers/net/ethernet/intel/ice/ice_main.c | 25 +-
drivers/net/ethernet/intel/ice/ice_osdep.h | 11 +-
drivers/net/ethernet/intel/ice/ice_repr.c | 6 +-
drivers/net/ethernet/intel/ice/ice_repr.h | 1 -
drivers/net/ethernet/intel/ice/ice_sriov.c | 2305 ++++++++++---
drivers/net/ethernet/intel/ice/ice_sriov.h | 165 +-
drivers/net/ethernet/intel/ice/ice_type.h | 1 +
drivers/net/ethernet/intel/ice/ice_vf_lib.c | 1029 ++++++
drivers/net/ethernet/intel/ice/ice_vf_lib.h | 290 ++
.../ethernet/intel/ice/ice_vf_lib_private.h | 40 +
.../intel/ice/{ice_sriov.c => ice_vf_mbx.c} | 2 +-
.../intel/ice/{ice_sriov.h => ice_vf_mbx.h} | 6 +-
.../ethernet/intel/ice/ice_vf_vsi_vlan_ops.c | 2 +-
.../ice/{ice_virtchnl_pf.c => ice_virtchnl.c} | 3002 +----------------
drivers/net/ethernet/intel/ice/ice_virtchnl.h | 82 +
.../ethernet/intel/ice/ice_virtchnl_fdir.c | 1 +
.../ethernet/intel/ice/ice_virtchnl_fdir.h | 1 +
.../net/ethernet/intel/ice/ice_virtchnl_pf.h | 437 ---
drivers/net/ethernet/intel/ice/ice_xsk.h | 1 -
29 files changed, 3566 insertions(+), 3867 deletions(-)
create mode 100644 drivers/net/ethernet/intel/ice/ice_vf_lib.c
create mode 100644 drivers/net/ethernet/intel/ice/ice_vf_lib.h
create mode 100644 drivers/net/ethernet/intel/ice/ice_vf_lib_private.h
copy drivers/net/ethernet/intel/ice/{ice_sriov.c => ice_vf_mbx.c} (99%)
copy drivers/net/ethernet/intel/ice/{ice_sriov.h => ice_vf_mbx.h} (95%)
rename drivers/net/ethernet/intel/ice/{ice_virtchnl_pf.c => ice_virtchnl.c} (57%)
create mode 100644 drivers/net/ethernet/intel/ice/ice_virtchnl.h
delete mode 100644 drivers/net/ethernet/intel/ice/ice_virtchnl_pf.hbase-commit: 81003a1453e724321ed9cc9f75fb92d74884c413
prerequisite-patch-id: 9685201f53a380b760fafc19ce4c52503dce7b0f
Signature · 1 line
2.35.1.129.gb80121027d12
PATCH 1/25 ice: rename ice_sriov.c to ice_vf_mbx.c
The ice_sriov.c file primarily contains code which handles the logic for mailbox overflow detection and some other utility functions related to the virtualization mailbox.
The bulk of the SR-IOV implementation is actually found in ice_virtchnl_pf.c, and this file isn't strictly SR-IOV specific.
In the future, the ice driver will support an additional virtualization scheme known as Scalable IOV, and the code in this file will be used for this alternative implementation.
Rename this file (and its associated header) to ice_vf_mbx.c, so that we can later re-use the ice_sriov.c file as the SR-IOV specific file.
---
drivers/net/ethernet/intel/ice/Makefile | 2 +-
drivers/net/ethernet/intel/ice/ice.h | 2 +-
.../net/ethernet/intel/ice/{ice_sriov.c => ice_vf_mbx.c} | 2 +-
.../net/ethernet/intel/ice/{ice_sriov.h => ice_vf_mbx.h} | 6 +++---
4 files changed, 6 insertions(+), 6 deletions(-)
rename drivers/net/ethernet/intel/ice/{ice_sriov.c => ice_vf_mbx.c} (99%)
rename drivers/net/ethernet/intel/ice/{ice_sriov.h => ice_vf_mbx.h} (95%)drivers/net/ethernet/intel/ice/Makefile +1 -1
@@ -36,7 +36,7 @@ ice-y := ice_main.o \ ice-$(CONFIG_PCI_IOV) += \ ice_virtchnl_allowlist.o \ ice_virtchnl_fdir.o \ - ice_sriov.o \ + ice_vf_mbx.o \ ice_vf_vsi_vlan_ops.o \ ice_virtchnl_pf.o ice-$(CONFIG_PTP_1588_CLOCK) += ice_ptp.o ice_ptp_hw.o
drivers/net/ethernet/intel/ice/ice.h +1 -1
@@ -67,7 +67,7 @@#include "ice_sched.h" #include "ice_idc_int.h" #include "ice_virtchnl_pf.h" -#include "ice_sriov.h" +#include "ice_vf_mbx.h" #include "ice_ptp.h" #include "ice_fdir.h" #include "ice_xsk.h"
drivers/net/ethernet/intel/ice/ice_vf_mbx.c renamed from drivers/net/ethernet/intel/ice/ice_sriov.c +1 -1
@@ -2,7 +2,7 @@/* Copyright (c) 2018, Intel Corporation. */ #include "ice_common.h" -#include "ice_sriov.h" +#include "ice_vf_mbx.h" /** * ice_aq_send_msg_to_vf
drivers/net/ethernet/intel/ice/ice_vf_mbx.h renamed from drivers/net/ethernet/intel/ice/ice_sriov.h +3 -3
@@ -1,8 +1,8 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Copyright (c) 2018, Intel Corporation. */ -#ifndef _ICE_SRIOV_H_ -#define _ICE_SRIOV_H_ +#ifndef _ICE_VF_MBX_H_ +#define _ICE_VF_MBX_H_#include "ice_type.h" #include "ice_controlq.h"
@@ -49,4 +49,4 @@ ice_conv_link_speed_to_virtchnl(bool __always_unused adv_link_support, }#endif /* CONFIG_PCI_IOV */ -#endif /* _ICE_SRIOV_H_ */ +#endif /* _ICE_VF_MBX_H_ */
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 1/25 ice: rename ice_sriov.c to ice_vf_mbx.c
drivers/net/ethernet/intel/ice/Makefile ice-y := ice_main.o \
Quoted 40 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 01/25] ice: renameice_sriov.ctoice_vf_mbx.cThe
ice_sriov.cfile primarily contains code which handles the logic for mailbox overflow detection and some other utility functions related to the virtualization mailbox.The bulk of the SR-IOV implementation is actually found in
ice_virtchnl_pf.c, and this file isn't strictly SR-IOV specific.In the future, the ice driver will support an additional virtualization scheme known as Scalable IOV, and the code in this file will be used for this alternative implementation.
Rename this file (and its associated header) to
ice_vf_mbx.c, so that we can later re-use theice_sriov.cfile as the SR-IOV specific file.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/Makefile | 2 +- drivers/net/ethernet/intel/ice/ice.h | 2 +- .../net/ethernet/intel/ice/{ice_sriov.c => ice_vf_mbx.c} | 2 +- .../net/ethernet/intel/ice/{ice_sriov.h => ice_vf_mbx.h} | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) rename
drivers/net/ethernet/intel/ice/{ice_sriov.c=>ice_vf_mbx.c} (99%) renamedrivers/net/ethernet/intel/ice/{ice_sriov.h=>ice_vf_mbx.h} (95%)drivers/net/ethernet/intel/ice/Makefile +0
-0@@ -36,7 +36,7 @@ ice-y := ice_main.o \
PATCH 2/25 ice: rename ice_virtchnl_pf.c to ice_sriov.c
In reply to Jacob KellerThe ice_virtchnl_pf.c and ice_virtchnl_pf.h files are where most of the code for implementing Single Root IOV virtualization resides. This code includes support for bringing up and tearing down VFs, hooks into the kernel SR-IOV netdev operations, and for handling virtchnl messages from VFs.
In the future, we plan to support Scalable IOV in addition to Single Root IOV as an alternative virtualization scheme. This implementation will re-use some but not all of the code in ice_virtchnl_pf.c
To prepare for this future, we want to refactor and split up the code in ice_virtchnl_pf.c into the following scheme:
* ice_vf_lib.[ch]
Basic VF structures and accessors. This is where scheme-independent code will reside.
* ice_virtchnl.[ch]
Virtchnl message handling. This is where the bulk of the logic for processing messages from VFs using the virtchnl messaging scheme will reside. This is separated from ice_vf_lib.c because it is distinct and has a bulk of the processing code.
* ice_sriov.[ch]
Single Root IOV implementation, including initialization and the routines for interacting with SR-IOV based netdev operations.
* (future) ice_siov.[ch]
Scalable IOV implementation.
As a first step, lets assume that all of the code in ice_virtchnl_pf.[ch] is for Single Root IOV. Rename this file to ice_sriov.c and its header to ice_sriov.h
Future changes will further split out the code in these files following the plan outlined here.
---
drivers/net/ethernet/intel/ice/Makefile | 2 +-
drivers/net/ethernet/intel/ice/ice.h | 2 +-
drivers/net/ethernet/intel/ice/ice_base.c | 2 +-
drivers/net/ethernet/intel/ice/ice_repr.c | 2 +-
.../ethernet/intel/ice/{ice_virtchnl_pf.c => ice_sriov.c} | 0
.../ethernet/intel/ice/{ice_virtchnl_pf.h => ice_sriov.h} | 6 +++---
drivers/net/ethernet/intel/ice/ice_vf_vsi_vlan_ops.c | 2 +-
7 files changed, 8 insertions(+), 8 deletions(-)
rename drivers/net/ethernet/intel/ice/{ice_virtchnl_pf.c => ice_sriov.c} (100%)
rename drivers/net/ethernet/intel/ice/{ice_virtchnl_pf.h => ice_sriov.h} (99%)drivers/net/ethernet/intel/ice/Makefile +1 -1
@@ -38,7 +38,7 @@ ice-$(CONFIG_PCI_IOV) += \ ice_virtchnl_fdir.o \ ice_vf_mbx.o \ ice_vf_vsi_vlan_ops.o \ - ice_virtchnl_pf.o + ice_sriov.o ice-$(CONFIG_PTP_1588_CLOCK) += ice_ptp.o ice_ptp_hw.o ice-$(CONFIG_TTY) += ice_gnss.o ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_nl.o ice_dcb_lib.o
drivers/net/ethernet/intel/ice/ice.h +1 -1
@@ -66,7 +66,7 @@#include "ice_flow.h" #include "ice_sched.h" #include "ice_idc_int.h" -#include "ice_virtchnl_pf.h" +#include "ice_sriov.h" #include "ice_vf_mbx.h" #include "ice_ptp.h" #include "ice_fdir.h"
drivers/net/ethernet/intel/ice/ice_base.c +1 -1
@@ -5,7 +5,7 @@#include "ice_base.h" #include "ice_lib.h" #include "ice_dcb_lib.h" -#include "ice_virtchnl_pf.h" +#include "ice_sriov.h" static bool ice_alloc_rx_buf_zc (struct ice_rx_ring *rx_ring) {
drivers/net/ethernet/intel/ice/ice_repr.c +1 -1
@@ -4,7 +4,7 @@#include "ice.h" #include "ice_eswitch.h" #include "ice_devlink.h" -#include "ice_virtchnl_pf.h" +#include "ice_sriov.h" #include "ice_tc_lib.h" /**
drivers/net/ethernet/intel/ice/ice_sriov.c renamed from drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +0 -0
drivers/net/ethernet/intel/ice/ice_sriov.h renamed from drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +3 -3
@@ -1,8 +1,8 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Copyright (c) 2018, Intel Corporation. */ -#ifndef _ICE_VIRTCHNL_PF_H_ -#define _ICE_VIRTCHNL_PF_H_ +#ifndef _ICE_SRIOV_H_ +#define _ICE_SRIOV_H_#include "ice.h" #include "ice_virtchnl_fdir.h" #include "ice_vsi_vlan_ops.h"
@@ -434,4 +434,4 @@ static inline bool ice_vf_is_port_vlan_ena(struct ice_vf __always_unused *vf)return false; }#endif /* CONFIG_PCI_IOV */ -#endif /* _ICE_VIRTCHNL_PF_H_ */ +#endif /* _ICE_SRIOV_H_ */
drivers/net/ethernet/intel/ice/ice_vf_vsi_vlan_ops.c +1 -1
@@ -6,7 +6,7 @@#include "ice_vlan_mode.h" #include "ice.h" #include "ice_vf_vsi_vlan_ops.h" -#include "ice_virtchnl_pf.h" +#include "ice_sriov.h" static int noop_vlan_arg(struct ice_vsi __always_unused *vsi,
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 2/25 ice: rename ice_virtchnl_pf.c to ice_sriov.c
drivers/net/ethernet/intel/ice/ice.h
Quoted 83 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 02/25] ice: renameice_virtchnl_pf.ctoice_sriov.cThe
ice_virtchnl_pf.candice_virtchnl_pf.hfiles are where most of the code for implementing Single Root IOV virtualization resides. This code includes support for bringing up and tearing down VFs, hooks into the kernel SR-IOV netdev operations, and for handling virtchnl messages from VFs.In the future, we plan to support Scalable IOV in addition to Single Root IOV as an alternative virtualization scheme. This implementation will re-use some but not all of the code in
ice_virtchnl_pf.cTo prepare for this future, we want to refactor and split up the code in
ice_virtchnl_pf.cinto the following scheme:* ice_vf_lib.[ch]
Basic VF structures and accessors. This is where scheme-independent code will reside.
* ice_virtchnl.[ch]
Virtchnl message handling. This is where the bulk of the logic for processing messages from VFs using the virtchnl messaging scheme will reside. This is separated from
ice_vf_lib.cbecause it is distinct and has a bulk of the processing code.* ice_sriov.[ch]
Single Root IOV implementation, including initialization and the routines for interacting with SR-IOV based netdev operations.
* (future) ice_siov.[ch]
Scalable IOV implementation.
As a first step, lets assume that all of the code in ice_virtchnl_pf.[ch] is for Single Root IOV. Rename this file to
ice_sriov.cand its header toice_sriov.hFuture changes will further split out the code in these files following the plan outlined here.
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/Makefile | 2 +- drivers/net/ethernet/intel/ice/ice.h | 2 +- drivers/net/ethernet/intel/ice/ice_base.c | 2 +- drivers/net/ethernet/intel/ice/ice_repr.c | 2 +- .../ethernet/intel/ice/{ice_virtchnl_pf.c => ice_sriov.c} | 0 .../ethernet/intel/ice/{ice_virtchnl_pf.h => ice_sriov.h} | 6 +++--- drivers/net/ethernet/intel/ice/ice_vf_vsi_vlan_ops.c | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) rename
drivers/net/ethernet/intel/ice/{ice_virtchnl_pf.c=>ice_sriov.c} (100%) renamedrivers/net/ethernet/intel/ice/{ice_virtchnl_pf.h=>ice_sriov.h} (99%)drivers/net/ethernet/intel/ice/Makefile +1
-1@@ -38,7 +38,7 @@ ice-$(CONFIG_PCI_IOV) += \ ice_virtchnl_fdir.o \ ice_vf_mbx.o \ ice_vf_vsi_vlan_ops.o \ - ice_virtchnl_pf.o + ice_sriov.o ice-$(CONFIG_PTP_1588_CLOCK) += ice_ptp.o ice_ptp_hw.o ice-$(CONFIG_TTY) += ice_gnss.o ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_nl.o ice_dcb_lib.o diff --git
a/drivers/net/ethernet/intel/ice/ice.hb/drivers/net/ethernet/intel/ice/ice.h
index6c41edd99410..0fd15b45ce23100644drivers/net/ethernet/intel/ice/ice.h +0
-0@@ -66,7 +66,7 @@
PATCH 3/25 ice: remove circular header dependencies on ice.h
In reply to Jacob KellerSeveral headers in the ice driver include ice.h even though they are themselves included by that header. The most notable of these is ice_common.h, but several other headers also do this.
Such a recursive inclusion is problematic as it forces headers to be included in a strict order, otherwise compilation errors can result. The circular inclusions do not trigger an endless loop due to standard header inclusion guards, however other errors can occur.
For example, ice_flow.h defines ice_rss_hash_cfg, which is used by ice_sriov.h as part of the definition of ice_vf_hash_ip_ctx.
ice_flow.h includes ice_acl.h, which includes ice_common.h, and which finally includes ice.h. Since ice.h itself includes ice_sriov.h, this creates a circular dependency.
The definition in ice_sriov.h requires things from ice_flow.h, but ice_flow.h itself will lead to trying to load ice_sriov.h as part of its process for expanding ice.h. The current code avoids this issue by having an implicit dependency without the include of ice_flow.h.
If we were to fix that so that ice_sriov.h explicitly depends on ice_flow.h the following pattern would occur:
ice_flow.h -> ice_acl.h -> ice_common.h -> ice.h -> ice_sriov.h
At this point, during the expansion of, the header guard for ice_flow.h is already set, so when ice_sriov.h attempts to load the ice_flow.h header it is skipped. Then, we go on to begin including the rest of ice_sriov.h, including structure definitions which depend on ice_rss_hash_cfg. This produces a compiler warning because ice_rss_hash_cfg hasn't yet been included. Remember, we're just at the start of ice_flow.h!
If the order of headers is incorrect (ice_flow.h is not implicitly loaded first in all files which include ice_sriov.h) then we get the same failure.
Removing this recursive inclusion requires fixing a few cases where some headers depended on the header inclusions from ice.h. In addition, a few other changes are also required.
Most notably, ice_hw_to_dev is implemented as a macro in ice_osdep.h, which is the likely reason that ice_common.h includes ice.h at all. This macro implementation requires the full definition of ice_pf in order to properly compile.
Fix this by moving it to a function declared in ice_main.c, so that we do not require all files to depend on the layout of the ice_pf structure.
Note that this change only fixes circular dependencies, but it does not fully resolve all implicit dependencies where one header may depend on the inclusion of another. I tried to fix as many of the implicit dependencies as I noticed, but fixing them all requires a somewhat tedious analysis of each header and attempting to compile it separately.
--- drivers/net/ethernet/intel/ice/ice.h | 3 --- drivers/net/ethernet/intel/ice/ice_arfs.h | 3 +++ drivers/net/ethernet/intel/ice/ice_common.h | 4 ++-- drivers/net/ethernet/intel/ice/ice_dcb.h | 1 + drivers/net/ethernet/intel/ice/ice_flex_pipe.c | 1 + drivers/net/ethernet/intel/ice/ice_flow.c | 1 + drivers/net/ethernet/intel/ice/ice_flow.h | 2 ++ drivers/net/ethernet/intel/ice/ice_idc_int.h | 1 - drivers/net/ethernet/intel/ice/ice_main.c | 15 +++++++++++++++ drivers/net/ethernet/intel/ice/ice_osdep.h | 11 +++++++++-- drivers/net/ethernet/intel/ice/ice_repr.h | 1 - drivers/net/ethernet/intel/ice/ice_sriov.h | 1 - drivers/net/ethernet/intel/ice/ice_type.h | 1 + drivers/net/ethernet/intel/ice/ice_xsk.h | 1 - 14 files changed, 35 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +0 -3
@@ -54,9 +54,6 @@#include <net/gre.h> #include <net/udp_tunnel.h> #include <net/vxlan.h> -#if IS_ENABLED (CONFIG_DCB ) -#include <scsi/iscsi_proto.h> -#endif /* CONFIG_DCB */ #include "ice_devids.h" #include "ice_type.h" #include "ice_txrx.h"
drivers/net/ethernet/intel/ice/ice_arfs.h +3 -0
@@ -3,6 +3,9 @@#ifndef _ICE_ARFS_H_#define _ICE_ARFS_H_ + +#include "ice_fdir.h" +enum ice_arfs_fltr_state {ICE_ARFS_INACTIVE , ICE_ARFS_ACTIVE,
drivers/net/ethernet/intel/ice/ice_common.h +2 -2
@@ -4,12 +4,12 @@#ifndef _ICE_COMMON_H_#define _ICE_COMMON_H_ -#include "ice.h" #include "ice_type.h" #include "ice_nvm.h" #include "ice_flex_pipe.h" -#include "ice_switch.h" #include <linux/avf/virtchnl.h> +#include "ice_switch.h" +#include "ice_fdir.h" #define ICE_SQ_SEND_DELAY_TIME_MS 10#define ICE_SQ_SEND_MAX_EXECUTE 3
drivers/net/ethernet/intel/ice/ice_dcb.h +1 -0
@@ -5,6 +5,7 @@#define _ICE_DCB_H_#include "ice_type.h" +#include <scsi/iscsi_proto.h> #define ICE_DCBX_STATUS_NOT_STARTED 0#define ICE_DCBX_STATUS_IN_PROGRESS 1
drivers/net/ethernet/intel/ice/ice_flex_pipe.c +1 -0
@@ -4,6 +4,7 @@#include "ice_common.h" #include "ice_flex_pipe.h" #include "ice_flow.h" +#include "ice.h" /* For supporting double VLAN mode, it is necessary to enable or disable certain * boost tcam entries. The metadata labels names that match the following
drivers/net/ethernet/intel/ice/ice_flow.c +1 -0
@@ -3,6 +3,7 @@#include "ice_common.h" #include "ice_flow.h" +#include <net/gre.h> /* Describe properties of a protocol header field */ struct ice_flow_field_info {
drivers/net/ethernet/intel/ice/ice_flow.h +2 -0
@@ -4,6 +4,8 @@#ifndef _ICE_FLOW_H_#define _ICE_FLOW_H_ +#include "ice_flex_type.h" +#define ICE_FLOW_ENTRY_HANDLE_INVAL 0#define ICE_FLOW_FLD_OFF_INVAL 0xffff
drivers/net/ethernet/intel/ice/ice_idc_int.h +0 -1
@@ -5,7 +5,6 @@#define _ICE_IDC_INT_H_#include <linux/net/intel/iidc.h> -#include "ice.h" struct ice_pf ;
drivers/net/ethernet/intel/ice/ice_main.c +15 -0
@@ -48,6 +48,21 @@ static DEFINE_IDA(ice_aux_ida);DEFINE_STATIC_KEY_FALSE (ice_xdp_locking_key);EXPORT_SYMBOL (ice_xdp_locking_key); +/** +* ice_hw_to_dev - Get device pointer from the hardware structure +* @hw: pointer to the device HW structure +* +* Used to access the device pointer from compilation units which can't easily +* include the definition of struct ice_pf without leading to circular header +* dependencies. +*/ +struct device *ice_hw_to_dev (struct ice_hw *hw) +{ + struct ice_pf *pf = container_of(hw, struct ice_pf, hw); + +return &pf->pdev->dev; +} +static struct workqueue_struct *ice_wq;static const struct net_device_ops ice_netdev_safe_mode_ops;static const struct net_device_ops ice_netdev_ops;
drivers/net/ethernet/intel/ice/ice_osdep.h +9 -2
@@ -5,7 +5,14 @@#define _ICE_OSDEP_H_#include <linux/types.h> +#include <linux/ctype.h> +#include <linux/delay.h> #include <linux/io.h> +#include <linux/bitops.h> +#include <linux/ethtool.h> +#include <linux/etherdevice.h> +#include <linux/if_ether.h> +#include <linux/pci_ids.h> #ifndef CONFIG_64BIT #include <linux/io-64-nonatomic-lo-hi.h> #endif
@@ -25,8 +32,8 @@ struct ice_dma_mem {size_t size; }; -#define ice_hw_to_dev (ptr) \ - (&(container_of((ptr), struct ice_pf, hw))->pdev->dev) +struct ice_hw ; +struct device *ice_hw_to_dev (struct ice_hw *hw);#ifdef CONFIG_DYNAMIC_DEBUG #define ice_debug(hw, type, fmt, args...) \
drivers/net/ethernet/intel/ice/ice_repr.h +0 -1
@@ -5,7 +5,6 @@#define _ICE_REPR_H_#include <net/dst_metadata.h> -#include "ice.h" struct ice_repr {struct ice_vsi *src_vsi;
drivers/net/ethernet/intel/ice/ice_sriov.h +0 -1
@@ -3,7 +3,6 @@#ifndef _ICE_SRIOV_H_#define _ICE_SRIOV_H_ -#include "ice.h" #include "ice_virtchnl_fdir.h" #include "ice_vsi_vlan_ops.h"
drivers/net/ethernet/intel/ice/ice_type.h +1 -0
@@ -9,6 +9,7 @@#define ICE_CHNL_MAX_TC 16#include "ice_hw_autogen.h" +#include "ice_devids.h" #include "ice_osdep.h" #include "ice_controlq.h" #include "ice_lan_tx_rx.h"
drivers/net/ethernet/intel/ice/ice_xsk.h +0 -1
@@ -4,7 +4,6 @@#ifndef _ICE_XSK_H_#define _ICE_XSK_H_#include "ice_txrx.h" -#include "ice.h" #define PKTS_PER_BATCH 8
Signature · 1 line
2.35.1.129.gb80121027d12
G
PATCH 3/25 ice: remove circular header dependencies on ice.h
Quoted 65 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 5:57 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 03/25] ice: remove circular header dependencies onice.hSeveral headers in the ice driver include
ice.heven though they are themselves included by that header. The most notable of these isice_common.h, but several other headers also do this.Such a recursive inclusion is problematic as it forces headers to be included in a strict order, otherwise compilation errors can result. The circular inclusions do not trigger an endless loop due to standard header inclusion guards, however other errors can occur.
For example,
ice_flow.hdefinesice_rss_hash_cfg, which is used byice_sriov.has part of the definition ofice_vf_hash_ip_ctx.
ice_flow.hincludesice_acl.h, which includesice_common.h, and which finally includesice.h. Sinceice.hitself includesice_sriov.h, this creates a circular dependency.The definition in
ice_sriov.hrequires things fromice_flow.h, butice_flow.hitself will lead to trying to loadice_sriov.has part of its process for expandingice.h. The current code avoids this issue by having an implicit dependency without the include ofice_flow.h.If we were to fix that so that
ice_sriov.hexplicitly depends onice_flow.hthe following pattern would occur:
ice_flow.h->ice_acl.h->ice_common.h->ice.h->ice_sriov.hAt this point, during the expansion of, the header guard for
ice_flow.his already set, so whenice_sriov.hattempts to load theice_flow.hheader it is skipped. Then, we go on to begin including the rest ofice_sriov.h, including structure definitions which depend onice_rss_hash_cfg. This produces a compiler warning becauseice_rss_hash_cfghasn't yet been included. Remember, we're just at the start ofice_flow.h!If the order of headers is incorrect (
ice_flow.his not implicitly loaded first in all files which includeice_sriov.h) then we get the same failure.Removing this recursive inclusion requires fixing a few cases where some headers depended on the header inclusions from
ice.h. In addition, a few other changes are also required.Most notably,
ice_hw_to_devis implemented as a macro inice_osdep.h, which is the likely reason thatice_common.hincludesice.hat all. This macro implementation requires the full definition ofice_pfin order to properly compile.Fix this by moving it to a function declared in
ice_main.c, so that we do not require all files to depend on the layout of theice_pfstructure.Note that this change only fixes circular dependencies, but it does not fully resolve all implicit dependencies where one header may depend on the inclusion of another. I tried to fix as many of the implicit dependencies as I noticed, but fixing them all requires a somewhat tedious analysis of each header and attempting to compile it separately.
Signed-off-by Jacob Keller <[email protected]>
Quoted 17 lines
--- drivers/net/ethernet/intel/ice/ice.h | 3 --- drivers/net/ethernet/intel/ice/ice_arfs.h | 3 +++ drivers/net/ethernet/intel/ice/ice_common.h | 4 ++-- drivers/net/ethernet/intel/ice/ice_dcb.h | 1 + drivers/net/ethernet/intel/ice/ice_flex_pipe.c | 1 + drivers/net/ethernet/intel/ice/ice_flow.c | 1 + drivers/net/ethernet/intel/ice/ice_flow.h | 2 ++ drivers/net/ethernet/intel/ice/ice_idc_int.h | 1 - drivers/net/ethernet/intel/ice/ice_main.c | 15 +++++++++++++++ drivers/net/ethernet/intel/ice/ice_osdep.h | 11 +++++++++-- drivers/net/ethernet/intel/ice/ice_repr.h | 1 - drivers/net/ethernet/intel/ice/ice_sriov.h | 1 - drivers/net/ethernet/intel/ice/ice_type.h | 1 + drivers/net/ethernet/intel/ice/ice_xsk.h | 1 - 14 files changed, 35 insertions(+), 11 deletions(-)
PATCH 4/25 ice: convert vf->vc_ops to a const pointer
In reply to Jacob KellerThe vc_ops structure is used to allow different handlers for virtchnl commands when the driver is in representor mode. The current implementation uses a copy of the ops table in each VF, and modifies this copy dynamically.
The usual practice in kernel code is to store the ops table in a constant structure and point to different versions. This has a number of advantages:
1. Reduced memory usage. Each VF merely points to the correct table, so they're able to re-use the same contsnat lookup table in memory.
2. Consistency. It becomes more difficult to accidentally update or edit only one op call. Instead, the code switches to the correct able by a single pointer write. In general this is atomic, either the pointer is updated or its not.
3. Code Layout. The VF structure can store a pointer to the table without needing to have the full structure definition defined prior to the VF structure definition. This will aid in future refactoring of code by allowing the VF pointer to be kept in ice_vf_lib.h while the virtchnl ops table can be maintained in ice_virtchnl.h
There is one major downside in the case of the vc_ops structure. Most of the operations in the table are the same between the two current implementations. This can appear to lead to duplication since each implementation must now fill in the complete table. It could make spotting the differences in the representor mode more challenging. Unfortunately, methods to make this less error prone either add complexity overhead (macros using CPP token concatenation) or don't work on all compilers we support (constant initializer from another constant structure).
The cost of maintaining two structures does not out weigh the benefits of the constant table model.
While we're making these changes, go ahead and rename the structure and implementations with "virtchnl" instead of "vc_vf_". This will more closely align with the planned file renaming, and avoid similar names when we later introduce a "vf ops" table for separating Scalable IOV and Single Root IOV implementations.
Leave the accessor/assignment functions in order to avoid issues with compiling with options disabled. The interface makes it easier to handle when CONFIG_PCI_IOV is disabled in the kernel.
--- drivers/net/ethernet/intel/ice/ice_repr.c | 4 +- drivers/net/ethernet/intel/ice/ice_sriov.c | 61 +++++++++++++++++----- drivers/net/ethernet/intel/ice/ice_sriov.h | 13 +++-- 3 files changed, 55 insertions(+), 23 deletions(-)
drivers/net/ethernet/intel/ice/ice_repr.c +2 -2
@@ -339,7 +339,7 @@ static int ice_repr_add(struct ice_vf *vf)devlink_port_type_eth_set (&vf->devlink_port, repr->netdev); -ice_vc_change_ops_to_repr (&vf->vc_ops); +ice_virtchnl_set_repr_ops (vf);return 0 ;
@@ -384,7 +384,7 @@ static void ice_repr_rem(struct ice_vf *vf)kfree (vf->repr); vf->repr =NULL ; -ice_vc_set_dflt_vf_ops (&vf->vc_ops); +ice_virtchnl_set_dflt_ops (vf); }/**
drivers/net/ethernet/intel/ice/ice_sriov.c +47 -14
100 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_sriov.h +6 -7
@@ -113,7 +113,7 @@ struct ice_mdd_vf_events {struct ice_vf ; -struct ice_vc_vf_ops { +struct ice_virtchnl_ops {int (*get_ver_msg)(struct ice_vf *vf,u8 *msg);int (*get_vf_res_msg)(struct ice_vf *vf,u8 *msg);void (*reset_vf)(struct ice_vf *vf);
@@ -206,8 +206,7 @@ struct ice_vf {DECLARE_BITMAP (opcodes_allowlist,VIRTCHNL_OP_MAX );struct ice_repr *repr; - -struct ice_vc_vf_ops vc_ops; +const struct ice_virtchnl_ops *virtchnl_ops;/* devlink port data */ struct devlink_port devlink_port;
@@ -230,8 +229,8 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event);void ice_vc_notify_link_state (struct ice_pf *pf);void ice_vc_notify_reset (struct ice_pf *pf);void ice_vc_notify_vf_link_state (struct ice_vf *vf); -void ice_vc_change_ops_to_repr (struct ice_vc_vf_ops *ops); -void ice_vc_set_dflt_vf_ops (struct ice_vc_vf_ops *ops); +void ice_virtchnl_set_repr_ops (struct ice_vf *vf); +void ice_virtchnl_set_dflt_ops (struct ice_vf *vf);bool ice_reset_all_vfs (struct ice_pf *pf,bool is_vflr);bool ice_reset_vf (struct ice_vf *vf,bool is_vflr);void ice_restore_all_vfs_msi_state (struct pci_dev *pdev);
@@ -303,8 +302,8 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event) {static inline void ice_vc_notify_link_state (struct ice_pf *pf) { }static inline void ice_vc_notify_reset (struct ice_pf *pf) { }static inline void ice_vc_notify_vf_link_state (struct ice_vf *vf) { } -static inline void ice_vc_change_ops_to_repr (struct ice_vc_vf_ops *ops) { } -static inline void ice_vc_set_dflt_vf_ops (struct ice_vc_vf_ops *ops) { } +static inline void ice_virtchnl_set_repr_ops (struct ice_vf *vf) { } +static inline void ice_virtchnl_set_dflt_ops (struct ice_vf *vf) { }static inline void ice_set_vf_state_qs_dis (struct ice_vf *vf) { }static inline void ice_vf_lan_overflow_event (struct ice_pf *pf,struct ice_rq_event_info *event) { }
Signature · 1 line
2.35.1.129.gb80121027d12
Penigalapati
PATCH 4/25 ice: convert vf->vc_ops to a const pointer
Quoted 51 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 5:57 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 04/25] ice: convertvf->vc_opsto a const pointerThe
vc_opsstructure is used to allow different handlers for virtchnl commands when the driver is in representor mode. The current implementation uses a copy of the ops table in each VF, and modifies this copy dynamically.The usual practice in kernel code is to store the ops table in a constant structure and point to different versions. This has a number of advantages:
1. Reduced memory usage. Each VF merely points to the correct table, so they're able to re-use the same contsnat lookup table in memory.
2. Consistency. It becomes more difficult to accidentally update or edit only one op call. Instead, the code switches to the correct able by a single pointer write. In general this is atomic, either the pointer is updated or its not.
3. Code Layout. The VF structure can store a pointer to the table without needing to have the full structure definition defined prior to the VF structure definition. This will aid in future refactoring of code by allowing the VF pointer to be kept inice_vf_lib.hwhile the virtchnl ops table can be maintained inice_virtchnl.hThere is one major downside in the case of the
vc_opsstructure. Most of the operations in the table are the same between the two current implementations. This can appear to lead to duplication since each implementation must now fill in the complete table. It could make spotting the differences in the representor mode more challenging. Unfortunately, methods to make this less error prone either add complexity overhead (macros using CPP token concatenation) or don't work on all compilers we support (constant initializer from another constant structure).The cost of maintaining two structures does not out weigh the benefits of the constant table model.
While we're making these changes, go ahead and rename the structure and implementations with "virtchnl" instead of "
vc_vf_". This will more closely align with the planned file renaming, and avoid similar names when we later introduce a "vf ops" table for separating Scalable IOV and Single Root IOV implementations.Leave the accessor/assignment functions in order to avoid issues with compiling with options disabled. The interface makes it easier to handle when
CONFIG_PCI_IOVis disabled in the kernel.
Quoted 7 lines
Signed-off-by Jacob Keller <[email protected]>---
drivers/net/ethernet/intel/ice/ice_repr.c | 4 +- drivers/net/ethernet/intel/ice/ice_sriov.c | 61 +++++++++++++++++----- drivers/net/ethernet/intel/ice/ice_sriov.h | 13 +++-- 3 files changed, 55 insertions(+), 23 deletions(-)
PATCH 5/25 ice: remmove unused definitions from ice_sriov.h
In reply to Jacob KellerA few more macros exist in ice_sriov.h which are not used anywhere. These can be safely removed. Note that ICE_VIRTCHNL_VF_CAP_L2 capability is set but never checked anywhere in the driver. Thus it is also safe to remove.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 1 - drivers/net/ethernet/intel/ice/ice_sriov.h | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +0 -1
@@ -2012,7 +2012,6 @@ static int ice_create_vf_entries(struct ice_pf *pf, u16 num_vfs) vf->vf_sw_id = pf->first_sw;/* assign default capabilities */ -set_bit (ICE_VIRTCHNL_VF_CAP_L2 , &vf->vf_caps); vf->spoofchk = true; vf->num_vf_qs = pf->vfs.num_qps_per;ice_vc_set_default_allowlist (vf);
drivers/net/ethernet/intel/ice/ice_sriov.h +1 -6
@@ -13,9 +13,6 @@*/ #define ICE_MAX_MACADDR_PER_VF 18 -/* Malicious Driver Detection */ -#define ICE_MDD_EVENTS_THRESHOLD 30 -/* Static VF transaction/status register def */ #define VF_DEVICE_STATUS 0xAA#define VF_TRANS_PENDING_M 0x20
@@ -28,7 +25,6 @@#define ICE_MAX_VF_COUNT 256#define ICE_MIN_QS_PER_VF 1#define ICE_NONQ_VECS_VF 1 -#define ICE_MAX_SCATTER_QS_PER_VF 16#define ICE_MAX_RSS_QS_PER_VF 16#define ICE_NUM_VF_MSIX_MED 17#define ICE_NUM_VF_MSIX_SMALL 5
@@ -95,8 +91,7 @@ enum ice_vf_states {/* VF capabilities */ enum ice_virtchnl_cap { -ICE_VIRTCHNL_VF_CAP_L2 =0 , -ICE_VIRTCHNL_VF_CAP_PRIVILEGE , +ICE_VIRTCHNL_VF_CAP_PRIVILEGE =0 , };struct ice_time_mac {
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 5/25 ice: remmove unused definitions from ice_sriov.h
drivers/net/ethernet/intel/ice/ice_sriov.h
Quoted 40 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 05/25] ice: remmove unused definitions fromice_sriov.hA few more macros exist in
ice_sriov.hwhich are not used anywhere. These can be safely removed. Note thatICE_VIRTCHNL_VF_CAP_L2capability is set but never checked anywhere in the driver. Thus it is also safe to remove.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_sriov.c | 1 - drivers/net/ethernet/intel/ice/ice_sriov.h | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-)drivers/net/ethernet/intel/ice/ice_sriov.c +0
-1@@ -2012,7 +2012,6 @@ static int ice_create_vf_entries(struct ice_pf *pf, u16 num_vfs) vf->vf_sw_id = pf->first_sw;/* assign default capabilities */ -set_bit (ICE_VIRTCHNL_VF_CAP_L2 , &vf->vf_caps); vf->spoofchk = true; vf->num_vf_qs = pf->vfs.num_qps_per;drivers/net/ethernet/intel/ice/ice_sriov.c +0
-0ice_vc_set_default_allowlist (vf);drivers/net/ethernet/intel/ice/ice_sriov.h +0
-0
PATCH 6/25 ice: rename ICE_MAX_VF_COUNT to avoid confusion
In reply to Jacob KellerThe ICE_MAX_VF_COUNT field is defined in ice_sriov.h. This count is true for SR-IOV but will not be true for all VF implementations, such as when the ice driver supports Scalable IOV.
Rename this definition to clearly indicate ICE_MAX_SRIOV_VFS.
--- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_sriov.c | 8 ++++---- drivers/net/ethernet/intel/ice/ice_sriov.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +1 -1
@@ -3868,7 +3868,7 @@ static void ice_set_pf_caps(struct ice_pf *pf)if (func_caps->common_cap.sr_iov_1_1) {set_bit (ICE_FLAG_SRIOV_CAPABLE , pf->flags); pf->vfs.num_supported =min_t (int, func_caps->num_allocd_vfs, -ICE_MAX_VF_COUNT ); +ICE_MAX_SRIOV_VFS ); }clear_bit (ICE_FLAG_RSS_ENA , pf->flags);if (func_caps->common_cap.rss_table_size)
drivers/net/ethernet/intel/ice/ice_sriov.c +4 -4
@@ -661,7 +661,7 @@ void ice_free_vfs(struct ice_pf *pf)/* clear malicious info since the VF is getting released */ if (ice_mbx_clear_malvf (&hw->mbx_snapshot, pf->vfs.malvfs, -ICE_MAX_VF_COUNT , vf->vf_id)) +ICE_MAX_SRIOV_VFS , vf->vf_id))dev_dbg (dev,"failed to clear malicious VF state for VF %u\n" , vf->vf_id);
@@ -1591,7 +1591,7 @@ bool ice_reset_all_vfs(struct ice_pf *pf, bool is_vflr)/* clear all malicious info if the VFs are getting reset */ ice_for_each_vf (pf, bkt, vf)if (ice_mbx_clear_malvf (&hw->mbx_snapshot, pf->vfs.malvfs, -ICE_MAX_VF_COUNT , vf->vf_id)) +ICE_MAX_SRIOV_VFS , vf->vf_id))dev_dbg (dev,"failed to clear malicious VF state for VF %u\n" , vf->vf_id);
@@ -1805,7 +1805,7 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)/* if the VF has been reset allow it to come up again */ if (ice_mbx_clear_malvf (&hw->mbx_snapshot, pf->vfs.malvfs, -ICE_MAX_VF_COUNT , vf->vf_id)) +ICE_MAX_SRIOV_VFS , vf->vf_id))dev_dbg (dev,"failed to clear malicious VF state for VF %u\n" , i);return true;
@@ -6624,7 +6624,7 @@ ice_is_malicious_vf(struct ice_pf *pf, struct ice_rq_event_info *event,* know about it, then let them know now */ status =ice_mbx_report_malvf (&pf->hw, pf->vfs.malvfs, -ICE_MAX_VF_COUNT , vf_id, +ICE_MAX_SRIOV_VFS , vf_id, &report_vf);if (status)dev_dbg (dev,"Error reporting malicious VF\n" );
drivers/net/ethernet/intel/ice/ice_sriov.h +2 -2
@@ -22,7 +22,7 @@#define ICE_PCI_CIAD_WAIT_DELAY_US 1/* VF resource constraints */ -#define ICE_MAX_VF_COUNT 256 +#define ICE_MAX_SRIOV_VFS 256#define ICE_MIN_QS_PER_VF 1#define ICE_NONQ_VECS_VF 1#define ICE_MAX_RSS_QS_PER_VF 16
@@ -147,7 +147,7 @@ struct ice_vfs {u16 num_qps_per;/* number of queue pairs per VF */ u16 num_msix_per;/* number of MSi-X vectors per VF */ unsigned long last_printed_mdd_jiffies;/* MDD message rate limit */ -DECLARE_BITMAP (malvfs,ICE_MAX_VF_COUNT );/* malicious VF indicator */ +DECLARE_BITMAP (malvfs,ICE_MAX_SRIOV_VFS );/* malicious VF indicator */ };/* VF information structure */
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 6/25 ice: rename ICE_MAX_VF_COUNT to avoid confusion
drivers/net/ethernet/intel/ice/ice_main.c static void ice_set_pf_caps(struct ice_pf *pf)
Quoted 29 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 06/25] ice: renameICE_MAX_VF_COUNTto avoid confusionThe
ICE_MAX_VF_COUNTfield is defined inice_sriov.h. This count is true for SR-IOV but will not be true for all VF implementations, such as when the ice driver supports Scalable IOV.Rename this definition to clearly indicate
ICE_MAX_SRIOV_VFS.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_sriov.c | 8 ++++---- drivers/net/ethernet/intel/ice/ice_sriov.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)drivers/net/ethernet/intel/ice/ice_main.c +0
-0@@ -3868,7 +3868,7 @@ static void ice_set_pf_caps(struct ice_pf *pf)
PATCH 7/25 ice: refactor spoofchk control code in ice_sriov.c
In reply to Jacob KellerThe API to control the VSI spoof checking for a VF VSI has three
functions: enable, disable, and set. The set function takes the VSI and the VF and decides whether to call enable or disable based on the vf->spoofchk field.
In some flows, vf->spoofchk is not yet set, such as the function used to control the setting for a VF. (vf->spoofchk is only updated after a success).
Simplify this API by refactoring ice_vf_set_spoofchk_cfg to be "ice_vsi_apply_spoofchk" which takes the boolean and allows all callers to avoid having to determine whether to call enable or disable themselves.
This matches the expected callers better, and will prevent the need to export more than one function when this code must be called from another file.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +7 -11
@@ -985,16 +985,15 @@ static int ice_vsi_dis_spoofchk(struct ice_vsi *vsi) }/** -* ice_vf_set_spoofchk_cfg - apply Tx spoof checking setting -* @vf: VF set spoofchk for +* ice_vsi_apply_spoofchk - Apply Tx spoof checking setting to a VSI * @vsi: VSI associated to the VF +* @enable: whether to enable or disable the spoof checking */ -static int -ice_vf_set_spoofchk_cfg (struct ice_vf *vf,struct ice_vsi *vsi) +static int ice_vsi_apply_spoofchk (struct ice_vsi *vsi,bool enable) {int err; -if (vf->spoofchk) +if (enable) err =ice_vsi_ena_spoofchk (vsi);else err =ice_vsi_dis_spoofchk (vsi);
@@ -1478,7 +1477,7 @@ static void ice_vf_rebuild_host_cfg(struct ice_vf *vf)dev_err (dev,"failed to rebuild Tx rate limiting configuration for VF %u\n" , vf->vf_id); -if (ice_vf_set_spoofchk_cfg (vf, vsi)) +if (ice_vsi_apply_spoofchk (vsi, vf->spoofchk))dev_err (dev,"failed to rebuild spoofchk configuration for VF %d\n" , vf->vf_id);
@@ -1915,7 +1914,7 @@ static int ice_init_vf_vsi_res(struct ice_vf *vf) goto release_vsi; } - err =ice_vf_set_spoofchk_cfg (vf, vsi); + err =ice_vsi_apply_spoofchk (vsi, vf->spoofchk);if (err) {dev_warn (dev,"Failed to initialize spoofchk setting for VF %d\n" , vf->vf_id);
@@ -3129,10 +3128,7 @@ int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena) goto out_put_vf; } -if (ena) - ret =ice_vsi_ena_spoofchk (vf_vsi); -else - ret =ice_vsi_dis_spoofchk (vf_vsi); + ret =ice_vsi_apply_spoofchk (vf_vsi, ena);if (ret)dev_err (dev,"Failed to set spoofchk %s for VF %d VSI %d\n error %d\n" , ena ?"ON" :"OFF" , vf->vf_id, vf_vsi->vsi_num, ret);
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 7/25 ice: refactor spoofchk control code in ice_sriov.c
Quoted 37 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 07/25] ice: refactor spoofchk control code inice_sriov.cThe API to control the VSI spoof checking for a VF VSI has three
functions: enable, disable, and set. The set function takes the VSI and the VF and decides whether to call enable or disable based on thevf->spoofchkfield.In some flows,
vf->spoofchkis not yet set, such as the function used to control the setting for a VF. (vf->spoofchkis only updated after a success).Simplify this API by refactoring
ice_vf_set_spoofchk_cfgto be "ice_vsi_apply_spoofchk" which takes the boolean and allows all callers to avoid having to determine whether to call enable or disable themselves.This matches the expected callers better, and will prevent the need to export more than one function when this code must be called from another file.
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_sriov.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)drivers/net/ethernet/intel/ice/ice_sriov.c +0
-0
drivers/net/ethernet/intel/ice/ice_sriov.c static int ice_vsi_dis_spoofchk(struct ice_vsi *vsi) } · line 985
Quoted 1 line
drivers/net/ethernet/intel/ice/ice_sriov.c +0
-0@@ -985,16 +985,15 @@ static int ice_vsi_dis_spoofchk(struct ice_vsi *vsi) }
PATCH 8/25 ice: move ice_set_vf_port_vlan near other .ndo ops
In reply to Jacob KellerThe ice_set_vf_port_vlan function is located in ice_sriov.c very far away from the other .ndo operations that it is similar to. Move this so that its located near the other .ndo operation definitions.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 192 ++++++++++----------- 1 file changed, 96 insertions(+), 96 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +96 -96
@@ -4249,102 +4249,6 @@ static int ice_vc_request_qs_msg(struct ice_vf *vf, u8 *msg) v_ret, (u8 *)vfres, sizeof(*vfres)); } -/** -* ice_is_supported_port_vlan_proto - make sure the vlan_proto is supported -* @hw: hardware structure used to check the VLAN mode -* @vlan_proto: VLAN TPID being checked -* -* If the device is configured in Double VLAN Mode (DVM), then both ETH_P_8021Q -* and ETH_P_8021AD are supported. If the device is configured in Single VLAN -* Mode (SVM), then only ETH_P_8021Q is supported. -*/ -static bool -ice_is_supported_port_vlan_proto (struct ice_hw *hw,u16 vlan_proto) -{ -bool is_supported = false; - -switch (vlan_proto) { -case ETH_P_8021Q : - is_supported = true; -break ; -case ETH_P_8021AD : -if (ice_is_dvm_ena (hw)) - is_supported = true; -break ; - } - -return is_supported; -} - -/** -* ice_set_vf_port_vlan -* @netdev: network interface device structure -* @vf_id: VF identifier -* @vlan_id: VLAN ID being set -* @qos: priority setting -* @vlan_proto: VLAN protocol -* -* program VF Port VLAN ID and/or QoS -*/ -int -ice_set_vf_port_vlan (struct net_device *netdev,int vf_id,u16 vlan_id,u8 qos, -__be16 vlan_proto) -{ -struct ice_pf *pf =ice_netdev_to_pf (netdev); -u16 local_vlan_proto =ntohs (vlan_proto); -struct device *dev; -struct ice_vf *vf; -int ret; - - dev =ice_pf_to_dev (pf); - -if (vlan_id >=VLAN_N_VID || qos >7 ) { -dev_err (dev,"Invalid Port VLAN parameters for VF %d, ID %d, QoS %d\n" , - vf_id, vlan_id, qos); -return -EINVAL ; - } - -if (!ice_is_supported_port_vlan_proto (&pf->hw, local_vlan_proto)) { -dev_err (dev,"VF VLAN protocol 0x%04x is not supported\n" , - local_vlan_proto); -return -EPROTONOSUPPORT ; - } - - vf =ice_get_vf_by_id (pf, vf_id); -if (!vf) -return -EINVAL ; - - ret =ice_check_vf_ready_for_cfg (vf); -if (ret) - goto out_put_vf; - -if (ice_vf_get_port_vlan_prio (vf) == qos && -ice_vf_get_port_vlan_tpid (vf) == local_vlan_proto && -ice_vf_get_port_vlan_id (vf) == vlan_id) { -/* duplicate request, so just return success */ -dev_dbg (dev,"Duplicate port VLAN %u, QoS %u, TPID 0x%04x request\n" , - vlan_id, qos, local_vlan_proto); - ret =0 ; - goto out_put_vf; - } - -mutex_lock (&vf->cfg_lock); - - vf->port_vlan_info =ICE_VLAN (local_vlan_proto, vlan_id, qos); -if (ice_vf_is_port_vlan_ena (vf)) -dev_info (dev,"Setting VLAN %u, QoS %u, TPID 0x%04x on VF %d\n" , - vlan_id, qos, local_vlan_proto, vf_id); -else -dev_info (dev,"Clearing port VLAN on VF %d\n" , vf_id); - -ice_vc_reset_vf (vf); -mutex_unlock (&vf->cfg_lock); - -out_put_vf: -ice_put_vf (vf); -return ret; -} -/** * ice_vf_vlan_offload_ena - determine if capabilities support VLAN offloads * @caps: VF driver negotiated capabilities
@@ -6483,6 +6387,102 @@ int ice_get_vf_stats(struct net_device *netdev, int vf_id,return ret; } +/** +* ice_is_supported_port_vlan_proto - make sure the vlan_proto is supported +* @hw: hardware structure used to check the VLAN mode +* @vlan_proto: VLAN TPID being checked +* +* If the device is configured in Double VLAN Mode (DVM), then both ETH_P_8021Q +* and ETH_P_8021AD are supported. If the device is configured in Single VLAN +* Mode (SVM), then only ETH_P_8021Q is supported. +*/ +static bool +ice_is_supported_port_vlan_proto (struct ice_hw *hw,u16 vlan_proto) +{ +bool is_supported = false; + +switch (vlan_proto) { +case ETH_P_8021Q : + is_supported = true; +break ; +case ETH_P_8021AD : +if (ice_is_dvm_ena (hw)) + is_supported = true; +break ; + } + +return is_supported; +} + +/** +* ice_set_vf_port_vlan +* @netdev: network interface device structure +* @vf_id: VF identifier +* @vlan_id: VLAN ID being set +* @qos: priority setting +* @vlan_proto: VLAN protocol +* +* program VF Port VLAN ID and/or QoS +*/ +int +ice_set_vf_port_vlan (struct net_device *netdev,int vf_id,u16 vlan_id,u8 qos, +__be16 vlan_proto) +{ +struct ice_pf *pf =ice_netdev_to_pf (netdev); +u16 local_vlan_proto =ntohs (vlan_proto); +struct device *dev; +struct ice_vf *vf; +int ret; + + dev =ice_pf_to_dev (pf); + +if (vlan_id >=VLAN_N_VID || qos >7 ) { +dev_err (dev,"Invalid Port VLAN parameters for VF %d, ID %d, QoS %d\n" , + vf_id, vlan_id, qos); +return -EINVAL ; + } + +if (!ice_is_supported_port_vlan_proto (&pf->hw, local_vlan_proto)) { +dev_err (dev,"VF VLAN protocol 0x%04x is not supported\n" , + local_vlan_proto); +return -EPROTONOSUPPORT ; + } + + vf =ice_get_vf_by_id (pf, vf_id); +if (!vf) +return -EINVAL ; + + ret =ice_check_vf_ready_for_cfg (vf); +if (ret) + goto out_put_vf; + +if (ice_vf_get_port_vlan_prio (vf) == qos && +ice_vf_get_port_vlan_tpid (vf) == local_vlan_proto && +ice_vf_get_port_vlan_id (vf) == vlan_id) { +/* duplicate request, so just return success */ +dev_dbg (dev,"Duplicate port VLAN %u, QoS %u, TPID 0x%04x request\n" , + vlan_id, qos, local_vlan_proto); + ret =0 ; + goto out_put_vf; + } + +mutex_lock (&vf->cfg_lock); + + vf->port_vlan_info =ICE_VLAN (local_vlan_proto, vlan_id, qos); +if (ice_vf_is_port_vlan_ena (vf)) +dev_info (dev,"Setting VLAN %u, QoS %u, TPID 0x%04x on VF %d\n" , + vlan_id, qos, local_vlan_proto, vf_id); +else +dev_info (dev,"Clearing port VLAN on VF %d\n" , vf_id); + +ice_vc_reset_vf (vf); +mutex_unlock (&vf->cfg_lock); + +out_put_vf: +ice_put_vf (vf); +return ret; +} +/** * ice_print_vf_rx_mdd_event - print VF Rx malicious driver detect event * @vf: pointer to the VF structure
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 8/25 ice: move ice_set_vf_port_vlan near other .ndo ops
drivers/net/ethernet/intel/ice/ice_sriov.c static int ice_vc_request_qs_msg(struct ice_vf
Quoted 25 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 08/25] ice: moveice_set_vf_port_vlannear other .ndo opsThe
ice_set_vf_port_vlanfunction is located inice_sriov.cvery far away from the other .ndo operations that it is similar to. Move this so that its located near the other .ndo operation definitions.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_sriov.c | 192 ++++++++++----------- 1 file changed, 96 insertions(+), 96 deletions(-)drivers/net/ethernet/intel/ice/ice_sriov.c +0
-0@@ -4249,102 +4249,6 @@ static int ice_vc_request_qs_msg(struct ice_vf
PATCH 9/25 ice: cleanup error logging for ice_ena_vfs
In reply to Jacob KellerThe ice_ena_vfs function and some of its sub-functions like ice_set_per_vf_res use a "if (<function>) { <print error> ; <exit> }" flow. This flow discards specialized errors reported by the called function.
This style is generally not preferred as it makes tracing error sources more difficult. It also means we cannot log the actual error received properly.
Refactor several calls in the ice_ena_vfs function that do this to catch the error in the 'ret' variable. Report this in the messages, and then return the more precise error value.
Doing this reveals that ice_set_per_vf_res returns -EINVAL or -EIO in places where -ENOSPC makes more sense. Fix these calls up to return the more appropriate value.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 32 +++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +19 -13
@@ -1275,12 +1275,16 @@ static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs)u16 num_msix_per_vf, num_txq, num_rxq, avail_qs;int msix_avail_per_vf, msix_avail_for_sriov;struct device *dev =ice_pf_to_dev (pf); +int err;lockdep_assert_held (&pf->vfs.table_lock); -if (!num_vfs || max_valid_res_idx <0 ) +if (!num_vfs)return -EINVAL ; +if (max_valid_res_idx <0 ) +return -ENOSPC ; +/* determine MSI-X resources per VF */ msix_avail_for_sriov = pf->hw.func_caps.common_cap.num_msix_vectors - pf->irq_tracker->num_entries;
@@ -1297,7 +1301,7 @@ static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs)dev_err (dev,"Only %d MSI-X interrupts available for SR-IOV. Not enough to support minimum of %d MSI-X interrupts per VF for %d VFs\n" , msix_avail_for_sriov,ICE_MIN_INTR_PER_VF , num_vfs); -return -EIO ; +return -ENOSPC ; } num_txq = min_t(u16, num_msix_per_vf - ICE_NONQ_VECS_VF,
@@ -1319,13 +1323,14 @@ static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs)if (num_txq <ICE_MIN_QS_PER_VF || num_rxq <ICE_MIN_QS_PER_VF ) {dev_err (dev,"Not enough queues to support minimum of %d queue pairs per VF for %d VFs\n" ,ICE_MIN_QS_PER_VF , num_vfs); -return -EIO ; +return -ENOSPC ; } -if (ice_sriov_set_msix_res (pf, num_msix_per_vf * num_vfs)) { -dev_err (dev,"Unable to set MSI-X resources for %d VFs\n" , - num_vfs); -return -EINVAL ; + err =ice_sriov_set_msix_res (pf, num_msix_per_vf * num_vfs); +if (err) { +dev_err (dev,"Unable to set MSI-X resources for %d VFs, err %d\n" , + num_vfs, err); +return err; }/* only allow equal Tx/Rx queue count (i.e. queue pairs) */
@@ -2058,10 +2063,10 @@ static int ice_ena_vfs(struct ice_pf *pf, u16 num_vfs)mutex_lock (&pf->vfs.table_lock); -if (ice_set_per_vf_res (pf, num_vfs)) { -dev_err (dev,"Not enough resources for %d VFs, try with fewer number of VFs\n" , - num_vfs); - ret = -ENOSPC ; + ret =ice_set_per_vf_res (pf, num_vfs); +if (ret) { +dev_err (dev,"Not enough resources for %d VFs, err %d. Try with fewer number of VFs\n" , + num_vfs, ret); goto err_unroll_sriov; }
@@ -2072,8 +2077,9 @@ static int ice_ena_vfs(struct ice_pf *pf, u16 num_vfs) goto err_unroll_sriov; } -if (ice_start_vfs (pf)) { -dev_err (dev,"Failed to start VF(s)\n" ); + ret =ice_start_vfs (pf); +if (ret) { +dev_err (dev,"Failed to start %d VFs, err %d\n" , num_vfs, ret); ret = -EAGAIN ; goto err_unroll_vf_entries; }
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 9/25 ice: cleanup error logging for ice_ena_vfs
drivers/net/ethernet/intel/ice/ice_sriov.c static int ice_set_per_vf_res(struct ice_pf *pf,
Quoted 36 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 09/25] ice: cleanup error logging forice_ena_vfsThe
ice_ena_vfsfunction and some of its sub-functions likeice_set_per_vf_resuse a "if (<function>) { <print error> ; <exit> }" flow. This flow discards specialized errors reported by the called function.This style is generally not preferred as it makes tracing error sources more difficult. It also means we cannot log the actual error received properly.
Refactor several calls in the
ice_ena_vfsfunction that do this to catch the error in the 'ret' variable. Report this in the messages, and then return the more precise error value.Doing this reveals that
ice_set_per_vf_resreturns-EINVALor-EIOin places where-ENOSPCmakes more sense. Fix these calls up to return the more appropriate value.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_sriov.c | 32 +++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-)drivers/net/ethernet/intel/ice/ice_sriov.c +0
-0@@ -1275,12 +1275,16 @@ static int ice_set_per_vf_res(struct ice_pf *pf,
PATCH 10/25 ice: log an error message when eswitch fails to configure
In reply to Jacob KellerWhen ice_eswitch_configure fails, print an error message to make it more obvious why VF initialization did not succeed.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +3 -1
@@ -2087,8 +2087,10 @@ static int ice_ena_vfs(struct ice_pf *pf, u16 num_vfs)clear_bit (ICE_VF_DIS , pf->state); ret =ice_eswitch_configure (pf); -if (ret) +if (ret) { +dev_err (dev,"Failed to configure eswitch, err %d\n" , ret); goto err_unroll_sriov; + }/* rearm global interrupts */ if (test_and_clear_bit (ICE_OICR_INTR_DIS , pf->state))
Signature · 1 line
2.35.1.129.gb80121027d12
Penigalapati
PATCH 10/25 ice: log an error message when eswitch fails to configure
Quoted 8 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 5:57 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 10/25] ice: log an error message when eswitch fails to configure
Quoted 8 lines
When
ice_eswitch_configurefails, print an error message to make it more obvious why VF initialization did not succeed.Signed-off-by Jacob Keller <[email protected]>---
drivers/net/ethernet/intel/ice/ice_sriov.c| 4 +++-1 file changed, 3 insertions(+), 1 deletion(-)
PATCH 11/25 ice: use ice_is_vf_trusted helper function
In reply to Jacob KellerThe ice_vc_cfg_promiscuous_mode_msg function directly checks ICE_VIRTCHNL_VF_CAP_PRIVILEGE, instead of using the existing helper function ice_is_vf_trusted. Switch this to use the helper function so that all trusted checks are consistent. This aids in any potential future refactor by ensuring consistent code.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +10 -10
@@ -3148,6 +3148,15 @@ int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena)return ret; } +/** +* ice_is_vf_trusted +* @vf: pointer to the VF info +*/ +static bool ice_is_vf_trusted (struct ice_vf *vf) +{ +return test_bit (ICE_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps); +} +/** * ice_is_any_vf_in_promisc - check if any VF(s) are in promiscuous mode * @pf: PF structure for accessing VF(s)
@@ -3212,7 +3221,7 @@ static int ice_vc_cfg_promiscuous_mode_msg(struct ice_vf *vf, u8 *msg) } dev =ice_pf_to_dev (pf); -if (!test_bit (ICE_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps)) { +if (!ice_is_vf_trusted (vf)) {dev_err (dev,"Unprivileged VF %d is attempting to configure promiscuous mode\n" , vf->vf_id);/* Leave v_ret alone, lie to the VF on purpose. */
@@ -3862,15 +3871,6 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) NULL, 0); } -/** -* ice_is_vf_trusted -* @vf: pointer to the VF info -*/ -static bool ice_is_vf_trusted (struct ice_vf *vf) -{ -return test_bit (ICE_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps); -} -/** * ice_can_vf_change_mac * @vf: pointer to the VF info
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 11/25 ice: use ice_is_vf_trusted helper function
drivers/net/ethernet/intel/ice/ice_sriov.c int ice_set_vf_spoofchk(struct net_device
Quoted 27 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 11/25] ice: useice_is_vf_trustedhelper functionThe
ice_vc_cfg_promiscuous_mode_msgfunction directly checksICE_VIRTCHNL_VF_CAP_PRIVILEGE, instead of using the existing helper functionice_is_vf_trusted. Switch this to use the helper function so that all trusted checks are consistent. This aids in any potential future refactor by ensuring consistent code.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_sriov.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)drivers/net/ethernet/intel/ice/ice_sriov.c +0
-0@@ -3148,6 +3148,15 @@ int ice_set_vf_spoofchk(struct net_device
PATCH 12/25 ice: introduce ice_vf_lib.c, ice_vf_lib.h, and ice_vf_lib_private.h
In reply to Jacob KellerIntroduce the ice_vf_lib.c file along with the ice_vf_lib.h and ice_vf_lib_private.h header files.
These files will house the generic VF structures and access functions. Move struct ice_vf and its dependent definitions into this new header file.
The ice_vf_lib.c is compiled conditionally on CONFIG_PCI_IOV. Some of its functionality is required by all driver files. However, some of its functionality will only be required by other files also conditionally compiled based on CONFIG_PCI_IOV.
Declaring these functions used only in CONFIG_PCI_IOV files in ice_vf_lib.h is verbose. This is because we must provide a fallback implementation for each function in this header since it is included in files which may not be compiled with CONFIG_PCI_IOV.
Instead, introduce a new ice_vf_lib_private.h header which verifies that CONFIG_PCI_IOV is enabled. This header is intended to be directly included in .c files which are CONFIG_PCI_IOV only. Add a #error indication that will complain if the file ever gets included by another C file on a kernel with CONFIG_PCI_IOV disabled. Add a comment indicating the nature of the file and why it is useful.
This makes it so that we can easily define functions exposed from ice_vf_lib.c into other virtualization files without needing to add fallback implementations for every single function.
This begins the path to separate out generic code which will be reused by other virtualization implementations from ice_sriov.h and ice_sriov.c
--- drivers/net/ethernet/intel/ice/Makefile | 3 +- drivers/net/ethernet/intel/ice/ice_sriov.c | 509 +---------------- drivers/net/ethernet/intel/ice/ice_sriov.h | 203 +------ drivers/net/ethernet/intel/ice/ice_vf_lib.c | 519 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_vf_lib.h | 259 +++++++++ .../ethernet/intel/ice/ice_vf_lib_private.h | 39 ++ .../ethernet/intel/ice/ice_virtchnl_fdir.c | 1 + .../ethernet/intel/ice/ice_virtchnl_fdir.h | 1 + 8 files changed, 823 insertions(+), 711 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_vf_lib.c create mode 100644 drivers/net/ethernet/intel/ice/ice_vf_lib.h create mode 100644 drivers/net/ethernet/intel/ice/ice_vf_lib_private.h
drivers/net/ethernet/intel/ice/Makefile +2 -1
@@ -34,11 +34,12 @@ ice-y := ice_main.o \ ice_repr.o \ ice_tc_lib.o ice-$(CONFIG_PCI_IOV) += \ + ice_sriov.o \ ice_virtchnl_allowlist.o \ ice_virtchnl_fdir.o \ ice_vf_mbx.o \ ice_vf_vsi_vlan_ops.o \ - ice_sriov.o + ice_vf_lib.o ice-$(CONFIG_PTP_1588_CLOCK) += ice_ptp.o ice_ptp_hw.o ice-$(CONFIG_TTY) += ice_gnss.o ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_nl.o ice_dcb_lib.o
drivers/net/ethernet/intel/ice/ice_sriov.c +1 -508
599 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_sriov.h +1 -202
271 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_vf_lib.c new file +519 -0
519 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_vf_lib.h new file +259 -0
259 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_vf_lib_private.h new file +39 -0
@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2018-2021, Intel Corporation. */ + +#ifndef _ICE_VF_LIB_PRIVATE_H_ +#define _ICE_VF_LIB_PRIVATE_H_ + +#include "ice_vf_lib.h" + +/* This header file is for exposing functions in ice_vf_lib.c to other files +* which are also conditionally compiled depending on CONFIG_PCI_IOV. +* Functions which may be used by other files should be exposed as part of +* ice_vf_lib.h +* +* Functions in this file are exposed only when CONFIG_PCI_IOV is enabled, and +* thus this header must not be included by .c files which may be compiled +* with CONFIG_PCI_IOV disabled. +* +* To avoid this, only include this header file directly within .c files that +* are conditionally enabled in the "ice-$(CONFIG_PCI_IOV)" block. +*/ + +#ifndef CONFIG_PCI_IOV +#warning "Only include ice_vf_lib_private.h in CONFIG_PCI_IOV virtualization files" +#endif + +void ice_dis_vf_qs (struct ice_vf *vf); +int ice_check_vf_init (struct ice_pf *pf,struct ice_vf *vf); +struct ice_port_info *ice_vf_get_port_info (struct ice_vf *vf); +int ice_vsi_apply_spoofchk (struct ice_vsi *vsi,bool enable); +bool ice_is_vf_trusted (struct ice_vf *vf); +bool ice_vf_has_no_qs_ena (struct ice_vf *vf); +bool ice_is_vf_link_up (struct ice_vf *vf); +void ice_vf_ctrl_invalidate_vsi (struct ice_vf *vf); +void ice_vf_ctrl_vsi_release (struct ice_vf *vf); +struct ice_vsi *ice_vf_ctrl_vsi_setup (struct ice_vf *vf); +void ice_vf_invalidate_vsi (struct ice_vf *vf); +void ice_vf_set_initialized (struct ice_vf *vf); + +#endif /* _ICE_VF_LIB_PRIVATE_H_ */
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +1 -0
@@ -5,6 +5,7 @@#include "ice_base.h" #include "ice_lib.h" #include "ice_flow.h" +#include "ice_vf_lib_private.h" #define to_fltr_conf_from_desc (p) \ container_of(p, struct virtchnl_fdir_fltr_conf, input)
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.h +1 -0
@@ -6,6 +6,7 @@struct ice_vf ;struct ice_pf ; +struct ice_vsi ;enum ice_fdir_ctx_stat {ICE_FDIR_CTX_READY ,
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 12/25 ice: introduce ice_vf_lib.c, ice_vf_lib.h, and ice_vf_lib_private.h
drivers/net/ethernet/intel/ice/Makefile ice-y := ice_main.o \
Quoted 62 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 12/25] ice: introduceice_vf_lib.c,ice_vf_lib.h, andice_vf_lib_private.hIntroduce the
ice_vf_lib.cfile along with theice_vf_lib.handice_vf_lib_private.hheader files.These files will house the generic VF structures and access functions. Move struct
ice_vfand its dependent definitions into this new header file.The
ice_vf_lib.cis compiled conditionally onCONFIG_PCI_IOV. Some of its functionality is required by all driver files. However, some of its functionality will only be required by other files also conditionally compiled based onCONFIG_PCI_IOV.Declaring these functions used only in
CONFIG_PCI_IOVfiles inice_vf_lib.his verbose. This is because we must provide a fallback implementation for each function in this header since it is included in files which may not be compiled withCONFIG_PCI_IOV.Instead, introduce a new
ice_vf_lib_private.hheader which verifies thatCONFIG_PCI_IOVis enabled. This header is intended to be directly included in .c files which areCONFIG_PCI_IOVonly. Add a #error indication that will complain if the file ever gets included by another C file on a kernel withCONFIG_PCI_IOVdisabled. Add a comment indicating the nature of the file and why it is useful.This makes it so that we can easily define functions exposed from
ice_vf_lib.cinto other virtualization files without needing to add fallback implementations for every single function.This begins the path to separate out generic code which will be reused by other virtualization implementations from
ice_sriov.handice_sriov.cSigned-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/Makefile | 3 +- drivers/net/ethernet/intel/ice/ice_sriov.c | 509 +---------------- drivers/net/ethernet/intel/ice/ice_sriov.h | 203 +------ drivers/net/ethernet/intel/ice/ice_vf_lib.c | 519 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_vf_lib.h | 259 +++++++++ .../ethernet/intel/ice/ice_vf_lib_private.h | 39 ++ .../ethernet/intel/ice/ice_virtchnl_fdir.c | 1 + .../ethernet/intel/ice/ice_virtchnl_fdir.h | 1 + 8 files changed, 823 insertions(+), 711 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_vf_lib.c create mode 100644 drivers/net/ethernet/intel/ice/ice_vf_lib.h create mode 100644 drivers/net/ethernet/intel/ice/ice_vf_lib_private.hdrivers/net/ethernet/intel/ice/Makefile +0
-0@@ -34,11 +34,12 @@ ice-y := ice_main.o \
PATCH 13/25 ice: fix incorrect dev_dbg print mistaking 'i' for vf->vf_id
In reply to Jacob KellerIf we fail to clear the malicious VF indication after a VF reset, the dev_dbg message which is printed uses the local variable 'i' when it meant to use vf->vf_id. Fix this.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +2 -1
@@ -1381,7 +1381,8 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)/* if the VF has been reset allow it to come up again */ if (ice_mbx_clear_malvf (&hw->mbx_snapshot, pf->vfs.malvfs,ICE_MAX_SRIOV_VFS , vf->vf_id)) -dev_dbg (dev,"failed to clear malicious VF state for VF %u\n" , i); +dev_dbg (dev,"failed to clear malicious VF state for VF %u\n" , + vf->vf_id);return true; }
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 13/25 ice: fix incorrect dev_dbg print mistaking 'i' for vf->vf_id
drivers/net/ethernet/intel/ice/ice_sriov.c bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)
Quoted 26 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 13/25] ice: fix incorrectdev_dbgprint mistaking 'i' forvf->vf_idIf we fail to clear the malicious VF indication after a VF reset, the
dev_dbgmessage which is printed uses the local variable 'i' when it meant to use vf-Quoted 1 line
vf_id. Fix this.Fixes 0891c89674e8 ("ice: warn about potentially malicious VFs")Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_sriov.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/ice/ice_sriov.c +0
-0@@ -1381,7 +1381,8 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)
PATCH 14/25 ice: introduce VF operations structure for reset flows
In reply to Jacob KellerThe ice driver currently supports virtualization using Single Root IOV, with code in the ice_sriov.c file. In the future, we plan to also implement support for Scalable IOV, which uses slightly different hardware implementations for some functionality.
To eventually allow this, we introduce a new ice_vf_ops structure which will contain the basic operations that are different between the two IOV implementations. This primarily includes logic for how to handle the VF reset registers, as well as what to do before and after rebuilding the VF's VSI.
Implement these ops structures and call the ops table instead of directly calling the SR-IOV specific function. This will allow us to easily add the Scalable IOV implementation in the future. Additionally, it helps separate the generalized VF logic from SR-IOV specifics. This change allows us to move the reset logic out of ice_sriov.c and into ice_vf_lib.c without placing any Single Root specific details into the generic file.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 318 +++++++++++--------- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 +- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 13 + 3 files changed, 196 insertions(+), 139 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +182 -136
@@ -478,16 +478,6 @@ void ice_free_vfs(struct ice_pf *pf)*/ static void ice_trigger_vf_reset (struct ice_vf *vf,bool is_vflr,bool is_pfr) { -struct ice_pf *pf = vf->pf; -u32 reg, reg_idx, bit_idx; -unsigned int vf_abs_id, i; -struct device *dev; -struct ice_hw *hw; - - dev =ice_pf_to_dev (pf); - hw = &pf->hw; - vf_abs_id = vf->vf_id + hw->func_caps.vf_base_id; -/* Inform VF that it is no longer active, as a warning */ clear_bit (ICE_VF_STATE_ACTIVE , vf->vf_states);
@@ -501,37 +491,10 @@ static void ice_trigger_vf_reset(struct ice_vf *vf, bool is_vflr, bool is_pfr)* PFR, it can mess up VF resets because the VF driver may already * have started cleanup by the time we get here. */ -if (!is_pfr) { -wr32 (hw,VF_MBX_ARQLEN (vf->vf_id),0 ); -wr32 (hw,VF_MBX_ATQLEN (vf->vf_id),0 ); - } +if (!is_pfr) + vf->vf_ops->clear_mbx_register (vf); -/* In the case of a VFLR, the HW has already reset the VF and we -* just need to clean up, so don't hit the VFRTRIG register. -*/ -if (!is_vflr) { -/* reset VF using VPGEN_VFRTRIG reg */ - reg =rd32 (hw,VPGEN_VFRTRIG (vf->vf_id)); - reg |=VPGEN_VFRTRIG_VFSWR_M ; -wr32 (hw,VPGEN_VFRTRIG (vf->vf_id), reg); - } -/* clear the VFLR bit in GLGEN_VFLRSTAT */ - reg_idx = (vf_abs_id) /32 ; - bit_idx = (vf_abs_id) %32 ; -wr32 (hw,GLGEN_VFLRSTAT (reg_idx),BIT (bit_idx)); -ice_flush (hw); - -wr32 (hw,PF_PCI_CIAA , -VF_DEVICE_STATUS | (vf_abs_id <<PF_PCI_CIAA_VF_NUM_S )); -for (i =0 ; i <ICE_PCI_CIAD_WAIT_COUNT ; i++) { - reg =rd32 (hw,PF_PCI_CIAD ); -/* no transactions pending so stop polling */ -if ((reg &VF_TRANS_PENDING_M ) ==0 ) -break ; - -dev_err (dev,"VF %u PCI transactions stuck\n" , vf->vf_id); -udelay (ICE_PCI_CIAD_WAIT_DELAY_US ); - } + vf->vf_ops->trigger_reset_register (vf, is_vflr); }/**
@@ -995,21 +958,6 @@ static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs)return 0 ; } -/** -* ice_clear_vf_reset_trigger - enable VF to access hardware -* @vf: VF to enabled hardware access for -*/ -static void ice_clear_vf_reset_trigger (struct ice_vf *vf) -{ -struct ice_hw *hw = &vf->pf->hw; -u32 reg; - - reg =rd32 (hw,VPGEN_VFRTRIG (vf->vf_id)); - reg &= ~VPGEN_VFRTRIG_VFSWR_M ; -wr32 (hw,VPGEN_VFRTRIG (vf->vf_id), reg); -ice_flush (hw); -} -static void ice_vf_clear_counters (struct ice_vf *vf) {struct ice_vsi *vsi =ice_get_vf_vsi (vf);
@@ -1030,7 +978,7 @@ static void ice_vf_clear_counters(struct ice_vf *vf)static void ice_vf_pre_vsi_rebuild (struct ice_vf *vf) {ice_vf_clear_counters (vf); -ice_clear_vf_reset_trigger (vf); + vf->vf_ops->clear_reset_trigger (vf); }/**
@@ -1097,22 +1045,6 @@ static void ice_vf_rebuild_host_cfg(struct ice_vf *vf)ice_vf_rebuild_aggregator_node_cfg (vsi); } -/** -* ice_vf_rebuild_vsi_with_release - release and setup the VF's VSI -* @vf: VF to release and setup the VSI for -* -* This is only called when a single VF is being reset (i.e. VFR, VFLR, host VF -* configuration change, etc.). -*/ -static int ice_vf_rebuild_vsi_with_release (struct ice_vf *vf) -{ -ice_vf_vsi_release (vf); -if (!ice_vf_vsi_setup (vf)) -return -ENOMEM ; - -return 0 ; -} -/** * ice_vf_rebuild_vsi - rebuild the VF's VSI * @vf: VF to rebuild the VSI for
@@ -1139,24 +1071,6 @@ static int ice_vf_rebuild_vsi(struct ice_vf *vf)return 0 ; } -/** -* ice_vf_post_vsi_rebuild - tasks to do after the VF's VSI have been rebuilt -* @vf: VF to perform tasks on -*/ -static void ice_vf_post_vsi_rebuild (struct ice_vf *vf) -{ -struct ice_pf *pf = vf->pf; -struct ice_hw *hw; - - hw = &pf->hw; - -ice_vf_rebuild_host_cfg (vf); - -ice_vf_set_initialized (vf); -ice_ena_vf_mappings (vf); -wr32 (hw,VFGEN_RSTAT (vf->vf_id),VIRTCHNL_VFR_VFACTIVE ); -} -/** * ice_reset_all_vfs - reset all allocated VFs in one go * @pf: pointer to the PF structure
@@ -1200,28 +1114,11 @@ bool ice_reset_all_vfs(struct ice_pf *pf, bool is_vflr)ice_trigger_vf_reset (vf, is_vflr, true);/* HW requires some time to make sure it can flush the FIFO for a VF -* when it resets it. Poll the VPGEN_VFRSTAT register for each VF in -* sequence to make sure that it has completed. We'll keep track of -* the VFs using a simple iterator that increments once that VF has -* finished resetting. +* when it resets it. Now that we've triggered all of the VFs, iterate +* the table again and wait for each VF to complete. */ ice_for_each_vf (pf, bkt, vf) { -bool done = false; -unsigned int i; -u32 reg; - -for (i =0 ; i <10 ; i++) { - reg =rd32 (&pf->hw,VPGEN_VFRSTAT (vf->vf_id)); -if (reg &VPGEN_VFRSTAT_VFRD_M ) { - done = true; -break ; - } - -/* only delay if check failed */ -usleep_range (10 ,20 ); - } - -if (!done) { +if (!vf->vf_ops->poll_reset_status (vf)) {/* Display a warning if at least one VF didn't manage * to reset in time, but continue on with the * operation.
@@ -1248,7 +1145,7 @@ bool ice_reset_all_vfs(struct ice_pf *pf, bool is_vflr)ice_vf_pre_vsi_rebuild (vf);ice_vf_rebuild_vsi (vf); -ice_vf_post_vsi_rebuild (vf); + vf->vf_ops->post_vsi_rebuild (vf);mutex_unlock (&vf->cfg_lock); }
@@ -1279,14 +1176,13 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)struct ice_vsi *vsi;struct device *dev;struct ice_hw *hw; -bool rsd = false;u8 promisc_m; -u32 reg; -int i; +bool rsd;lockdep_assert_held (&vf->cfg_lock); dev =ice_pf_to_dev (pf); + hw = &pf->hw;if (test_bit (ICE_VF_RESETS_DISABLED , pf->state)) { dev_dbg(dev, "Trying to reset VF %d, but all VF resets are disabled\n",
@@ -1312,29 +1208,12 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)* enabled. This is needed for successful completion of VFR. */ ice_dis_vsi_txq (vsi->port_info, vsi->idx,0 ,0 ,NULL ,NULL , -NULL ,ICE_VF_RESET , vf->vf_id,NULL ); +NULL , vf->vf_ops->reset_type, vf->vf_id,NULL ); - hw = &pf->hw;/* poll VPGEN_VFRSTAT reg to make sure * that reset is complete */ -for (i =0 ; i <10 ; i++) { -/* VF reset requires driver to first reset the VF and then -* poll the status register to make sure that the reset -* completed successfully. -*/ - reg =rd32 (hw,VPGEN_VFRSTAT (vf->vf_id)); -if (reg &VPGEN_VFRSTAT_VFRD_M ) { - rsd = true; -break ; - } - -/* only sleep if the reset is not done */ -usleep_range (10 ,20 ); - } - - vf->driver_caps =0 ; -ice_vc_set_default_allowlist (vf); + rsd = vf->vf_ops->poll_reset_status (vf);/* Display a warning if VF didn't manage to reset in time, but need to * continue on with the operation.
@@ -1342,6 +1221,9 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)if (!rsd)dev_warn (dev,"VF reset check timeout on VF %d\n" , vf->vf_id); + vf->driver_caps =0 ; +ice_vc_set_default_allowlist (vf); +/* disable promiscuous modes in case they were enabled * ignore any error if disabling process failed */
@@ -1368,12 +1250,12 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)ice_vf_pre_vsi_rebuild (vf); -if (ice_vf_rebuild_vsi_with_release (vf)) { +if (vf->vf_ops->vsi_rebuild (vf)) {dev_err (dev,"Failed to release and setup the VF%u's VSI\n" , vf->vf_id);return false; } -ice_vf_post_vsi_rebuild (vf); + vf->vf_ops->post_vsi_rebuild (vf); vsi =ice_get_vf_vsi (vf);ice_eswitch_update_repr (vsi);ice_eswitch_replay_vf_mac_rule (vf);
@@ -1522,7 +1404,7 @@ static int ice_start_vfs(struct ice_pf *pf) it_cnt =0 ;ice_for_each_vf (pf, bkt, vf) { -ice_clear_vf_reset_trigger (vf); + vf->vf_ops->clear_reset_trigger (vf); retval =ice_init_vf_vsi_res (vf);if (retval) {
@@ -1553,6 +1435,167 @@ static int ice_start_vfs(struct ice_pf *pf)return retval; } +/** +* ice_sriov_free_vf - Free VF memory after all references are dropped +* @vf: pointer to VF to free +* +* Called by ice_put_vf through ice_release_vf once the last reference to a VF +* structure has been dropped. +*/ +static void ice_sriov_free_vf (struct ice_vf *vf) +{ +mutex_destroy (&vf->cfg_lock); + +kfree_rcu (vf, rcu); +} + +/** +* ice_sriov_clear_mbx_register - clears SRIOV VF's mailbox registers +* @vf: the vf to configure +*/ +static void ice_sriov_clear_mbx_register (struct ice_vf *vf) +{ +struct ice_pf *pf = vf->pf; + +wr32 (&pf->hw,VF_MBX_ARQLEN (vf->vf_id),0 ); +wr32 (&pf->hw,VF_MBX_ATQLEN (vf->vf_id),0 ); +} + +/** +* ice_sriov_trigger_reset_register - trigger VF reset for SRIOV VF +* @vf: pointer to VF structure +* @is_vflr: true if reset occurred due to VFLR +* +* Trigger and cleanup after a VF reset for a SR-IOV VF. +*/ +static void ice_sriov_trigger_reset_register (struct ice_vf *vf,bool is_vflr) +{ +struct ice_pf *pf = vf->pf; +u32 reg, reg_idx, bit_idx; +unsigned int vf_abs_id, i; +struct device *dev; +struct ice_hw *hw; + + dev =ice_pf_to_dev (pf); + hw = &pf->hw; + vf_abs_id = vf->vf_id + hw->func_caps.vf_base_id; + +/* In the case of a VFLR, HW has already reset the VF and we just need +* to clean up. Otherwise we must first trigger the reset using the +* VFRTRIG register. +*/ +if (!is_vflr) { + reg =rd32 (hw,VPGEN_VFRTRIG (vf->vf_id)); + reg |=VPGEN_VFRTRIG_VFSWR_M ; +wr32 (hw,VPGEN_VFRTRIG (vf->vf_id), reg); + } + +/* clear the VFLR bit in GLGEN_VFLRSTAT */ + reg_idx = (vf_abs_id) /32 ; + bit_idx = (vf_abs_id) %32 ; +wr32 (hw,GLGEN_VFLRSTAT (reg_idx),BIT (bit_idx)); +ice_flush (hw); + +wr32 (hw,PF_PCI_CIAA , +VF_DEVICE_STATUS | (vf_abs_id <<PF_PCI_CIAA_VF_NUM_S )); +for (i =0 ; i <ICE_PCI_CIAD_WAIT_COUNT ; i++) { + reg =rd32 (hw,PF_PCI_CIAD ); +/* no transactions pending so stop polling */ +if ((reg &VF_TRANS_PENDING_M ) ==0 ) +break ; + +dev_err (dev,"VF %u PCI transactions stuck\n" , vf->vf_id); +udelay (ICE_PCI_CIAD_WAIT_DELAY_US ); + } +} + +/** +* ice_sriov_poll_reset_status - poll SRIOV VF reset status +* @vf: pointer to VF structure +* +* Returns true when reset is successful, else returns false +*/ +static bool ice_sriov_poll_reset_status (struct ice_vf *vf) +{ +struct ice_pf *pf = vf->pf; +unsigned int i; +u32 reg; + +for (i =0 ; i <10 ; i++) { +/* VF reset requires driver to first reset the VF and then +* poll the status register to make sure that the reset +* completed successfully. +*/ + reg =rd32 (&pf->hw,VPGEN_VFRSTAT (vf->vf_id)); +if (reg &VPGEN_VFRSTAT_VFRD_M ) +return true; + +/* only sleep if the reset is not done */ +usleep_range (10 ,20 ); + } +return false; +} + +/** +* ice_sriov_clear_reset_trigger - enable VF to access hardware +* @vf: VF to enabled hardware access for +*/ +static void ice_sriov_clear_reset_trigger (struct ice_vf *vf) +{ +struct ice_hw *hw = &vf->pf->hw; +u32 reg; + + reg =rd32 (hw,VPGEN_VFRTRIG (vf->vf_id)); + reg &= ~VPGEN_VFRTRIG_VFSWR_M ; +wr32 (hw,VPGEN_VFRTRIG (vf->vf_id), reg); +ice_flush (hw); +} + +/** +* ice_sriov_vsi_rebuild - release and rebuild VF's VSI +* @vf: VF to release and setup the VSI for +* +* This is only called when a single VF is being reset (i.e. VFR, VFLR, host VF +* configuration change, etc.). +*/ +static int ice_sriov_vsi_rebuild (struct ice_vf *vf) +{ +struct ice_pf *pf = vf->pf; + +ice_vf_vsi_release (vf); +if (!ice_vf_vsi_setup (vf)) { +dev_err (ice_pf_to_dev (pf), +"Failed to release and setup the VF%u's VSI\n" , + vf->vf_id); +return -ENOMEM ; + } + +return 0 ; +} + +/** +* ice_sriov_post_vsi_rebuild - tasks to do after the VF's VSI have been rebuilt +* @vf: VF to perform tasks on +*/ +static void ice_sriov_post_vsi_rebuild (struct ice_vf *vf) +{ +ice_vf_rebuild_host_cfg (vf); +ice_vf_set_initialized (vf); +ice_ena_vf_mappings (vf); +wr32 (&vf->pf->hw,VFGEN_RSTAT (vf->vf_id),VIRTCHNL_VFR_VFACTIVE ); +} + +static const struct ice_vf_ops ice_sriov_vf_ops = { + .reset_type =ICE_VF_RESET , + .free = ice_sriov_free_vf, + .clear_mbx_register = ice_sriov_clear_mbx_register, + .trigger_reset_register = ice_sriov_trigger_reset_register, + .poll_reset_status = ice_sriov_poll_reset_status, + .clear_reset_trigger = ice_sriov_clear_reset_trigger, + .vsi_rebuild = ice_sriov_vsi_rebuild, + .post_vsi_rebuild = ice_sriov_post_vsi_rebuild, +}; +/** * ice_create_vf_entries - Allocate and insert VF entries * @pf: pointer to the PF structure
@@ -1586,6 +1629,9 @@ static int ice_create_vf_entries(struct ice_pf *pf, u16 num_vfs) vf->pf = pf; vf->vf_id = vf_id; +/* set sriov vf ops for VFs created during SRIOV flow */ + vf->vf_ops = &ice_sriov_vf_ops; + vf->vf_sw_id = pf->first_sw;/* assign default capabilities */ vf->spoofchk = true;
drivers/net/ethernet/intel/ice/ice_vf_lib.c +1 -3
@@ -56,9 +56,7 @@ static void ice_release_vf(struct kref *ref) { struct ice_vf *vf = container_of(ref, struct ice_vf, refcnt); -mutex_destroy (&vf->cfg_lock); - -kfree_rcu (vf, rcu); + vf->vf_ops->free (vf); }/**
drivers/net/ethernet/intel/ice/ice_vf_lib.h +13 -0
@@ -52,6 +52,18 @@ struct ice_mdd_vf_events {u16 last_printed; }; +/* VF operations */ +struct ice_vf_ops { +enum ice_disq_rst_src reset_type; +void (*free)(struct ice_vf *vf); +void (*clear_mbx_register)(struct ice_vf *vf); +void (*trigger_reset_register)(struct ice_vf *vf,bool is_vflr); +bool (*poll_reset_status)(struct ice_vf *vf); +void (*clear_reset_trigger)(struct ice_vf *vf); +int (*vsi_rebuild)(struct ice_vf *vf); +void (*post_vsi_rebuild)(struct ice_vf *vf); +}; +/* Virtchnl/SR-IOV config info */ struct ice_vfs { DECLARE_HASHTABLE(table, 8); /* table of VF entries */
@@ -115,6 +127,7 @@ struct ice_vf {struct ice_repr *repr;const struct ice_virtchnl_ops *virtchnl_ops; +const struct ice_vf_ops *vf_ops;/* devlink port data */ struct devlink_port devlink_port;
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 14/25 ice: introduce VF operations structure for reset flows
drivers/net/ethernet/intel/ice/ice_sriov.c void ice_free_vfs(struct ice_pf *pf)
Quoted 40 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 14/25] ice: introduce VF operations structure for reset flowsThe ice driver currently supports virtualization using Single Root IOV, with code in the
ice_sriov.cfile. In the future, we plan to also implement support for Scalable IOV, which uses slightly different hardware implementations for some functionality.To eventually allow this, we introduce a new
ice_vf_opsstructure which will contain the basic operations that are different between the two IOV implementations. This primarily includes logic for how to handle the VF reset registers, as well as what to do before and after rebuilding the VF's VSI.Implement these ops structures and call the ops table instead of directly calling the SR-IOV specific function. This will allow us to easily add the Scalable IOV implementation in the future. Additionally, it helps separate the generalized VF logic from SR-IOV specifics. This change allows us to move the reset logic out of
ice_sriov.cand intoice_vf_lib.cwithout placing any Single Root specific details into the generic file.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_sriov.c | 318 +++++++++++--------- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 4 +- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 13 + 3 files changed, 196 insertions(+), 139 deletions(-)drivers/net/ethernet/intel/ice/ice_sriov.c +0
-0@@ -478,16 +478,6 @@ void ice_free_vfs(struct ice_pf *pf)
PATCH 15/25 ice: fix a long line warning in ice_reset_vf
In reply to Jacob KellerWe're about to move ice_reset_vf out of ice_sriov.c and into ice_vf_lib.c
One of the dev_err statements has a checkpatch.pl violation due to putting the vf->vf_id on the same line as the dev_err. Fix this style issue first before moving the code.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +2 -1
@@ -1251,7 +1251,8 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)ice_vf_pre_vsi_rebuild (vf);if (vf->vf_ops->vsi_rebuild (vf)) { -dev_err (dev,"Failed to release and setup the VF%u's VSI\n" , vf->vf_id); +dev_err (dev,"Failed to release and setup the VF%u's VSI\n" , + vf->vf_id);return false; }
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 15/25 ice: fix a long line warning in ice_reset_vf
drivers/net/ethernet/intel/ice/ice_sriov.c bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)
Quoted 27 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 15/25] ice: fix a long line warning inice_reset_vfWe're about to move
ice_reset_vfout ofice_sriov.cand intoice_vf_lib.cOne of the
dev_errstatements has a checkpatch.pl violation due to putting thevf->vf_idon the same line as thedev_err. Fix this style issue first before moving the code.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_sriov.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/ice/ice_sriov.c +0
-0@@ -1251,7 +1251,8 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)
PATCH 16/25 ice: move reset functionality into ice_vf_lib.c
In reply to Jacob KellerNow that the reset functions do not rely on Single Root specific behavior, move the ice_reset_vf, ice_reset_all_vfs, and ice_vf_rebuild_host_cfg functions and their dependent helper functions out of ice_sriov.c and into ice_vf_lib.c
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 475 ------------------ drivers/net/ethernet/intel/ice/ice_sriov.h | 15 - drivers/net/ethernet/intel/ice/ice_vf_lib.c | 475 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_vf_lib.h | 12 + .../ethernet/intel/ice/ice_vf_lib_private.h | 1 + 5 files changed, 488 insertions(+), 490 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +0 -475
@@ -466,37 +466,6 @@ void ice_free_vfs(struct ice_pf *pf)clear_bit (ICE_FLAG_SRIOV_ENA , pf->flags); } -/** -* ice_trigger_vf_reset - Reset a VF on HW -* @vf: pointer to the VF structure -* @is_vflr: true if VFLR was issued, false if not -* @is_pfr: true if the reset was triggered due to a previous PFR -* -* Trigger hardware to start a reset for a particular VF. Expects the caller -* to wait the proper amount of time to allow hardware to reset the VF before -* it cleans up and restores VF functionality. -*/ -static void ice_trigger_vf_reset (struct ice_vf *vf,bool is_vflr,bool is_pfr) -{ -/* Inform VF that it is no longer active, as a warning */ -clear_bit (ICE_VF_STATE_ACTIVE , vf->vf_states); - -/* Disable VF's configuration API during reset. The flag is re-enabled -* when it's safe again to access VF's VSI. -*/ -clear_bit (ICE_VF_STATE_INIT , vf->vf_states); - -/* VF_MBX_ARQLEN and VF_MBX_ATQLEN are cleared by PFR, so the driver -* needs to clear them in the case of VFR/VFLR. If this is done for -* PFR, it can mess up VF resets because the VF driver may already -* have started cleanup by the time we get here. -*/ -if (!is_pfr) - vf->vf_ops->clear_mbx_register (vf); - - vf->vf_ops->trigger_reset_register (vf, is_vflr); -} -/** * ice_vf_vsi_setup - Set up a VF VSI * @vf: VF to setup VSI for
@@ -541,138 +510,6 @@ static int ice_calc_vf_first_vector_idx(struct ice_pf *pf, struct ice_vf *vf)return pf->sriov_base_vector + vf->vf_id * pf->vfs.num_msix_per; } -/** -* ice_vf_rebuild_host_tx_rate_cfg - re-apply the Tx rate limiting configuration -* @vf: VF to re-apply the configuration for -* -* Called after a VF VSI has been re-added/rebuild during reset. The PF driver -* needs to re-apply the host configured Tx rate limiting configuration. -*/ -static int ice_vf_rebuild_host_tx_rate_cfg (struct ice_vf *vf) -{ -struct device *dev =ice_pf_to_dev (vf->pf); -struct ice_vsi *vsi =ice_get_vf_vsi (vf); -int err; - -if (vf->min_tx_rate) { - err =ice_set_min_bw_limit (vsi, (u64 )vf->min_tx_rate *1000 ); -if (err) { -dev_err (dev,"failed to set min Tx rate to %d Mbps for VF %u, error %d\n" , - vf->min_tx_rate, vf->vf_id, err); -return err; - } - } - -if (vf->max_tx_rate) { - err =ice_set_max_bw_limit (vsi, (u64 )vf->max_tx_rate *1000 ); -if (err) { -dev_err (dev,"failed to set max Tx rate to %d Mbps for VF %u, error %d\n" , - vf->max_tx_rate, vf->vf_id, err); -return err; - } - } - -return 0 ; -} - -/** -* ice_vf_rebuild_host_vlan_cfg - add VLAN 0 filter or rebuild the Port VLAN -* @vf: VF to add MAC filters for -* @vsi: Pointer to VSI -* -* Called after a VF VSI has been re-added/rebuilt during reset. The PF driver -* always re-adds either a VLAN 0 or port VLAN based filter after reset. -*/ -static int ice_vf_rebuild_host_vlan_cfg (struct ice_vf *vf,struct ice_vsi *vsi) -{ -struct ice_vsi_vlan_ops *vlan_ops =ice_get_compat_vsi_vlan_ops (vsi); -struct device *dev =ice_pf_to_dev (vf->pf); -int err; - -if (ice_vf_is_port_vlan_ena (vf)) { - err = vlan_ops->set_port_vlan (vsi, &vf->port_vlan_info); -if (err) { -dev_err (dev,"failed to configure port VLAN via VSI parameters for VF %u, error %d\n" , - vf->vf_id, err); -return err; - } - - err = vlan_ops->add_vlan (vsi, &vf->port_vlan_info); - }else { - err =ice_vsi_add_vlan_zero (vsi); - } - -if (err) { -dev_err (dev,"failed to add VLAN %u filter for VF %u during VF rebuild, error %d\n" , -ice_vf_is_port_vlan_ena (vf) ? -ice_vf_get_port_vlan_id (vf) :0 , vf->vf_id, err); -return err; - } - - err = vlan_ops->ena_rx_filtering (vsi); -if (err) -dev_warn (dev,"failed to enable Rx VLAN filtering for VF %d VSI %d during VF rebuild, error %d\n" , - vf->vf_id, vsi->idx, err); - -return 0 ; -} - -/** -* ice_vf_rebuild_host_mac_cfg - add broadcast and the VF's perm_addr/LAA -* @vf: VF to add MAC filters for -* -* Called after a VF VSI has been re-added/rebuilt during reset. The PF driver -* always re-adds a broadcast filter and the VF's perm_addr/LAA after reset. -*/ -static int ice_vf_rebuild_host_mac_cfg (struct ice_vf *vf) -{ -struct device *dev =ice_pf_to_dev (vf->pf); -struct ice_vsi *vsi =ice_get_vf_vsi (vf); -u8 broadcast[ETH_ALEN ]; -int status; - -if (ice_is_eswitch_mode_switchdev (vf->pf)) -return 0 ; - -eth_broadcast_addr (broadcast); - status =ice_fltr_add_mac (vsi, broadcast,ICE_FWD_TO_VSI ); -if (status) { -dev_err (dev,"failed to add broadcast MAC filter for VF %u, error %d\n" , - vf->vf_id, status); -return status; - } - - vf->num_mac++; - -if (is_valid_ether_addr (vf->hw_lan_addr.addr)) { - status =ice_fltr_add_mac (vsi, vf->hw_lan_addr.addr, -ICE_FWD_TO_VSI ); -if (status) { -dev_err (dev,"failed to add default unicast MAC filter %pM for VF %u, error %d\n" , - &vf->hw_lan_addr.addr[0 ], vf->vf_id, - status); -return status; - } - vf->num_mac++; - -ether_addr_copy (vf->dev_lan_addr.addr, vf->hw_lan_addr.addr); - } - -return 0 ; -} - -/** -* ice_vf_set_host_trust_cfg - set trust setting based on pre-reset value -* @vf: VF to configure trust setting for -*/ -static void ice_vf_set_host_trust_cfg (struct ice_vf *vf) -{ -if (vf->trusted) -set_bit (ICE_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps); -else -clear_bit (ICE_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps); -} -/** * ice_ena_vf_msix_mappings - enable VF MSIX mappings in hardware * @vf: VF to enable MSIX mappings for
@@ -958,318 +795,6 @@ static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs)return 0 ; } -static void ice_vf_clear_counters (struct ice_vf *vf) -{ -struct ice_vsi *vsi =ice_get_vf_vsi (vf); - - vf->num_mac =0 ; - vsi->num_vlan =0 ; -memset (&vf->mdd_tx_events,0 ,sizeof (vf->mdd_tx_events)); -memset (&vf->mdd_rx_events,0 ,sizeof (vf->mdd_rx_events)); -} - -/** -* ice_vf_pre_vsi_rebuild - tasks to be done prior to VSI rebuild -* @vf: VF to perform pre VSI rebuild tasks -* -* These tasks are items that don't need to be amortized since they are most -* likely called in a for loop with all VF(s) in the reset_all_vfs() case. -*/ -static void ice_vf_pre_vsi_rebuild (struct ice_vf *vf) -{ -ice_vf_clear_counters (vf); - vf->vf_ops->clear_reset_trigger (vf); -} - -/** -* ice_vf_rebuild_aggregator_node_cfg - rebuild aggregator node config -* @vsi: Pointer to VSI -* -* This function moves VSI into corresponding scheduler aggregator node -* based on cached value of "aggregator node info" per VSI -*/ -static void ice_vf_rebuild_aggregator_node_cfg (struct ice_vsi *vsi) -{ -struct ice_pf *pf = vsi->back; -struct device *dev; -int status; - -if (!vsi->agg_node) -return ; - - dev =ice_pf_to_dev (pf); -if (vsi->agg_node->num_vsis ==ICE_MAX_VSIS_IN_AGG_NODE ) { -dev_dbg (dev, -"agg_id %u already has reached max_num_vsis %u\n" , - vsi->agg_node->agg_id, vsi->agg_node->num_vsis); -return ; - } - - status =ice_move_vsi_to_agg (pf->hw.port_info, vsi->agg_node->agg_id, - vsi->idx, vsi->tc_cfg.ena_tc); -if (status) -dev_dbg (dev,"unable to move VSI idx %u into aggregator %u node" , - vsi->idx, vsi->agg_node->agg_id); -else - vsi->agg_node->num_vsis++; -} - -/** -* ice_vf_rebuild_host_cfg - host admin configuration is persistent across reset -* @vf: VF to rebuild host configuration on -*/ -static void ice_vf_rebuild_host_cfg (struct ice_vf *vf) -{ -struct device *dev =ice_pf_to_dev (vf->pf); -struct ice_vsi *vsi =ice_get_vf_vsi (vf); - -ice_vf_set_host_trust_cfg (vf); - -if (ice_vf_rebuild_host_mac_cfg (vf)) -dev_err (dev,"failed to rebuild default MAC configuration for VF %d\n" , - vf->vf_id); - -if (ice_vf_rebuild_host_vlan_cfg (vf, vsi)) -dev_err (dev,"failed to rebuild VLAN configuration for VF %u\n" , - vf->vf_id); - -if (ice_vf_rebuild_host_tx_rate_cfg (vf)) -dev_err (dev,"failed to rebuild Tx rate limiting configuration for VF %u\n" , - vf->vf_id); - -if (ice_vsi_apply_spoofchk (vsi, vf->spoofchk)) -dev_err (dev,"failed to rebuild spoofchk configuration for VF %d\n" , - vf->vf_id); - -/* rebuild aggregator node config for main VF VSI */ -ice_vf_rebuild_aggregator_node_cfg (vsi); -} - -/** -* ice_vf_rebuild_vsi - rebuild the VF's VSI -* @vf: VF to rebuild the VSI for -* -* This is only called when all VF(s) are being reset (i.e. PCIe Reset on the -* host, PFR, CORER, etc.). -*/ -static int ice_vf_rebuild_vsi (struct ice_vf *vf) -{ -struct ice_vsi *vsi =ice_get_vf_vsi (vf); -struct ice_pf *pf = vf->pf; - -if (ice_vsi_rebuild (vsi, true)) { -dev_err (ice_pf_to_dev (pf),"failed to rebuild VF %d VSI\n" , - vf->vf_id); -return -EIO ; - } -/* vsi->idx will remain the same in this case so don't update -* vf->lan_vsi_idx -*/ - vsi->vsi_num =ice_get_hw_vsi_num (&pf->hw, vsi->idx); - vf->lan_vsi_num = vsi->vsi_num; - -return 0 ; -} - -/** -* ice_reset_all_vfs - reset all allocated VFs in one go -* @pf: pointer to the PF structure -* @is_vflr: true if VFLR was issued, false if not -* -* First, tell the hardware to reset each VF, then do all the waiting in one -* chunk, and finally finish restoring each VF after the wait. This is useful -* during PF routines which need to reset all VFs, as otherwise it must perform -* these resets in a serialized fashion. -* -* Returns true if any VFs were reset, and false otherwise. -*/ -bool ice_reset_all_vfs (struct ice_pf *pf,bool is_vflr) -{ -struct device *dev =ice_pf_to_dev (pf); -struct ice_hw *hw = &pf->hw; -struct ice_vf *vf; -unsigned int bkt; - -/* If we don't have any VFs, then there is nothing to reset */ -if (!ice_has_vfs (pf)) -return false; - -mutex_lock (&pf->vfs.table_lock); - -/* clear all malicious info if the VFs are getting reset */ -ice_for_each_vf (pf, bkt, vf) -if (ice_mbx_clear_malvf (&hw->mbx_snapshot, pf->vfs.malvfs, -ICE_MAX_SRIOV_VFS , vf->vf_id)) -dev_dbg (dev,"failed to clear malicious VF state for VF %u\n" , - vf->vf_id); - -/* If VFs have been disabled, there is no need to reset */ -if (test_and_set_bit (ICE_VF_DIS , pf->state)) { -mutex_unlock (&pf->vfs.table_lock); -return false; - } - -/* Begin reset on all VFs at once */ -ice_for_each_vf (pf, bkt, vf) -ice_trigger_vf_reset (vf, is_vflr, true); - -/* HW requires some time to make sure it can flush the FIFO for a VF -* when it resets it. Now that we've triggered all of the VFs, iterate -* the table again and wait for each VF to complete. -*/ -ice_for_each_vf (pf, bkt, vf) { -if (!vf->vf_ops->poll_reset_status (vf)) { -/* Display a warning if at least one VF didn't manage -* to reset in time, but continue on with the -* operation. -*/ -dev_warn (dev,"VF %u reset check timeout\n" , vf->vf_id); -break ; - } - } - -/* free VF resources to begin resetting the VSI state */ -ice_for_each_vf (pf, bkt, vf) { -mutex_lock (&vf->cfg_lock); - - vf->driver_caps =0 ; -ice_vc_set_default_allowlist (vf); - -ice_vf_fdir_exit (vf); -ice_vf_fdir_init (vf); -/* clean VF control VSI when resetting VFs since it should be -* setup only when VF creates its first FDIR rule. -*/ -if (vf->ctrl_vsi_idx !=ICE_NO_VSI ) -ice_vf_ctrl_invalidate_vsi (vf); - -ice_vf_pre_vsi_rebuild (vf); -ice_vf_rebuild_vsi (vf); - vf->vf_ops->post_vsi_rebuild (vf); - -mutex_unlock (&vf->cfg_lock); - } - -if (ice_is_eswitch_mode_switchdev (pf)) -if (ice_eswitch_rebuild (pf)) -dev_warn (dev,"eswitch rebuild failed\n" ); - -ice_flush (hw); -clear_bit (ICE_VF_DIS , pf->state); - -mutex_unlock (&pf->vfs.table_lock); - -return true; -} - -/** -* ice_reset_vf - Reset a particular VF -* @vf: pointer to the VF structure -* @is_vflr: true if VFLR was issued, false if not -* -* Returns true if the VF is currently in reset, resets successfully, or resets -* are disabled and false otherwise. -*/ -bool ice_reset_vf (struct ice_vf *vf,bool is_vflr) -{ -struct ice_pf *pf = vf->pf; -struct ice_vsi *vsi; -struct device *dev; -struct ice_hw *hw; -u8 promisc_m; -bool rsd; - -lockdep_assert_held (&vf->cfg_lock); - - dev =ice_pf_to_dev (pf); - hw = &pf->hw; - -if (test_bit (ICE_VF_RESETS_DISABLED , pf->state)) { -dev_dbg (dev,"Trying to reset VF %d, but all VF resets are disabled\n" , - vf->vf_id); -return true; - } - -if (ice_is_vf_disabled (vf)) { -dev_dbg (dev,"VF is already disabled, there is no need for resetting it, telling VM, all is fine %d\n" , - vf->vf_id); -return true; - } - -/* Set VF disable bit state here, before triggering reset */ -set_bit (ICE_VF_STATE_DIS , vf->vf_states); -ice_trigger_vf_reset (vf, is_vflr, false); - - vsi =ice_get_vf_vsi (vf); - -ice_dis_vf_qs (vf); - -/* Call Disable LAN Tx queue AQ whether or not queues are -* enabled. This is needed for successful completion of VFR. -*/ -ice_dis_vsi_txq (vsi->port_info, vsi->idx,0 ,0 ,NULL ,NULL , -NULL , vf->vf_ops->reset_type, vf->vf_id,NULL ); - -/* poll VPGEN_VFRSTAT reg to make sure -* that reset is complete -*/ - rsd = vf->vf_ops->poll_reset_status (vf); - -/* Display a warning if VF didn't manage to reset in time, but need to -* continue on with the operation. -*/ -if (!rsd) -dev_warn (dev,"VF reset check timeout on VF %d\n" , vf->vf_id); - - vf->driver_caps =0 ; -ice_vc_set_default_allowlist (vf); - -/* disable promiscuous modes in case they were enabled -* ignore any error if disabling process failed -*/ -if (test_bit (ICE_VF_STATE_UC_PROMISC , vf->vf_states) || -test_bit (ICE_VF_STATE_MC_PROMISC , vf->vf_states)) { -if (ice_vf_is_port_vlan_ena (vf) || vsi->num_vlan) - promisc_m =ICE_UCAST_VLAN_PROMISC_BITS ; -else - promisc_m =ICE_UCAST_PROMISC_BITS ; - -if (ice_vf_clear_vsi_promisc (vf, vsi, promisc_m)) -dev_err (dev,"disabling promiscuous mode failed\n" ); - } - -ice_eswitch_del_vf_mac_rule (vf); - -ice_vf_fdir_exit (vf); -ice_vf_fdir_init (vf); -/* clean VF control VSI when resetting VF since it should be setup -* only when VF creates its first FDIR rule. -*/ -if (vf->ctrl_vsi_idx !=ICE_NO_VSI ) -ice_vf_ctrl_vsi_release (vf); - -ice_vf_pre_vsi_rebuild (vf); - -if (vf->vf_ops->vsi_rebuild (vf)) { -dev_err (dev,"Failed to release and setup the VF%u's VSI\n" , - vf->vf_id); -return false; - } - - vf->vf_ops->post_vsi_rebuild (vf); - vsi =ice_get_vf_vsi (vf); -ice_eswitch_update_repr (vsi); -ice_eswitch_replay_vf_mac_rule (vf); - -/* if the VF has been reset allow it to come up again */ -if (ice_mbx_clear_malvf (&hw->mbx_snapshot, pf->vfs.malvfs, -ICE_MAX_SRIOV_VFS , vf->vf_id)) -dev_dbg (dev,"failed to clear malicious VF state for VF %u\n" , - vf->vf_id); - -return true; -} -/** * ice_vc_notify_link_state - Inform all VFs on a PF of link status * @pf: pointer to the PF structure
drivers/net/ethernet/intel/ice/ice_sriov.h +0 -15
@@ -78,8 +78,6 @@ void ice_vc_notify_reset(struct ice_pf *pf);void ice_vc_notify_vf_link_state (struct ice_vf *vf);void ice_virtchnl_set_repr_ops (struct ice_vf *vf);void ice_virtchnl_set_dflt_ops (struct ice_vf *vf); -bool ice_reset_all_vfs (struct ice_pf *pf,bool is_vflr); -bool ice_reset_vf (struct ice_vf *vf,bool is_vflr);void ice_restore_all_vfs_msi_state (struct pci_dev *pdev); bool ice_is_malicious_vf(struct ice_pf *pf, struct ice_rq_event_info *event,
@@ -139,19 +137,6 @@ ice_is_malicious_vf(struct ice_pf __always_unused *pf,return false; } -static inline bool -ice_reset_all_vfs (struct ice_pf __always_unused *pf, -bool __always_unused is_vflr) -{ -return true; -} - -static inline bool -ice_reset_vf (struct ice_vf __always_unused *vf,bool __always_unused is_vflr) -{ -return true; -} -static inline int ice_sriov_configure (struct pci_dev __always_unused *pdev,int __always_unused num_vfs)
drivers/net/ethernet/intel/ice/ice_vf_lib.c +475 -0
493 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_vf_lib.h +12 -0
@@ -212,6 +212,8 @@ int ice_vf_set_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m);int ice_vf_clear_vsi_promisc (struct ice_vf *vf,struct ice_vsi *vsi,u8 promisc_m); +bool ice_reset_vf (struct ice_vf *vf,bool is_vflr); +bool ice_reset_all_vfs (struct ice_pf *pf,bool is_vflr);#else /* CONFIG_PCI_IOV */ static inline struct ice_vf *ice_get_vf_by_id (struct ice_pf *pf,u16 vf_id) {
@@ -267,6 +269,16 @@ ice_vf_clear_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m) {return -EOPNOTSUPP ; } + +static inline bool ice_reset_vf (struct ice_vf *vf,bool is_vflr) +{ +return true; +} + +static inline bool ice_reset_all_vfs (struct ice_pf *pf,bool is_vflr) +{ +return true; +}#endif /* !CONFIG_PCI_IOV */ #endif /* _ICE_VF_LIB_H_ */
drivers/net/ethernet/intel/ice/ice_vf_lib_private.h +1 -0
@@ -30,6 +30,7 @@ int ice_vsi_apply_spoofchk(struct ice_vsi *vsi, bool enable);bool ice_is_vf_trusted (struct ice_vf *vf);bool ice_vf_has_no_qs_ena (struct ice_vf *vf);bool ice_is_vf_link_up (struct ice_vf *vf); +void ice_vf_rebuild_host_cfg (struct ice_vf *vf);void ice_vf_ctrl_invalidate_vsi (struct ice_vf *vf);void ice_vf_ctrl_vsi_release (struct ice_vf *vf);struct ice_vsi *ice_vf_ctrl_vsi_setup (struct ice_vf *vf);
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 16/25 ice: move reset functionality into ice_vf_lib.c
drivers/net/ethernet/intel/ice/ice_sriov.c void ice_free_vfs(struct ice_pf *pf)
Quoted 30 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 16/25] ice: move reset functionality intoice_vf_lib.cNow that the reset functions do not rely on Single Root specific behavior, move the
ice_reset_vf,ice_reset_all_vfs, andice_vf_rebuild_host_cfgfunctions and their dependent helper functions out ofice_sriov.cand intoice_vf_lib.cSigned-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_sriov.c | 475 ------------------ drivers/net/ethernet/intel/ice/ice_sriov.h | 15 - drivers/net/ethernet/intel/ice/ice_vf_lib.c | 475 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_vf_lib.h | 12 + .../ethernet/intel/ice/ice_vf_lib_private.h | 1 + 5 files changed, 488 insertions(+), 490 deletions(-)drivers/net/ethernet/intel/ice/ice_sriov.c +0
-0@@ -466,37 +466,6 @@ void ice_free_vfs(struct ice_pf *pf)
PATCH 17/25 ice: drop is_vflr parameter from ice_reset_all_vfs
In reply to Jacob KellerThe ice_reset_all_vfs function takes a parameter to handle whether its operating after a VFLR event or not. This is not necessary as every caller always passes true. Simplify the interface by removing the parameter.
--- drivers/net/ethernet/intel/ice/ice_main.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 5 ++--- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +2 -2
@@ -768,7 +768,7 @@ static void ice_do_reset(struct ice_pf *pf, enum ice_reset_req reset_type)clear_bit (ICE_PREPARED_FOR_RESET , pf->state);clear_bit (ICE_PFR_REQ , pf->state);wake_up (&pf->reset_wait_queue); -ice_reset_all_vfs (pf, true); +ice_reset_all_vfs (pf); } }
@@ -819,7 +819,7 @@ static void ice_reset_subtask(struct ice_pf *pf)clear_bit (ICE_CORER_REQ , pf->state);clear_bit (ICE_GLOBR_REQ , pf->state);wake_up (&pf->reset_wait_queue); -ice_reset_all_vfs (pf, true); +ice_reset_all_vfs (pf); }return ;
drivers/net/ethernet/intel/ice/ice_vf_lib.c +2 -3
@@ -356,7 +356,6 @@ ice_vf_clear_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m)/** * ice_reset_all_vfs - reset all allocated VFs in one go * @pf: pointer to the PF structure -* @is_vflr: true if VFLR was issued, false if not * * First, tell the hardware to reset each VF, then do all the waiting in one * chunk, and finally finish restoring each VF after the wait. This is useful
@@ -365,7 +364,7 @@ ice_vf_clear_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m)* * Returns true if any VFs were reset, and false otherwise. */ -bool ice_reset_all_vfs (struct ice_pf *pf,bool is_vflr) +bool ice_reset_all_vfs (struct ice_pf *pf) {struct device *dev =ice_pf_to_dev (pf);struct ice_hw *hw = &pf->hw;
@@ -393,7 +392,7 @@ bool ice_reset_all_vfs(struct ice_pf *pf, bool is_vflr)/* Begin reset on all VFs at once */ ice_for_each_vf (pf, bkt, vf) -ice_trigger_vf_reset (vf, is_vflr, true); +ice_trigger_vf_reset (vf, true, true);/* HW requires some time to make sure it can flush the FIFO for a VF * when it resets it. Now that we've triggered all of the VFs, iterate
drivers/net/ethernet/intel/ice/ice_vf_lib.h +2 -2
@@ -213,7 +213,7 @@ ice_vf_set_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m);int ice_vf_clear_vsi_promisc (struct ice_vf *vf,struct ice_vsi *vsi,u8 promisc_m);bool ice_reset_vf (struct ice_vf *vf,bool is_vflr); -bool ice_reset_all_vfs (struct ice_pf *pf,bool is_vflr); +bool ice_reset_all_vfs (struct ice_pf *pf);#else /* CONFIG_PCI_IOV */ static inline struct ice_vf *ice_get_vf_by_id (struct ice_pf *pf,u16 vf_id) {
@@ -275,7 +275,7 @@ static inline bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)return true; } -static inline bool ice_reset_all_vfs (struct ice_pf *pf,bool is_vflr) +static inline bool ice_reset_all_vfs (struct ice_pf *pf) {return true; }
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 17/25 ice: drop is_vflr parameter from ice_reset_all_vfs
drivers/net/ethernet/intel/ice/ice_main.c static void ice_do_reset(struct ice_pf *pf, enum
Quoted 27 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 17/25] ice: dropis_vflrparameter fromice_reset_all_vfsThe
ice_reset_all_vfsfunction takes a parameter to handle whether its operating after a VFLR event or not. This is not necessary as every caller always passes true. Simplify the interface by removing the parameter.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 5 ++--- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-)drivers/net/ethernet/intel/ice/ice_main.c +0
-0@@ -768,7 +768,7 @@ static void ice_do_reset(struct ice_pf *pf, enum
PATCH 18/25 ice: make ice_reset_all_vfs void
In reply to Jacob KellerThe ice_reset_all_vfs function returns true if any VFs were reset, and false otherwise. However, no callers check the return value.
Drop this return value and make the function void since the callers do not care about this.
--- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 8 +++----- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 5 ++--- 2 files changed, 5 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/ice/ice_vf_lib.c +3 -5
@@ -364,7 +364,7 @@ ice_vf_clear_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m)* * Returns true if any VFs were reset, and false otherwise. */ -bool ice_reset_all_vfs (struct ice_pf *pf) +void ice_reset_all_vfs (struct ice_pf *pf) {struct device *dev =ice_pf_to_dev (pf);struct ice_hw *hw = &pf->hw;
@@ -373,7 +373,7 @@ bool ice_reset_all_vfs(struct ice_pf *pf)/* If we don't have any VFs, then there is nothing to reset */ if (!ice_has_vfs (pf)) -return false; +return ;mutex_lock (&pf->vfs.table_lock);
@@ -387,7 +387,7 @@ bool ice_reset_all_vfs(struct ice_pf *pf)/* If VFs have been disabled, there is no need to reset */ if (test_and_set_bit (ICE_VF_DIS , pf->state)) {mutex_unlock (&pf->vfs.table_lock); -return false; +return ; }/* Begin reset on all VFs at once */
@@ -439,8 +439,6 @@ bool ice_reset_all_vfs(struct ice_pf *pf)clear_bit (ICE_VF_DIS , pf->state);mutex_unlock (&pf->vfs.table_lock); - -return true; }/**
drivers/net/ethernet/intel/ice/ice_vf_lib.h +2 -3
@@ -213,7 +213,7 @@ ice_vf_set_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m);int ice_vf_clear_vsi_promisc (struct ice_vf *vf,struct ice_vsi *vsi,u8 promisc_m);bool ice_reset_vf (struct ice_vf *vf,bool is_vflr); -bool ice_reset_all_vfs (struct ice_pf *pf); +void ice_reset_all_vfs (struct ice_pf *pf);#else /* CONFIG_PCI_IOV */ static inline struct ice_vf *ice_get_vf_by_id (struct ice_pf *pf,u16 vf_id) {
@@ -275,9 +275,8 @@ static inline bool ice_reset_vf(struct ice_vf *vf, bool is_vflr) return true; } -static inline bool ice_reset_all_vfs (struct ice_pf *pf) +static inline void ice_reset_all_vfs (struct ice_pf *pf) { -return true; }#endif /* !CONFIG_PCI_IOV */
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 18/25 ice: make ice_reset_all_vfs void
drivers/net/ethernet/intel/ice/ice_vf_lib.c
Quoted 27 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 18/25] ice: makeice_reset_all_vfsvoidThe
ice_reset_all_vfsfunction returns true if any VFs were reset, and false otherwise. However, no callers check the return value.Drop this return value and make the function void since the callers do not care about this.
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 8 +++----- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 5 ++--- 2 files changed, 5 insertions(+), 8 deletions(-)drivers/net/ethernet/intel/ice/ice_vf_lib.c +0
-0
PATCH 19/25 ice: convert ice_reset_vf to standard error codes
In reply to Jacob KellerThe ice_reset_vf function returns a boolean value indicating whether or not the VF reset. This is a bit confusing since it means that callers need to know how to interpret the return value when needing to indicate an error.
Refactor the function and call sites to report a regular error code. We still report success (i.e. return 0) in cases where the reset is in progress or is disabled.
Existing callers don't care because they do not check the return value. We keep the error code anyways instead of a void return because we expect future code which may care about or at least report the error value.
--- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 15 ++++++++------- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 6 +++--- 2 files changed, 11 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/ice/ice_vf_lib.c +8 -7
@@ -446,10 +446,11 @@ void ice_reset_all_vfs(struct ice_pf *pf)* @vf: pointer to the VF structure * @is_vflr: true if VFLR was issued, false if not * -* Returns true if the VF is currently in reset, resets successfully, or resets -* are disabled and false otherwise. +* Returns 0 if the VF is currently in reset, if the resets are disabled, or +* if the VF resets successfully. Returns an error code if the VF fails to +* rebuild. */ -bool ice_reset_vf (struct ice_vf *vf,bool is_vflr) +int ice_reset_vf (struct ice_vf *vf,bool is_vflr) {struct ice_pf *pf = vf->pf;struct ice_vsi *vsi;
@@ -466,13 +467,13 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)if (test_bit (ICE_VF_RESETS_DISABLED , pf->state)) {dev_dbg (dev,"Trying to reset VF %d, but all VF resets are disabled\n" , vf->vf_id); -return true; +return 0 ; }if (ice_is_vf_disabled (vf)) {dev_dbg (dev,"VF is already disabled, there is no need for resetting it, telling VM, all is fine %d\n" , vf->vf_id); -return true; +return 0 ; }/* Set VF disable bit state here, before triggering reset */
@@ -532,7 +533,7 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)if (vf->vf_ops->vsi_rebuild (vf)) {dev_err (dev,"Failed to release and setup the VF%u's VSI\n" , vf->vf_id); -return false; +return -EFAULT ; } vf->vf_ops->post_vsi_rebuild (vf);
@@ -546,7 +547,7 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr)dev_dbg (dev,"failed to clear malicious VF state for VF %u\n" , vf->vf_id); -return true; +return 0 ; }/**
drivers/net/ethernet/intel/ice/ice_vf_lib.h +3 -3
@@ -212,7 +212,7 @@ int ice_vf_set_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m);int ice_vf_clear_vsi_promisc (struct ice_vf *vf,struct ice_vsi *vsi,u8 promisc_m); -bool ice_reset_vf (struct ice_vf *vf,bool is_vflr); +int ice_reset_vf (struct ice_vf *vf,bool is_vflr);void ice_reset_all_vfs (struct ice_pf *pf);#else /* CONFIG_PCI_IOV */ static inline struct ice_vf *ice_get_vf_by_id (struct ice_pf *pf,u16 vf_id)
@@ -270,9 +270,9 @@ ice_vf_clear_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m)return -EOPNOTSUPP ; } -static inline bool ice_reset_vf (struct ice_vf *vf,bool is_vflr) +static inline int ice_reset_vf (struct ice_vf *vf,bool is_vflr) { -return true; +return 0 ; }static inline void ice_reset_all_vfs (struct ice_pf *pf)
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 19/25 ice: convert ice_reset_vf to standard error codes
drivers/net/ethernet/intel/ice/ice_vf_lib.c void ice_reset_all_vfs(struct ice_pf *pf)
Quoted 34 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 19/25] ice: convertice_reset_vfto standard error codesThe
ice_reset_vffunction returns a boolean value indicating whether or not the VF reset. This is a bit confusing since it means that callers need to know how to interpret the return value when needing to indicate an error.Refactor the function and call sites to report a regular error code. We still report success (i.e. return 0) in cases where the reset is in progress or is disabled.
Existing callers don't care because they do not check the return value. We keep the error code anyways instead of a void return because we expect future code which may care about or at least report the error value.
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 15 ++++++++------- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 6 +++--- 2 files changed, 11 insertions(+), 10 deletions(-)drivers/net/ethernet/intel/ice/ice_vf_lib.c +0
-0@@ -446,10 +446,11 @@ void ice_reset_all_vfs(struct ice_pf *pf)
PATCH 20/25 ice: convert ice_reset_vf to take flags
In reply to Jacob KellerThe ice_reset_vf function takes a boolean parameter which indicates whether or not the reset is due to a VFLR event.
This is somewhat confusing to read because readers must interpret what "true" and "false" mean when seeing a line of code like "ice_reset_vf(vf, false)".
We will want to add another toggle to the ice_reset_vf in a following change. To avoid proliferating many arguments, convert this function to take flags instead. ICE_VF_RESET_VFLR will indicate if this is a VFLR reset. A value of 0 indicates no flags.
One could argue that "ice_reset_vf(vf, 0)" is no more readable than "ice_reset_vf(vf, false)".. However, this type of flags interface is somewhat common and using 0 to mean "no flags" makes sense in this context. We could bother to add a define for "ICE_VF_RESET_PLAIN" or something similar, but this can be confusing since its not an actual bit flag.
This paves the way to add another flag to the function in a following change.
--- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_sriov.c | 6 +++--- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 9 ++++++--- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 9 +++++++-- 4 files changed, 17 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +1 -1
@@ -1958,7 +1958,7 @@ static void ice_handle_mdd_event(struct ice_pf *pf)*/ ice_print_vf_rx_mdd_event (vf);mutex_lock (&vf->cfg_lock); -ice_reset_vf (vf, false); +ice_reset_vf (vf,0 );mutex_unlock (&vf->cfg_lock); } }
drivers/net/ethernet/intel/ice/ice_sriov.c +3 -3
@@ -1393,7 +1393,7 @@ void ice_process_vflr_event(struct ice_pf *pf)if (reg &BIT (bit_idx)) {/* GLGEN_VFLRSTAT bit will be cleared in ice_reset_vf */ mutex_lock (&vf->cfg_lock); -ice_reset_vf (vf, true); +ice_reset_vf (vf,ICE_VF_RESET_VFLR );mutex_unlock (&vf->cfg_lock); } }
@@ -1407,7 +1407,7 @@ void ice_process_vflr_event(struct ice_pf *pf)static void ice_vc_reset_vf (struct ice_vf *vf) {ice_vc_notify_vf_reset (vf); -ice_reset_vf (vf, false); +ice_reset_vf (vf,0 ); }/**
@@ -1724,7 +1724,7 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg)static void ice_vc_reset_vf_msg (struct ice_vf *vf) {if (test_bit (ICE_VF_STATE_INIT , vf->vf_states)) -ice_reset_vf (vf, false); +ice_reset_vf (vf,0 ); }/**
drivers/net/ethernet/intel/ice/ice_vf_lib.c +6 -3
@@ -444,13 +444,16 @@ void ice_reset_all_vfs(struct ice_pf *pf)/** * ice_reset_vf - Reset a particular VF * @vf: pointer to the VF structure -* @is_vflr: true if VFLR was issued, false if not +* @flags: flags controlling behavior of the reset +* +* Flags: +* ICE_VF_RESET_VFLR - Indicates a reset is due to VFLR event * * Returns 0 if the VF is currently in reset, if the resets are disabled, or * if the VF resets successfully. Returns an error code if the VF fails to * rebuild. */ -int ice_reset_vf (struct ice_vf *vf,bool is_vflr) +int ice_reset_vf (struct ice_vf *vf,u32 flags) {struct ice_pf *pf = vf->pf;struct ice_vsi *vsi;
@@ -478,7 +481,7 @@ int ice_reset_vf(struct ice_vf *vf, bool is_vflr)/* Set VF disable bit state here, before triggering reset */ set_bit (ICE_VF_STATE_DIS , vf->vf_states); -ice_trigger_vf_reset (vf, is_vflr, false); +ice_trigger_vf_reset (vf, flags &ICE_VF_RESET_VFLR , false); vsi =ice_get_vf_vsi (vf);
drivers/net/ethernet/intel/ice/ice_vf_lib.h +7 -2
@@ -133,6 +133,11 @@ struct ice_vf {struct devlink_port devlink_port; }; +/* Flags for controlling behavior of ice_reset_vf */ +enum ice_vf_reset_flags { +ICE_VF_RESET_VFLR =BIT (0 ),/* Indicate a VFLR reset */ +}; +static inline u16 ice_vf_get_port_vlan_id (struct ice_vf *vf) {return vf->port_vlan_info.vid;
@@ -212,7 +217,7 @@ int ice_vf_set_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m);int ice_vf_clear_vsi_promisc (struct ice_vf *vf,struct ice_vsi *vsi,u8 promisc_m); -int ice_reset_vf (struct ice_vf *vf,bool is_vflr); +int ice_reset_vf (struct ice_vf *vf,u32 flags);void ice_reset_all_vfs (struct ice_pf *pf);#else /* CONFIG_PCI_IOV */ static inline struct ice_vf *ice_get_vf_by_id (struct ice_pf *pf,u16 vf_id)
@@ -270,7 +275,7 @@ ice_vf_clear_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m)return -EOPNOTSUPP ; } -static inline int ice_reset_vf (struct ice_vf *vf,bool is_vflr) +static inline int ice_reset_vf (struct ice_vf *vf,u32 flags) {return 0 ; }
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 20/25 ice: convert ice_reset_vf to take flags
drivers/net/ethernet/intel/ice/ice_main.c
Quoted 43 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 20/25] ice: convertice_reset_vfto take flagsThe
ice_reset_vffunction takes a boolean parameter which indicates whether or not the reset is due to a VFLR event.This is somewhat confusing to read because readers must interpret what "true" and "false" mean when seeing a line of code like "
ice_reset_vf(vf, false)".We will want to add another toggle to the
ice_reset_vfin a following change. To avoid proliferating many arguments, convert this function to take flags instead.ICE_VF_RESET_VFLRwill indicate if this is a VFLR reset. A value of 0 indicates no flags.One could argue that "
ice_reset_vf(vf, 0)" is no more readable than "ice_reset_vf(vf, false)".. However, this type of flags interface is somewhat common and using 0 to mean "no flags" makes sense in this context. We could bother to add a define for "ICE_VF_RESET_PLAIN" or something similar, but this can be confusing since its not an actual bit flag.This paves the way to add another flag to the function in a following change.
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_sriov.c | 6 +++--- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 9 ++++++--- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 9 +++++++-- 4 files changed, 17 insertions(+), 9 deletions(-)drivers/net/ethernet/intel/ice/ice_main.c +0
-0
PATCH 21/25 ice: introduce ICE_VF_RESET_NOTIFY flag
In reply to Jacob KellerIn some cases of resetting a VF, the PF would like to first notify the VF that a reset is impending. This is currently done via ice_vc_notify_vf_reset. A wrapper to ice_reset_vf, ice_vf_reset_vf, is used to call this function first before calling ice_reset_vf.
In fact, every single call to ice_vc_notify_vf_reset occurs just prior to a call to ice_vc_reset_vf.
Now that ice_reset_vf has flags, replace this separate call with an ICE_VF_RESET_NOTIFY flag. This removes an unnecessary exported function of ice_vc_notify_vf_reset, and also makes there be a single function to reset VFs (ice_reset_vf).
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 44 +++------------------ drivers/net/ethernet/intel/ice/ice_vf_lib.c | 28 +++++++++++++ drivers/net/ethernet/intel/ice/ice_vf_lib.h | 1 + 3 files changed, 34 insertions(+), 39 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +5 -39
@@ -829,30 +829,6 @@ void ice_vc_notify_reset(struct ice_pf *pf) (u8 *)&pfe, sizeof(struct virtchnl_pf_event)); } -/** -* ice_vc_notify_vf_reset - Notify VF of a reset event -* @vf: pointer to the VF structure -*/ -static void ice_vc_notify_vf_reset (struct ice_vf *vf) -{ -struct virtchnl_pf_event pfe; -struct ice_pf *pf = vf->pf; - -/* Bail out if VF is in disabled state, neither initialized, nor active -* state - otherwise proceed with notifications -*/ -if ((!test_bit (ICE_VF_STATE_INIT , vf->vf_states) && - !test_bit (ICE_VF_STATE_ACTIVE , vf->vf_states)) || -test_bit (ICE_VF_STATE_DIS , vf->vf_states)) -return ; - - pfe.event =VIRTCHNL_EVENT_RESET_IMPENDING ; - pfe.severity =PF_EVENT_SEVERITY_CERTAIN_DOOM ; -ice_aq_send_msg_to_vf (&pf->hw, vf->vf_id,VIRTCHNL_OP_EVENT , -VIRTCHNL_STATUS_SUCCESS , (u8 *)&pfe,sizeof (pfe), -NULL ); -} -/** * ice_init_vf_vsi_res - initialize/setup VF VSI resources * @vf: VF to initialize/setup the VSI for
@@ -1400,16 +1376,6 @@ void ice_process_vflr_event(struct ice_pf *pf)mutex_unlock (&pf->vfs.table_lock); } -/** -* ice_vc_reset_vf - Perform software reset on the VF after informing the AVF -* @vf: pointer to the VF info -*/ -static void ice_vc_reset_vf (struct ice_vf *vf) -{ -ice_vc_notify_vf_reset (vf); -ice_reset_vf (vf,0 ); -} -/** * ice_get_vf_from_pfq - get the VF who owns the PF space queue passed in * @pf: PF used to index all VFs
@@ -1488,7 +1454,7 @@ ice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event)return ;mutex_lock (&vf->cfg_lock); -ice_vc_reset_vf (vf); +ice_reset_vf (vf,ICE_VF_RESET_NOTIFY );mutex_unlock (&vf->cfg_lock);ice_put_vf (vf);
@@ -3311,7 +3277,7 @@ static int ice_vc_request_qs_msg(struct ice_vf *vf, u8 *msg) }else {/* request is successful, then reset VF */ vf->num_req_qs = req_queues; -ice_vc_reset_vf (vf); +ice_reset_vf (vf,ICE_VF_RESET_NOTIFY );dev_info (dev,"VF %d granted request of %u queues.\n" , vf->vf_id, req_queues);return 0 ;
@@ -5183,7 +5149,7 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) mac, vf_id); } -ice_vc_reset_vf (vf); +ice_reset_vf (vf,ICE_VF_RESET_NOTIFY );mutex_unlock (&vf->cfg_lock); out_put_vf:
@@ -5227,7 +5193,7 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted)mutex_lock (&vf->cfg_lock); vf->trusted = trusted; -ice_vc_reset_vf (vf); +ice_reset_vf (vf,ICE_VF_RESET_NOTIFY );dev_info (ice_pf_to_dev (pf),"VF %u is now %strusted\n" , vf_id, trusted ?"" :"un" );
@@ -5549,7 +5515,7 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,else dev_info (dev,"Clearing port VLAN on VF %d\n" , vf_id); -ice_vc_reset_vf (vf); +ice_reset_vf (vf,ICE_VF_RESET_NOTIFY );mutex_unlock (&vf->cfg_lock); out_put_vf:
drivers/net/ethernet/intel/ice/ice_vf_lib.c +28 -0
@@ -441,6 +441,30 @@ void ice_reset_all_vfs(struct ice_pf *pf)mutex_unlock (&pf->vfs.table_lock); } +/** +* ice_notify_vf_reset - Notify VF of a reset event +* @vf: pointer to the VF structure +*/ +static void ice_notify_vf_reset (struct ice_vf *vf) +{ +struct ice_hw *hw = &vf->pf->hw; +struct virtchnl_pf_event pfe; + +/* Bail out if VF is in disabled state, neither initialized, nor active +* state - otherwise proceed with notifications +*/ +if ((!test_bit (ICE_VF_STATE_INIT , vf->vf_states) && + !test_bit (ICE_VF_STATE_ACTIVE , vf->vf_states)) || +test_bit (ICE_VF_STATE_DIS , vf->vf_states)) +return ; + + pfe.event =VIRTCHNL_EVENT_RESET_IMPENDING ; + pfe.severity =PF_EVENT_SEVERITY_CERTAIN_DOOM ; +ice_aq_send_msg_to_vf (hw, vf->vf_id,VIRTCHNL_OP_EVENT , +VIRTCHNL_STATUS_SUCCESS , (u8 *)&pfe,sizeof (pfe), +NULL ); +} +/** * ice_reset_vf - Reset a particular VF * @vf: pointer to the VF structure
@@ -448,6 +472,7 @@ void ice_reset_all_vfs(struct ice_pf *pf)* * Flags: * ICE_VF_RESET_VFLR - Indicates a reset is due to VFLR event +* ICE_VF_RESET_NOTIFY - Send VF a notification prior to reset * * Returns 0 if the VF is currently in reset, if the resets are disabled, or * if the VF resets successfully. Returns an error code if the VF fails to
@@ -467,6 +492,9 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags) dev =ice_pf_to_dev (pf); hw = &pf->hw; +if (flags &ICE_VF_RESET_NOTIFY ) +ice_notify_vf_reset (vf); +if (test_bit (ICE_VF_RESETS_DISABLED , pf->state)) {dev_dbg (dev,"Trying to reset VF %d, but all VF resets are disabled\n" , vf->vf_id);
drivers/net/ethernet/intel/ice/ice_vf_lib.h +1 -0
@@ -136,6 +136,7 @@ struct ice_vf {/* Flags for controlling behavior of ice_reset_vf */ enum ice_vf_reset_flags {ICE_VF_RESET_VFLR =BIT (0 ),/* Indicate a VFLR reset */ +ICE_VF_RESET_NOTIFY =BIT (1 ),/* Notify VF prior to reset */ };static inline u16 ice_vf_get_port_vlan_id (struct ice_vf *vf)
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 21/25 ice: introduce ICE_VF_RESET_NOTIFY flag
drivers/net/ethernet/intel/ice/ice_sriov.c
Quoted 35 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 21/25] ice: introduceICE_VF_RESET_NOTIFYflagIn some cases of resetting a VF, the PF would like to first notify the VF that a reset is impending. This is currently done via
ice_vc_notify_vf_reset. A wrapper toice_reset_vf,ice_vf_reset_vf, is used to call this function first before callingice_reset_vf.In fact, every single call to
ice_vc_notify_vf_resetoccurs just prior to a call toice_vc_reset_vf.Now that
ice_reset_vfhas flags, replace this separate call with anICE_VF_RESET_NOTIFYflag. This removes an unnecessary exported function ofice_vc_notify_vf_reset, and also makes there be a single function to reset VFs (ice_reset_vf).Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_sriov.c | 44 +++------------------ drivers/net/ethernet/intel/ice/ice_vf_lib.c | 28 +++++++++++++ drivers/net/ethernet/intel/ice/ice_vf_lib.h | 1 + 3 files changed, 34 insertions(+), 39 deletions(-)drivers/net/ethernet/intel/ice/ice_sriov.c +0
-0
PATCH 22/25 ice: introduce ICE_VF_RESET_LOCK flag
In reply to Jacob KellerThe ice_reset_vf function performs actions which must be taken only while holding the VF configuration lock. Some flows already acquired the lock, while other flows must acquire it just for the reset function. Add the ICE_VF_RESET_LOCK flag to the function so that it can handle taking and releasing the lock instead at the appropriate scope.
--- drivers/net/ethernet/intel/ice/ice_main.c | 4 +--- drivers/net/ethernet/intel/ice/ice_sriov.c | 12 +++--------- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 18 ++++++++++++++---- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 1 + 4 files changed, 19 insertions(+), 16 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +1 -3
@@ -1957,9 +1957,7 @@ static void ice_handle_mdd_event(struct ice_pf *pf)* reset, so print the event prior to reset. */ ice_print_vf_rx_mdd_event (vf); -mutex_lock (&vf->cfg_lock); -ice_reset_vf (vf,0 ); -mutex_unlock (&vf->cfg_lock); +ice_reset_vf (vf,ICE_VF_RESET_LOCK ); } } }
drivers/net/ethernet/intel/ice/ice_sriov.c +3 -9
@@ -1366,12 +1366,9 @@ void ice_process_vflr_event(struct ice_pf *pf) bit_idx = (hw->func_caps.vf_base_id + vf->vf_id) %32 ;/* read GLGEN_VFLRSTAT register to find out the flr VFs */ reg =rd32 (hw,GLGEN_VFLRSTAT (reg_idx)); -if (reg &BIT (bit_idx)) { +if (reg &BIT (bit_idx))/* GLGEN_VFLRSTAT bit will be cleared in ice_reset_vf */ -mutex_lock (&vf->cfg_lock); -ice_reset_vf (vf,ICE_VF_RESET_VFLR ); -mutex_unlock (&vf->cfg_lock); - } +ice_reset_vf (vf,ICE_VF_RESET_VFLR |ICE_VF_RESET_LOCK ); }mutex_unlock (&pf->vfs.table_lock); }
@@ -1453,10 +1450,7 @@ ice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event)if (!vf)return ; -mutex_lock (&vf->cfg_lock); -ice_reset_vf (vf,ICE_VF_RESET_NOTIFY ); -mutex_unlock (&vf->cfg_lock); - +ice_reset_vf (vf,ICE_VF_RESET_NOTIFY |ICE_VF_RESET_LOCK );ice_put_vf (vf); }
drivers/net/ethernet/intel/ice/ice_vf_lib.c +14 -4
@@ -473,6 +473,7 @@ static void ice_notify_vf_reset(struct ice_vf *vf)* Flags: * ICE_VF_RESET_VFLR - Indicates a reset is due to VFLR event * ICE_VF_RESET_NOTIFY - Send VF a notification prior to reset +* ICE_VF_RESET_LOCK - Acquire VF cfg_lock before resetting * * Returns 0 if the VF is currently in reset, if the resets are disabled, or * if the VF resets successfully. Returns an error code if the VF fails to
@@ -485,10 +486,9 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)struct device *dev;struct ice_hw *hw;u8 promisc_m; +int err =0 ;bool rsd; -lockdep_assert_held (&vf->cfg_lock); - dev =ice_pf_to_dev (pf); hw = &pf->hw;
@@ -507,6 +507,11 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)return 0 ; } +if (flags &ICE_VF_RESET_LOCK ) +mutex_lock (&vf->cfg_lock); +else +lockdep_assert_held (&vf->cfg_lock); +/* Set VF disable bit state here, before triggering reset */ set_bit (ICE_VF_STATE_DIS , vf->vf_states);ice_trigger_vf_reset (vf, flags &ICE_VF_RESET_VFLR , false);
@@ -564,7 +569,8 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)if (vf->vf_ops->vsi_rebuild (vf)) {dev_err (dev,"Failed to release and setup the VF%u's VSI\n" , vf->vf_id); -return -EFAULT ; + err = -EFAULT ; + goto out_unlock; } vf->vf_ops->post_vsi_rebuild (vf);
@@ -578,7 +584,11 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)dev_dbg (dev,"failed to clear malicious VF state for VF %u\n" , vf->vf_id); -return 0 ; +out_unlock: +if (flags &ICE_VF_RESET_LOCK ) +mutex_unlock (&vf->cfg_lock); + +return err; }/**
drivers/net/ethernet/intel/ice/ice_vf_lib.h +1 -0
@@ -137,6 +137,7 @@ struct ice_vf {enum ice_vf_reset_flags {ICE_VF_RESET_VFLR =BIT (0 ),/* Indicate a VFLR reset */ ICE_VF_RESET_NOTIFY =BIT (1 ),/* Notify VF prior to reset */ +ICE_VF_RESET_LOCK =BIT (2 ),/* Acquire the VF cfg_lock */ };static inline u16 ice_vf_get_port_vlan_id (struct ice_vf *vf)
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 22/25 ice: introduce ICE_VF_RESET_LOCK flag
drivers/net/ethernet/intel/ice/ice_main.c
Quoted 29 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 22/25] ice: introduceICE_VF_RESET_LOCKflagThe
ice_reset_vffunction performs actions which must be taken only while holding the VF configuration lock. Some flows already acquired the lock, while other flows must acquire it just for the reset function. Add theICE_VF_RESET_LOCKflag to the function so that it can handle taking and releasing the lock instead at the appropriate scope.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 4 +--- drivers/net/ethernet/intel/ice/ice_sriov.c | 12 +++--------- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 18 ++++++++++++++---- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 1 + 4 files changed, 19 insertions(+), 16 deletions(-)drivers/net/ethernet/intel/ice/ice_main.c +0
-0
Jankowski
PATCH 22/25 ice: introduce ICE_VF_RESET_LOCK flag
In reply to Jacob Kellerdrivers/net/ethernet/intel/ice/ice_sriov.c void ice_process_vflr_event(struct ice_pf *pf)
Quoted 47 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 22/25] ice: introduceICE_VF_RESET_LOCKflagThe
ice_reset_vffunction performs actions which must be taken only while holding the VF configuration lock. Some flows already acquired the lock, while other flows must acquire it just for the reset function. Add theICE_VF_RESET_LOCKflag to the function so that it can handle taking and releasing the lock instead at the appropriate scope.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 4 +--- drivers/net/ethernet/intel/ice/ice_sriov.c | 12 +++--------- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 18 ++++++++++++++---- drivers/net/ethernet/intel/ice/ice_vf_lib.h | 1 + 4 files changed, 19 insertions(+), 16 deletions(-)drivers/net/ethernet/intel/ice/ice_main.c +1
-3@@ -1957,9 +1957,7 @@ static void ice_handle_mdd_event(struct ice_pf*pf) * reset, so print the event prior to reset. */ ice_print_vf_rx_mdd_event (vf); -mutex_lock (&vf->cfg_lock); -ice_reset_vf (vf,0 ); -mutex_unlock (&vf->cfg_lock); +ice_reset_vf (vf,ICE_VF_RESET_LOCK ); } }drivers/net/ethernet/intel/ice/ice_main.c +0
-0}drivers/net/ethernet/intel/ice/ice_sriov.c +0
-0@@ -1366,12 +1366,9 @@ void ice_process_vflr_event(struct ice_pf *pf)
PATCH 23/25 ice: cleanup long longs in ice_sriov.c
In reply to Jacob KellerBefore we move the virtchnl message handling from ice_sriov.c into ice_virtchnl.c, cleanup some long line warnings to avoid checkpatch.pl complaints.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 39 +++++++++++++++------- 1 file changed, 27 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +27 -12
@@ -2325,16 +2325,21 @@ static int ice_vc_cfg_promiscuous_mode_msg(struct ice_vf *vf, u8 *msg) !test_and_set_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states))dev_info (dev,"VF %u successfully set multicast promiscuous mode\n" , vf->vf_id); - else if (!allmulti && test_and_clear_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states)) + else if (!allmulti && + test_and_clear_bit(ICE_VF_STATE_MC_PROMISC, + vf->vf_states))dev_info (dev,"VF %u successfully unset multicast promiscuous mode\n" , vf->vf_id); }if (!ucast_err) { -if (alluni && !test_and_set_bit (ICE_VF_STATE_UC_PROMISC , vf->vf_states)) +if (alluni && + !test_and_set_bit (ICE_VF_STATE_UC_PROMISC , vf->vf_states))dev_info (dev,"VF %u successfully set unicast promiscuous mode\n" , vf->vf_id); -else if (!alluni &&test_and_clear_bit (ICE_VF_STATE_UC_PROMISC , vf->vf_states)) +else if (!alluni && +test_and_clear_bit (ICE_VF_STATE_UC_PROMISC , + vf->vf_states))dev_info (dev,"VF %u successfully unset unicast promiscuous mode\n" , vf->vf_id); }
@@ -2878,8 +2883,9 @@ static int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg) } vsi->max_frame = qpi->rxq.max_pkt_size; -/* add space for the port VLAN since the VF driver is not -* expected to account for it in the MTU calculation +/* add space for the port VLAN since the VF driver is +* not expected to account for it in the MTU +* calculation */ if (ice_vf_is_port_vlan_ena (vf)) vsi->max_frame +=VLAN_HLEN ;
@@ -3665,8 +3671,11 @@ static u16 ice_vc_get_max_vlan_fltrs(struct ice_vf *vf) }/** -* ice_vf_outer_vlan_not_allowed - check outer VLAN can be used when the device is in DVM +* ice_vf_outer_vlan_not_allowed - check if outer VLAN can be used * @vf: VF that being checked for +* +* When the device is in double VLAN mode, check whether or not the outer VLAN +* is allowed. */ static bool ice_vf_outer_vlan_not_allowed (struct ice_vf *vf) {
@@ -3944,9 +3953,11 @@ ice_vc_validate_vlan_filter_list(struct virtchnl_vlan_filtering_caps *vfc,return false;if ((ice_vc_is_valid_vlan (outer) && - !ice_vc_validate_vlan_tpid (filtering_support->outer, outer->tpid)) || + !ice_vc_validate_vlan_tpid (filtering_support->outer, + outer->tpid)) || (ice_vc_is_valid_vlan (inner) && - !ice_vc_validate_vlan_tpid (filtering_support->inner, inner->tpid))) + !ice_vc_validate_vlan_tpid (filtering_support->inner, + inner->tpid)))return false; }
@@ -4421,7 +4432,8 @@ static int ice_vc_ena_vlan_stripping_v2_msg(struct ice_vf *vf, u8 *msg) } out: -return ice_vc_send_msg_to_vf (vf,VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 , v_ret,NULL ,0 ); +return ice_vc_send_msg_to_vf (vf,VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 , + v_ret,NULL ,0 ); }/**
@@ -4490,7 +4502,8 @@ static int ice_vc_dis_vlan_stripping_v2_msg(struct ice_vf *vf, u8 *msg) } out: -return ice_vc_send_msg_to_vf (vf,VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 , v_ret,NULL ,0 ); +return ice_vc_send_msg_to_vf (vf,VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 , + v_ret,NULL ,0 ); }/**
@@ -4548,7 +4561,8 @@ static int ice_vc_ena_vlan_insertion_v2_msg(struct ice_vf *vf, u8 *msg) } out: -return ice_vc_send_msg_to_vf (vf,VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 , v_ret,NULL ,0 ); +return ice_vc_send_msg_to_vf (vf,VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 , + v_ret,NULL ,0 ); }/**
@@ -4602,7 +4616,8 @@ static int ice_vc_dis_vlan_insertion_v2_msg(struct ice_vf *vf, u8 *msg) } out: -return ice_vc_send_msg_to_vf (vf,VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 , v_ret,NULL ,0 ); +return ice_vc_send_msg_to_vf (vf,VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 , + v_ret,NULL ,0 ); }static const struct ice_virtchnl_ops ice_virtchnl_dflt_ops = {
Signature · 1 line
2.35.1.129.gb80121027d12
PATCH 23/25 ice: cleanup long longs in ice_sriov.c
Subject should be "cleanup long lines" not "cleanup long longs"
Quoted 5 lines · Jacob Keller
Before we move the virtchnl message handling from
ice_sriov.cintoice_virtchnl.c, cleanup some long line warnings to avoid checkpatch.pl complaints.Signed-off-by Jacob Keller <[email protected]>
Keller
PATCH 23/25 ice: cleanup long longs in ice_sriov.c
Quoted 10 lines
-----Original Message-----
From: Brandeburg, Jesse <[email protected]>
Sent: Tuesday, February 22, 2022 5:47 PM
To: Keller, Jacob E <[email protected]>; Intel Wired LAN <intel-wired- lan at lists.osuosl.org>
Subject: Re: [Intel-wired-lan] [net-next PATCH 23/25] ice: cleanup long longs inice_sriov.c
Quoted 10 lines
Subject should be "cleanup long lines" not "cleanup long longs"
Quoted 5 lines · Jacob Keller
Before we move the virtchnl message handling from
ice_sriov.cintoice_virtchnl.c, cleanup some long line warnings to avoid checkpatch.pl complaints.Signed-off-by Jacob Keller <[email protected]>
Oops, thanks for the review Jesse!
Tony, can you fix this up in your tree?
Thanks,
Haje
Nguyen
PATCH 23/25 ice: cleanup long longs in ice_sriov.c
Quoted 22 lines · Jacob E
Quoted 22 lines
-----Original Message-----
From: Brandeburg, Jesse <[email protected]>
Sent: Tuesday, February 22, 2022 5:47 PM
To: Keller, Jacob E <[email protected]>; Intel Wired LAN <intel-wired-
lan at lists.osuosl.org>
Subject: Re: [Intel-wired-lan] [net-next PATCH 23/25] ice: cleanup long longs inice_sriov.cSubject should be "cleanup long lines" not "cleanup long longs"
Quoted 6 lines · Jacob Keller
Before we move the virtchnl message handling from
ice_sriov.cintoice_virtchnl.c, cleanup some long line warnings to avoid checkpatch.pl
complaints.
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Jacob Keller <[email protected]>Oops, thanks for the review Jesse!
Tony, can you fix this up in your tree?
Yea, I'll fix that up in the tree.
Thanks,
Tony
Quoted 6 lines
Thanks,
Haje
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan at osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Jankowski
PATCH 23/25 ice: cleanup long longs in ice_sriov.c
In reply to Jacob Kellerdrivers/net/ethernet/intel/ice/ice_sriov.c static int
Quoted 25 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 23/25] ice: cleanup long longs inice_sriov.cBefore we move the virtchnl message handling from
ice_sriov.cintoice_virtchnl.c, cleanup some long line warnings to avoid checkpatch.pl complaints.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_sriov.c | 39 +++++++++++++++------- 1 file changed, 27 insertions(+), 12 deletions(-)drivers/net/ethernet/intel/ice/ice_sriov.c +0
-0@@ -2325,16 +2325,21 @@ static int
PATCH 24/25 ice: introduce ice_virtchnl.c and ice_virtchnl.h
In reply to Jacob KellerJust as we moved the generic virtualization library logic into ice_vf_lib.c, move the virtchnl message handling into ice_virtchnl.c
---
drivers/net/ethernet/intel/ice/Makefile | 1 +
drivers/net/ethernet/intel/ice/ice_sriov.c | 3771 -----------------
drivers/net/ethernet/intel/ice/ice_sriov.h | 55 +-
.../intel/ice/{ice_sriov.c => ice_virtchnl.c} | 1915 +--------
drivers/net/ethernet/intel/ice/ice_virtchnl.h | 82 +
5 files changed, 89 insertions(+), 5735 deletions(-)
copy drivers/net/ethernet/intel/ice/{ice_sriov.c => ice_virtchnl.c} (68%)
create mode 100644 drivers/net/ethernet/intel/ice/ice_virtchnl.hdrivers/net/ethernet/intel/ice/Makefile +1 -0
@@ -35,6 +35,7 @@ ice-y := ice_main.o \ ice_tc_lib.o ice-$(CONFIG_PCI_IOV) += \ ice_sriov.o \ + ice_virtchnl.o \ ice_virtchnl_allowlist.o \ ice_virtchnl_fdir.o \ ice_vf_mbx.o \
drivers/net/ethernet/intel/ice/ice_sriov.c +0 -3771
2,993 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_sriov.h +1 -54
55 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_virtchnl.c renamed from drivers/net/ethernet/intel/ice/ice_sriov.c +5 -1910
1,915 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_virtchnl.h new file +82 -0
82 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.35.1.129.gb80121027d12
Part of the diff is not shown here. View the raw message.
Jankowski
PATCH 24/25 ice: introduce ice_virtchnl.c and ice_virtchnl.h
drivers/net/ethernet/intel/ice/Makefile
Quoted 29 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 24/25] ice: introduceice_virtchnl.candice_virtchnl.hJust as we moved the generic virtualization library logic into
ice_vf_lib.c, move the virtchnl message handling intoice_virtchnl.cSigned-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/Makefile | 1 + drivers/net/ethernet/intel/ice/ice_sriov.c | 3771 ----------------- drivers/net/ethernet/intel/ice/ice_sriov.h | 55 +- .../intel/ice/{ice_sriov.c => ice_virtchnl.c} | 1915 +-------- drivers/net/ethernet/intel/ice/ice_virtchnl.h | 82 + 5 files changed, 89 insertions(+), 5735 deletions(-) copy drivers/net/ethernet/intel/ice/{ice_sriov.c => ice_virtchnl.c} (68%) create mode 100644 drivers/net/ethernet/intel/ice/ice_virtchnl.hdrivers/net/ethernet/intel/ice/Makefile +0
-0
PATCH 25/25 ice: remove PF pointer from ice_check_vf_init
In reply to Jacob KellerThe ice_check_vf_init function takes both a PF and a VF pointer. Every caller looks up the PF pointer from the VF structure. Some callers only use of the PF pointer is call this function. Move the lookup inside ice_check_vf_init and drop the unnecessary argument.
Cleanup the callers to drop the now unnecessary local variables. In particular, replace the local PF pointer with a HW structure pointer in ice_vc_get_vf_res_msg which simplifies a few accesses to the HW structure in that function.
--- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 16 +++++++--------- .../net/ethernet/intel/ice/ice_vf_lib_private.h | 2 +- drivers/net/ethernet/intel/ice/ice_virtchnl.c | 12 ++++++------ 3 files changed, 14 insertions(+), 16 deletions(-)
drivers/net/ethernet/intel/ice/ice_vf_lib.c +7 -9
@@ -174,15 +174,12 @@ static void ice_wait_on_vf_reset(struct ice_vf *vf)*/ int ice_check_vf_ready_for_cfg (struct ice_vf *vf) { -struct ice_pf *pf; -ice_wait_on_vf_reset (vf);if (ice_is_vf_disabled (vf))return -EINVAL ; - pf = vf->pf; -if (ice_check_vf_init (pf, vf)) +if (ice_check_vf_init (vf))return -EBUSY ;return 0 ;
@@ -620,11 +617,12 @@ void ice_dis_vf_qs(struct ice_vf *vf)/** * ice_check_vf_init - helper to check if VF init complete -* @pf: pointer to the PF structure * @vf: the pointer to the VF to check */ -int ice_check_vf_init (struct ice_pf *pf,struct ice_vf *vf) +int ice_check_vf_init (struct ice_vf *vf) { +struct ice_pf *pf = vf->pf; +if (!test_bit (ICE_VF_STATE_INIT , vf->vf_states)) {dev_err (ice_pf_to_dev (pf),"VF ID: %u in reset. Try again.\n" , vf->vf_id);
@@ -752,9 +750,9 @@ bool ice_vf_has_no_qs_ena(struct ice_vf *vf)*/ bool ice_is_vf_link_up (struct ice_vf *vf) { -struct ice_pf *pf = vf->pf; +struct ice_port_info *pi =ice_vf_get_port_info (vf); -if (ice_check_vf_init (pf, vf)) +if (ice_check_vf_init (vf))return false;if (ice_vf_has_no_qs_ena (vf))
@@ -762,7 +760,7 @@ bool ice_is_vf_link_up(struct ice_vf *vf)else if (vf->link_forced)return vf->link_up;else -return pf->hw.port_info->phy.link_info.link_info & +return pi->phy.link_info.link_info &ICE_AQ_LINK_UP ; }
drivers/net/ethernet/intel/ice/ice_vf_lib_private.h +1 -1
@@ -24,7 +24,7 @@#endif void ice_dis_vf_qs (struct ice_vf *vf); -int ice_check_vf_init (struct ice_pf *pf,struct ice_vf *vf); +int ice_check_vf_init (struct ice_vf *vf);struct ice_port_info *ice_vf_get_port_info (struct ice_vf *vf);int ice_vsi_apply_spoofchk (struct ice_vsi *vsi,bool enable);bool ice_is_vf_trusted (struct ice_vf *vf);
drivers/net/ethernet/intel/ice/ice_virtchnl.c +6 -6
@@ -370,12 +370,12 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg) {enum virtchnl_status_code v_ret =VIRTCHNL_STATUS_SUCCESS ;struct virtchnl_vf_resource *vfres =NULL ; -struct ice_pf *pf = vf->pf; +struct ice_hw *hw = &vf->pf->hw;struct ice_vsi *vsi;int len =0 ;int ret; -if (ice_check_vf_init (pf, vf)) { +if (ice_check_vf_init (vf)) { v_ret =VIRTCHNL_STATUS_ERR_PARAM ; goto err; }
@@ -412,9 +412,9 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg)* inner/single VLAN respectively and don't allow VF to * negotiate VIRTCHNL_VF_OFFLOAD in any other cases */ -if (ice_is_dvm_ena (&pf->hw) &&ice_vf_is_port_vlan_ena (vf)) { +if (ice_is_dvm_ena (hw) &&ice_vf_is_port_vlan_ena (vf)) { vfres->vf_cap_flags |=VIRTCHNL_VF_OFFLOAD_VLAN ; - }else if (!ice_is_dvm_ena (&pf->hw) && + }else if (!ice_is_dvm_ena (hw) && !ice_vf_is_port_vlan_ena (vf)) { vfres->vf_cap_flags |=VIRTCHNL_VF_OFFLOAD_VLAN ;/* configure backward compatible support for VFs that
@@ -422,7 +422,7 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg)* configured in SVM, and no port VLAN is configured */ ice_vf_vsi_cfg_svm_legacy_vlan_mode (vsi); - }else if (ice_is_dvm_ena (&pf->hw)) { + }else if (ice_is_dvm_ena (hw)) {/* configure software offloaded VLAN support when DVM * is enabled, but no port VLAN is enabled */
@@ -472,7 +472,7 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg) vfres->num_vsis =1 ;/* Tx and Rx queue are equal for VF */ vfres->num_queue_pairs = vsi->num_txq; - vfres->max_vectors = pf->vfs.num_msix_per; + vfres->max_vectors = vf->pf->vfs.num_msix_per; vfres->rss_key_size =ICE_VSIQF_HKEY_ARRAY_SIZE ; vfres->rss_lut_size =ICE_VSIQF_HLUT_ARRAY_SIZE ; vfres->max_mtu =ice_vc_get_max_frame_size (vf);
Signature · 1 line
2.35.1.129.gb80121027d12
Jankowski
PATCH 25/25 ice: remove PF pointer from ice_check_vf_init
drivers/net/ethernet/intel/ice/ice_vf_lib.c static void ice_wait_on_vf_reset(struct ice_vf *vf)
Quoted 33 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, February 23, 2022 1:27 AM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [net-next PATCH 25/25] ice: remove PF pointer fromice_check_vf_initThe
ice_check_vf_initfunction takes both a PF and a VF pointer. Every caller looks up the PF pointer from the VF structure. Some callers only use of the PF pointer is call this function. Move the lookup insideice_check_vf_initand drop the unnecessary argument.Cleanup the callers to drop the now unnecessary local variables. In particular, replace the local PF pointer with a HW structure pointer in
ice_vc_get_vf_res_msgwhich simplifies a few accesses to the HW structure in that function.Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 16 +++++++--------- .../net/ethernet/intel/ice/ice_vf_lib_private.h | 2 +- drivers/net/ethernet/intel/ice/ice_virtchnl.c | 12 ++++++------ 3 files changed, 14 insertions(+), 16 deletions(-)drivers/net/ethernet/intel/ice/ice_vf_lib.c +0
-0@@ -174,15 +174,12 @@ static void ice_wait_on_vf_reset(struct ice_vf *vf)