Skip to content

Commit be49b1a

Browse files
jacob-kelleranguy11
authored andcommitted
ice: preserve NVM capabilities in safe mode
If the driver initializes in safe mode, it will call ice_set_safe_mode_caps. This results in clearing the capabilities structures, in order to set them up for operating in safe mode, ensuring many features are disabled. This has a side effect of also clearing the capability bits that relate to NVM update. The result is that the device driver will not indicate support for unified update, even if the firmware is capable. Fix this by adding the relevant capability fields to the list of values we preserve. To simplify the code, use a common_cap structure instead of a handful of local variables. To reduce some duplication of the capability name, introduce a couple of macros used to restore the capabilities values from the cached copy. Fixes: de9b277 ("ice: Add support for unified NVM update flow capability") Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Brijesh Behera <brijeshx.behera@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 0ec86e8 commit be49b1a

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

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

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,26 +2288,28 @@ void ice_set_safe_mode_caps(struct ice_hw *hw)
22882288
{
22892289
struct ice_hw_func_caps *func_caps = &hw->func_caps;
22902290
struct ice_hw_dev_caps *dev_caps = &hw->dev_caps;
2291-
u32 valid_func, rxq_first_id, txq_first_id;
2292-
u32 msix_vector_first_id, max_mtu;
2291+
struct ice_hw_common_caps cached_caps;
22932292
u32 num_funcs;
22942293

22952294
/* cache some func_caps values that should be restored after memset */
2296-
valid_func = func_caps->common_cap.valid_functions;
2297-
txq_first_id = func_caps->common_cap.txq_first_id;
2298-
rxq_first_id = func_caps->common_cap.rxq_first_id;
2299-
msix_vector_first_id = func_caps->common_cap.msix_vector_first_id;
2300-
max_mtu = func_caps->common_cap.max_mtu;
2295+
cached_caps = func_caps->common_cap;
23012296

23022297
/* unset func capabilities */
23032298
memset(func_caps, 0, sizeof(*func_caps));
23042299

2300+
#define ICE_RESTORE_FUNC_CAP(name) \
2301+
func_caps->common_cap.name = cached_caps.name
2302+
23052303
/* restore cached values */
2306-
func_caps->common_cap.valid_functions = valid_func;
2307-
func_caps->common_cap.txq_first_id = txq_first_id;
2308-
func_caps->common_cap.rxq_first_id = rxq_first_id;
2309-
func_caps->common_cap.msix_vector_first_id = msix_vector_first_id;
2310-
func_caps->common_cap.max_mtu = max_mtu;
2304+
ICE_RESTORE_FUNC_CAP(valid_functions);
2305+
ICE_RESTORE_FUNC_CAP(txq_first_id);
2306+
ICE_RESTORE_FUNC_CAP(rxq_first_id);
2307+
ICE_RESTORE_FUNC_CAP(msix_vector_first_id);
2308+
ICE_RESTORE_FUNC_CAP(max_mtu);
2309+
ICE_RESTORE_FUNC_CAP(nvm_unified_update);
2310+
ICE_RESTORE_FUNC_CAP(nvm_update_pending_nvm);
2311+
ICE_RESTORE_FUNC_CAP(nvm_update_pending_orom);
2312+
ICE_RESTORE_FUNC_CAP(nvm_update_pending_netlist);
23112313

23122314
/* one Tx and one Rx queue in safe mode */
23132315
func_caps->common_cap.num_rxq = 1;
@@ -2318,22 +2320,25 @@ void ice_set_safe_mode_caps(struct ice_hw *hw)
23182320
func_caps->guar_num_vsi = 1;
23192321

23202322
/* cache some dev_caps values that should be restored after memset */
2321-
valid_func = dev_caps->common_cap.valid_functions;
2322-
txq_first_id = dev_caps->common_cap.txq_first_id;
2323-
rxq_first_id = dev_caps->common_cap.rxq_first_id;
2324-
msix_vector_first_id = dev_caps->common_cap.msix_vector_first_id;
2325-
max_mtu = dev_caps->common_cap.max_mtu;
2323+
cached_caps = dev_caps->common_cap;
23262324
num_funcs = dev_caps->num_funcs;
23272325

23282326
/* unset dev capabilities */
23292327
memset(dev_caps, 0, sizeof(*dev_caps));
23302328

2329+
#define ICE_RESTORE_DEV_CAP(name) \
2330+
dev_caps->common_cap.name = cached_caps.name
2331+
23312332
/* restore cached values */
2332-
dev_caps->common_cap.valid_functions = valid_func;
2333-
dev_caps->common_cap.txq_first_id = txq_first_id;
2334-
dev_caps->common_cap.rxq_first_id = rxq_first_id;
2335-
dev_caps->common_cap.msix_vector_first_id = msix_vector_first_id;
2336-
dev_caps->common_cap.max_mtu = max_mtu;
2333+
ICE_RESTORE_DEV_CAP(valid_functions);
2334+
ICE_RESTORE_DEV_CAP(txq_first_id);
2335+
ICE_RESTORE_DEV_CAP(rxq_first_id);
2336+
ICE_RESTORE_DEV_CAP(msix_vector_first_id);
2337+
ICE_RESTORE_DEV_CAP(max_mtu);
2338+
ICE_RESTORE_DEV_CAP(nvm_unified_update);
2339+
ICE_RESTORE_DEV_CAP(nvm_update_pending_nvm);
2340+
ICE_RESTORE_DEV_CAP(nvm_update_pending_orom);
2341+
ICE_RESTORE_DEV_CAP(nvm_update_pending_netlist);
23372342
dev_caps->num_funcs = num_funcs;
23382343

23392344
/* one Tx and one Rx queue per function in safe mode */

0 commit comments

Comments
 (0)