Skip to content

Commit 4134c84

Browse files
committed
Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/nex
t-queue Tony Nguyen says: ==================== 100GbE Intel Wired LAN Driver Updates 2021-12-15 This series contains updates to ice driver only. Jake makes changes to flash update. This includes the following: * a new shadow-ram region similar to NVM region but for the device shadow RAM contents. This is distinct from NVM region because shadow RAM is built up during device init and may be different from the raw NVM flash data. * refactoring of the ice_flash_pldm_image to become the main flash update entry point. This is simpler than having both an ice_devlink_flash_update and an ice_flash_pldm_image. It will make additions like dry-run easier in the future. * reducing time to read Option ROM version information. * adding support for firmware activation via devlink reload, when possible. The major new work is the reload support, which allows activating firmware immediately without a reboot when possible. Reload support only supports firmware activation. Jesse improves transmit code: utilizing newer netif_tx* API, adding some prefetch calls, correcting expected conditions when calling ice_vsi_down(), and utilizing __netdev_tx_sent_queue() call. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 823f7a5 + 9c99d09 commit 4134c84

File tree

13 files changed

+558
-167
lines changed

13 files changed

+558
-167
lines changed

Documentation/networking/devlink/ice.rst

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ The ``ice`` driver reports the following versions
2626
* - ``fw.mgmt``
2727
- running
2828
- 2.1.7
29-
- 3-digit version number of the management firmware that controls the
30-
PHY, link, etc.
29+
- 3-digit version number of the management firmware running on the
30+
Embedded Management Processor of the device. It controls the PHY,
31+
link, access to device resources, etc. Intel documentation refers to
32+
this as the EMP firmware.
3133
* - ``fw.mgmt.api``
3234
- running
3335
- 1.5.1
@@ -119,6 +121,24 @@ preserving settings, and thus ``DEVLINK_FLASH_OVERWRITE_IDENTIFIERS`` on its
119121
own will be rejected. If no overwrite mask is provided, the firmware will be
120122
instructed to preserve all settings and identifying fields when updating.
121123

