iPXE
Data Structures | Macros | Enumerations | Functions
mlx_nvconfig.h File Reference
#include "../mlx_reg_access/mlx_reg_access.h"
#include "../../include/public/mlx_utils.h"

Go to the source code of this file.

Data Structures

struct  nvconfig_tlv_type_per_port
 
struct  nvconfig_tlv_type_per_host
 
struct  nvconfig_tlv_type_global
 
struct  nvconfig_tlv_mapping
 
union  nvconfig_tlv_type
 
struct  nvconfig_nvqc
 
struct  nvconfig_header
 
struct  nvconfig_nvda
 
struct  nv_conf_cap
 
struct  mlx_nvconfig_virt_net_addr
 

Macros

#define NVCONFIG_MAX_TLV_SIZE   256
 

Enumerations

enum  NVRAM_CLASS_CODE { NVRAM_TLV_CLASS_GLOBAL = 0, NVRAM_TLV_CLASS_PHYSICAL_PORT = 1, NVRAM_TLV_CLASS_HOST = 3 }
 
enum  NVDA_WRITER_ID { NVDA_NV_HEADER_WRITER_ID_UEFI_HII = 0x6, NVDA_NV_HEADER_WRITER_ID_FLEXBOOT = 0x8 }
 
enum  NV_DEFAULT_OPT { TLV_ACCESS_DEFAULT_DIS = 0, TLV_ACCESS_CURRENT = 1, TLV_ACCESS_DEFAULT_EN = 2 }
 

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
mlx_status nvconfig_query_capability (IN mlx_utils *utils, IN mlx_uint8 port, IN mlx_uint16 tlv_type, OUT mlx_boolean *read_supported, OUT mlx_boolean *write_supported)
 
mlx_status nvconfig_nvdata_invalidate (IN mlx_utils *utils, IN mlx_uint8 port, IN mlx_uint16 tlv_type)
 
mlx_status nvconfig_nvdata_access (IN mlx_utils *utils, IN mlx_uint8 port, IN mlx_uint16 tlv_type, IN REG_ACCESS_OPT opt, IN mlx_size data_size, IN NV_DEFAULT_OPT def_en, IN NVDA_WRITER_ID writer_id, IN OUT mlx_uint8 *version, IN OUT mlx_void *data)
 

Macro Definition Documentation

◆ NVCONFIG_MAX_TLV_SIZE

#define NVCONFIG_MAX_TLV_SIZE   256

Definition at line 112 of file mlx_nvconfig.h.

Enumeration Type Documentation

◆ NVRAM_CLASS_CODE

Enumerator
NVRAM_TLV_CLASS_GLOBAL 
NVRAM_TLV_CLASS_PHYSICAL_PORT 
NVRAM_TLV_CLASS_HOST 

Definition at line 28 of file mlx_nvconfig.h.

◆ NVDA_WRITER_ID

Enumerator
NVDA_NV_HEADER_WRITER_ID_UEFI_HII 
NVDA_NV_HEADER_WRITER_ID_FLEXBOOT 

Definition at line 34 of file mlx_nvconfig.h.

◆ NV_DEFAULT_OPT

Enumerator
TLV_ACCESS_DEFAULT_DIS 
TLV_ACCESS_CURRENT 
TLV_ACCESS_DEFAULT_EN 

Definition at line 39 of file mlx_nvconfig.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ nvconfig_query_capability()

mlx_status nvconfig_query_capability ( IN mlx_utils utils,
IN mlx_uint8  port,
IN mlx_uint16  tlv_type,
OUT mlx_boolean read_supported,
OUT mlx_boolean write_supported 
)

Definition at line 155 of file mlx_nvconfig.c.

