iPXE
mlx_nvconfig.h
Go to the documentation of this file.
00001 #ifndef MLX_NVCONFIG_H_
00002 #define MLX_NVCONFIG_H_
00003 
00004 /*
00005  * Copyright (C) 2015 Mellanox Technologies Ltd.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License as
00009  * published by the Free Software Foundation; either version 2 of the
00010  * License, or any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020  * 02110-1301, USA.
00021  */
00022 
00023 FILE_LICENCE ( GPL2_OR_LATER );
00024 
00025 #include "../mlx_reg_access/mlx_reg_access.h"
00026 #include "../../include/public/mlx_utils.h"
00027 
00028 typedef enum {
00029         NVRAM_TLV_CLASS_GLOBAL = 0,
00030         NVRAM_TLV_CLASS_PHYSICAL_PORT = 1,
00031         NVRAM_TLV_CLASS_HOST = 3,
00032 } NVRAM_CLASS_CODE;
00033 
00034 typedef enum {
00035         NVDA_NV_HEADER_WRITER_ID_UEFI_HII  = 0x6,
00036         NVDA_NV_HEADER_WRITER_ID_FLEXBOOT = 0x8,
00037 } NVDA_WRITER_ID;
00038 
00039 typedef enum {
00040   TLV_ACCESS_DEFAULT_DIS = 0,
00041   TLV_ACCESS_CURRENT = 1,
00042   TLV_ACCESS_DEFAULT_EN = 2,
00043 } NV_DEFAULT_OPT;
00044 
00045 struct nvconfig_tlv_type_per_port {
00046          mlx_uint32 param_idx   :16;
00047          mlx_uint32 port                :8;
00048          mlx_uint32 param_class :8;
00049 };
00050 
00051 struct nvconfig_tlv_type_per_host {
00052         mlx_uint32 param_idx    :10;
00053         mlx_uint32 function             :8;
00054         mlx_uint32 host                 :6;
00055         mlx_uint32 param_class  :8;
00056 };
00057 
00058 struct nvconfig_tlv_type_global {
00059         mlx_uint32 param_idx    :24;
00060         mlx_uint32 param_class  :8;
00061 };
00062 
00063 struct nvconfig_tlv_mapping{
00064         mlx_uint16      tlv_type;
00065         mlx_uint16      real_tlv_type;
00066         NVRAM_CLASS_CODE class_code;
00067         mlx_boolean fw_reset_needed;
00068 };
00069 
00070 union nvconfig_tlv_type {
00071         struct nvconfig_tlv_type_per_port per_port;
00072         struct nvconfig_tlv_type_per_host per_host;
00073         struct nvconfig_tlv_type_global global;
00074 };
00075 
00076 
00077 struct nvconfig_nvqc {
00078         union nvconfig_tlv_type tlv_type;
00079 /* -------------- */
00080          mlx_uint32 support_rd  :1; /*the configuration item is supported and can be read */
00081          mlx_uint32 support_wr  :1; /*the configuration item is supported and can be updated */
00082          mlx_uint32 reserved1   :2;
00083          mlx_uint32 version             :4; /*The maximum version of the configuration item currently supported by the firmware. */
00084          mlx_uint32 reserved2   :24;
00085 };
00086 
00087 
00088 struct nvconfig_header {
00089          mlx_uint32 length              :9; /*Size of configuration item data in bytes between 0..256 */
00090          mlx_uint32 reserved0   :3;
00091          mlx_uint32 version             :4; /* Configuration item version */
00092          mlx_uint32 writer_id   :5;
00093          mlx_uint32 reserved1   :1;
00094 
00095          mlx_uint32 access_mode :2; /*Defines which value of the Configuration Item will be accessed.
00096                                                                 0x0: NEXT - Next value to be applied
00097                                                                 0x1: CURRENT - Currently set values (only valid for Query operation) Supported only if NVGC.nvda_read_current_settings==1.
00098                                                                 0x2: FACTORY - Default factory values (only valid for Query operation). Supported only if NVGC.nvda_read_factory_settings==1.*/
00099 
00100          mlx_uint32 reserved2   :2;
00101          mlx_uint32 header_type :2;
00102          mlx_uint32 reserved3   :2;
00103          mlx_uint32 valid       :2;
00104 /* -------------- */
00105          union nvconfig_tlv_type tlv_type;;
00106 /* -------------- */
00107         mlx_uint32 crc                  :16;
00108         mlx_uint32 reserved             :16;
00109 
00110 };
00111 
00112 #define NVCONFIG_MAX_TLV_SIZE 256
00113 
00114 struct nvconfig_nvda {
00115         struct nvconfig_header nv_header;
00116         mlx_uint8 data[NVCONFIG_MAX_TLV_SIZE];
00117 };
00118 
00119 struct nv_conf_cap {
00120         /** WOL En/Dis **/
00121         mlx_uint8       wol_en;
00122         /** VPI En/Dis **/
00123         mlx_uint8       vpi_en;
00124 };
00125 
00126 struct mlx_nvconfig_virt_net_addr {
00127                 mlx_uint32      reserved1               :29;
00128                 mlx_uint32      erase_on_powerup:1;
00129                 mlx_uint32      reserverd2              :1;
00130                 mlx_uint32      virtual_mac_en  :1;
00131                 mlx_uint32      virtual_mac_high;
00132                 mlx_uint32      virtual_mac_low;
00133 };
00134 
00135 
00136 mlx_status
00137 nvconfig_query_capability(
00138                 IN mlx_utils *utils,
00139                 IN mlx_uint8 port,
00140                 IN mlx_uint16 tlv_type,
00141                 OUT mlx_boolean *read_supported,
00142                 OUT mlx_boolean *write_supported
00143                 );
00144 
00145 
00146 mlx_status
00147 nvconfig_nvdata_invalidate(
00148                 IN mlx_utils *utils,
00149                 IN mlx_uint8 port,
00150                 IN mlx_uint16 tlv_type
00151                 );
00152 
00153 mlx_status
00154 nvconfig_nvdata_access(
00155                 IN mlx_utils *utils,
00156                 IN mlx_uint8 port,
00157                 IN mlx_uint16 tlv_type,
00158                 IN REG_ACCESS_OPT opt,
00159                 IN mlx_size data_size,
00160                 IN NV_DEFAULT_OPT def_en,
00161                 IN NVDA_WRITER_ID writer_id,
00162                 IN OUT mlx_uint8 *version,
00163                 IN OUT mlx_void *data
00164                 );
00165 
00166 #endif /* MLX_NVCONFIG_H_ */