net/ice/base: whitelist register for NVM access
[dpdk.git] / drivers / net / ice / base / ice_nvm.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2001-2019
3  */
4
5 #include "ice_common.h"
6
7 /**
8  * ice_aq_read_nvm
9  * @hw: pointer to the HW struct
10  * @module_typeid: module pointer location in words from the NVM beginning
11  * @offset: byte offset from the module beginning
12  * @length: length of the section to be read (in bytes from the offset)
13  * @data: command buffer (size [bytes] = length)
14  * @last_command: tells if this is the last command in a series
15  * @read_shadow_ram: tell if this is a shadow RAM read
16  * @cd: pointer to command details structure or NULL
17  *
18  * Read the NVM using the admin queue commands (0x0701)
19  */
20 static enum ice_status
21 ice_aq_read_nvm(struct ice_hw *hw, u16 module_typeid, u32 offset, u16 length,
22                 void *data, bool last_command, bool read_shadow_ram,
23                 struct ice_sq_cd *cd)
24 {
25         struct ice_aq_desc desc;
26         struct ice_aqc_nvm *cmd;
27
28         ice_debug(hw, ICE_DBG_TRACE, "%s\n", __func__);
29
30         cmd = &desc.params.nvm;
31
32         /* In offset the highest byte must be zeroed. */
33         if (offset & 0xFF000000)
34                 return ICE_ERR_PARAM;
35
36         ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_nvm_read);
37
38         if (!read_shadow_ram && module_typeid == ICE_AQC_NVM_START_POINT)
39                 cmd->cmd_flags |= ICE_AQC_NVM_FLASH_ONLY;
40
41         /* If this is the last command in a series, set the proper flag. */
42         if (last_command)
43                 cmd->cmd_flags |= ICE_AQC_NVM_LAST_CMD;
44         cmd->module_typeid = CPU_TO_LE16(module_typeid);
45         cmd->offset_low = CPU_TO_LE16(offset & 0xFFFF);
46         cmd->offset_high = (offset >> 16) & 0xFF;
47         cmd->length = CPU_TO_LE16(length);
48
49         return ice_aq_send_cmd(hw, &desc, data, length, cd);
50 }
51
52 /**
53  * ice_check_sr_access_params - verify params for Shadow RAM R/W operations.
54  * @hw: pointer to the HW structure
55  * @offset: offset in words from module start
56  * @words: number of words to access
57  */
58 static enum ice_status
59 ice_check_sr_access_params(struct ice_hw *hw, u32 offset, u16 words)
60 {
61         if ((offset + words) > hw->nvm.sr_words) {
62                 ice_debug(hw, ICE_DBG_NVM,
63                           "NVM error: offset beyond SR lmt.\n");
64                 return ICE_ERR_PARAM;
65         }
66
67         if (words > ICE_SR_SECTOR_SIZE_IN_WORDS) {
68                 /* We can access only up to 4KB (one sector), in one AQ write */
69                 ice_debug(hw, ICE_DBG_NVM,
70                           "NVM error: tried to access %d words, limit is %d.\n",
71                           words, ICE_SR_SECTOR_SIZE_IN_WORDS);
72                 return ICE_ERR_PARAM;
73         }
74
75         if (((offset + (words - 1)) / ICE_SR_SECTOR_SIZE_IN_WORDS) !=
76             (offset / ICE_SR_SECTOR_SIZE_IN_WORDS)) {
77                 /* A single access cannot spread over two sectors */
78                 ice_debug(hw, ICE_DBG_NVM,
79                           "NVM error: cannot spread over two sectors.\n");
80                 return ICE_ERR_PARAM;
81         }
82
83         return ICE_SUCCESS;
84 }
85
86 /**
87  * ice_read_sr_aq - Read Shadow RAM.
88  * @hw: pointer to the HW structure
89  * @offset: offset in words from module start
90  * @words: number of words to read
91  * @data: buffer for words reads from Shadow RAM
92  * @last_command: tells the AdminQ that this is the last command
93  *
94  * Reads 16-bit word buffers from the Shadow RAM using the admin command.
95  */
96 static enum ice_status
97 ice_read_sr_aq(struct ice_hw *hw, u32 offset, u16 words, u16 *data,
98                bool last_command)
99 {
100         enum ice_status status;
101
102         ice_debug(hw, ICE_DBG_TRACE, "%s\n", __func__);
103
104         status = ice_check_sr_access_params(hw, offset, words);
105
106         /* values in "offset" and "words" parameters are sized as words
107          * (16 bits) but ice_aq_read_nvm expects these values in bytes.
108          * So do this conversion while calling ice_aq_read_nvm.
109          */
110         if (!status)
111                 status = ice_aq_read_nvm(hw, ICE_AQC_NVM_START_POINT,
112                                          2 * offset, 2 * words, data,
113                                          last_command, true, NULL);
114
115         return status;
116 }
117
118 /**
119  * ice_read_sr_word_aq - Reads Shadow RAM via AQ
120  * @hw: pointer to the HW structure
121  * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
122  * @data: word read from the Shadow RAM
123  *
124  * Reads one 16 bit word from the Shadow RAM using the ice_read_sr_aq method.
125  */
126 static enum ice_status
127 ice_read_sr_word_aq(struct ice_hw *hw, u16 offset, u16 *data)
128 {
129         enum ice_status status;
130
131         ice_debug(hw, ICE_DBG_TRACE, "%s\n", __func__);
132
133         status = ice_read_sr_aq(hw, offset, 1, data, true);
134         if (!status)
135                 *data = LE16_TO_CPU(*(_FORCE_ __le16 *)data);
136
137         return status;
138 }
139
140 /**
141  * ice_read_sr_buf_aq - Reads Shadow RAM buf via AQ
142  * @hw: pointer to the HW structure
143  * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
144  * @words: (in) number of words to read; (out) number of words actually read
145  * @data: words read from the Shadow RAM
146  *
147  * Reads 16 bit words (data buf) from the SR using the ice_read_sr_aq
148  * method. Ownership of the NVM is taken before reading the buffer and later
149  * released.
150  */
151 static enum ice_status
152 ice_read_sr_buf_aq(struct ice_hw *hw, u16 offset, u16 *words, u16 *data)
153 {
154         enum ice_status status;
155         bool last_cmd = false;
156         u16 words_read = 0;
157         u16 i = 0;
158
159         ice_debug(hw, ICE_DBG_TRACE, "%s\n", __func__);
160
161         do {
162                 u16 read_size, off_w;
163
164                 /* Calculate number of bytes we should read in this step.
165                  * It's not allowed to read more than one page at a time or
166                  * to cross page boundaries.
167                  */
168                 off_w = offset % ICE_SR_SECTOR_SIZE_IN_WORDS;
169                 read_size = off_w ?
170                         MIN_T(u16, *words,
171                               (ICE_SR_SECTOR_SIZE_IN_WORDS - off_w)) :
172                         MIN_T(u16, (*words - words_read),
173                               ICE_SR_SECTOR_SIZE_IN_WORDS);
174
175                 /* Check if this is last command, if so set proper flag */
176                 if ((words_read + read_size) >= *words)
177                         last_cmd = true;
178
179                 status = ice_read_sr_aq(hw, offset, read_size,
180                                         data + words_read, last_cmd);
181                 if (status)
182                         goto read_nvm_buf_aq_exit;
183
184                 /* Increment counter for words already read and move offset to
185                  * new read location
186                  */
187                 words_read += read_size;
188                 offset += read_size;
189         } while (words_read < *words);
190
191         for (i = 0; i < *words; i++)
192                 data[i] = LE16_TO_CPU(((_FORCE_ __le16 *)data)[i]);
193
194 read_nvm_buf_aq_exit:
195         *words = words_read;
196         return status;
197 }
198
199 /**
200  * ice_acquire_nvm - Generic request for acquiring the NVM ownership
201  * @hw: pointer to the HW structure
202  * @access: NVM access type (read or write)
203  *
204  * This function will request NVM ownership.
205  */
206 static enum ice_status
207 ice_acquire_nvm(struct ice_hw *hw, enum ice_aq_res_access_type access)
208 {
209         ice_debug(hw, ICE_DBG_TRACE, "%s\n", __func__);
210
211         if (hw->nvm.blank_nvm_mode)
212                 return ICE_SUCCESS;
213
214         return ice_acquire_res(hw, ICE_NVM_RES_ID, access, ICE_NVM_TIMEOUT);
215 }
216
217 /**
218  * ice_release_nvm - Generic request for releasing the NVM ownership
219  * @hw: pointer to the HW structure
220  *
221  * This function will release NVM ownership.
222  */
223 static void ice_release_nvm(struct ice_hw *hw)
224 {
225         ice_debug(hw, ICE_DBG_TRACE, "%s\n", __func__);
226
227         if (hw->nvm.blank_nvm_mode)
228                 return;
229
230         ice_release_res(hw, ICE_NVM_RES_ID);
231 }
232
233 /**
234  * ice_read_sr_word - Reads Shadow RAM word and acquire NVM if necessary
235  * @hw: pointer to the HW structure
236  * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
237  * @data: word read from the Shadow RAM
238  *
239  * Reads one 16 bit word from the Shadow RAM using the ice_read_sr_word_aq.
240  */
241 enum ice_status ice_read_sr_word(struct ice_hw *hw, u16 offset, u16 *data)
242 {
243         enum ice_status status;
244
245         status = ice_acquire_nvm(hw, ICE_RES_READ);
246         if (!status) {
247                 status = ice_read_sr_word_aq(hw, offset, data);
248                 ice_release_nvm(hw);
249         }
250
251         return status;
252 }
253
254 /**
255  * ice_init_nvm - initializes NVM setting
256  * @hw: pointer to the HW struct
257  *
258  * This function reads and populates NVM settings such as Shadow RAM size,
259  * max_timeout, and blank_nvm_mode
260  */
261 enum ice_status ice_init_nvm(struct ice_hw *hw)
262 {
263         u16 oem_hi, oem_lo, boot_cfg_tlv, boot_cfg_tlv_len;
264         struct ice_nvm_info *nvm = &hw->nvm;
265         u16 eetrack_lo, eetrack_hi;
266         enum ice_status status;
267         u32 fla, gens_stat;
268         u8 sr_size;
269
270         ice_debug(hw, ICE_DBG_TRACE, "%s\n", __func__);
271
272         /* The SR size is stored regardless of the NVM programming mode
273          * as the blank mode may be used in the factory line.
274          */
275         gens_stat = rd32(hw, GLNVM_GENS);
276         sr_size = (gens_stat & GLNVM_GENS_SR_SIZE_M) >> GLNVM_GENS_SR_SIZE_S;
277
278         /* Switching to words (sr_size contains power of 2) */
279         nvm->sr_words = BIT(sr_size) * ICE_SR_WORDS_IN_1KB;
280
281         /* Check if we are in the normal or blank NVM programming mode */
282         fla = rd32(hw, GLNVM_FLA);
283         if (fla & GLNVM_FLA_LOCKED_M) { /* Normal programming mode */
284                 nvm->blank_nvm_mode = false;
285         } else {
286                 /* Blank programming mode */
287                 nvm->blank_nvm_mode = true;
288                 ice_debug(hw, ICE_DBG_NVM,
289                           "NVM init error: unsupported blank mode.\n");
290                 return ICE_ERR_NVM_BLANK_MODE;
291         }
292
293         status = ice_read_sr_word(hw, ICE_SR_NVM_DEV_STARTER_VER, &nvm->ver);
294         if (status) {
295                 ice_debug(hw, ICE_DBG_INIT,
296                           "Failed to read DEV starter version.\n");
297                 return status;
298         }
299
300         status = ice_read_sr_word(hw, ICE_SR_NVM_EETRACK_LO, &eetrack_lo);
301         if (status) {
302                 ice_debug(hw, ICE_DBG_INIT, "Failed to read EETRACK lo.\n");
303                 return status;
304         }
305         status = ice_read_sr_word(hw, ICE_SR_NVM_EETRACK_HI, &eetrack_hi);
306         if (status) {
307                 ice_debug(hw, ICE_DBG_INIT, "Failed to read EETRACK hi.\n");
308                 return status;
309         }
310
311         nvm->eetrack = (eetrack_hi << 16) | eetrack_lo;
312
313         /* the following devices do not have boot_cfg_tlv yet */
314         if (hw->device_id == ICE_DEV_ID_C822N_BACKPLANE ||
315             hw->device_id == ICE_DEV_ID_C822N_QSFP ||
316             hw->device_id == ICE_DEV_ID_C822N_SFP)
317                 return status;
318
319         status = ice_get_pfa_module_tlv(hw, &boot_cfg_tlv, &boot_cfg_tlv_len,
320                                         ICE_SR_BOOT_CFG_PTR);
321         if (status) {
322                 ice_debug(hw, ICE_DBG_INIT,
323                           "Failed to read Boot Configuration Block TLV.\n");
324                 return status;
325         }
326
327         /* Boot Configuration Block must have length at least 2 words
328          * (Combo Image Version High and Combo Image Version Low)
329          */
330         if (boot_cfg_tlv_len < 2) {
331                 ice_debug(hw, ICE_DBG_INIT,
332                           "Invalid Boot Configuration Block TLV size.\n");
333                 return ICE_ERR_INVAL_SIZE;
334         }
335
336         status = ice_read_sr_word(hw, (boot_cfg_tlv + ICE_NVM_OEM_VER_OFF),
337                                   &oem_hi);
338         if (status) {
339                 ice_debug(hw, ICE_DBG_INIT, "Failed to read OEM_VER hi.\n");
340                 return status;
341         }
342
343         status = ice_read_sr_word(hw, (boot_cfg_tlv + ICE_NVM_OEM_VER_OFF + 1),
344                                   &oem_lo);
345         if (status) {
346                 ice_debug(hw, ICE_DBG_INIT, "Failed to read OEM_VER lo.\n");
347                 return status;
348         }
349
350         nvm->oem_ver = ((u32)oem_hi << 16) | oem_lo;
351
352         return ICE_SUCCESS;
353 }
354
355 /**
356  * ice_read_sr_buf - Reads Shadow RAM buf and acquire lock if necessary
357  * @hw: pointer to the HW structure
358  * @offset: offset of the Shadow RAM word to read (0x000000 - 0x001FFF)
359  * @words: (in) number of words to read; (out) number of words actually read
360  * @data: words read from the Shadow RAM
361  *
362  * Reads 16 bit words (data buf) from the SR using the ice_read_nvm_buf_aq
363  * method. The buf read is preceded by the NVM ownership take
364  * and followed by the release.
365  */
366 enum ice_status
367 ice_read_sr_buf(struct ice_hw *hw, u16 offset, u16 *words, u16 *data)
368 {
369         enum ice_status status;
370
371         status = ice_acquire_nvm(hw, ICE_RES_READ);
372         if (!status) {
373                 status = ice_read_sr_buf_aq(hw, offset, words, data);
374                 ice_release_nvm(hw);
375         }
376
377         return status;
378 }
379
380 /**
381  * ice_nvm_validate_checksum
382  * @hw: pointer to the HW struct
383  *
384  * Verify NVM PFA checksum validity (0x0706)
385  */
386 enum ice_status ice_nvm_validate_checksum(struct ice_hw *hw)
387 {
388         struct ice_aqc_nvm_checksum *cmd;
389         struct ice_aq_desc desc;
390         enum ice_status status;
391
392         status = ice_acquire_nvm(hw, ICE_RES_READ);
393         if (status)
394                 return status;
395
396         cmd = &desc.params.nvm_checksum;
397
398         ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_nvm_checksum);
399         cmd->flags = ICE_AQC_NVM_CHECKSUM_VERIFY;
400
401         status = ice_aq_send_cmd(hw, &desc, NULL, 0, NULL);
402         ice_release_nvm(hw);
403
404         if (!status)
405                 if (LE16_TO_CPU(cmd->checksum) != ICE_AQC_NVM_CHECKSUM_CORRECT)
406                         status = ICE_ERR_NVM_CHECKSUM;
407
408         return status;
409 }
410
411 /**
412  * ice_nvm_access_get_features - Return the NVM access features structure
413  * @cmd: NVM access command to process
414  * @data: storage for the driver NVM features
415  *
416  * Fill in the data section of the NVM access request with a copy of the NVM
417  * features structure.
418  */
419 enum ice_status
420 ice_nvm_access_get_features(struct ice_nvm_access_cmd *cmd,
421                             union ice_nvm_access_data *data)
422 {
423         /* The provided data_size must be at least as large as our NVM
424          * features structure. A larger size should not be treated as an
425          * error, to allow future extensions to to the features structure to
426          * work on older drivers.
427          */
428         if (cmd->data_size < sizeof(struct ice_nvm_features))
429                 return ICE_ERR_NO_MEMORY;
430
431         /* Initialize the data buffer to zeros */
432         ice_memset(data, 0, cmd->data_size, ICE_NONDMA_MEM);
433
434         /* Fill in the features data */
435         data->drv_features.major = ICE_NVM_ACCESS_MAJOR_VER;
436         data->drv_features.minor = ICE_NVM_ACCESS_MINOR_VER;
437         data->drv_features.size = sizeof(struct ice_nvm_features);
438         data->drv_features.features[0] = ICE_NVM_FEATURES_0_REG_ACCESS;
439
440         return ICE_SUCCESS;
441 }
442
443 /**
444  * ice_nvm_access_get_module - Helper function to read module value
445  * @cmd: NVM access command structure
446  *
447  * Reads the module value out of the NVM access config field.
448  */
449 u32 ice_nvm_access_get_module(struct ice_nvm_access_cmd *cmd)
450 {
451         return ((cmd->config & ICE_NVM_CFG_MODULE_M) >> ICE_NVM_CFG_MODULE_S);
452 }
453
454 /**
455  * ice_nvm_access_get_flags - Helper function to read flags value
456  * @cmd: NVM access command structure
457  *
458  * Reads the flags value out of the NVM access config field.
459  */
460 u32 ice_nvm_access_get_flags(struct ice_nvm_access_cmd *cmd)
461 {
462         return ((cmd->config & ICE_NVM_CFG_FLAGS_M) >> ICE_NVM_CFG_FLAGS_S);
463 }
464
465 /**
466  * ice_nvm_access_get_adapter - Helper function to read adapter info
467  * @cmd: NVM access command structure
468  *
469  * Read the adapter info value out of the NVM access config field.
470  */
471 u32 ice_nvm_access_get_adapter(struct ice_nvm_access_cmd *cmd)
472 {
473         return ((cmd->config & ICE_NVM_CFG_ADAPTER_INFO_M) >>
474                 ICE_NVM_CFG_ADAPTER_INFO_S);
475 }
476
477 /**
478  * ice_validate_nvm_rw_reg - Check than an NVM access request is valid
479  * @cmd: NVM access command structure
480  *
481  * Validates that an NVM access structure is request to read or write a valid
482  * register offset. First validates that the module and flags are correct, and
483  * then ensures that the register offset is one of the accepted registers.
484  */
485 static enum ice_status
486 ice_validate_nvm_rw_reg(struct ice_nvm_access_cmd *cmd)
487 {
488         u32 module, flags, offset;
489         u16 i;
490
491         module = ice_nvm_access_get_module(cmd);
492         flags = ice_nvm_access_get_flags(cmd);
493         offset = cmd->offset;
494
495         /* Make sure the module and flags indicate a read/write request */
496         if (module != ICE_NVM_REG_RW_MODULE ||
497             flags != ICE_NVM_REG_RW_FLAGS ||
498             cmd->data_size != FIELD_SIZEOF(union ice_nvm_access_data, regval))
499                 return ICE_ERR_PARAM;
500
501         switch (offset) {
502         case GL_HICR:
503         case GL_HICR_EN: /* Note, this register is read only */
504         case GL_FWSTS:
505         case GL_MNG_FWSM:
506         case GLGEN_CSR_DEBUG_C:
507         case GLGEN_RSTAT:
508         case GLPCI_LBARCTRL:
509         case GLNVM_GENS:
510         case GLNVM_FLA:
511         case PF_FUNC_RID:
512                 return ICE_SUCCESS;
513         default:
514                 break;
515         }
516
517         for (i = 0; i <= ICE_NVM_ACCESS_GL_HIDA_MAX; i++)
518                 if (offset == (u32)GL_HIDA(i))
519                         return ICE_SUCCESS;
520
521         for (i = 0; i <= ICE_NVM_ACCESS_GL_HIBA_MAX; i++)
522                 if (offset == (u32)GL_HIBA(i))
523                         return ICE_SUCCESS;
524
525         /* All other register offsets are not valid */
526         return ICE_ERR_OUT_OF_RANGE;
527 }
528
529 /**
530  * ice_nvm_access_read - Handle an NVM read request
531  * @hw: pointer to the HW struct
532  * @cmd: NVM access command to process
533  * @data: storage for the register value read
534  *
535  * Process an NVM access request to read a register.
536  */
537 enum ice_status
538 ice_nvm_access_read(struct ice_hw *hw, struct ice_nvm_access_cmd *cmd,
539                     union ice_nvm_access_data *data)
540 {
541         enum ice_status status;
542
543         ice_debug(hw, ICE_DBG_TRACE, "%s\n", __func__);
544
545         /* Always initialize the output data, even on failure */
546         ice_memset(data, 0, cmd->data_size, ICE_NONDMA_MEM);
547
548         /* Make sure this is a valid read/write access request */
549         status = ice_validate_nvm_rw_reg(cmd);
550         if (status)
551                 return status;
552
553         ice_debug(hw, ICE_DBG_NVM, "NVM access: reading register %08x\n",
554                   cmd->offset);
555
556         /* Read the register and store the contents in the data field */
557         data->regval = rd32(hw, cmd->offset);
558
559         return ICE_SUCCESS;
560 }
561
562 /**
563  * ice_nvm_access_write - Handle an NVM write request
564  * @hw: pointer to the HW struct
565  * @cmd: NVM access command to process
566  * @data: NVM access data to write
567  *
568  * Process an NVM access request to write a register.
569  */
570 enum ice_status
571 ice_nvm_access_write(struct ice_hw *hw, struct ice_nvm_access_cmd *cmd,
572                      union ice_nvm_access_data *data)
573 {
574         enum ice_status status;
575
576         ice_debug(hw, ICE_DBG_TRACE, "%s\n", __func__);
577
578         /* Make sure this is a valid read/write access request */
579         status = ice_validate_nvm_rw_reg(cmd);
580         if (status)
581                 return status;
582
583         /* Reject requests to write to read-only registers */
584         switch (cmd->offset) {
585         case GL_HICR_EN:
586         case GLGEN_RSTAT:
587                 return ICE_ERR_OUT_OF_RANGE;
588         default:
589                 break;
590         }
591
592         ice_debug(hw, ICE_DBG_NVM,
593                   "NVM access: writing register %08x with value %08x\n",
594                   cmd->offset, data->regval);
595
596         /* Write the data field to the specified register */
597         wr32(hw, cmd->offset, data->regval);
598
599         return ICE_SUCCESS;
600 }
601
602 /**
603  * ice_handle_nvm_access - Handle an NVM access request
604  * @hw: pointer to the HW struct
605  * @cmd: NVM access command info
606  * @data: pointer to read or return data
607  *
608  * Process an NVM access request. Read the command structure information and
609  * determine if it is valid. If not, report an error indicating the command
610  * was invalid.
611  *
612  * For valid commands, perform the necessary function, copying the data into
613  * the provided data buffer.
614  */
615 enum ice_status
616 ice_handle_nvm_access(struct ice_hw *hw, struct ice_nvm_access_cmd *cmd,
617                       union ice_nvm_access_data *data)
618 {
619         u32 module, flags, adapter_info;
620
621         ice_debug(hw, ICE_DBG_TRACE, "%s\n", __func__);
622
623         /* Extended flags are currently reserved and must be zero */
624         if ((cmd->config & ICE_NVM_CFG_EXT_FLAGS_M) != 0)
625                 return ICE_ERR_PARAM;
626
627         /* Adapter info must match the HW device ID */
628         adapter_info = ice_nvm_access_get_adapter(cmd);
629         if (adapter_info != hw->device_id)
630                 return ICE_ERR_PARAM;
631
632         switch (cmd->command) {
633         case ICE_NVM_CMD_READ:
634                 module = ice_nvm_access_get_module(cmd);
635                 flags = ice_nvm_access_get_flags(cmd);
636
637                 /* Getting the driver's NVM features structure shares the same
638                  * command type as reading a register. Read the config field
639                  * to determine if this is a request to get features.
640                  */
641                 if (module == ICE_NVM_GET_FEATURES_MODULE &&
642                     flags == ICE_NVM_GET_FEATURES_FLAGS &&
643                     cmd->offset == 0)
644                         return ice_nvm_access_get_features(cmd, data);
645                 else
646                         return ice_nvm_access_read(hw, cmd, data);
647         case ICE_NVM_CMD_WRITE:
648                 return ice_nvm_access_write(hw, cmd, data);
649         default:
650                 return ICE_ERR_PARAM;
651         }
652 }