162 {
164  struct nvconfig_nvqc nvqc;
165  mlx_uint32 reg_status;
166  NVRAM_CLASS_CODE class_code;
167  mlx_uint16 real_tlv_type;
168 
169  if (utils == NULL || read_supported == NULL || write_supported == NULL) {
171  goto bad_param;
172  }
173 
174  status = nvconfig_get_tlv_type_and_class(tlv_type, &real_tlv_type, &class_code);
175  MLX_CHECK_STATUS(utils, status, tlv_not_supported, "tlv not supported");
176 
177  mlx_memory_set(utils, &nvqc, 0, sizeof(nvqc));
178  nvconfig_fill_tlv_type(port, class_code, real_tlv_type, &nvqc.tlv_type);
179 
180  status = mlx_reg_access(utils, REG_ID_NVQC, REG_ACCESS_READ, &nvqc, sizeof(nvqc),
181  &reg_status);
182  MLX_CHECK_STATUS(utils, status, reg_err, "mlx_reg_access failed ");
183  if (reg_status != 0) {
184  MLX_DEBUG_ERROR(utils,"mlx_reg_access failed with status = %d\n", reg_status);
185  status = MLX_FAILED;
186  goto reg_err;
187  }
188  *read_supported = nvqc.support_rd;
189  *write_supported = nvqc.support_wr;
190 reg_err:
191 tlv_not_supported:
192 bad_param:
193  return status;
194 }
static mlx_status nvconfig_get_tlv_type_and_class(IN mlx_uint16 tlv_type, OUT mlx_uint16 *real_tlv_type, OUT NVRAM_CLASS_CODE *class_code)
Definition: mlx_nvconfig.c:113
#define MLX_INVALID_PARAMETER
#define REG_ID_NVQC
static void nvconfig_fill_tlv_type(IN mlx_uint8 port, IN NVRAM_CLASS_CODE class_code, IN mlx_uint16 tlv_type, OUT union nvconfig_tlv_type *nvconfig_tlv_type)
Definition: mlx_nvconfig.c:131
uint8_t status
Status.
Definition: ena.h:16
uint32_t mlx_uint32
mlx_status mlx_memory_set(IN mlx_utils *utils, IN mlx_void *block, IN mlx_int32 value, IN mlx_size size)
Definition: mlx_memory.c:171
u8 port
Port number.
Definition: CIB_PRM.h:31
#define MLX_SUCCESS
#define MLX_FAILED
uint16_t mlx_uint16
union nvconfig_tlv_type tlv_type
Definition: mlx_nvconfig.h:78
#define MLX_DEBUG_ERROR(...)
Definition: mlx_logging.h:29
int mlx_status
mlx_status mlx_reg_access(IN mlx_utils *utils, IN mlx_uint16 reg_id, IN REG_ACCESS_OPT reg_opt, IN OUT mlx_void *reg_data, IN mlx_size reg_size, OUT mlx_uint32 *reg_status)
NVRAM_CLASS_CODE
Definition: mlx_nvconfig.h:28
#define MLX_CHECK_STATUS(id, status, label, message)
Definition: mlx_bail.h:37
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References MLX_CHECK_STATUS, MLX_DEBUG_ERROR, MLX_FAILED, MLX_INVALID_PARAMETER, mlx_memory_set(), mlx_reg_access(), MLX_SUCCESS, NULL, nvconfig_fill_tlv_type(), nvconfig_get_tlv_type_and_class(), port, REG_ACCESS_READ, REG_ID_NVQC, status, nvconfig_nvqc::support_rd, nvconfig_nvqc::support_wr, and nvconfig_nvqc::tlv_type.

◆ nvconfig_nvdata_invalidate()

mlx_status nvconfig_nvdata_invalidate ( IN mlx_utils utils,
IN mlx_uint8  port,
IN mlx_uint16  tlv_type 
)

Definition at line 197 of file mlx_nvconfig.c.

