ice devlink updates
Subsystems (5)
cover ice devlink updates
This series includes a couple of minor cleanups in ice_devlink.c
First, Ani converts ice_info_get_dsn into a void function, as it always returns success and does not need to conform to the factory pattern of the other info reporting functions.
Second, Jake adds reporting of the DDP Track ID for the DDP package to devlink info. The track ID is indicated as a bundle_id which refers to the tracking identifier for the DDP package. This is similar to the fw.bundle_id which refers to the main firmware block. This track ID is useful as the DDP version alone is not enough to uniquely identify the DDP package.
Finally, Jake refactored the devlink_port to be tracked by the ice_vsi structure instead of ice_pf. Doing so helps avoid some cleanup ordering issues that resulted in possibly calling devlink_port_unregister twice, or for a devlink_port that was never registered. Additionally, this paves the way for a future addition of devlink_port for virtual functions and other types of ports besides the main PF port.
Anirudh Venkataramanan (1):
ice: Change ice_info_get_dsn to be void
Jacob Keller (2):
ice: add the DDP Track ID to devlink info
ice: refactor devlink_port to be per-VSI
Documentation/networking/devlink/ice.rst | 5 ++ drivers/net/ethernet/intel/ice/ice.h | 7 +- drivers/net/ethernet/intel/ice/ice_devlink.c | 72 ++++++++++++-------- drivers/net/ethernet/intel/ice/ice_devlink.h | 4 +- drivers/net/ethernet/intel/ice/ice_lib.c | 5 +- drivers/net/ethernet/intel/ice/ice_main.c | 8 +-- 6 files changed, 60 insertions(+), 41 deletions(-)
base-commit: 94f0e130c54caede97dd62d5fec8ada4142fe68f
Signature · 1 line
2.28.0.218.ge27853923b9d.dirty
PATCH 1/3 ice: Change ice_info_get_dsn to be void
From: Anirudh Venkataramanan <[email protected]>
ice_info_get_dsn always returns 0, so just make it void.
--- drivers/net/ethernet/intel/ice/ice_devlink.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/ice/ice_devlink.c +2 -8
@@ -6,7 +6,7 @@#include "ice_devlink.h" #include "ice_fw_update.h" -static int ice_info_get_dsn (struct ice_pf *pf,char *buf,size_t len) +static void ice_info_get_dsn (struct ice_pf *pf,char *buf,size_t len) {u8 dsn[8 ];
@@ -14,8 +14,6 @@ static int ice_info_get_dsn(struct ice_pf *pf, char *buf, size_t len)put_unaligned_be64 (pci_get_dsn (pf->pdev), dsn);snprintf (buf, len,"%8phD" , dsn); - -return 0 ; }static int ice_info_pba (struct ice_pf *pf,char *buf,size_t len)
@@ -178,11 +176,7 @@ static int ice_devlink_info_get(struct devlink *devlink,return err; } - err =ice_info_get_dsn (pf, buf,sizeof (buf)); -if (err) { -NL_SET_ERR_MSG_MOD (extack,"Unable to obtain serial number" ); -return err; - } +ice_info_get_dsn (pf, buf,sizeof (buf)); err =devlink_info_serial_number_put (req, buf);if (err) {
Signature · 1 line
2.28.0.218.ge27853923b9d.dirty
Brown
PATCH 1/3 ice: Change ice_info_get_dsn to be void
Quoted 7 lines
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, August 19, 2020 2:59 PM
To: Intel Wired LAN <[email protected]>; Nguyen, Anthony L <[email protected]>
Subject: [Intel-wired-lan] [PATCH 1/3] ice: Changeice_info_get_dsnto be void
Quoted 9 lines
From: Anirudh Venkataramanan <[email protected]>
ice_info_get_dsnalways returns 0, so just make it void.Signed-off-by Anirudh Venkataramanan <[email protected]>--- drivers/net/ethernet/intel/ice/ice_devlink.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
PATCH 2/3 ice: add the DDP Track ID to devlink info
In reply to Jacob KellerAdd "fw.app.bundle_id" to display the DDP Track ID of the active DDP package. This id is similar to "fw.bundle_id" and is a unique identifier for the DDP package that is loaded in the device. Each new DDP has a unique Track ID generated for it, and the ID can be used to identify and track the DDP package.
Add documentation for the new devlink info version.
--- Documentation/networking/devlink/ice.rst | 5 +++++ drivers/net/ethernet/intel/ice/ice_devlink.c | 8 ++++++++ 2 files changed, 13 insertions(+)
Documentation/networking/devlink/ice.rst +5 -0
@@ -69,6 +69,11 @@ The ``ice`` driver reports the following versions - The version of the DDP package that is active in the device. Note that both the name (as reported by ``fw.app.name``) and version are required to uniquely identify the package. + * - ``fw.app.bundle_id`` + - 0xc0000001 + - Unique identifier for the DDP package loaded in the device. Also + referred to as the DDP Track ID. Can be used to uniquely identify + the specific DDP package. * - ``fw.netlist`` - running - 1.1.2000-6.7.0
drivers/net/ethernet/intel/ice/ice_devlink.c +8 -0
@@ -102,6 +102,13 @@ static int ice_info_ddp_pkg_version(struct ice_pf *pf, char *buf, size_t len)return 0 ; } +static int ice_info_ddp_pkg_bundle_id (struct ice_pf *pf,char *buf,size_t len) +{ +snprintf (buf, len,"0x%08x" , pf->hw.active_track_id); + +return 0 ; +} +static int ice_info_netlist_ver (struct ice_pf *pf,char *buf,size_t len) {struct ice_netlist_ver_info *netlist = &pf->hw.netlist_ver;
@@ -146,6 +153,7 @@ static const struct ice_devlink_version {running (DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID , ice_info_eetrack),running ("fw.app.name" , ice_info_ddp_pkg_name),running (DEVLINK_INFO_VERSION_GENERIC_FW_APP , ice_info_ddp_pkg_version), +running ("fw.app.bundle_id" , ice_info_ddp_pkg_bundle_id),running ("fw.netlist" , ice_info_netlist_ver), running("fw.netlist.build", ice_info_netlist_build), };
Signature · 1 line
2.28.0.218.ge27853923b9d.dirty
Brown
PATCH 2/3 ice: add the DDP Track ID to devlink info
Quoted 13 lines
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, August 19, 2020 2:59 PM
To: Intel Wired LAN <[email protected]>; Nguyen, Anthony L <[email protected]>
Subject: [Intel-wired-lan] [PATCH 2/3] ice: add the DDP Track ID to devlink infoAdd "fw.app.bundle_id" to display the DDP Track ID of the active DDP package. This id is similar to "fw.bundle_id" and is a unique identifier for the DDP package that is loaded in the device. Each new DDP has a unique Track ID generated for it, and the ID can be used to identify and track the DDP package.
Quoted 8 lines
Add documentation for the new devlink info version.
Signed-off-by Jacob Keller <[email protected]>--- Documentation/networking/devlink/ice.rst | 5 +++++ drivers/net/ethernet/intel/ice/ice_devlink.c | 8 ++++++++ 2 files changed, 13 insertions(+)
PATCH 3/3 ice: refactor devlink_port to be per-VSI
In reply to Jacob KellerCurrently, the devlink_port structure is stored within the ice_pf. This made sense because we create a single devlink_port for each PF. This setup does not mesh with the abstractions in the driver very well, and led to a flow where we accidentally call devlink_port_unregister twice during error cleanup.
In particular, if devlink_port_register or devlink_port_unregister are called twice, this leads to a kernel panic. This appears to occur during some possible flows while cleaning up from a failure during driver probe.
If register_netdev fails, then we will call devlink_port_unregister in ice_cfg_netdev as it cleans up. Later, we again call devlink_port_unregister since we assume that we must cleanup the port that is associated with the PF structure.
This occurs because we cleanup the devlink_port for the main PF even though it was not allocated. We allocated the port within a per-VSI function for managing the main netdev, but did not release the port when cleaning up that VSI, the allocation and destruction are not aligned.
Instead of attempting to manage the devlink_port as part of the PF structure, manage it as part of the PF VSI. Doing this has advantages, as we can match the de-allocation of the devlink_port with the unregister_netdev associated with the main PF VSI.
Moving the port to the VSI is preferable as it paves the way for handling devlink ports allocated for other purposes such as SR-IOV VFs.
Since we're changing up how we allocate the devlink_port, also change the indexing. Originally, we indexed the port using the PF id number. This came from an old goal of sharing a devlink for each physical function. Managing devlink instances across multiple function drivers is not workable. Instead, lets set the port number to the logical port number returned by firmware and set the index using the VSI index (sometimes referred to as VSI handle).
--- drivers/net/ethernet/intel/ice/ice.h | 7 +-- drivers/net/ethernet/intel/ice/ice_devlink.c | 54 ++++++++++++-------- drivers/net/ethernet/intel/ice/ice_devlink.h | 4 +- drivers/net/ethernet/intel/ice/ice_lib.c | 5 +- drivers/net/ethernet/intel/ice/ice_main.c | 8 ++- 5 files changed, 45 insertions(+), 33 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +4 -3
@@ -284,6 +284,10 @@ struct ice_vsi {spinlock_t arfs_lock;/* protects aRFS hash table and filter state */ atomic_t *arfs_last_fltr_id; +/* devlink port data */ +struct devlink_port devlink_port; +bool devlink_port_registered; +u16 max_frame;u16 rx_buf_len;
@@ -375,9 +379,6 @@ enum ice_pf_flags {struct ice_pf {struct pci_dev *pdev; -/* devlink port data */ -struct devlink_port devlink_port; -struct devlink_region *nvm_region;struct devlink_region *devcaps_region;
drivers/net/ethernet/intel/ice/ice_devlink.c +32 -22
82 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_devlink.h +2 -2
@@ -8,8 +8,8 @@ struct ice_pf *ice_allocate_pf(struct device *dev);int ice_devlink_register (struct ice_pf *pf);void ice_devlink_unregister (struct ice_pf *pf); -int ice_devlink_create_port (struct ice_pf *pf); -void ice_devlink_destroy_port (struct ice_pf *pf); +int ice_devlink_create_port (struct ice_vsi *vsi); +void ice_devlink_destroy_port (struct ice_vsi *vsi);void ice_devlink_init_regions (struct ice_pf *pf);void ice_devlink_destroy_regions (struct ice_pf *pf);
drivers/net/ethernet/intel/ice/ice_lib.c +4 -1
@@ -7,6 +7,7 @@#include "ice_lib.h" #include "ice_fltr.h" #include "ice_dcb_lib.h" +#include "ice_devlink.h" /** * ice_vsi_type_str - maps VSI type enum to string equivalents
@@ -2604,8 +2605,10 @@ int ice_vsi_release(struct ice_vsi *vsi)* PF that is running the work queue items currently. This is done to * avoid check_flush_dependency() warning on this wq */ -if (vsi->netdev && !ice_is_reset_in_progress (pf->state)) +if (vsi->netdev && !ice_is_reset_in_progress (pf->state)) {unregister_netdev (vsi->netdev); +ice_devlink_destroy_port (vsi); + }if (test_bit (ICE_FLAG_RSS_ENA , pf->flags))ice_rss_clean (vsi);
drivers/net/ethernet/intel/ice/ice_main.c +3 -5
@@ -2954,7 +2954,7 @@ static int ice_cfg_netdev(struct ice_vsi *vsi)u8 mac_addr[ETH_ALEN ];int err; - err =ice_devlink_create_port (pf); + err =ice_devlink_create_port (vsi);if (err)return err;
@@ -2995,7 +2995,7 @@ static int ice_cfg_netdev(struct ice_vsi *vsi)if (err) goto err_free_netdev; -devlink_port_type_eth_set (&pf->devlink_port, vsi->netdev); +devlink_port_type_eth_set (&vsi->devlink_port, vsi->netdev);netif_carrier_off (vsi->netdev);
@@ -3008,7 +3008,7 @@ static int ice_cfg_netdev(struct ice_vsi *vsi)free_netdev (vsi->netdev); vsi->netdev =NULL ; err_destroy_devlink_port: -ice_devlink_destroy_port (pf); +ice_devlink_destroy_port (vsi);return err; }
@@ -4250,7 +4250,6 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) err_send_version_unroll:ice_vsi_release_all (pf); err_alloc_sw_unroll: -ice_devlink_destroy_port (pf);set_bit (__ICE_SERVICE_DIS, pf->state);set_bit (__ICE_DOWN, pf->state);devm_kfree (dev, pf->first_sw);
@@ -4365,7 +4364,6 @@ static void ice_remove(struct pci_dev *pdev)if (!ice_is_safe_mode (pf))ice_remove_arfs (pf);ice_setup_mc_magic_wake (pf); -ice_devlink_destroy_port (pf);ice_vsi_release_all (pf);ice_set_wake (pf);ice_free_irq_msix_misc (pf);
Signature · 1 line
2.28.0.218.ge27853923b9d.dirty
Brown
PATCH 3/3 ice: refactor devlink_port to be per-VSI
Quoted 44 lines
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Wednesday, August 19, 2020 2:59 PM
To: Intel Wired LAN <[email protected]>; Nguyen, Anthony L <[email protected]>
Subject: [Intel-wired-lan] [PATCH 3/3] ice: refactordevlink_portto be per-VSICurrently, the
devlink_portstructure is stored within theice_pf. This made sense because we create a singledevlink_portfor each PF. This setup does not mesh with the abstractions in the driver very well, and led to a flow where we accidentally calldevlink_port_unregistertwice during error cleanup.In particular, if
devlink_port_registerordevlink_port_unregisterare called twice, this leads to a kernel panic. This appears to occur during some possible flows while cleaning up from a failure during driver probe.If
register_netdevfails, then we will calldevlink_port_unregisterinice_cfg_netdevas it cleans up. Later, we again calldevlink_port_unregistersince we assume that we must cleanup the port that is associated with the PF structure.This occurs because we cleanup the
devlink_portfor the main PF even though it was not allocated. We allocated the port within a per-VSI function for managing the main netdev, but did not release the port when cleaning up that VSI, the allocation and destruction are not aligned.Instead of attempting to manage the
devlink_portas part of the PF structure, manage it as part of the PF VSI. Doing this has advantages, as we can match the de-allocation of thedevlink_portwith theunregister_netdevassociated with the main PF VSI.Moving the port to the VSI is preferable as it paves the way for handling devlink ports allocated for other purposes such as SR-IOV VFs.
Since we're changing up how we allocate the
devlink_port, also change the indexing. Originally, we indexed the port using the PF id number. This came from an old goal of sharing a devlink for each physical function. Managing devlink instances across multiple function drivers is not workable. Instead, lets set the port number to the logical port number returned by firmware and set the index using the VSI index (sometimes referred to as VSI handle).
Quoted 9 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice.h | 7 +-- drivers/net/ethernet/intel/ice/ice_devlink.c | 54 ++++++++++++-------- drivers/net/ethernet/intel/ice/ice_devlink.h | 4 +- drivers/net/ethernet/intel/ice/ice_lib.c | 5 +- drivers/net/ethernet/intel/ice/ice_main.c | 8 ++- 5 files changed, 45 insertions(+), 33 deletions(-)