124+
Reload
125+
======
126+
127+
The ``ice`` driver supports activating new firmware after a flash update
128+
using ``DEVLINK_CMD_RELOAD`` with the ``DEVLINK_RELOAD_ACTION_FW_ACTIVATE``
129+
action.
130+
131+
.. code:: shell
132+
133+
$ devlink dev reload pci/0000:01:00.0 reload action fw_activate
134+
135+
The new firmware is activated by issuing a device specific Embedded
136+
Management Processor reset which requests the device to reset and reload the
137+
EMP firmware image.
138+
139+
The driver does not currently support reloading the driver via
140+
``DEVLINK_RELOAD_ACTION_DRIVER_REINIT``.
141+
122142
Regions
123143
=======
124144

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ struct ice_pf {
503503
struct pci_dev *pdev;
504504

505505
struct devlink_region *nvm_region;
506+
struct devlink_region *sram_region;
506507
struct devlink_region *devcaps_region;
507508

508509
/* devlink port data */
@@ -552,6 +553,7 @@ struct ice_pf {
552553
spinlock_t aq_wait_lock;
553554
struct hlist_head aq_wait_list;
554555
wait_queue_head_t aq_wait_queue;
556+
bool fw_emp_reset_disabled;
555557

556558
wait_queue_head_t reset_wait_queue;
557559

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ struct ice_aqc_list_caps_elem {
117117
#define ICE_AQC_CAPS_NET_VER 0x004C
118118
#define ICE_AQC_CAPS_PENDING_NET_VER 0x004D
119119
#define ICE_AQC_CAPS_RDMA 0x0051
120+
#define ICE_AQC_CAPS_PCIE_RESET_AVOIDANCE 0x0076
121+
#define ICE_AQC_CAPS_POST_UPDATE_RESET_RESTRICT 0x0077
120122
#define ICE_AQC_CAPS_NVM_MGMT 0x0080
121123

122124
u8 major_ver;
@@ -1408,6 +1410,11 @@ struct ice_aqc_nvm {
14081410
#define ICE_AQC_NVM_REVERT_LAST_ACTIV BIT(6) /* Write Activate only */
14091411
#define ICE_AQC_NVM_ACTIV_SEL_MASK ICE_M(0x7, 3)
14101412
#define ICE_AQC_NVM_FLASH_ONLY BIT(7)
1413+
#define ICE_AQC_NVM_RESET_LVL_M ICE_M(0x3, 0) /* Write reply only */
1414+
#define ICE_AQC_NVM_POR_FLAG 0
1415+
#define ICE_AQC_NVM_PERST_FLAG 1
1416+
#define ICE_AQC_NVM_EMPR_FLAG 2
1417+
#define ICE_AQC_NVM_EMPR_ENA BIT(0) /* Write Activate reply only */
14111418
__le16 module_typeid;
14121419
__le16 length;
14131420
#define ICE_AQC_NVM_ERASE_LEN 0xFFFF

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,6 +2068,18 @@ ice_parse_common_caps(struct ice_hw *hw, struct ice_hw_common_caps *caps,
20682068
ice_debug(hw, ICE_DBG_INIT, "%s: max_mtu = %d\n",
20692069
prefix, caps->max_mtu);
20702070
break;
2071+
case ICE_AQC_CAPS_PCIE_RESET_AVOIDANCE:
2072+
caps->pcie_reset_avoidance = (number > 0);
2073+
ice_debug(hw, ICE_DBG_INIT,
2074+
"%s: pcie_reset_avoidance = %d\n", prefix,
2075+
caps->pcie_reset_avoidance);
2076+
break;
2077+
case ICE_AQC_CAPS_POST_UPDATE_RESET_RESTRICT:
2078+
caps->reset_restrict_support = (number == 1);
2079+
ice_debug(hw, ICE_DBG_INIT,
2080+
"%s: reset_restrict_support = %d\n", prefix,
2081+
caps->reset_restrict_support);
2082+
break;
20712083
default:
20722084
/* Not one of the recognized common capabilities */
20732085
found = false;

drivers/net/ethernet/intel/ice/ice_devlink.c

Lines changed: 167 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -371,57 +371,105 @@ static int ice_devlink_info_get(struct devlink *devlink,
371371
}
372372

373373
/**
374-
* ice_devlink_flash_update - Update firmware stored in flash on the device
375-
* @devlink: pointer to devlink associated with device to update
376-
* @params: flash update parameters
374+
* ice_devlink_reload_empr_start - Start EMP reset to activate new firmware
375+
* @devlink: pointer to the devlink instance to reload
376+
* @netns_change: if true, the network namespace is changing
377+
* @action: the action to perform. Must be DEVLINK_RELOAD_ACTION_FW_ACTIVATE
378+
* @limit: limits on what reload should do, such as not resetting
377379
* @extack: netlink extended ACK structure
378380
*
379-
* Perform a device flash update. The bulk of the update logic is contained
380-
* within the ice_flash_pldm_image function.
381+
* Allow user to activate new Embedded Management Processor firmware by
382+
* issuing device specific EMP reset. Called in response to
383+
* a DEVLINK_CMD_RELOAD with the DEVLINK_RELOAD_ACTION_FW_ACTIVATE.
381384
*
382-
* Returns: zero on success, or an error code on failure.
385+
* Note that teardown and rebuild of the driver state happens automatically as
386+
* part of an interrupt and watchdog task. This is because all physical
387+
* functions on the device must be able to reset when an EMP reset occurs from
388+
* any source.
383389
*/
384390
static int
385-
ice_devlink_flash_update(struct devlink *devlink,
386-
struct devlink_flash_update_params *params,
387-
struct netlink_ext_ack *extack)
391+
ice_devlink_reload_empr_start(struct devlink *devlink, bool netns_change,
392+
enum devlink_reload_action action,
393+
enum devlink_reload_limit limit,
394+
struct netlink_ext_ack *extack)
388395
{
389396
struct ice_pf *pf = devlink_priv(devlink);
397+
struct device *dev = ice_pf_to_dev(pf);
390398
struct ice_hw *hw = &pf->hw;
391-
u8 preservation;
399+
u8 pending;
392400
int err;
393401

394-
if (!params->overwrite_mask) {
395-
/* preserve all settings and identifiers */
396-
preservation = ICE_AQC_NVM_PRESERVE_ALL;
397-
} else if (params->overwrite_mask == DEVLINK_FLASH_OVERWRITE_SETTINGS) {
398-
/* overwrite settings, but preserve the vital device identifiers */
399-
preservation = ICE_AQC_NVM_PRESERVE_SELECTED;
400-
} else if (params->overwrite_mask == (DEVLINK_FLASH_OVERWRITE_SETTINGS |
401-
DEVLINK_FLASH_OVERWRITE_IDENTIFIERS)) {
402-
/* overwrite both settings and identifiers, preserve nothing */
403-
preservation = ICE_AQC_NVM_NO_PRESERVATION;
404-
} else {
405-
NL_SET_ERR_MSG_MOD(extack, "Requested overwrite mask is not supported");
406-
return -EOPNOTSUPP;
402+
err = ice_get_pending_updates(pf, &pending, extack);
403+
if (err)
404+
return err;
405+
406+
/* pending is a bitmask of which flash banks have a pending update,
407+
* including the main NVM bank, the Option ROM bank, and the netlist
408+
* bank. If any of these bits are set, then there is a pending update
409+
* waiting to be activated.
410+
*/
411+
if (!pending) {
412+
NL_SET_ERR_MSG_MOD(extack, "No pending firmware update");
413+
return -ECANCELED;
407414
}
408415

409-
if (!hw->dev_caps.common_cap.nvm_unified_update) {
410-
NL_SET_ERR_MSG_MOD(extack, "Current firmware does not support unified update");
411-
return -EOPNOTSUPP;
416+
if (pf->fw_emp_reset_disabled) {
417+
NL_SET_ERR_MSG_MOD(extack, "EMP reset is not available. To activate firmware, a reboot or power cycle is needed");
418+
return -ECANCELED;
412419
}
413420

414-
err = ice_check_for_pending_update(pf, NULL, extack);
415-
if (err)
421+
dev_dbg(dev, "Issuing device EMP reset to activate firmware\n");
422+
423+
err = ice_aq_nvm_update_empr(hw);
424+
if (err) {
425+
dev_err(dev, "Failed to trigger EMP device reset to reload firmware, err %d aq_err %s\n",
426+
err, ice_aq_str(hw->adminq.sq_last_status));
427+
NL_SET_ERR_MSG_MOD(extack, "Failed to trigger EMP device reset to reload firmware");
416428
return err;
429+
}
417430

418-
devlink_flash_update_status_notify(devlink, "Preparing to flash", NULL, 0, 0);
431+
return 0;
432+
}
419433

420-
return ice_flash_pldm_image(pf, params->fw, preservation, extack);
434+
/**
435+
* ice_devlink_reload_empr_finish - Wait for EMP reset to finish
436+
* @devlink: pointer to the devlink instance reloading
437+
* @action: the action requested
438+
* @limit: limits imposed by userspace, such as not resetting
439+
* @actions_performed: on return, indicate what actions actually performed
440+
* @extack: netlink extended ACK structure
441+
*
442+
* Wait for driver to finish rebuilding after EMP reset is completed. This
443+
* includes time to wait for both the actual device reset as well as the time
444+
* for the driver's rebuild to complete.
445+
*/
446+
static int
447+
ice_devlink_reload_empr_finish(struct devlink *devlink,
448+
enum devlink_reload_action action,
449+
enum devlink_reload_limit limit,
450+
u32 *actions_performed,
451+
struct netlink_ext_ack *extack)
452+
{
453+
struct ice_pf *pf = devlink_priv(devlink);
454+
int err;
455+
456+
*actions_performed = BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE);
457+
458+
err = ice_wait_for_reset(pf, 60 * HZ);
459+
if (err) {
460+
NL_SET_ERR_MSG_MOD(extack, "Device still resetting after 1 minute");
461+
return err;
462+
}
463+
464+
return 0;
421465
}
422466

423467
static const struct devlink_ops ice_devlink_ops = {
424468
.supported_flash_update_params = DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK,
469+
.reload_actions = BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE),
470+
/* The ice driver currently does not support driver reinit */
471+
.reload_down = ice_devlink_reload_empr_start,
472+
.reload_up = ice_devlink_reload_empr_finish,
425473
.eswitch_mode_get = ice_eswitch_mode_get,
426474
.eswitch_mode_set = ice_eswitch_mode_set,
427475
.info_get = ice_devlink_info_get,
@@ -582,6 +630,7 @@ void ice_devlink_register(struct ice_pf *pf)
582630
{
583631
struct devlink *devlink = priv_to_devlink(pf);
584632

633+
devlink_set_features(devlink, DEVLINK_F_RELOAD);
585634
devlink_register(devlink);
586635
}
587636

@@ -739,16 +788,20 @@ void ice_devlink_destroy_vf_port(struct ice_vf *vf)
739788
}
740789

741790
/**
742-
* ice_devlink_nvm_snapshot - Capture a snapshot of the Shadow RAM contents
791+
* ice_devlink_nvm_snapshot - Capture a snapshot of the NVM flash contents
743792
* @devlink: the devlink instance
744793
* @ops: the devlink region being snapshotted
745794
* @extack: extended ACK response structure
746795
* @data: on exit points to snapshot data buffer
747796
*
748797
* This function is called in response to the DEVLINK_CMD_REGION_TRIGGER for
749-
* the shadow-ram devlink region. It captures a snapshot of the shadow ram
750-
* contents. This snapshot can later be viewed via the devlink-region
751-
* interface.
798+
* the nvm-flash devlink region. It captures a snapshot of the full NVM flash
799+
* contents, including both banks of flash. This snapshot can later be viewed
800+
* via the devlink-region interface.
801+
*
802+
* It captures the flash using the FLASH_ONLY bit set when reading via
803+
* firmware, so it does not read the current Shadow RAM contents. For that,
804+
* use the shadow-ram region.
752805
*
753806
* @returns zero on success, and updates the data pointer. Returns a non-zero
754807
* error code on failure.
@@ -795,6 +848,66 @@ static int ice_devlink_nvm_snapshot(struct devlink *devlink,
795848
return 0;
796849
}
797850

851+
/**
852+
* ice_devlink_sram_snapshot - Capture a snapshot of the Shadow RAM contents
853+
* @devlink: the devlink instance
854+
* @ops: the devlink region being snapshotted
855+
* @extack: extended ACK response structure
856+
* @data: on exit points to snapshot data buffer
857+
*
858+
* This function is called in response to the DEVLINK_CMD_REGION_TRIGGER for
859+
* the shadow-ram devlink region. It captures a snapshot of the shadow ram
860+
* contents. This snapshot can later be viewed via the devlink-region
861+
* interface.
862+
*
863+
* @returns zero on success, and updates the data pointer. Returns a non-zero
864+
* error code on failure.
865+
*/
866+
static int
867+
ice_devlink_sram_snapshot(struct devlink *devlink,
868+
const struct devlink_region_ops __always_unused *ops,
869+
struct netlink_ext_ack *extack, u8 **data)
870+
{
871+
struct ice_pf *pf = devlink_priv(devlink);
872+
struct device *dev = ice_pf_to_dev(pf);
873+
struct ice_hw *hw = &pf->hw;
874+
u8 *sram_data;
875+
u32 sram_size;
876+
int err;
877+
878+
sram_size = hw->flash.sr_words * 2u;
879+
sram_data = vzalloc(sram_size);
880+
if (!sram_data)
881+
return -ENOMEM;
882+
883+
err = ice_acquire_nvm(hw, ICE_RES_READ);
884+
if (err) {
885+
dev_dbg(dev, "ice_acquire_nvm failed, err %d aq_err %d\n",
886+
err, hw->adminq.sq_last_status);
887+
NL_SET_ERR_MSG_MOD(extack, "Failed to acquire NVM semaphore");
888+
vfree(sram_data);
889+
return err;
890+
}
891+
892+
/* Read from the Shadow RAM, rather than directly from NVM */
893+
err = ice_read_flat_nvm(hw, 0, &sram_size, sram_data, true);
894+
if (err) {
895+
dev_dbg(dev, "ice_read_flat_nvm failed after reading %u bytes, err %d aq_err %d\n",
896+
sram_size, err, hw->adminq.sq_last_status);
897+
NL_SET_ERR_MSG_MOD(extack,
898+
"Failed to read Shadow RAM contents");
899+
ice_release_nvm(hw);
900+
vfree(sram_data);
901+
return err;
902+
}
903+
904+
ice_release_nvm(hw);
905+
906+
*data = sram_data;
907+
908+
return 0;
909+
}
910+
798911
/**
799912
* ice_devlink_devcaps_snapshot - Capture snapshot of device capabilities
800913
* @devlink: the devlink instance
@@ -845,6 +958,12 @@ static const struct devlink_region_ops ice_nvm_region_ops = {
845958
.snapshot = ice_devlink_nvm_snapshot,
846959
};
847960

961+
static const struct devlink_region_ops ice_sram_region_ops = {
962+
.name = "shadow-ram",
963+
.destructor = vfree,
964+
.snapshot = ice_devlink_sram_snapshot,
965+
};
966+
848967
static const struct devlink_region_ops ice_devcaps_region_ops = {
849968
.name = "device-caps",
850969
.destructor = vfree,
@@ -862,7 +981,7 @@ void ice_devlink_init_regions(struct ice_pf *pf)
862981
{
863982
struct devlink *devlink = priv_to_devlink(pf);
864983
struct device *dev = ice_pf_to_dev(pf);
865-
u64 nvm_size;
984+
u64 nvm_size, sram_size;
866985

867986
nvm_size = pf->hw.flash.flash_size;
868987
pf->nvm_region = devlink_region_create(devlink, &ice_nvm_region_ops, 1,
@@ -873,6 +992,15 @@ void ice_devlink_init_regions(struct ice_pf *pf)
873992
pf->nvm_region = NULL;
874993
}
875994

995+
sram_size = pf->hw.flash.sr_words * 2u;
996+
pf->sram_region = devlink_region_create(devlink, &ice_sram_region_ops,
997+
1, sram_size);
998+
if (IS_ERR(pf->sram_region)) {
999+
dev_err(dev, "failed to create shadow-ram devlink region, err %ld\n",
1000+
PTR_ERR(pf->sram_region));
1001+
pf->sram_region = NULL;
1002+
}
1003+
8761004
pf->devcaps_region = devlink_region_create(devlink,
8771005
&ice_devcaps_region_ops, 10,
8781006
ICE_AQ_MAX_BUF_LEN);
@@ -893,6 +1021,10 @@ void ice_devlink_destroy_regions(struct ice_pf *pf)
8931021
{
8941022
if (pf->nvm_region)
8951023
devlink_region_destroy(pf->nvm_region);
1024+
1025+
if (pf->sram_region)
1026+
devlink_region_destroy(pf->sram_region);
1027+
8961028
if (pf->devcaps_region)
8971029
devlink_region_destroy(pf->devcaps_region);
8981030
}

drivers/net/ethernet/intel/ice/ice_ethtool.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,8 +1280,10 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags)
12801280
}
12811281
if (test_bit(ICE_FLAG_LEGACY_RX, change_flags)) {
12821282
/* down and up VSI so that changes of Rx cfg are reflected. */
1283-
ice_down(vsi);
1284-
ice_up(vsi);
1283+
if (!test_and_set_bit(ICE_VSI_DOWN, vsi->state)) {
1284+
ice_down(vsi);
1285+
ice_up(vsi);
1286+
}
12851287
}
12861288
/* don't allow modification of this flag when a single VF is in
12871289
* promiscuous mode because it's not supported

0 commit comments

Comments
 (0)