202 {
204  struct nvconfig_header nv_header;
205  mlx_uint32 reg_status;
206  NVRAM_CLASS_CODE class_code;
207  mlx_uint16 real_tlv_type;
208 
209  if (utils == NULL) {
211  goto bad_param;
212  }
213 
214  status = nvconfig_get_tlv_type_and_class(tlv_type, &real_tlv_type, &class_code);
215  MLX_CHECK_STATUS(utils, status, tlv_not_supported, "tlv not supported");
216 
217  mlx_memory_set(utils, &nv_header, 0, sizeof(nv_header));
218  nvconfig_fill_tlv_type(port, class_code, real_tlv_type, &nv_header.tlv_type);
219 
220  status = mlx_reg_access(utils, REG_ID_NVDI, REG_ACCESS_WRITE, &nv_header, sizeof(nv_header),
221  &reg_status);
222  MLX_CHECK_STATUS(utils, status, reg_err, "mlx_reg_access failed ");
223  if (reg_status != 0) {
224  MLX_DEBUG_ERROR(utils,"mlx_reg_access failed with status = %d\n", reg_status);
225  status = MLX_FAILED;
226  goto reg_err;
227  }
228 reg_err:
229 tlv_not_supported:
230 bad_param:
231  return status;
232 }
static mlx_status nvconfig_get_tlv_type_and_class(IN mlx_uint16 tlv_type, OUT mlx_uint16 *real_tlv_type, OUT NVRAM_CLASS_CODE *class_code)
Definition: mlx_nvconfig.c:113
#define MLX_INVALID_PARAMETER
#define REG_ID_NVDI
static void nvconfig_fill_tlv_type(IN mlx_uint8 port, IN NVRAM_CLASS_CODE class_code, IN mlx_uint16 tlv_type, OUT union nvconfig_tlv_type *nvconfig_tlv_type)
Definition: mlx_nvconfig.c:131
uint8_t status
Status.
Definition: ena.h:16
uint32_t mlx_uint32
union nvconfig_tlv_type tlv_type
Definition: mlx_nvconfig.h:105
mlx_status mlx_memory_set(IN mlx_utils *utils, IN mlx_void *block, IN mlx_int32 value, IN mlx_size size)
Definition: mlx_memory.c:171
u8 port
Port number.
Definition: CIB_PRM.h:31
#define MLX_SUCCESS
#define MLX_FAILED
uint16_t mlx_uint16
#define MLX_DEBUG_ERROR(...)
Definition: mlx_logging.h:29
int mlx_status
mlx_status mlx_reg_access(IN mlx_utils *utils, IN mlx_uint16 reg_id, IN REG_ACCESS_OPT reg_opt, IN OUT mlx_void *reg_data, IN mlx_size reg_size, OUT mlx_uint32 *reg_status)
NVRAM_CLASS_CODE
Definition: mlx_nvconfig.h:28
#define MLX_CHECK_STATUS(id, status, label, message)
Definition: mlx_bail.h:37
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References MLX_CHECK_STATUS, MLX_DEBUG_ERROR, MLX_FAILED, MLX_INVALID_PARAMETER, mlx_memory_set(), mlx_reg_access(), MLX_SUCCESS, NULL, nvconfig_fill_tlv_type(), nvconfig_get_tlv_type_and_class(), port, REG_ACCESS_WRITE, REG_ID_NVDI, status, and nvconfig_header::tlv_type.

◆ nvconfig_nvdata_access()

mlx_status nvconfig_nvdata_access ( IN mlx_utils utils,
IN mlx_uint8  port,
IN mlx_uint16  tlv_type,
IN REG_ACCESS_OPT  opt,
IN mlx_size  data_size,
IN NV_DEFAULT_OPT  def_en,
IN NVDA_WRITER_ID  writer_id,
IN OUT mlx_uint8 version,
IN OUT mlx_void data 
)

Definition at line 235 of file mlx_nvconfig.c.

