[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-21 15:09:13 +02:00
committed by Michael Brown
parent 3df598849b
commit 0a20373a2f
57 changed files with 13097 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
/*
* DebugPriv.h
*
* Created on: Jan 19, 2015
* Author: maord
*/
#ifndef STUB_MLXUTILS_INCLUDE_PRIVATE_FLEXBOOT_DEBUG_H_
#define STUB_MLXUTILS_INCLUDE_PRIVATE_FLEXBOOT_DEBUG_H_
#include <stdio.h>
#include <compiler.h>
#define MLX_DEBUG_FATAL_ERROR_PRIVATE(...) do { \
DBG("%s: ",__func__); \
DBG(__VA_ARGS__); \
} while ( 0 )
#define MLX_DEBUG_ERROR_PRIVATE(id, ...) do { \
DBGC(id, "%s: ",__func__); \
DBGC(id, __VA_ARGS__); \
} while ( 0 )
#define MLX_DEBUG_WARN_PRIVATE(id, ...) do { \
DBGC(id, "%s: ",__func__); \
DBGC(id, __VA_ARGS__); \
} while ( 0 )
#define MLX_DEBUG_INFO1_PRIVATE(id, ...) do { \
DBGC(id, "%s: ",__func__); \
DBGC(id, __VA_ARGS__); \
} while ( 0 )
#define MLX_DEBUG_INFO2_PRIVATE(id, ...) do { \
DBGC2(id, "%s: ",__func__); \
DBGC2(id, __VA_ARGS__); \
} while ( 0 )
#define MLX_DBG_ERROR_PRIVATE(...) do { \
DBG("%s: ",__func__); \
DBG(__VA_ARGS__); \
} while ( 0 )
#define MLX_DBG_WARN_PRIVATE(...) do { \
DBG("%s: ",__func__); \
DBG(__VA_ARGS__); \
} while ( 0 )
#define MLX_DBG_INFO1_PRIVATE(...) do { \
DBG("%s: ",__func__); \
DBG(__VA_ARGS__); \
} while ( 0 )
#define MLX_DBG_INFO2_PRIVATE(...) do { \
DBG2("%s: ",__func__); \
DBG2(__VA_ARGS__); \
} while ( 0 )
#endif /* STUB_MLXUTILS_INCLUDE_PRIVATE_FLEXBOOT_DEBUG_H_ */

View File

@@ -0,0 +1,60 @@
/*
* types.h
*
* Created on: Jan 18, 2015
* Author: maord
*/
#ifndef A_MLXUTILS_INCLUDE_PUBLIC_TYPES_H_
#define A_MLXUTILS_INCLUDE_PUBLIC_TYPES_H_
#include <stdint.h>
//#include <errno.h>
#include <ipxe/pci.h>
#define MLX_SUCCESS 0
#define MLX_OUT_OF_RESOURCES (-1)
//(-ENOMEM)
#define MLX_INVALID_PARAMETER (-2)
//(-EINVAL)
#define MLX_UNSUPPORTED (-3)
//(-ENOSYS)
#define MLX_NOT_FOUND (-4)
#define MLX_FAILED (-5)
#undef TRUE
#define TRUE 1
#undef FALSE
#define FALSE !TRUE
typedef int mlx_status;
typedef uint8_t mlx_uint8;
typedef uint16_t mlx_uint16;
typedef uint32_t mlx_uint32;
typedef uint64_t mlx_uint64;
typedef uint32_t mlx_uintn;
typedef int8_t mlx_int8;
typedef int16_t mlx_int16;;
typedef int32_t mlx_int32;
typedef int64_t mlx_int64;
typedef uint8_t mlx_boolean;
typedef struct pci_device mlx_pci;
typedef size_t mlx_size;
typedef void mlx_void;
#define MAC_ADDR_LEN 6
typedef unsigned long mlx_physical_address;
typedef union {
struct {
uint32_t low;
uint32_t high;
} __attribute__ (( packed ));
uint8_t addr[MAC_ADDR_LEN];
} mlx_mac_address;
#endif /* A_MLXUTILS_INCLUDE_PUBLIC_TYPES_H_ */

View File

