[golan] Add Connect-IB, ConnectX-4 and ConnectX-4 Lx (Infiniband) support

Signed-off-by: Wissam Shoukair <wissams@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Wissam Shoukair
2016-03-22 17:55:55 +00:00
committed by Michael Brown
parent 3df598849b
commit 0a20373a2f
57 changed files with 13097 additions and 0 deletions
@@ -0,0 +1,54 @@
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "../../mlx_lib/mlx_blink_leds/mlx_blink_leds.h"
#include "../../include/public/mlx_memory.h"
#include "../../include/public/mlx_bail.h"
mlx_status
mlx_blink_leds(
IN mlx_utils *utils,
IN mlx_uint16 secs
)
{
mlx_status status = MLX_SUCCESS;
struct mlx_led_control led_control;
mlx_uint32 reg_status;
if (utils == NULL ) {
status = MLX_INVALID_PARAMETER;
goto bad_param;
}
mlx_memory_set(utils, &led_control, 0, sizeof(led_control));
led_control.beacon_duration = secs;
status = mlx_reg_access(utils, REG_ID_MLCR, REG_ACCESS_WRITE, &led_control, sizeof(led_control),
&reg_status);
MLX_CHECK_STATUS(utils, status, reg_err, "mlx_reg_access failed ");
if (reg_status != 0) {
MLX_DEBUG_ERROR(utils,"mlx_reg_access failed with status = %d\n", reg_status);
status = MLX_FAILED;
goto reg_err;
}
reg_err:
bad_param:
return status;
}
@@ -0,0 +1,46 @@
#ifndef MLX_BLINK_LEDS_H_
#define MLX_BLINK_LEDS_H_
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "../../mlx_lib/mlx_reg_access/mlx_reg_access.h"
#include "../../include/public/mlx_utils.h"
struct mlx_led_control {
mlx_uint32 reserved1 :16;
mlx_uint32 port :8;
mlx_uint32 bla :8;
/* -------------- */
mlx_uint32 beacon_duration :16;
mlx_uint32 reserved2 :16;
/* -------------- */
mlx_uint32 beacon_remain :16;
mlx_uint32 reserved3 :16;
};
mlx_status
mlx_blink_leds(
IN mlx_utils *utils,
IN mlx_uint16 secs
);
#endif /* MLX_NVCONFIG_H_ */
@@ -0,0 +1,180 @@
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "../../mlx_lib/mlx_link_speed/mlx_link_speed.h"
#include "../../include/public/mlx_memory.h"
#include "../../include/public/mlx_bail.h"
mlx_status
mlx_set_link_speed(
IN mlx_utils *utils,
IN mlx_uint8 port_num,
IN LINK_SPEED_TYPE type,
IN LINK_SPEED speed
)
{
mlx_status status = MLX_SUCCESS;
struct mlx_link_speed link_speed;
mlx_uint32 reg_status;
if (utils == NULL) {
status = MLX_INVALID_PARAMETER;
goto bad_param;
}
mlx_memory_set(utils, &link_speed, 0, sizeof(link_speed));
link_speed.loacl_port = port_num;
link_speed.proto_mask = 1 << type;
status = mlx_reg_access(utils, REG_ID_PTYS, REG_ACCESS_READ, &link_speed,
sizeof(link_speed), &reg_status);
MLX_CHECK_STATUS(utils, status, reg_err, "mlx_reg_access failed ");
if (reg_status != 0) {
MLX_DEBUG_ERROR(utils,"mlx_reg_access failed with status = %d\n", reg_status);
status = MLX_FAILED;
goto reg_err;
}
switch (speed) {
case LINK_SPEED_1GB:
link_speed.eth_proto_admin = link_speed.eth_proto_capability & LINK_SPEED_1GB_MASK;
break;
case LINK_SPEED_10GB:
link_speed.eth_proto_admin = link_speed.eth_proto_capability & LINK_SPEED_10GB_MASK;
break;
case LINK_SPEED_40GB:
link_speed.eth_proto_admin = link_speed.eth_proto_capability & LINK_SPEED_40GB_MASK;
break;
case LINK_SPEED_100GB:
link_speed.eth_proto_admin = link_speed.eth_proto_capability & LINK_SPEED_100GB_MASK;
break;
case LINK_SPEED_SDR:
link_speed.ib_proto_admin = link_speed.ib_proto_capability & LINK_SPEED_SDR_MASK;
break;
case LINK_SPEED_DEFAULT:
if (type == LINK_SPEED_ETH) {
link_speed.eth_proto_admin = link_speed.eth_proto_capability;
} else {
link_speed.ib_proto_admin = link_speed.ib_proto_capability;
}
break;
}
status = mlx_reg_access(utils, REG_ID_PTYS, REG_ACCESS_WRITE, &link_speed,
sizeof(link_speed), &reg_status);
MLX_CHECK_STATUS(utils, status, reg_err, "mlx_reg_access failed ");
if (reg_status != 0) {
MLX_DEBUG_ERROR(utils,"mlx_reg_access failed with status = %d\n", reg_status);
status = MLX_FAILED;
goto reg_err;
}
reg_err:
bad_param:
return status;
}
mlx_status
mlx_get_max_speed(
IN mlx_utils *utils,
IN mlx_uint8 port_num,
IN LINK_SPEED_TYPE type,
OUT mlx_uint64 *speed
)
{
mlx_status status = MLX_SUCCESS;
struct mlx_link_speed link_speed;
mlx_uint32 reg_status;
mlx_uint64 speed_giga = 0;
mlx_uint8 lanes_number = 1;
*speed = 0;
if (utils == NULL) {
status = MLX_INVALID_PARAMETER;
goto bad_param;
}
mlx_memory_set(utils, &link_speed, 0, sizeof(link_speed));
link_speed.loacl_port = port_num;
link_speed.proto_mask = 1 << type;
status = mlx_reg_access(utils, REG_ID_PTYS, REG_ACCESS_READ, &link_speed,
sizeof(link_speed), &reg_status);
MLX_CHECK_STATUS(utils, status, reg_err, "mlx_reg_access failed ");
if (reg_status != 0) {
MLX_DEBUG_ERROR(utils,"mlx_reg_access failed with status = %d\n", reg_status);
status = MLX_FAILED;
goto reg_err;
}
if ( type == LINK_SPEED_ETH ) {
if ( link_speed.eth_proto_capability & LINK_SPEED_100GB_MASK ) {
speed_giga = 100;
} else if ( link_speed.eth_proto_capability & LINK_SPEED_56GB_MASK ) {
speed_giga = 56;
} else if ( link_speed.eth_proto_capability & LINK_SPEED_50GB_MASK ) {
speed_giga = 50;
} else if ( link_speed.eth_proto_capability & LINK_SPEED_40GB_MASK ) {
speed_giga = 40;
} else if (link_speed.eth_proto_capability & LINK_SPEED_25GB_MASK) {
speed_giga = 25;
} else if ( link_speed.eth_proto_capability & LINK_SPEED_20GB_MASK ) {
speed_giga = 20;
} else if ( link_speed.eth_proto_capability & LINK_SPEED_10GB_MASK) {
speed_giga = 10;
} else if ( link_speed.eth_proto_capability & LINK_SPEED_1GB_MASK ) {
speed_giga = 1;
}
} else {
if ( link_speed.ib_proto_capability & LINK_SPEED_EDR_MASK ) {
speed_giga = 25;
} else if ( link_speed.ib_proto_capability & LINK_SPEED_EDR20_MASK ) {
speed_giga = 20;
} else if ( link_speed.ib_proto_capability & LINK_SPEED_FDR_MASK ) {
speed_giga = 14;
} else if ( link_speed.ib_proto_capability & LINK_SPEED_QDR_MASK ) {
speed_giga = 10;
} else if ( link_speed.ib_proto_capability & LINK_SPEED_DDR_MASK ) {
speed_giga = 5;
} else if ( link_speed.ib_proto_capability & LINK_SPEED_SDR_MASK ) {
speed_giga = 2.5;
}
if ( link_speed.ib_link_width_capability & LINK_SPEED_WITDH_12_MASK ) {
lanes_number = 12;
} else if ( link_speed.ib_link_width_capability & LINK_SPEED_WITDH_8_MASK ) {
lanes_number = 8;
} else if (link_speed.ib_link_width_capability & LINK_SPEED_WITDH_4_MASK ) {
lanes_number = 4;
} else if (link_speed.ib_link_width_capability & LINK_SPEED_WITDH_2_MASK ) {
lanes_number = 2;
} else if (link_speed.ib_link_width_capability & LINK_SPEED_WITDH_1_MASK ) {
lanes_number = 1;
}
speed_giga = speed_giga * lanes_number;
}
// Return data in bits
*speed = speed_giga * GIGA_TO_BIT;
reg_err:
bad_param:
return status;
}
@@ -0,0 +1,145 @@
#ifndef MLX_LINK_SPEED_H_
#define MLX_LINK_SPEED_H_
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "../../mlx_lib/mlx_reg_access/mlx_reg_access.h"
#include "../../include/public/mlx_utils.h"
#define LINK_SPEED_100GB_MASK (ETH_SPEED_ENABLE_MASK_100GBASECR4 | ETH_SPEED_ENABLE_MASK_100GBASESR4 | ETH_SPEED_ENABLE_MASK_100GBASEKR4 | ETH_SPEED_ENABLE_MASK_100GBASELR4)
#define LINK_SPEED_56GB_MASK (ETH_SPEED_ENABLE_MASK_56GBASER4)
#define LINK_SPEED_50GB_MASK (ETH_SPEED_ENABLE_MASK_50GBASECR2 | ETH_SPEED_ENABLE_MASK_50GBASEKR2)
#define LINK_SPEED_40GB_MASK (ETH_SPEED_ENABLE_MASK_40GBASECR4 | ETH_SPEED_ENABLE_MASK_40GBASEKR4 | ETH_SPEED_ENABLE_MASK_40GBASESR4 | ETH_SPEED_ENABLE_MASK_40GBASELR4)
#define LINK_SPEED_25GB_MASK (ETH_SPEED_ENABLE_MASK_25GBASECR | ETH_SPEED_ENABLE_MASK_25GBASEKR | ETH_SPEED_ENABLE_MASK_25GBASESR)
#define LINK_SPEED_20GB_MASK (ETH_SPEED_ENABLE_MASK_20GBASER2)
#define LINK_SPEED_10GB_MASK (ETH_SPEED_ENABLE_MASK_10GBASECR | ETH_SPEED_ENABLE_MASK_10GBASESR | ETH_SPEED_ENABLE_MASK_10GBASELR | ETH_SPEED_ENABLE_MASK_10GBASEKR)
#define LINK_SPEED_1GB_MASK (ETH_SPEED_ENABLE_MASK_1000BASECX | ETH_SPEED_ENABLE_MASK_1000BASEKX | ETH_SPEED_ENABLE_MASK_100BaseTX | ETH_SPEED_ENABLE_MASK_1000BASET)
#define LINK_SPEED_SDR_MASK 0x1
#define LINK_SPEED_DDR_MASK 0x2
#define LINK_SPEED_QDR_MASK 0xC
#define LINK_SPEED_FDR_MASK 0x10
#define LINK_SPEED_EDR20_MASK 0x200
#define LINK_SPEED_EDR_MASK 0x20
#define LINK_SPEED_WITDH_1_MASK 0x1
#define LINK_SPEED_WITDH_2_MASK 0x2
#define LINK_SPEED_WITDH_4_MASK 0x4
#define LINK_SPEED_WITDH_8_MASK 0x8
#define LINK_SPEED_WITDH_12_MASK 0x10
#define GIGA_TO_BIT 0x40000000
enum {
ETH_SPEED_ENABLE_MASK_1000BASECX = 0x0001,
ETH_SPEED_ENABLE_MASK_1000BASEKX = 0x0002,
ETH_SPEED_ENABLE_MASK_10GBASECX4 = 0x0004,
ETH_SPEED_ENABLE_MASK_10GBASEKX4 = 0x0008,
ETH_SPEED_ENABLE_MASK_10GBASEKR = 0x0010,
ETH_SPEED_ENABLE_MASK_20GBASER2 = 0x0020,
ETH_SPEED_ENABLE_MASK_40GBASECR4 = 0x0040,
ETH_SPEED_ENABLE_MASK_40GBASEKR4 = 0x0080,
ETH_SPEED_ENABLE_MASK_56GBASER4 = 0x0100,
ETH_SPEED_ENABLE_MASK_10GBASECR = 0x1000,
ETH_SPEED_ENABLE_MASK_10GBASESR = 0x2000,
ETH_SPEED_ENABLE_MASK_10GBASELR = 0x4000,
ETH_SPEED_ENABLE_MASK_40GBASESR4 = 0x8000,
ETH_SPEED_ENABLE_MASK_40GBASELR4 = 0x10000,
ETH_SPEED_ENABLE_MASK_50GBASEKR4 = 0x80000,
ETH_SPEED_ENABLE_MASK_100GBASECR4 = 0x100000,
ETH_SPEED_ENABLE_MASK_100GBASESR4 = 0x200000,
ETH_SPEED_ENABLE_MASK_100GBASEKR4 = 0x400000,
ETH_SPEED_ENABLE_MASK_100GBASELR4 = 0x800000,
ETH_SPEED_ENABLE_MASK_100BaseTX = 0x1000000,
ETH_SPEED_ENABLE_MASK_1000BASET = 0x2000000,
ETH_SPEED_ENABLE_MASK_10GBASET = 0x4000000,
ETH_SPEED_ENABLE_MASK_25GBASECR = 0x8000000,
ETH_SPEED_ENABLE_MASK_25GBASEKR = 0x10000000,
ETH_SPEED_ENABLE_MASK_25GBASESR = 0x20000000,
ETH_SPEED_ENABLE_MASK_50GBASECR2 = 0x40000000,
ETH_SPEED_ENABLE_MASK_50GBASEKR2 = 0x80000000,
ETH_SPEED_ENABLE_MASK_BAD = 0xffff,
};
typedef enum {
LINK_SPEED_IB = 0,
LINK_SPEED_FC,
LINK_SPEED_ETH,
} LINK_SPEED_TYPE;
typedef enum {
LINK_SPEED_1GB = 0,
LINK_SPEED_10GB,
LINK_SPEED_40GB,
LINK_SPEED_100GB,
LINK_SPEED_SDR,
LINK_SPEED_DEFAULT,
} LINK_SPEED;
struct mlx_link_speed {
mlx_uint32 proto_mask :3;
mlx_uint32 reserved1 :13;
mlx_uint32 loacl_port :8;
mlx_uint32 reserved2 :8;
/* -------------- */
mlx_uint32 reserved3 :32;
/* -------------- */
mlx_uint32 reserved4 :32;
/* -------------- */
mlx_uint32 eth_proto_capability :32;
/* -------------- */
mlx_uint32 ib_proto_capability :16;
mlx_uint32 ib_link_width_capability :16;
/* -------------- */
mlx_uint32 reserved5 :32;
/* -------------- */
mlx_uint32 eth_proto_admin :32;
/* -------------- */
mlx_uint32 ib_proto_admin :16;
mlx_uint32 ib_link_width_admin :16;
/* -------------- */
mlx_uint32 reserved6 :32;
/* -------------- */
mlx_uint32 eth_proto_oper :32;
/* -------------- */
mlx_uint32 ib_proto_oper :16;
mlx_uint32 ib_link_width_oper :16;
};
mlx_status
mlx_set_link_speed(
IN mlx_utils *utils,
IN mlx_uint8 port_num,
IN LINK_SPEED_TYPE type,
IN LINK_SPEED speed
);
mlx_status
mlx_get_max_speed(
IN mlx_utils *utils,
IN mlx_uint8 port_num,
IN LINK_SPEED_TYPE type,
OUT mlx_uint64 *speed
);
#endif /* MLX_LINK_SPEED_H_ */
@@ -0,0 +1,60 @@
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "mlx_mtu.h"
#include "mlx_memory.h"
#include "mlx_bail.h"
mlx_status
mlx_get_max_mtu(
IN mlx_utils *utils,
IN mlx_uint8 port_num,
OUT mlx_uint32 *max_mtu
)
{
mlx_status status = MLX_SUCCESS;
struct mlx_mtu mtu;
mlx_uint32 reg_status;
*max_mtu = 0;
if (utils == NULL) {
status = MLX_INVALID_PARAMETER;
goto bad_param;
}
mlx_memory_set(utils, &mtu, 0, sizeof(mtu));
mtu.local_port = port_num;
status = mlx_reg_access(utils, REG_ID_PMTU, REG_ACCESS_READ, &mtu,
sizeof(mtu), &reg_status);
MLX_CHECK_STATUS(utils, status, reg_err, "mlx_reg_access failed ");
if (reg_status != 0) {
MLX_DEBUG_ERROR(utils,"mlx_reg_access failed with status = %d\n", reg_status);
status = MLX_FAILED;
goto reg_err;
}
// Return data in bits
*max_mtu = mtu.max_mtu * BYTE_TO_BIT;
reg_err:
bad_param:
return status;
}
@@ -0,0 +1,52 @@
#ifndef MLX_MTU_H_
#define MLX_MTU_H_
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "mlx_reg_access.h"
#include "mlx_utils.h"
#define BYTE_TO_BIT 0x8
struct mlx_mtu {
mlx_uint32 reserved1 :16;
mlx_uint32 local_port :8;
mlx_uint32 reserved2 :8;
/* -------------- */
mlx_uint32 reserved3 :16;
mlx_uint32 max_mtu :16;
/* -------------- */
mlx_uint32 reserved4 :16;
mlx_uint32 admin_mtu :16;
/* -------------- */
mlx_uint32 reserved5 :16;
mlx_uint32 oper_mtu :16;
};
mlx_status
mlx_get_max_mtu(
IN mlx_utils *utils,
IN mlx_uint8 port_num,
OUT mlx_uint32 *max_mtu
);
#endif /* MLX_MTU_H_ */
@@ -0,0 +1,295 @@
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "../../mlx_lib/mlx_nvconfig/mlx_nvconfig.h"
#include "../../include/public/mlx_memory.h"
#include "../../include/public/mlx_bail.h"
#define TlvMappingEntry( _tlv_type, _real_tlv_type, _class_code, _fw_reset_needed) { \
.tlv_type = _tlv_type, \
.real_tlv_type = _real_tlv_type, \
.class_code = _class_code, \
.fw_reset_needed = _fw_reset_needed, \
}
struct nvconfig_tlv_mapping nvconfig_tlv_mapping[] = {
TlvMappingEntry(0x10, 0x10, NVRAM_TLV_CLASS_HOST, TRUE),
TlvMappingEntry(0x12, 0x12, NVRAM_TLV_CLASS_PHYSICAL_PORT, TRUE),
TlvMappingEntry(0x80, 0x80, NVRAM_TLV_CLASS_GLOBAL, TRUE),
TlvMappingEntry(0x81, 0x81, NVRAM_TLV_CLASS_GLOBAL, TRUE),
TlvMappingEntry(0x100, 0x100, NVRAM_TLV_CLASS_GLOBAL, TRUE),
TlvMappingEntry(0x2001, 0x195, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2010, 0x210, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2011, 0x211, NVRAM_TLV_CLASS_GLOBAL, FALSE),
TlvMappingEntry(0x2020, 0x2020, NVRAM_TLV_CLASS_PHYSICAL_PORT, FALSE),
TlvMappingEntry(0x2021, 0x221, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2023, 0x223, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2100, 0x230, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2101, 0x231, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2102, 0x232, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2103, 0x233, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2104, 0x234, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2105, 0x235, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2106, 0x236, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2107, 0x237, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2108, 0x238, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2109, 0x239, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x210A, 0x23A, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2200, 0x240, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2201, 0x241, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2202, 0x242, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2203, 0x243, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2204, 0x244, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2205, 0x245, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0x2207, 0x247, NVRAM_TLV_CLASS_HOST, FALSE),
TlvMappingEntry(0, 0, 0, 0),
};
static
mlx_status
nvconfig_set_fw_reset_level(
IN mlx_utils *utils,
IN mlx_uint16 tlv_type
)
{
#define WARM_REBOOT_RESET ((mlx_uint64)0x1 << 38)
mlx_status status = MLX_SUCCESS;
mlx_uint32 reg_status;
mlx_uint64 mfrl = WARM_REBOOT_RESET ;
mlx_uint8 index = 0;
mlx_boolean reset_needed = FALSE;
for (index = 0 ; nvconfig_tlv_mapping[index].tlv_type != 0 ; index++) {
if (nvconfig_tlv_mapping[index].tlv_type == tlv_type) {
reset_needed = nvconfig_tlv_mapping[index].fw_reset_needed;
}
}
if (reset_needed == FALSE) {
goto no_fw_reset_needed;
}
status = mlx_reg_access(utils, REG_ID_MFRL, REG_ACCESS_WRITE, &mfrl, sizeof(mfrl),
&reg_status);
MLX_CHECK_STATUS(utils, status, reg_err, "mlx_reg_access failed ");
if (reg_status != 0) {
MLX_DEBUG_ERROR(utils,"nvconfig_set_fw_reset_level failed with status = %d\n", reg_status);
status = MLX_FAILED;
goto reg_err;
}
reg_err:
no_fw_reset_needed:
return status;
}
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
)
{
mlx_uint8 index = 0;
for ( ; nvconfig_tlv_mapping[index].tlv_type != 0 ; index ++) {
if ( nvconfig_tlv_mapping[index].tlv_type == tlv_type) {
*real_tlv_type = nvconfig_tlv_mapping[index].real_tlv_type;
*class_code = nvconfig_tlv_mapping[index].class_code;
return MLX_SUCCESS;
}
}
return MLX_NOT_FOUND;
}
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
)
{
switch (class_code) {
case NVRAM_TLV_CLASS_GLOBAL:
nvconfig_tlv_type->global.param_class = NVRAM_TLV_CLASS_GLOBAL;
nvconfig_tlv_type->global.param_idx = tlv_type;
break;
case NVRAM_TLV_CLASS_HOST:
nvconfig_tlv_type->per_host.param_class = NVRAM_TLV_CLASS_HOST;
nvconfig_tlv_type->per_host.param_idx = tlv_type;
break;
case NVRAM_TLV_CLASS_PHYSICAL_PORT:
nvconfig_tlv_type->per_port.param_class = NVRAM_TLV_CLASS_PHYSICAL_PORT;
nvconfig_tlv_type->per_port.param_idx = tlv_type;
nvconfig_tlv_type->per_port.port = port;
break;
}
}
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 status = MLX_SUCCESS;
struct nvconfig_nvqc nvqc;
mlx_uint32 reg_status;
NVRAM_CLASS_CODE class_code;
mlx_uint16 real_tlv_type;
if (utils == NULL || read_supported == NULL || write_supported == NULL) {
status = MLX_INVALID_PARAMETER;
goto bad_param;
}
status = nvconfig_get_tlv_type_and_class(tlv_type, &real_tlv_type, &class_code);
MLX_CHECK_STATUS(utils, status, tlv_not_supported, "tlv not supported");
mlx_memory_set(utils, &nvqc, 0, sizeof(nvqc));
nvconfig_fill_tlv_type(port, class_code, real_tlv_type, &nvqc.tlv_type);
status = mlx_reg_access(utils, REG_ID_NVQC, REG_ACCESS_READ, &nvqc, sizeof(nvqc),
&reg_status);
MLX_CHECK_STATUS(utils, status, reg_err, "mlx_reg_access failed ");
if (reg_status != 0) {
MLX_DEBUG_ERROR(utils,"mlx_reg_access failed with status = %d\n", reg_status);
status = MLX_FAILED;
goto reg_err;
}
*read_supported = nvqc.support_rd;
*write_supported = nvqc.support_wr;
reg_err:
tlv_not_supported:
bad_param:
return status;
}
mlx_status
nvconfig_nvdata_invalidate(
IN mlx_utils *utils,
IN mlx_uint8 port,
IN mlx_uint16 tlv_type
)
{
mlx_status status = MLX_SUCCESS;
struct nvconfig_header nv_header;
mlx_uint32 reg_status;
NVRAM_CLASS_CODE class_code;
mlx_uint16 real_tlv_type;
if (utils == NULL) {
status = MLX_INVALID_PARAMETER;
goto bad_param;
}
status = nvconfig_get_tlv_type_and_class(tlv_type, &real_tlv_type, &class_code);
MLX_CHECK_STATUS(utils, status, tlv_not_supported, "tlv not supported");
mlx_memory_set(utils, &nv_header, 0, sizeof(nv_header));
nvconfig_fill_tlv_type(port, class_code, real_tlv_type, &nv_header.tlv_type);
status = mlx_reg_access(utils, REG_ID_NVDI, REG_ACCESS_WRITE, &nv_header, sizeof(nv_header),
&reg_status);
MLX_CHECK_STATUS(utils, status, reg_err, "mlx_reg_access failed ");
if (reg_status != 0) {
MLX_DEBUG_ERROR(utils,"mlx_reg_access failed with status = %d\n", reg_status);
status = MLX_FAILED;
goto reg_err;
}
reg_err:
tlv_not_supported:
bad_param:
return status;
}
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 OUT mlx_uint8 *version,
IN OUT mlx_void *data
)
{
mlx_status status = MLX_SUCCESS;
struct nvconfig_nvda nvda;
mlx_uint32 reg_status;
mlx_uint32 real_size_to_read;
mlx_uint32 index;
NVRAM_CLASS_CODE class_code;
mlx_uint16 real_tlv_type;
mlx_size data_size_align_to_dword;
if (utils == NULL || data == NULL || data_size > NVCONFIG_MAX_TLV_SIZE) {
status = MLX_INVALID_PARAMETER;
goto bad_param;
}
status = nvconfig_get_tlv_type_and_class(tlv_type, &real_tlv_type, &class_code);
MLX_CHECK_STATUS(utils, status, tlv_not_supported, "tlv not supported");
data_size_align_to_dword = ((data_size + 3) / sizeof(mlx_uint32)) * sizeof(mlx_uint32);
mlx_memory_set(utils, &nvda, 0, sizeof(nvda));
nvda.nv_header.length = data_size_align_to_dword;
nvda.nv_header.rd_en = 0;
nvda.nv_header.def_en = def_en;
nvda.nv_header.over_en = 1;
nvda.nv_header.version = *version;
nvconfig_fill_tlv_type(port, class_code, real_tlv_type, &nvda.nv_header.tlv_type);
mlx_memory_cpy(utils, nvda.data, data, data_size);
for (index = 0 ; index * 4 < NVCONFIG_MAX_TLV_SIZE ; index++) {
mlx_memory_be32_to_cpu(utils,(((mlx_uint32 *)nvda.data)[index]), ((mlx_uint32 *)nvda.data) + index);
}
status = mlx_reg_access(utils, REG_ID_NVDA, opt, &nvda,
data_size_align_to_dword + sizeof(nvda.nv_header), &reg_status);
MLX_CHECK_STATUS(utils, status, reg_err, "mlx_reg_access failed ");
if (reg_status != 0) {
MLX_DEBUG_ERROR(utils,"mlx_reg_access failed with status = %d\n", reg_status);
status = MLX_FAILED;
goto reg_err;
}
for (index = 0 ; index * 4 < NVCONFIG_MAX_TLV_SIZE ; index++) {
mlx_memory_cpu_to_be32(utils,(((mlx_uint32 *)nvda.data)[index]), ((mlx_uint32 *)nvda.data) + index);
}
if (opt == REG_ACCESS_READ) {
real_size_to_read = (nvda.nv_header.length > data_size) ? data_size :
nvda.nv_header.length;
mlx_memory_cpy(utils, data, nvda.data, real_size_to_read);
*version = nvda.nv_header.version;
} else {
nvconfig_set_fw_reset_level(utils, tlv_type);
}
reg_err:
tlv_not_supported:
bad_param:
return status;
}
@@ -0,0 +1,140 @@
#ifndef MLX_NVCONFIG_H_
#define MLX_NVCONFIG_H_
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "../mlx_reg_access/mlx_reg_access.h"
#include "../../include/public/mlx_utils.h"
typedef enum {
NVRAM_TLV_CLASS_GLOBAL = 0,
NVRAM_TLV_CLASS_PHYSICAL_PORT = 1,
NVRAM_TLV_CLASS_HOST = 3,
} NVRAM_CLASS_CODE;
struct nvconfig_tlv_type_per_port {
mlx_uint32 param_idx :16;
mlx_uint32 port :8;
mlx_uint32 param_class :8;
};
struct nvconfig_tlv_type_per_host {
mlx_uint32 param_idx :10;
mlx_uint32 function :8;
mlx_uint32 host :6;
mlx_uint32 param_class :8;
};
struct nvconfig_tlv_type_global {
mlx_uint32 param_idx :24;
mlx_uint32 param_class :8;
};
struct nvconfig_tlv_mapping{
mlx_uint16 tlv_type;
mlx_uint16 real_tlv_type;
NVRAM_CLASS_CODE class_code;
mlx_boolean fw_reset_needed;
};
union nvconfig_tlv_type {
struct nvconfig_tlv_type_per_port per_port;
struct nvconfig_tlv_type_per_host per_host;
struct nvconfig_tlv_type_global global;
};
struct nvconfig_nvqc {
union nvconfig_tlv_type tlv_type;
/* -------------- */
mlx_uint32 support_rd :1; /*the configuration item is supported and can be read */
mlx_uint32 support_wr :1; /*the configuration item is supported and can be updated */
mlx_uint32 reserved1 :2;
mlx_uint32 version :4; /*The maximum version of the configuration item currently supported by the firmware. */
mlx_uint32 reserved2 :24;
};
struct nvconfig_header {
mlx_uint32 length :9; /*Size of configuration item data in bytes between 0..256 */
mlx_uint32 reserved0 :3;
mlx_uint32 version :4; /* Configuration item version */
mlx_uint32 reserved1 :7;
mlx_uint32 def_en :1; /*Choose whether to access the default value or the user-defined value.
0x0 Read or write the user-defined value.
0x1 Read the default value (only valid for reads).*/
mlx_uint32 rd_en :1; /*enables reading the TLV by lower priorities
0 - TLV can be read by the subsequent lifecycle priorities.
1 - TLV cannot be read by the subsequent lifecycle priorities. */
mlx_uint32 over_en :1; /*enables overwriting the TLV by lower priorities
0 - Can only be overwritten by the current lifecycle priority
1 - Allowed to be overwritten by subsequent lifecycle priorities */
mlx_uint32 header_type :2;
mlx_uint32 priority :2;
mlx_uint32 valid :2;
/* -------------- */
union nvconfig_tlv_type tlv_type;;
/* -------------- */
mlx_uint32 crc :16;
mlx_uint32 reserved :16;
};
#define NVCONFIG_MAX_TLV_SIZE 256
struct nvconfig_nvda {
struct nvconfig_header nv_header;
mlx_uint8 data[NVCONFIG_MAX_TLV_SIZE];
};
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 OUT mlx_uint8 *version,
IN OUT mlx_void *data
);
#endif /* MLX_NVCONFIG_H_ */
@@ -0,0 +1,482 @@
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE( GPL2_OR_LATER);
#include "../../mlx_lib/mlx_nvconfig/mlx_nvconfig.h"
#include "../../include/public/mlx_memory.h"
#include "../../include/public/mlx_bail.h"
#include "../../mlx_lib/mlx_nvconfig/mlx_nvconfig_defaults.h"
struct tlv_default {
mlx_uint16 tlv_type;
mlx_size data_size;
mlx_status (*set_defaults)( IN void *data, IN int status,
OUT void *def_struct);
};
#define TlvDefaultEntry( _tlv_type, _data_size, _set_defaults) { \
.tlv_type = _tlv_type, \
.data_size = sizeof ( _data_size ), \
.set_defaults = _set_defaults, \
}
static
mlx_status
nvconfig_get_boot_default_conf(
IN void *data,
IN int status,
OUT void *def_struct
)
{
union mlx_nvconfig_nic_boot_conf *nic_boot_conf =
(union mlx_nvconfig_nic_boot_conf *) data;
struct mlx_nvconfig_port_conf_defaults *port_conf_def =
(struct mlx_nvconfig_port_conf_defaults *) def_struct;
/* boot_option_rom_en is deprecated - enabled always */
port_conf_def->boot_option_rom_en = DEFAULT_OPTION_ROM_EN;
MLX_CHECK_STATUS(NULL, status, nvdata_access_err,
"TLV not found. Using hard-coded defaults ");
port_conf_def->boot_vlan = nic_boot_conf->vlan_id;
port_conf_def->boot_protocol = nic_boot_conf->legacy_boot_prot;
port_conf_def->boot_retry_count = nic_boot_conf->boot_retry_count;
port_conf_def->boot_vlan_en = nic_boot_conf->en_vlan;
return MLX_SUCCESS;
nvdata_access_err:
port_conf_def->boot_vlan = DEFAULT_BOOT_VLAN;
port_conf_def->boot_protocol = DEFAULT_BOOT_PROTOCOL;
return status;
}
static
mlx_status
nvconfig_get_boot_ext_default_conf(
IN void *data,
IN int status,
OUT void *def_struct
)
{
union mlx_nvconfig_nic_boot_ext_conf *nic_boot_ext_conf =
(union mlx_nvconfig_nic_boot_ext_conf *) data;
struct mlx_nvconfig_port_conf_defaults *port_conf_def =
(struct mlx_nvconfig_port_conf_defaults *) def_struct;
MLX_CHECK_STATUS(NULL, status, nvdata_access_err,
"TLV not found. Using hard-coded defaults ");
port_conf_def->linkup_timeout = nic_boot_ext_conf->linkup_timeout;
port_conf_def->ip_ver = nic_boot_ext_conf->ip_ver;
return MLX_SUCCESS;
nvdata_access_err:
port_conf_def->linkup_timeout = DEFAULT_BOOT_LINK_UP_TO;
port_conf_def->ip_ver = DEFAULT_BOOT_IP_VER;
return status;
}
static
mlx_status
nvconfig_get_iscsi_init_dhcp_default_conf(
IN void *data,
IN int status,
OUT void *def_struct
)
{
union mlx_nvconfig_iscsi_init_dhcp_conf *iscsi_init_dhcp_conf =
(union mlx_nvconfig_iscsi_init_dhcp_conf *) data;
struct mlx_nvconfig_port_conf_defaults *port_conf_def =
(struct mlx_nvconfig_port_conf_defaults *) def_struct;
MLX_CHECK_STATUS(NULL, status, nvdata_access_err,
"TLV not found. Using hard-coded defaults ");
port_conf_def->iscsi_dhcp_params_en = iscsi_init_dhcp_conf->dhcp_iscsi_en;
port_conf_def->iscsi_ipv4_dhcp_en = iscsi_init_dhcp_conf->ipv4_dhcp_en;
return MLX_SUCCESS;
nvdata_access_err:
port_conf_def->iscsi_dhcp_params_en = DEFAULT_ISCSI_DHCP_PARAM_EN;
port_conf_def->iscsi_ipv4_dhcp_en = DEFAULT_ISCSI_IPV4_DHCP_EN;
return status;
}
static
mlx_status
nvconfig_get_ib_boot_default_conf(
IN void *data,
IN int status,
OUT void *def_struct
)
{
union mlx_nvconfig_nic_ib_boot_conf *ib_boot_conf =
(union mlx_nvconfig_nic_ib_boot_conf *) data;
struct mlx_nvconfig_port_conf_defaults *port_conf_def =
(struct mlx_nvconfig_port_conf_defaults *) def_struct;
MLX_CHECK_STATUS(NULL, status, nvdata_access_err,
"nvconfig_nvdata_default_access failed ");
port_conf_def->boot_pkey = ib_boot_conf->boot_pkey;
nvdata_access_err:
return status;
}
static
mlx_status
nvconfig_get_wol_default_conf(
IN void *data,
IN int status,
OUT void *def_struct
)
{
union mlx_nvconfig_wol_conf *wol_conf = (union mlx_nvconfig_wol_conf *) data;
struct mlx_nvconfig_port_conf_defaults *port_conf_def =
(struct mlx_nvconfig_port_conf_defaults *) def_struct;
MLX_CHECK_STATUS(NULL, status, nvdata_access_err,
"nvconfig_nvdata_default_access failed ");
port_conf_def->en_wol_magic = wol_conf->en_wol_magic;
nvdata_access_err:
return status;
}
static
mlx_status
nvconfig_get_iscsi_gen_default_conf(
IN void *data,
IN int status,
OUT void *def_struct)
{
union mlx_nvconfig_iscsi_general *iscsi_gen =
(union mlx_nvconfig_iscsi_general *) data;
struct mlx_nvconfig_port_conf_defaults *port_conf_def =
(struct mlx_nvconfig_port_conf_defaults *) def_struct;
MLX_CHECK_STATUS(NULL, status, nvdata_access_err,
"nvconfig_nvdata_default_access failed ");
port_conf_def->iscsi_boot_to_target = iscsi_gen->boot_to_target;
port_conf_def->iscsi_vlan_en = iscsi_gen->vlan_en;
port_conf_def->iscsi_tcp_timestamps_en = iscsi_gen->tcp_timestamps_en;
port_conf_def->iscsi_chap_mutual_auth_en = iscsi_gen->chap_mutual_auth_en;
port_conf_def->iscsi_chap_auth_en = iscsi_gen->chap_auth_en;
port_conf_def->iscsi_lun_busy_retry_count = iscsi_gen->lun_busy_retry_count;
port_conf_def->iscsi_link_up_delay_time = iscsi_gen->link_up_delay_time;
nvdata_access_err:
return status;
}
static
mlx_status
nvconfig_get_ib_dhcp_default_conf(
IN void *data,
IN int status,
OUT void *def_struct
)
{
union mlx_nvconfig_ib_dhcp_conf *ib_dhcp =
(union mlx_nvconfig_ib_dhcp_conf *) data;
struct mlx_nvconfig_port_conf_defaults *port_conf_def =
(struct mlx_nvconfig_port_conf_defaults *) def_struct;
MLX_CHECK_STATUS(NULL, status, nvdata_access_err,
"nvconfig_nvdata_default_access failed ");
port_conf_def->client_identifier = ib_dhcp->client_identifier;
port_conf_def->mac_admin_bit = ib_dhcp->mac_admin_bit;
nvdata_access_err:
return status;
}
static
mlx_status
nvconfig_get_ocsd_ocbb_default_conf( IN void *data,
IN int status, OUT void *def_struct) {
union mlx_nvconfig_ocsd_ocbb_conf *ocsd_ocbb =
(union mlx_nvconfig_ocsd_ocbb_conf *) data;
struct mlx_nvconfig_conf_defaults *conf_def =
(struct mlx_nvconfig_conf_defaults *) def_struct;
MLX_CHECK_STATUS(NULL, status, nvdata_access_err,
"TLV not found. Using hard-coded defaults ");
conf_def->ocsd_ocbb_en = ocsd_ocbb->ocsd_ocbb_en;
return MLX_SUCCESS;
nvdata_access_err:
conf_def->ocsd_ocbb_en = DEFAULT_OCSD_OCBB_EN;
return status;
}
static
mlx_status
nvconfig_get_vpi_link_default_conf(
IN void *data,
IN int status,
OUT void *def_struct
)
{
union mlx_nvconfig_vpi_link_conf *vpi_link =
(union mlx_nvconfig_vpi_link_conf *) data;
struct mlx_nvconfig_port_conf_defaults *port_conf_def =
(struct mlx_nvconfig_port_conf_defaults *) def_struct;
MLX_CHECK_STATUS(NULL, status, nvdata_access_err,
"nvconfig_nvdata_default_access failed ");
port_conf_def->network_link_type = vpi_link->network_link_type;
port_conf_def->default_link_type = vpi_link->default_link_type;
nvdata_access_err:
return status;
}
static
mlx_status
nvconfig_get_rom_banner_to_default_conf(
IN void *data,
IN int status,
OUT void *def_struct
)
{
union mlx_nvconfig_rom_banner_timeout_conf *rom_banner_timeout_conf =
(union mlx_nvconfig_rom_banner_timeout_conf *) data;
struct mlx_nvconfig_conf_defaults *conf_def =
(struct mlx_nvconfig_conf_defaults *) def_struct;
MLX_CHECK_STATUS(NULL, status, nvdata_access_err,
"TLV not found. Using hard-coded defaults ");
conf_def->flexboot_menu_to = rom_banner_timeout_conf->rom_banner_to;
return MLX_SUCCESS;
nvdata_access_err:
conf_def->flexboot_menu_to = DEFAULT_FLEXBOOT_MENU_TO;
return status;
}
static
mlx_status
nvconfig_get_nv_virt_caps_default_conf(
IN void *data,
IN int status,
OUT void *def_struct
)
{
union mlx_nvconfig_virt_caps *nv_virt_caps =
(union mlx_nvconfig_virt_caps *) data;
struct mlx_nvconfig_conf_defaults *conf_def =
(struct mlx_nvconfig_conf_defaults *) def_struct;
MLX_CHECK_STATUS(NULL, status, nvdata_access_err,
"TLV not found. Using hard-coded defaults ");
conf_def->max_vfs = nv_virt_caps->max_vfs_per_pf;
return MLX_SUCCESS;
nvdata_access_err:
conf_def->max_vfs = DEFAULT_MAX_VFS;
return status;
}
static
mlx_status
nvconfig_get_nv_virt_default_conf(
IN void *data,
IN int status,
OUT void *def_struct
)
{
union mlx_nvconfig_virt_conf *nv_virt_conf =
(union mlx_nvconfig_virt_conf *) data;
struct mlx_nvconfig_conf_defaults *conf_def =
(struct mlx_nvconfig_conf_defaults *) def_struct;
MLX_CHECK_STATUS(NULL, status, nvdata_access_err,
"nvconfig_nvdata_default_access failed ");
conf_def->total_vfs = nv_virt_conf->num_of_vfs;
conf_def->sriov_en = nv_virt_conf->virt_mode;
nvdata_access_err:
return status;
}
static struct tlv_default tlv_port_defaults[] = {
TlvDefaultEntry(BOOT_SETTINGS_TYPE, union mlx_nvconfig_nic_boot_conf, &nvconfig_get_boot_default_conf),
TlvDefaultEntry(BOOT_SETTINGS_EXT_TYPE, union mlx_nvconfig_nic_boot_ext_conf, &nvconfig_get_boot_ext_default_conf),
TlvDefaultEntry(ISCSI_INITIATOR_DHCP_CONF_TYPE, union mlx_nvconfig_iscsi_init_dhcp_conf, &nvconfig_get_iscsi_init_dhcp_default_conf),
TlvDefaultEntry(IB_BOOT_SETTING_TYPE, union mlx_nvconfig_nic_ib_boot_conf, &nvconfig_get_ib_boot_default_conf),
TlvDefaultEntry(WAKE_ON_LAN_TYPE, union mlx_nvconfig_wol_conf, &nvconfig_get_wol_default_conf),
TlvDefaultEntry(ISCSI_GENERAL_SETTINGS_TYPE, union mlx_nvconfig_iscsi_general, &nvconfig_get_iscsi_gen_default_conf),
TlvDefaultEntry(IB_DHCP_SETTINGS_TYPE, union mlx_nvconfig_ib_dhcp_conf, &nvconfig_get_ib_dhcp_default_conf),
TlvDefaultEntry(VPI_LINK_TYPE, union mlx_nvconfig_vpi_link_conf, &nvconfig_get_vpi_link_default_conf),
};
static struct tlv_default tlv_general_defaults[] = {
TlvDefaultEntry(BANNER_TO_TYPE, union mlx_nvconfig_rom_banner_timeout_conf, &nvconfig_get_rom_banner_to_default_conf),
TlvDefaultEntry(GLOPAL_PCI_CAPS_TYPE, union mlx_nvconfig_virt_caps, &nvconfig_get_nv_virt_caps_default_conf),
TlvDefaultEntry(GLOPAL_PCI_SETTINGS_TYPE, union mlx_nvconfig_virt_conf, &nvconfig_get_nv_virt_default_conf),
TlvDefaultEntry(OCSD_OCBB_TYPE, union mlx_nvconfig_ocsd_ocbb_conf, &nvconfig_get_ocsd_ocbb_default_conf),
};
static
mlx_status
nvconfig_nvdata_default_access(
IN mlx_utils *utils,
IN mlx_uint8 port,
IN mlx_uint16 tlv_type,
IN mlx_size data_size,
OUT mlx_void *data
)
{
mlx_status status = MLX_SUCCESS;
mlx_uint32 index;
mlx_uint8 version = 0;
status = nvconfig_nvdata_access(utils, port, tlv_type, REG_ACCESS_READ,
data_size, TLV_ACCESS_DEFAULT_EN, &version, data);
MLX_CHECK_STATUS(NULL, status, nvdata_access_err,
"nvconfig_nvdata_access failed ");
for (index = 0; index * 4 < data_size; index++) {
mlx_memory_be32_to_cpu(utils, (((mlx_uint32 *) data)[index]),
((mlx_uint32 *) data) + index);
}
nvdata_access_err:
return status;
}
static
mlx_status
nvconfig_nvdata_read_default_value(
IN mlx_utils *utils,
IN mlx_uint8 modifier,
IN struct tlv_default *def,
OUT void *def_struct
)
{
mlx_status status = MLX_SUCCESS;
void *data = NULL;
status = mlx_memory_zalloc(utils, def->data_size,&data);
MLX_CHECK_STATUS(utils, status, memory_err,
"mlx_memory_zalloc failed ");
status = nvconfig_nvdata_default_access(utils, modifier, def->tlv_type,
def->data_size, data);
def->set_defaults(data, status, def_struct);
mlx_memory_free(utils, &data);
memory_err:
return status;
}
static
void
nvconfig_nvdata_read_default_values(
IN mlx_utils *utils,
IN mlx_uint8 modifier,
IN struct tlv_default defaults_table[],
IN mlx_uint8 defaults_table_size,
OUT void *def_strct
)
{
struct tlv_default *defs;
unsigned int i;
for (i = 0; i < defaults_table_size; i++) {
defs = &defaults_table[i];
nvconfig_nvdata_read_default_value(utils, modifier, defs, def_strct);
}
}
mlx_status
nvconfig_read_port_default_values(
IN mlx_utils *utils,
IN mlx_uint8 port,
OUT struct mlx_nvconfig_port_conf_defaults *port_conf_def
)
{
mlx_status status = MLX_SUCCESS;
if (utils == NULL || port_conf_def == NULL) {
status = MLX_INVALID_PARAMETER;
MLX_DEBUG_ERROR(utils,"bad params.");
goto bad_param;
}
mlx_memory_set(utils, port_conf_def, 0, sizeof(*port_conf_def));
nvconfig_nvdata_read_default_values(utils, port, tlv_port_defaults,
(sizeof(tlv_port_defaults)/sizeof(tlv_port_defaults[0])),
port_conf_def);
bad_param:
return status;
}
mlx_status
nvconfig_read_general_default_values(
IN mlx_utils *utils,
OUT struct mlx_nvconfig_conf_defaults *conf_def
)
{
mlx_status status = MLX_SUCCESS;
if (utils == NULL || conf_def == NULL) {
status = MLX_INVALID_PARAMETER;
MLX_DEBUG_ERROR(utils,"bad params.");
goto bad_param;
}
mlx_memory_set(utils, conf_def, 0, sizeof(*conf_def));
nvconfig_nvdata_read_default_values(utils, 0, tlv_general_defaults,
(sizeof(tlv_general_defaults)/sizeof(tlv_general_defaults[0])),
conf_def);
bad_param:
return status;
}
mlx_status
nvconfig_read_rom_ini_values(
IN mlx_utils *utils,
OUT struct mlx_nvcofnig_romini *rom_ini
)
{
mlx_status status = MLX_SUCCESS;
if (utils == NULL || rom_ini == NULL) {
status = MLX_INVALID_PARAMETER;
MLX_DEBUG_ERROR(utils,"bad params.");
goto bad_param;
}
mlx_memory_set(utils, rom_ini, 0, sizeof(*rom_ini));
status = nvconfig_nvdata_default_access(utils, 0, GLOBAL_ROM_INI_TYPE,
sizeof(*rom_ini), rom_ini);
bad_param:
return status;
}
@@ -0,0 +1,94 @@
#ifndef MLX_NVCONFIG_DEFAULTS_H_
#define MLX_NVCONFIG_DEFAULTS_H_
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "mlx_nvconfig_prm.h"
/*
* Default values
*/
#define DEFAULT_FLEXBOOT_MENU_TO 4
#define DEFAULT_MAX_VFS 8
#define DEFAULT_BOOT_PROTOCOL 1
#define DEFAULT_OPTION_ROM_EN 1
#define DEFAULT_BOOT_VLAN 1
#define DEFAULT_ISCSI_DHCP_PARAM_EN 1
#define DEFAULT_ISCSI_IPV4_DHCP_EN 1
#define DEFAULT_OCSD_OCBB_EN 1
#define DEFAULT_BOOT_IP_VER 0
#define DEFAULT_BOOT_LINK_UP_TO 0
struct mlx_nvconfig_port_conf_defaults {
mlx_uint8 pptx;
mlx_uint8 pprx;
mlx_boolean boot_option_rom_en;
mlx_boolean boot_vlan_en;
mlx_uint8 boot_retry_count;
mlx_uint8 boot_protocol;
mlx_uint8 boot_vlan;
mlx_uint8 boot_pkey;
mlx_boolean en_wol_magic;
mlx_uint8 network_link_type;
mlx_uint8 iscsi_boot_to_target;
mlx_boolean iscsi_vlan_en;
mlx_boolean iscsi_tcp_timestamps_en;
mlx_boolean iscsi_chap_mutual_auth_en;
mlx_boolean iscsi_chap_auth_en;
mlx_boolean iscsi_dhcp_params_en;
mlx_boolean iscsi_ipv4_dhcp_en;
mlx_uint8 iscsi_lun_busy_retry_count;
mlx_uint8 iscsi_link_up_delay_time;
mlx_uint8 client_identifier;
mlx_uint8 mac_admin_bit;
mlx_uint8 default_link_type;
mlx_uint8 linkup_timeout;
mlx_uint8 ip_ver;
};
struct mlx_nvconfig_conf_defaults {
mlx_uint8 max_vfs;
mlx_uint8 total_vfs;
mlx_uint8 sriov_en;
mlx_uint8 maximum_uar_bar_size;
mlx_uint8 uar_bar_size;
mlx_uint8 flexboot_menu_to;
mlx_boolean ocsd_ocbb_en;
};
mlx_status
nvconfig_read_port_default_values(
IN mlx_utils *utils,
IN mlx_uint8 port,
OUT struct mlx_nvconfig_port_conf_defaults *port_conf_def
);
mlx_status
nvconfig_read_general_default_values(
IN mlx_utils *utils,
OUT struct mlx_nvconfig_conf_defaults *conf_def
);
mlx_status
nvconfig_read_rom_ini_values(
IN mlx_utils *utils,
OUT struct mlx_nvcofnig_romini *rom_ini
);
#endif /* MLX_NVCONFIG_DEFAULTS_H_ */
@@ -0,0 +1,259 @@
#ifndef MLX_NVCONFIG_PRM_H_
#define MLX_NVCONFIG_PRM_H_
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "../../include/public/mlx_types.h"
enum {
WAKE_ON_LAN_TYPE = 0x10,
VIRTUALIZATION_TYPE = 0x11,
VPI_LINK_TYPE = 0x12,
BOOT_SETTINGS_EXT_TYPE = 0x2001,
BANNER_TO_TYPE = 0x2010,
OCSD_OCBB_TYPE = 0x2011,
FLOW_CONTROL_TYPE = 0x2020,
BOOT_SETTINGS_TYPE = 0x2021,
ISCSI_GENERAL_SETTINGS_TYPE = 0x2100,
IB_BOOT_SETTING_TYPE = 0x2022,
IB_DHCP_SETTINGS_TYPE = 0x2023,
GLOPAL_PCI_SETTINGS_TYPE = 0x80,
GLOPAL_PCI_CAPS_TYPE = 0x81,
GLOBAL_ROM_INI_TYPE = 0x100,
// Types for iSCSI strings
DHCP_VEND_ID = 0x2101,
ISCSI_INITIATOR_IPV4_ADDR = 0x2102,
ISCSI_INITIATOR_SUBNET = 0x2103,
ISCSI_INITIATOR_IPV4_GATEWAY = 0x2104,
ISCSI_INITIATOR_IPV4_PRIM_DNS = 0x2105,
ISCSI_INITIATOR_IPV4_SECDNS = 0x2106,
ISCSI_INITIATOR_NAME = 0x2107,
ISCSI_INITIATOR_CHAP_ID = 0x2108,
ISCSI_INITIATOR_CHAP_PWD = 0x2109,
ISCSI_INITIATOR_DHCP_CONF_TYPE = 0x210a,
CONNECT_FIRST_TGT = 0x2200,
FIRST_TGT_IP_ADDRESS = 0x2201,
FIRST_TGT_TCP_PORT = 0x2202,
FIRST_TGT_BOOT_LUN = 0x2203,
FIRST_TGT_ISCSI_NAME = 0x2204,
FIRST_TGT_CHAP_ID = 0x2205,
FIRST_TGT_CHAP_PWD = 0x2207,
};
union mlx_nvconfig_nic_boot_conf {
struct {
mlx_uint32 vlan_id : 12;
mlx_uint32 link_speed : 4;
mlx_uint32 legacy_boot_prot : 8;
mlx_uint32 boot_retry_count : 3;
mlx_uint32 boot_strap_type : 3;
mlx_uint32 en_vlan : 1;
mlx_uint32 en_option_rom : 1;
};
mlx_uint32 dword;
};
union mlx_nvconfig_nic_boot_ext_conf {
struct {
mlx_uint32 linkup_timeout : 8;
mlx_uint32 ip_ver : 2;
mlx_uint32 reserved0 : 22;
};
mlx_uint32 dword;
};
union mlx_nvconfig_rom_banner_timeout_conf {
struct {
mlx_uint32 rom_banner_to : 4;
mlx_uint32 reserved : 28;
};
mlx_uint32 dword;
};
union mlx_nvconfig_virt_conf {
struct {
mlx_uint32 reserved0 :24;
mlx_uint32 pf_bar_size_valid :1;
mlx_uint32 vf_bar_size_valid :1;
mlx_uint32 num_pf_msix_valid :1;
mlx_uint32 num_vf_msix_valid :1;
mlx_uint32 num_pfs_valid :1;
mlx_uint32 fpp_valid :1;
mlx_uint32 full_vf_qos_valid :1;
mlx_uint32 sriov_valid :1;
/*-------------------*/
mlx_uint32 num_of_vfs :16;
mlx_uint32 num_of_pfs :4;
mlx_uint32 reserved1 :9;
mlx_uint32 fpp_en :1;
mlx_uint32 full_vf_qos :1;
mlx_uint32 virt_mode :1; //sriov_en
/*-------------------*/
mlx_uint32 log_pf_uar_bar_size :6;
mlx_uint32 log_vf_uar_bar_size :6;
mlx_uint32 num_pf_msix :10;
mlx_uint32 num_vf_msix :10;
};
mlx_uint32 dword[3];
};
union mlx_nvconfig_virt_caps {
struct {
mlx_uint32 reserved0 :24;
mlx_uint32 max_vfs_per_pf_valid :1;
mlx_uint32 max_total_msix_valid :1;
mlx_uint32 max_total_bar_valid :1;
mlx_uint32 num_pfs_supported :1;
mlx_uint32 num_vf_msix_supported :1;
mlx_uint32 num_pf_msix_supported :1;
mlx_uint32 vf_bar_size_supported :1;
mlx_uint32 pf_bar_size_supported :1;
/*-------------------*/
mlx_uint32 max_vfs_per_pf :16;
mlx_uint32 max_num_pfs :4;
mlx_uint32 reserved1 :9;
mlx_uint32 fpp_support :1;
mlx_uint32 vf_qos_control_support :1;
mlx_uint32 sriov_support :1;
/*-------------------*/
mlx_uint32 max_log_pf_uar_bar_size :6;
mlx_uint32 max_log_vf_uar_bar_size :6;
mlx_uint32 max_num_pf_msix :10;
mlx_uint32 max_num_vf_msix :10;
/*-------------------*/
mlx_uint32 max_total_msix;
/*-------------------*/
mlx_uint32 max_total_bar;
};
mlx_uint32 dword[5];
};
union mlx_nvconfig_iscsi_init_dhcp_conf {
struct {
mlx_uint32 reserved0 :30;
mlx_uint32 dhcp_iscsi_en :1;
mlx_uint32 ipv4_dhcp_en :1;
};
mlx_uint32 dword;
};
union mlx_nvconfig_nic_ib_boot_conf {
struct {
mlx_uint32 boot_pkey : 16;
mlx_uint32 reserved0 : 16;
};
mlx_uint32 dword;
};
union mlx_nvconfig_wol_conf {
struct {
mlx_uint32 reserved0 :9;
mlx_uint32 en_wol_passwd :1;
mlx_uint32 en_wol_magic :1;
mlx_uint32 reserved1 :21;
mlx_uint32 reserved2 :32;
};
mlx_uint32 dword[2];
};
union mlx_nvconfig_iscsi_general {
struct {
mlx_uint32 reserved0 :22;
mlx_uint32 boot_to_target :2;
mlx_uint32 reserved1 :2;
mlx_uint32 vlan_en :1;
mlx_uint32 tcp_timestamps_en :1;
mlx_uint32 chap_mutual_auth_en :1;
mlx_uint32 chap_auth_en :1;
mlx_uint32 reserved2 :2;
/*-------------------*/
mlx_uint32 vlan :12;
mlx_uint32 reserved3 :20;
/*-------------------*/
mlx_uint32 lun_busy_retry_count:8;
mlx_uint32 link_up_delay_time :8;
mlx_uint32 reserved4 :16;
};
mlx_uint32 dword[3];
};
union mlx_nvconfig_ib_dhcp_conf {
struct {
mlx_uint32 reserved :24;
mlx_uint32 client_identifier :4;
mlx_uint32 mac_admin_bit :4;
};
mlx_uint32 dword;
};
union mlx_nvconfig_ocsd_ocbb_conf {
struct {
mlx_uint32 reserved :31;
mlx_uint32 ocsd_ocbb_en :1;
};
mlx_uint32 dword;
};
union mlx_nvconfig_vpi_link_conf {
struct {
mlx_uint32 network_link_type :2;
mlx_uint32 default_link_type :2;
mlx_uint32 reserved :28;
};
mlx_uint32 dword;
};
struct mlx_nvcofnig_romini {
mlx_uint32 reserved0 :1;
mlx_uint32 shared_memory_en :1;
mlx_uint32 hii_vpi_en :1;
mlx_uint32 tech_enum :1;
mlx_uint32 reserved1 :4;
mlx_uint32 static_component_name_string :1;
mlx_uint32 hii_iscsi_configuration :1;
mlx_uint32 hii_ibm_aim :1;
mlx_uint32 hii_platform_setup :1;
mlx_uint32 hii_bdf_decimal :1;
mlx_uint32 hii_read_only :1;
mlx_uint32 reserved2 :10;
mlx_uint32 mac_enum :1;
mlx_uint32 port_enum :1;
mlx_uint32 flash_en :1;
mlx_uint32 fmp_en :1;
mlx_uint32 bofm_en :1;
mlx_uint32 platform_to_driver_en :1;
mlx_uint32 hii_en :1;
mlx_uint32 undi_en :1;
/* -------------- */
mlx_uint64 dhcp_user_class;
/* -------------- */
mlx_uint32 reserved3 :22;
mlx_uint32 uri_boot_retry_delay :4;
mlx_uint32 uri_boot_retry :4;
mlx_uint32 option_rom_debug :1;
mlx_uint32 promiscuous_vlan :1;
};
#endif /* MLX_NVCONFIG_PRM_H_ */
@@ -0,0 +1,145 @@
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "mlx_ocbb.h"
#include "mlx_icmd.h"
#include "mlx_bail.h"
mlx_status
mlx_ocbb_init (
IN mlx_utils *utils,
IN mlx_uint64 address
)
{
mlx_status status = MLX_SUCCESS;
struct mlx_ocbb_init ocbb_init;
ocbb_init.address_hi = (mlx_uint32)(address >> 32);
ocbb_init.address_lo = (mlx_uint32)address;
if (utils == NULL) {
status = MLX_INVALID_PARAMETER;
goto bad_param;
}
status = mlx_icmd_send_command(
utils,
OCBB_INIT,
&ocbb_init,
sizeof(ocbb_init),
0
);
MLX_CHECK_STATUS(utils, status, icmd_err, "mlx_icmd_send_command failed");
icmd_err:
bad_param:
return status;
}
mlx_status
mlx_ocbb_query_header_status (
IN mlx_utils *utils,
OUT mlx_uint8 *ocbb_status
)
{
mlx_status status = MLX_SUCCESS;
struct mlx_ocbb_query_status ocbb_query_status;
if (utils == NULL) {
status = MLX_INVALID_PARAMETER;
goto bad_param;
}
status = mlx_icmd_send_command(
utils,
OCBB_QUERY_HEADER_STATUS,
&ocbb_query_status,
0,
sizeof(ocbb_query_status)
);
MLX_CHECK_STATUS(utils, status, icmd_err, "mlx_icmd_send_command failed");
*ocbb_status = ocbb_query_status.status;
icmd_err:
bad_param:
return status;
}
mlx_status
mlx_ocbb_query_etoc_status (
IN mlx_utils *utils,
OUT mlx_uint8 *ocbb_status
)
{
mlx_status status = MLX_SUCCESS;
struct mlx_ocbb_query_status ocbb_query_status;
if (utils == NULL) {
status = MLX_INVALID_PARAMETER;
goto bad_param;
}
status = mlx_icmd_send_command(
utils,
OCBB_QUERY_ETOC_STATUS,
&ocbb_query_status,
0,
sizeof(ocbb_query_status)
);
MLX_CHECK_STATUS(utils, status, icmd_err, "mlx_icmd_send_command failed");
*ocbb_status = ocbb_query_status.status;
icmd_err:
bad_param:
return status;
}
mlx_status
mlx_ocbb_set_event (
IN mlx_utils *utils,
IN mlx_uint64 event_data,
IN mlx_uint8 event_number,
IN mlx_uint8 event_length,
IN mlx_uint8 data_length,
IN mlx_uint8 data_start_offset
)
{
mlx_status status = MLX_SUCCESS;
struct mlx_ocbb_set_event ocbb_event;
if (utils == NULL) {
status = MLX_INVALID_PARAMETER;
goto bad_param;
}
ocbb_event.data_length = data_length;
ocbb_event.data_start_offset = data_start_offset;
ocbb_event.event_number = event_number;
ocbb_event.event_data = event_data;
ocbb_event.event_length = event_length;
status = mlx_icmd_send_command(
utils,
OCBB_QUERY_SET_EVENT,
&ocbb_event,
sizeof(ocbb_event),
0
);
MLX_CHECK_STATUS(utils, status, icmd_err, "mlx_icmd_send_command failed");
icmd_err:
bad_param:
return status;
}
@@ -0,0 +1,73 @@
#ifndef MLX_OCBB_H_
#define MLX_OCBB_H_
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "mlx_utils.h"
#define MLX_OCBB_EVENT_DATA_SIZE 2
struct mlx_ocbb_init {
mlx_uint32 address_hi;
mlx_uint32 address_lo;
};
struct mlx_ocbb_query_status {
mlx_uint32 reserved :24;
mlx_uint32 status :8;
};
struct mlx_ocbb_set_event {
mlx_uint64 event_data;
mlx_uint32 event_number :8;
mlx_uint32 event_length :8;
mlx_uint32 data_length :8;
mlx_uint32 data_start_offset :8;
};
mlx_status
mlx_ocbb_init (
IN mlx_utils *utils,
IN mlx_uint64 address
);
mlx_status
mlx_ocbb_query_header_status (
IN mlx_utils *utils,
OUT mlx_uint8 *ocbb_status
);
mlx_status
mlx_ocbb_query_etoc_status (
IN mlx_utils *utils,
OUT mlx_uint8 *ocbb_status
);
mlx_status
mlx_ocbb_set_event (
IN mlx_utils *utils,
IN mlx_uint64 EventData,
IN mlx_uint8 EventNumber,
IN mlx_uint8 EventLength,
IN mlx_uint8 DataLength,
IN mlx_uint8 DataStartOffset
);
#endif /* MLX_OCBB_H_ */
@@ -0,0 +1,90 @@
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "../../mlx_lib/mlx_reg_access/mlx_reg_access.h"
#include "../../include/public/mlx_icmd.h"
#include "../../include/public/mlx_bail.h"
#include "../../include/public/mlx_memory.h"
static
mlx_status
init_operation_tlv(
IN struct mail_box_tlv *mail_box_tlv,
IN mlx_uint16 reg_id,
IN REG_ACCESS_OPT reg_opt
)
{
#define TLV_OPERATION 1
mail_box_tlv->operation_tlv.Type = TLV_OPERATION;
#define MAD_CLASS_REG_ACCESS 1
mail_box_tlv->operation_tlv.cls = MAD_CLASS_REG_ACCESS;
#define TLV_OPERATION_SIZE 4
mail_box_tlv->operation_tlv.len = TLV_OPERATION_SIZE;
mail_box_tlv->operation_tlv.method = reg_opt;
mail_box_tlv->operation_tlv.register_id = reg_id;
return MLX_SUCCESS;
}
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
)
{
mlx_status status = MLX_SUCCESS;
struct mail_box_tlv mail_box_tlv;
if (utils == NULL || reg_data == NULL || reg_status == NULL
|| reg_size > REG_ACCESS_MAX_REG_SIZE) {
status = MLX_INVALID_PARAMETER;
goto bad_param;
}
mlx_memory_set(utils, &mail_box_tlv, 0, sizeof(mail_box_tlv));
init_operation_tlv(&mail_box_tlv, reg_id, reg_opt);
#define REG_ACCESS_TLV_REG 3
#define REG_TLV_HEADER_LEN 4
#define OP_TLV_SIZE 16
mail_box_tlv.reg_tlv.Type = REG_ACCESS_TLV_REG;
mail_box_tlv.reg_tlv.len = ((reg_size + REG_TLV_HEADER_LEN + 3) >> 2); // length is in dwords round up
mlx_memory_cpy(utils, &mail_box_tlv.reg_tlv.data, reg_data, reg_size);
reg_size += OP_TLV_SIZE + REG_TLV_HEADER_LEN;
status = mlx_icmd_send_command(utils, FLASH_REG_ACCESS, &mail_box_tlv, reg_size, reg_size);
MLX_CHECK_STATUS(utils, status, icmd_err, "failed to send icmd");
mlx_memory_cpy(utils, reg_data, &mail_box_tlv.reg_tlv.data,
reg_size - (OP_TLV_SIZE + REG_TLV_HEADER_LEN));
*reg_status = mail_box_tlv.operation_tlv.status;
icmd_err:
bad_param:
return status;
}
@@ -0,0 +1,82 @@
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#ifndef MLX_REG_ACCESS_H_
#define MLX_REG_ACCESS_H_
#include "../../include/public/mlx_icmd.h"
#define REG_ACCESS_MAX_REG_SIZE 236
typedef enum {
REG_ACCESS_READ = 1,
REG_ACCESS_WRITE = 2,
} REG_ACCESS_OPT;
typedef enum {
TLV_ACCESS_DEFAULT_DIS = 0,
TLV_ACCESS_DEFAULT_EN = 1,
} NV_DEFAULT_OPT;
#define REG_ID_NVDA 0x9024
#define REG_ID_NVDI 0x9025
#define REG_ID_NVIA 0x9029
#define REG_ID_MLCR 0x902b
#define REG_ID_NVQC 0x9030
#define REG_ID_MFRL 0x9028
#define REG_ID_PTYS 0x5004
#define REG_ID_PMTU 0x5003
struct operation_tlv {
mlx_uint32 reserved0 :8; /* bit_offset:0 */ /* element_size: 8 */
mlx_uint32 status :7; /* bit_offset:8 */ /* element_size: 7 */
mlx_uint32 dr :1; /* bit_offset:15 */ /* element_size: 1 */
mlx_uint32 len :11; /* bit_offset:16 */ /* element_size: 11 */
mlx_uint32 Type :5; /* bit_offset:27 */ /* element_size: 5 */
mlx_uint32 cls :8; /* bit_offset:32 */ /* element_size: 8 */
mlx_uint32 method :7; /* bit_offset:40 */ /* element_size: 7 */
mlx_uint32 r :1; /* bit_offset:47 */ /* element_size: 1 */
mlx_uint32 register_id :16; /* bit_offset:48 */ /* element_size: 16 */
mlx_uint64 tid ; /* bit_offset:64 */ /* element_size: 64 */
};
struct reg_tlv {
mlx_uint32 reserved0 :16; /* bit_offset:0 */ /* element_size: 16 */
mlx_uint32 len :11; /* bit_offset:16 */ /* element_size: 11 */
mlx_uint32 Type :5; /* bit_offset:27 */ /* element_size: 5 */
mlx_uint8 data[REG_ACCESS_MAX_REG_SIZE];
};
struct mail_box_tlv {
struct operation_tlv operation_tlv;
struct reg_tlv reg_tlv;
};
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
);
#endif /* MLX_REG_ACCESS_H_ */
@@ -0,0 +1,74 @@
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "../../mlx_lib/mlx_vmac/mlx_vmac.h"
#include "../../include/public/mlx_icmd.h"
#include "../../include/public/mlx_bail.h"
mlx_status
mlx_vmac_query_virt_mac (
IN mlx_utils *utils,
OUT struct mlx_vmac_query_virt_mac *virt_mac
)
{
mlx_status status = MLX_SUCCESS;
if (utils == NULL || virt_mac == NULL) {
status = MLX_INVALID_PARAMETER;
goto bad_param;
}
status = mlx_icmd_send_command(
utils,
QUERY_VIRTUAL_MAC,
virt_mac,
0,
sizeof(*virt_mac)
);
MLX_CHECK_STATUS(utils, status, icmd_err, "mlx_icmd_send_command failed");
icmd_err:
bad_param:
return status;
}
mlx_status
mlx_vmac_set_virt_mac (
IN mlx_utils *utils,
OUT struct mlx_vmac_set_virt_mac *virt_mac
)
{
mlx_status status = MLX_SUCCESS;
if (utils == NULL || virt_mac == NULL) {
status = MLX_INVALID_PARAMETER;
goto bad_param;
}
status = mlx_icmd_send_command(
utils,
SET_VIRTUAL_MAC,
virt_mac,
sizeof(*virt_mac),
0
);
MLX_CHECK_STATUS(utils, status, icmd_err, "mlx_icmd_send_command failed");
icmd_err:
bad_param:
return status;
}
@@ -0,0 +1,60 @@
#ifndef MLX_VMAC_H_
#define MLX_VMAC_H_
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "../../include/public/mlx_utils.h"
struct mlx_vmac_query_virt_mac {
mlx_uint32 reserved0 :30;
mlx_uint32 mac_aux_v :1;
mlx_uint32 virtual_mac_en :1;
mlx_uint32 parmanent_mac_high :16;
mlx_uint32 reserved1 :16;
mlx_uint32 parmanent_mac_low :32;
mlx_uint32 virtual_mac_high :16;
mlx_uint32 Reserved2 :16;
mlx_uint32 virtual_mac_low :32;
};
struct mlx_vmac_set_virt_mac {
mlx_uint32 Reserved0 :30;
mlx_uint32 mac_aux_v :1;
mlx_uint32 virtual_mac_en :1;
mlx_uint32 reserved1 :32;
mlx_uint32 reserved2 :32;
mlx_uint32 virtual_mac_high;
mlx_uint32 virtual_mac_low;
};
mlx_status
mlx_vmac_query_virt_mac (
IN mlx_utils *utils,
OUT struct mlx_vmac_query_virt_mac *virt_mac
);
mlx_status
mlx_vmac_set_virt_mac (
IN mlx_utils *utils,
OUT struct mlx_vmac_set_virt_mac *virt_mac
);
#endif /* MLX_VMAC_H_ */
@@ -0,0 +1,84 @@
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "mlx_wol_rol.h"
#include "mlx_icmd.h"
#include "mlx_memory.h"
#include "mlx_bail.h"
mlx_status
mlx_set_wol (
IN mlx_utils *utils,
IN mlx_uint8 wol_mask
)
{
mlx_status status = MLX_SUCCESS;
struct mlx_wol_rol wol_rol;
if (utils == NULL) {
status = MLX_INVALID_PARAMETER;
goto bad_param;
}
mlx_memory_set(utils, &wol_rol, 0, sizeof(wol_rol));
wol_rol.wol_mode_valid = TRUE;
wol_rol.wol_mode = wol_mask;
status = mlx_icmd_send_command(
utils,
SET_WOL_ROL,
&wol_rol,
sizeof(wol_rol),
0
);
MLX_CHECK_STATUS(utils, status, icmd_err, "mlx_icmd_send_command failed");
icmd_err:
bad_param:
return status;
}
mlx_status
mlx_query_wol (
IN mlx_utils *utils,
OUT mlx_uint8 *wol_mask
)
{
mlx_status status = MLX_SUCCESS;
struct mlx_wol_rol wol_rol;
if (utils == NULL || wol_mask == NULL) {
status = MLX_INVALID_PARAMETER;
goto bad_param;
}
mlx_memory_set(utils, &wol_rol, 0, sizeof(wol_rol));
status = mlx_icmd_send_command(
utils,
QUERY_WOL_ROL,
&wol_rol,
0,
sizeof(wol_rol)
);
MLX_CHECK_STATUS(utils, status, icmd_err, "mlx_icmd_send_command failed");
*wol_mask = wol_rol.wol_mode;
icmd_err:
bad_param:
return status;
}
@@ -0,0 +1,61 @@
#ifndef MLX_WOL_ROL_H_
#define MLX_WOL_ROL_H_
/*
* Copyright (C) 2015 Mellanox Technologies Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include "mlx_utils.h"
typedef enum {
WOL_MODE_DISABLE = 0x0,
WOL_MODE_SECURE = 0x2,
WOL_MODE_MAGIC = 0x4,
WOL_MODE_ARP = 0x8,
WOL_MODE_BC = 0x10,
WOL_MODE_MC = 0x20,
WOL_MODE_UC = 0x40,
WOL_MODE_PHY = 0x80,
} WOL_MODE;
struct mlx_wol_rol {
mlx_uint32 reserved0 :32;
mlx_uint32 reserved1 :32;
mlx_uint32 wol_mode :8;
mlx_uint32 rol_mode :8;
mlx_uint32 reserved3 :14;
mlx_uint32 wol_mode_valid :1;
mlx_uint32 rol_mode_valid :1;
};
mlx_status
mlx_set_wol (
IN mlx_utils *utils,
IN mlx_uint8 wol_mask
);
mlx_status
mlx_query_wol (
IN mlx_utils *utils,
OUT mlx_uint8 *wol_mask
);
#endif /* MLX_WOL_ROL_H_ */