246 {
248  struct nvconfig_nvda nvda;
249  mlx_uint32 reg_status;
250  mlx_uint32 real_size_to_read;
252  NVRAM_CLASS_CODE class_code;
253  mlx_uint16 real_tlv_type;
254  mlx_size data_size_align_to_dword;
255 
256  if (utils == NULL || data == NULL || data_size > NVCONFIG_MAX_TLV_SIZE) {
258  goto bad_param;
259  }
260 
261  status = nvconfig_get_tlv_type_and_class(tlv_type, &real_tlv_type, &class_code);
262  MLX_CHECK_STATUS(utils, status, tlv_not_supported, "tlv not supported");
263 
264  data_size_align_to_dword = ((data_size + 3) / sizeof(mlx_uint32)) * sizeof(mlx_uint32);
265  mlx_memory_set(utils, &nvda, 0, sizeof(nvda));
266  nvda.nv_header.length = data_size_align_to_dword;
267  nvda.nv_header.access_mode = def_en;
268  nvda.nv_header.version = *version;
269  nvda.nv_header.writer_id = writer_id;
270 
271  nvconfig_fill_tlv_type(port, class_code, real_tlv_type, &nvda.nv_header.tlv_type);
272 
273  mlx_memory_cpy(utils, nvda.data, data, data_size);
274  for (index = 0 ; index * 4 < NVCONFIG_MAX_TLV_SIZE ; index++) {
275  mlx_memory_be32_to_cpu(utils,(((mlx_uint32 *)nvda.data)[index]), ((mlx_uint32 *)nvda.data) + index);
276  }
277  status = mlx_reg_access(utils, REG_ID_NVDA, opt, &nvda,
278  data_size_align_to_dword + sizeof(nvda.nv_header), &reg_status);
279  MLX_CHECK_STATUS(utils, status, reg_err, "mlx_reg_access failed ");
280  if (reg_status != 0) {
281  MLX_DEBUG_ERROR(utils,"mlx_reg_access failed with status = %d\n", reg_status);
282  status = MLX_FAILED;
283  goto reg_err;
284  }
285  for (index = 0 ; index * 4 < NVCONFIG_MAX_TLV_SIZE ; index++) {
286  mlx_memory_cpu_to_be32(utils,(((mlx_uint32 *)nvda.data)[index]), ((mlx_uint32 *)nvda.data) + index);
287  }
288  if (opt == REG_ACCESS_READ) {
289  real_size_to_read = (nvda.nv_header.length > data_size) ? data_size :
290  nvda.nv_header.length;
291  mlx_memory_cpy(utils, data, nvda.data, real_size_to_read);
292  *version = nvda.nv_header.version;
293  } else {
294  nvconfig_set_fw_reset_level(utils, tlv_type);
295  }
296 reg_err:
297 tlv_not_supported:
298 bad_param:
299  return status;
300 }
mlx_status mlx_memory_cpu_to_be32(IN mlx_utils *utils, IN mlx_uint32 source, IN mlx_uint32 *destination)
Definition: mlx_memory.c:207
static mlx_status nvconfig_get_tlv_type_and_class(IN mlx_uint16 tlv_type, OUT mlx_uint16 *real_tlv_type, OUT NVRAM_CLASS_CODE *class_code)
Definition: mlx_nvconfig.c:113
#define MLX_INVALID_PARAMETER
static void nvconfig_fill_tlv_type(IN mlx_uint8 port, IN NVRAM_CLASS_CODE class_code, IN mlx_uint16 tlv_type, OUT union nvconfig_tlv_type *nvconfig_tlv_type)
Definition: mlx_nvconfig.c:131
uint8_t status
Status.
Definition: ena.h:16
uint32_t mlx_uint32
mlx_status mlx_memory_set(IN mlx_utils *utils, IN mlx_void *block, IN mlx_int32 value, IN mlx_size size)
Definition: mlx_memory.c:171
u8 port
Port number.
Definition: CIB_PRM.h:31
u32 version
Version number.
Definition: ath9k_hw.c:1983
static mlx_status nvconfig_set_fw_reset_level(IN mlx_utils *utils, IN mlx_uint16 tlv_type)
Definition: mlx_nvconfig.c:75
#define MLX_SUCCESS
size_t mlx_size
#define REG_ID_NVDA
#define MLX_FAILED
uint16_t mlx_uint16
#define NVCONFIG_MAX_TLV_SIZE
Definition: mlx_nvconfig.h:112
mlx_status mlx_memory_cpy(IN mlx_utils *utils, OUT mlx_void *destination_buffer, IN mlx_void *source_buffer, IN mlx_size length)
Definition: mlx_memory.c:189
#define MLX_DEBUG_ERROR(...)
Definition: mlx_logging.h:29
int mlx_status
mlx_status mlx_memory_be32_to_cpu(IN mlx_utils *utils, IN mlx_uint32 source, IN mlx_uint32 *destination)
Definition: mlx_memory.c:224
mlx_status mlx_reg_access(IN mlx_utils *utils, IN mlx_uint16 reg_id, IN REG_ACCESS_OPT reg_opt, IN OUT mlx_void *reg_data, IN mlx_size reg_size, OUT mlx_uint32 *reg_status)
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
NVRAM_CLASS_CODE
Definition: mlx_nvconfig.h:28
#define MLX_CHECK_STATUS(id, status, label, message)
Definition: mlx_bail.h:37
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References nvconfig_header::access_mode, data, nvconfig_nvda::data, index, nvconfig_header::length, MLX_CHECK_STATUS, MLX_DEBUG_ERROR, MLX_FAILED, MLX_INVALID_PARAMETER, mlx_memory_be32_to_cpu(), mlx_memory_cpu_to_be32(), mlx_memory_cpy(), mlx_memory_set(), mlx_reg_access(), MLX_SUCCESS, NULL, nvconfig_nvda::nv_header, nvconfig_fill_tlv_type(), nvconfig_get_tlv_type_and_class(), NVCONFIG_MAX_TLV_SIZE, nvconfig_set_fw_reset_level(), port, REG_ACCESS_READ, REG_ID_NVDA, status, nvconfig_header::tlv_type, nvconfig_header::version, version, and nvconfig_header::writer_id.

Referenced by nvconfig_nvdata_default_access(), and nvconfig_read_rom_ini_values().