@@ -0,0 +1,172 @@
/*
* MemoryPriv.c
*
* Created on: Jan 21, 2015
* Author: maord
*/
#include <ipxe/malloc.h>
#include <stddef.h>
#include <byteswap.h>
#include <ipxe/io.h>
#include "../../mlx_utils/include/private/mlx_memory_priv.h"
mlx_status
mlx_memory_alloc_priv(
IN mlx_utils *utils __attribute__ ((unused)),
IN mlx_size size,
OUT mlx_void **ptr
)
{
mlx_status status = MLX_SUCCESS;
*ptr = malloc(size);
if(*ptr == NULL){
status = MLX_OUT_OF_RESOURCES;
}
return status;
}
mlx_status
mlx_memory_zalloc_priv(
IN mlx_utils *utils __attribute__ ((unused)),
IN mlx_size size,
OUT mlx_void **ptr
)
{
mlx_status status = MLX_SUCCESS;
*ptr = zalloc(size);
if(*ptr == NULL){
status = MLX_OUT_OF_RESOURCES;
}
return status;
}
mlx_status
mlx_memory_free_priv(
IN mlx_utils *utils __attribute__ ((unused)),
IN mlx_void *ptr
)
{
mlx_status status = MLX_SUCCESS;
free(ptr);
return status;
}
mlx_status
mlx_memory_alloc_dma_priv(
IN mlx_utils *utils __attribute__ ((unused)),
IN mlx_size size ,
IN mlx_size align,
OUT mlx_void **ptr
)
{
mlx_status status = MLX_SUCCESS;
*ptr = malloc_dma(size, align);
if (*ptr == NULL) {
status = MLX_OUT_OF_RESOURCES;
} else {
memset(*ptr, 0, size);
}
return status;
}
mlx_status
mlx_memory_free_dma_priv(
IN mlx_utils *utils __attribute__ ((unused)),
IN mlx_size size ,
IN mlx_void *ptr
)
{
mlx_status status = MLX_SUCCESS;
free_dma(ptr, size);
return status;
}
mlx_status
mlx_memory_map_dma_priv(
IN mlx_utils *utils __attribute__ ((unused)),
IN mlx_void *addr ,
IN mlx_size number_of_bytes __attribute__ ((unused)),
OUT mlx_physical_address *phys_addr,
OUT mlx_void **mapping __attribute__ ((unused))
)
{
mlx_status status = MLX_SUCCESS;
*phys_addr = virt_to_bus(addr);
return status;
}
mlx_status
mlx_memory_ummap_dma_priv(
IN mlx_utils *utils __attribute__ ((unused)),
IN mlx_void *mapping __attribute__ ((unused))
)
{
mlx_status status = MLX_SUCCESS;
return status;
}
mlx_status
mlx_memory_cmp_priv(
IN mlx_utils *utils __unused,
IN mlx_void *first_block,
IN mlx_void *second_block,
IN mlx_size size,
OUT mlx_uint32 *out
)
{
mlx_status status = MLX_SUCCESS;
*out = memcmp(first_block, second_block, size);
return status;
}
mlx_status
mlx_memory_set_priv(
IN mlx_utils *utils __unused,
IN mlx_void *block,
IN mlx_int32 value,
IN mlx_size size
)
{
mlx_status status = MLX_SUCCESS;
memset(block, value, size);
return status;
}
mlx_status
mlx_memory_cpy_priv(
IN mlx_utils *utils __unused,
OUT mlx_void *destination_buffer,
IN mlx_void *source_buffer,
IN mlx_size length
)
{
mlx_status status = MLX_SUCCESS;
memcpy(destination_buffer, source_buffer, length);
return status;
}
mlx_status
mlx_memory_cpu_to_be32_priv(
IN mlx_utils *utils __unused,
IN mlx_uint32 source,
IN mlx_uint32 *destination
)
{
mlx_status status = MLX_SUCCESS;
*destination = cpu_to_be32(source);
return status;
}
mlx_status
mlx_memory_be32_to_cpu_priv(
IN mlx_utils *utils __unused,
IN mlx_uint32 source,
IN mlx_uint32 *destination
)
{
mlx_status status = MLX_SUCCESS;
*destination = be32_to_cpu(source);
return status;
}

View File

@@ -0,0 +1,182 @@
/*
* MlxPciPriv.c
*
* Created on: Jan 21, 2015
* Author: maord
*/
#include <ipxe/pci.h>
#include "../../mlx_utils/include/private/mlx_pci_priv.h"
static
mlx_status
mlx_pci_config_byte(
IN mlx_utils *utils,
IN mlx_boolean read,
IN mlx_uint32 offset,
IN OUT mlx_uint8 *buffer
)
{
mlx_status status = MLX_SUCCESS;
if (read) {
status = pci_read_config_byte(utils->pci, offset, buffer);
}else {
status = pci_write_config_byte(utils->pci, offset, *buffer);
}
return status;
}
static
mlx_status
mlx_pci_config_word(
IN mlx_utils *utils,
IN mlx_boolean read,
IN mlx_uint32 offset,
IN OUT mlx_uint16 *buffer
)
{
mlx_status status = MLX_SUCCESS;
if (read) {
status = pci_read_config_word(utils->pci, offset, buffer);
}else {
status = pci_write_config_word(utils->pci, offset, *buffer);
}
return status;
}
static
mlx_status
mlx_pci_config_dword(
IN mlx_utils *utils,
IN mlx_boolean read,
IN mlx_uint32 offset,
IN OUT mlx_uint32 *buffer
)
{
mlx_status status = MLX_SUCCESS;
if (read) {
status = pci_read_config_dword(utils->pci, offset, buffer);
}else {
status = pci_write_config_dword(utils->pci, offset, *buffer);
}
return status;
}
static
mlx_status
mlx_pci_config(
IN mlx_utils *utils,
IN mlx_boolean read,
IN mlx_pci_width width,
IN mlx_uint32 offset,
IN mlx_uintn count,
IN OUT mlx_void *buffer
)
{
mlx_status status = MLX_SUCCESS;
mlx_uint8 *tmp = (mlx_uint8*)buffer;
mlx_uintn iteration = 0;
if( width == MlxPciWidthUint64) {
width = MlxPciWidthUint32;
count = count * 2;
}
for(;iteration < count ; iteration++) {
switch (width){
case MlxPciWidthUint8:
status = mlx_pci_config_byte(utils, read , offset++, tmp++);
break;
case MlxPciWidthUint16:
status = mlx_pci_config_word(utils, read , offset, (mlx_uint16*)tmp);
tmp += 2;
offset += 2;
break;
case MlxPciWidthUint32:
status = mlx_pci_config_dword(utils, read , offset, (mlx_uint32*)tmp);
tmp += 4;
offset += 4;
break;
default:
status = MLX_INVALID_PARAMETER;
}
if(status != MLX_SUCCESS) {
goto config_error;
}
}
config_error:
return status;
}
mlx_status
mlx_pci_init_priv(
IN mlx_utils *utils
)
{
mlx_status status = MLX_SUCCESS;
adjust_pci_device ( utils->pci );
#ifdef DEVICE_CX3
utils->config = ioremap ( pci_bar_start ( utils->pci, PCI_BASE_ADDRESS_0),
0x100000 );
#endif
return status;
}
mlx_status
mlx_pci_read_priv(
IN mlx_utils *utils,
IN mlx_pci_width width,
IN mlx_uint32 offset,
IN mlx_uintn count,
OUT mlx_void *buffer
)
{
mlx_status status = MLX_SUCCESS;
status = mlx_pci_config(utils, TRUE, width, offset, count, buffer);
return status;
}
mlx_status
mlx_pci_write_priv(
IN mlx_utils *utils,
IN mlx_pci_width width,
IN mlx_uint32 offset,
IN mlx_uintn count,
IN mlx_void *buffer
)
{
mlx_status status = MLX_SUCCESS;
status = mlx_pci_config(utils, FALSE, width, offset, count, buffer);
return status;
}
mlx_status
mlx_pci_mem_read_priv(
IN mlx_utils *utils __attribute__ ((unused)),
IN mlx_pci_width width __attribute__ ((unused)),
IN mlx_uint8 bar_index __attribute__ ((unused)),
IN mlx_uint64 offset,
IN mlx_uintn count __attribute__ ((unused)),
OUT mlx_void *buffer
)
{
if (buffer == NULL || width != MlxPciWidthUint32)
return MLX_INVALID_PARAMETER;
*((mlx_uint32 *)buffer) = readl(offset);
return MLX_SUCCESS;
}
mlx_status
mlx_pci_mem_write_priv(
IN mlx_utils *utils __attribute__ ((unused)),
IN mlx_pci_width width __attribute__ ((unused)),
IN mlx_uint8 bar_index __attribute__ ((unused)),
IN mlx_uint64 offset,
IN mlx_uintn count __attribute__ ((unused)),
IN mlx_void *buffer
)
{
if (buffer == NULL || width != MlxPciWidthUint32)
return MLX_INVALID_PARAMETER;
barrier();
writel(*((mlx_uint32 *)buffer), offset);
return MLX_SUCCESS;
}

View File

@@ -0,0 +1,83 @@
/*
* MlxUtilsPriv.c
*
* Created on: Jan 25, 2015
* Author: maord
*/
#include <unistd.h>
#include <stdlib.h>
#include <strings.h>
#include "../../mlx_utils/include/private/mlx_utils_priv.h"
mlx_status
mlx_utils_delay_in_ms_priv(
IN mlx_uint32 msecs
)
{
mdelay(msecs);
return MLX_SUCCESS;
}
mlx_status
mlx_utils_delay_in_us_priv(
IN mlx_uint32 usecs
)
{
udelay(usecs);
return MLX_SUCCESS;
}
mlx_status
mlx_utils_ilog2_priv(
IN mlx_uint32 i,
OUT mlx_uint32 *log
)
{
*log = ( fls ( i ) - 1 );
return MLX_SUCCESS;
}
mlx_status
mlx_utils_init_lock_priv(
OUT void **lock __unused
)
{
return MLX_SUCCESS;
}
mlx_status
mlx_utils_free_lock_priv(
IN void *lock __unused
)
{
return MLX_SUCCESS;
}
mlx_status
mlx_utils_acquire_lock_priv (
IN void *lock __unused
)
{
return MLX_SUCCESS;
}
mlx_status
mlx_utils_release_lock_priv (
IN void *lock __unused
)
{
return MLX_SUCCESS;
}
mlx_status
mlx_utils_rand_priv (
IN mlx_utils *utils __unused,
OUT mlx_uint32 *rand_num
)
{
do {
*rand_num = rand();
} while ( *rand_num == 0 );
return MLX_SUCCESS;
}