summaryrefslogtreecommitdiff
path: root/roms/ipxe/src/drivers/infiniband/mlx_utils/src/public
diff options
context:
space:
mode:
Diffstat (limited to 'roms/ipxe/src/drivers/infiniband/mlx_utils/src/public')
-rw-r--r--roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_icmd.c371
-rw-r--r--roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_memory.c238
-rw-r--r--roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_pci.c117
-rw-r--r--roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_pci_gw.c392
-rw-r--r--roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_utils.c121
5 files changed, 0 insertions, 1239 deletions
diff --git a/roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_icmd.c b/roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_icmd.c
deleted file mode 100644
index f7d365dee..000000000
--- a/roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_icmd.c
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * 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_bail.h"
-#include "../../include/public/mlx_icmd.h"
-#include "../../include/public/mlx_pci_gw.h"
-#include "../../include/public/mlx_utils.h"
-
-static
-mlx_status
-mlx_icmd_get_semaphore(
- IN mlx_utils *utils
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_uint32 retries = 0;
- mlx_uint32 semaphore_id;
- mlx_uint32 buffer;
- if (utils == NULL) {
- status = MLX_INVALID_PARAMETER;
- goto invalid_param;
- }
-
- status = mlx_utils_rand(utils, &semaphore_id);
- MLX_CHECK_STATUS(utils, status, rand_err, "failed to get random number");
-#define ICMD_GET_SEMAPHORE_TRIES 2560
- for (retries = 0 ; retries < ICMD_GET_SEMAPHORE_TRIES ; retries++) {
- status = mlx_pci_gw_read( utils, PCI_GW_SPACE_SEMAPHORE,
- MLX_ICMD_SEMAPHORE_ADDR, &buffer);
- MLX_CHECK_STATUS(utils, status, read_err, "failed to read icmd semaphore");
- if (buffer != 0) {
- mlx_utils_delay_in_ms(10);
- continue;
- }
- mlx_pci_gw_write( utils, PCI_GW_SPACE_SEMAPHORE,
- MLX_ICMD_SEMAPHORE_ADDR, semaphore_id);
- MLX_CHECK_STATUS(utils, status, set_err, "failed to set icmd semaphore");
- status = mlx_pci_gw_read( utils, PCI_GW_SPACE_SEMAPHORE,
- MLX_ICMD_SEMAPHORE_ADDR, &buffer);
- MLX_CHECK_STATUS(utils, status, read_err, "failed to read icmd semaphore");
- if (semaphore_id == buffer) {
- status = MLX_SUCCESS;
- utils->icmd.took_semaphore = TRUE;
- break;
- }
- mlx_utils_delay_in_ms(10);
- }
- if (semaphore_id != buffer) {
- status = MLX_FAILED;
- }
-read_err:
-set_err:
-rand_err:
-invalid_param:
- return status;
-}
-static
-mlx_status
-mlx_icmd_clear_semaphore(
- IN mlx_utils *utils
- )
-{
- mlx_status status = MLX_SUCCESS;
-
- if (utils == NULL) {
- status = MLX_INVALID_PARAMETER;
- goto invalid_param;
- }
-
- if (utils->icmd.took_semaphore == FALSE) {
- goto semaphore_not_taken;
- }
- status = mlx_pci_gw_write( utils, PCI_GW_SPACE_SEMAPHORE,
- MLX_ICMD_SEMAPHORE_ADDR, 0);
- MLX_CHECK_STATUS(utils, status, read_err, "failed to clear icmd semaphore");
-
- utils->icmd.took_semaphore = FALSE;
-read_err:
-semaphore_not_taken:
-invalid_param:
- return status;
-}
-
-static
-mlx_status
-mlx_icmd_init(
- IN mlx_utils *utils
- )
-{
- mlx_status status = MLX_SUCCESS;
-
- if (utils == NULL) {
- status = MLX_INVALID_PARAMETER;
- goto invalid_param;
- }
- if (utils->icmd.icmd_opened == TRUE) {
- goto already_opened;
- }
-
- utils->icmd.took_semaphore = FALSE;
-
- status = mlx_pci_gw_read( utils, PCI_GW_SPACE_ALL_ICMD,
- MLX_ICMD_MB_SIZE_ADDR, &utils->icmd.max_cmd_size);
- MLX_CHECK_STATUS(utils, status, read_err, "failed to read icmd mail box size");
-
- utils->icmd.icmd_opened = TRUE;
-read_err:
-already_opened:
-invalid_param:
- return status;
-}
-
-static
-mlx_status
-mlx_icmd_set_opcode(
- IN mlx_utils *utils,
- IN mlx_uint16 opcode
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_uint32 buffer;
-
- if (utils == NULL) {
- status = MLX_INVALID_PARAMETER;
- goto invalid_param;
- }
-
- status = mlx_pci_gw_read( utils, PCI_GW_SPACE_ALL_ICMD,
- MLX_ICMD_CTRL_ADDR, &buffer);
- MLX_CHECK_STATUS(utils, status, read_err, "failed to read icmd ctrl");
-
-#define MLX_ICMD_OPCODE_ALIGN 16
-#define MLX_ICMD_OPCODE_MASK 0xffff
-
- buffer = buffer & ~(MLX_ICMD_OPCODE_MASK << MLX_ICMD_OPCODE_ALIGN);
- buffer = buffer | (opcode << MLX_ICMD_OPCODE_ALIGN);
-
- status = mlx_pci_gw_write( utils, PCI_GW_SPACE_ALL_ICMD,
- MLX_ICMD_CTRL_ADDR, buffer);
- MLX_CHECK_STATUS(utils, status, write_err, "failed to write icmd ctrl");
-write_err:
-read_err:
-invalid_param:
- return status;
-}
-
-static
-mlx_status
-mlx_icmd_go(
- IN mlx_utils *utils
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_uint32 buffer;
- mlx_uint32 busy;
- mlx_uint32 wait_iteration = 0;
-
- if (utils == NULL) {
- status = MLX_INVALID_PARAMETER;
- goto invalid_param;
- }
-
- status = mlx_pci_gw_read( utils, PCI_GW_SPACE_ALL_ICMD,
- MLX_ICMD_CTRL_ADDR, &buffer);
- MLX_CHECK_STATUS(utils, status, read_err, "failed to read icmd ctrl");
-
-#define MLX_ICMD_BUSY_ALIGN 0
-#define MLX_ICMD_BUSY_MASK 0x1
-
- busy = (buffer >> MLX_ICMD_BUSY_ALIGN) & MLX_ICMD_BUSY_MASK;
- if (busy != 0) {
- status = MLX_FAILED;
- goto already_busy;
- }
-
- buffer = buffer | (1 << MLX_ICMD_BUSY_ALIGN);
-
- status = mlx_pci_gw_write( utils, PCI_GW_SPACE_ALL_ICMD,
- MLX_ICMD_CTRL_ADDR, buffer);
- MLX_CHECK_STATUS(utils, status, write_err, "failed to write icmd ctrl");
-
-#define MLX_ICMD_BUSY_MAX_ITERATIONS 1024
- do {
- if (++wait_iteration > MLX_ICMD_BUSY_MAX_ITERATIONS) {
- status = MLX_FAILED;
- MLX_DEBUG_ERROR(utils, "ICMD time out");
- goto busy_timeout;
- }
-
- mlx_utils_delay_in_ms(10);
- status = mlx_pci_gw_read( utils, PCI_GW_SPACE_ALL_ICMD,
- MLX_ICMD_CTRL_ADDR, &buffer);
- MLX_CHECK_STATUS(utils, status, read_err, "failed to read icmd ctrl");
- busy = (buffer >> MLX_ICMD_BUSY_ALIGN) & MLX_ICMD_BUSY_MASK;
- } while (busy != 0);
-
-busy_timeout:
-write_err:
-already_busy:
-read_err:
-invalid_param:
- return status;
-}
-
-static
-mlx_status
-mlx_icmd_get_status(
- IN mlx_utils *utils,
- OUT mlx_uint32 *out_status
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_uint32 buffer;
-
- if (utils == NULL || out_status == NULL) {
- status = MLX_INVALID_PARAMETER;
- goto invalid_param;
- }
-
- status = mlx_pci_gw_read( utils, PCI_GW_SPACE_ALL_ICMD,
- MLX_ICMD_CTRL_ADDR, &buffer);
- MLX_CHECK_STATUS(utils, status, read_err, "failed to read icmd ctrl");
-
-#define MLX_ICMD_STATUS_ALIGN 8
-#define MLX_ICMD_STATUS_MASK 0xff
-
- *out_status = (buffer >> MLX_ICMD_STATUS_ALIGN) & MLX_ICMD_STATUS_MASK;
-
-read_err:
-invalid_param:
- return status;
-}
-
-static
-mlx_status
-mlx_icmd_write_buffer(
- IN mlx_utils *utils,
- IN mlx_void* data,
- IN mlx_uint32 data_size
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_uint32 data_offset = 0;
- mlx_size dword_size = sizeof(mlx_uint32);
-
- if (utils == NULL || data == NULL) {
- status = MLX_INVALID_PARAMETER;
- goto invalid_param;
- }
-
- for (data_offset = 0 ; data_offset*dword_size < data_size ; data_offset++) {
- status = mlx_pci_gw_write( utils, PCI_GW_SPACE_ALL_ICMD,
- MLX_ICMD_MB_ADDR + data_offset*dword_size,
- ((mlx_uint32*)data)[data_offset]);
- MLX_CHECK_STATUS(utils, status, write_err, "failed to write icmd MB");
- }
-write_err:
-invalid_param:
- return status;
-}
-
-
-static
-mlx_status
-mlx_icmd_read_buffer(
- IN mlx_utils *utils,
- OUT mlx_void* data,
- IN mlx_uint32 data_size
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_uint32 data_offset = 0;
- mlx_size dword_size = sizeof(mlx_uint32);
-
- if (utils == NULL || data == NULL) {
- status = MLX_INVALID_PARAMETER;
- goto invalid_param;
- }
-
- for (data_offset = 0 ; data_offset*dword_size < data_size ; data_offset++) {
- status = mlx_pci_gw_read( utils, PCI_GW_SPACE_ALL_ICMD,
- MLX_ICMD_MB_ADDR + data_offset*dword_size,
- (mlx_uint32*)data + data_offset);
- MLX_CHECK_STATUS(utils, status, read_err, "failed to read icmd MB");
- }
-read_err:
-invalid_param:
- return status;
-}
-mlx_status
-mlx_icmd_send_command(
- IN mlx_utils *utils,
- IN mlx_uint16 opcode,
- IN OUT mlx_void* data,
- IN mlx_uint32 write_data_size,
- IN mlx_uint32 read_data_size
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_uint32 icmd_status = MLX_FAILED;
-
- if (utils == NULL || data == NULL) {
- status = MLX_INVALID_PARAMETER;
- goto invalid_param;
- }
- status = mlx_icmd_init(utils);
- MLX_CHECK_STATUS(utils, status, open_err, "failed to open icmd");
-
- if (write_data_size > utils->icmd.max_cmd_size ||
- read_data_size > utils->icmd.max_cmd_size) {
- status = MLX_INVALID_PARAMETER;
- goto size_err;
- }
-
- status = mlx_icmd_get_semaphore(utils);
- MLX_CHECK_STATUS(utils, status, semaphore_err, "failed to get icmd semaphore");
-
- status = mlx_icmd_set_opcode(utils, opcode);
- MLX_CHECK_STATUS(utils, status, opcode_err, "failed to set icmd opcode");
-
- if (write_data_size != 0) {
- status = mlx_icmd_write_buffer(utils, data, write_data_size);
- MLX_CHECK_STATUS(utils, status, opcode_err, "failed to write icmd MB");
- }
-
- status = mlx_icmd_go(utils);
- MLX_CHECK_STATUS(utils, status, go_err, "failed to activate icmd");
-
- status = mlx_icmd_get_status(utils, &icmd_status);
- MLX_CHECK_STATUS(utils, status, get_status_err, "failed to set icmd opcode");
-
- if (icmd_status != 0) {
- MLX_DEBUG_ERROR(utils, "icmd failed with status = %d\n", icmd_status);
- status = MLX_FAILED;
- goto icmd_failed;
- }
- if (read_data_size != 0) {
- status = mlx_icmd_read_buffer(utils, data, read_data_size);
- MLX_CHECK_STATUS(utils, status, read_err, "failed to read icmd MB");
- }
-read_err:
-icmd_failed:
-get_status_err:
-go_err:
-opcode_err:
- mlx_icmd_clear_semaphore(utils);
-semaphore_err:
-size_err:
-open_err:
-invalid_param:
- return status;
-}
diff --git a/roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_memory.c b/roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_memory.c
deleted file mode 100644
index 5aa5a53d2..000000000
--- a/roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_memory.c
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * 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 <stddef.h>
-#include "../../include/private/mlx_memory_priv.h"
-#include "../../include/public/mlx_memory.h"
-
-mlx_status
-mlx_memory_alloc(
- IN mlx_utils *utils,
- IN mlx_size size,
- OUT mlx_void **ptr
- )
-{
- mlx_status status = MLX_SUCCESS;
- *ptr = NULL;
- if ( utils == NULL || size == 0 || *ptr != NULL ){
- status = MLX_INVALID_PARAMETER;
- goto bad_param;
- }
- status = mlx_memory_alloc_priv(utils, size, ptr);
-bad_param:
- return status;
-}
-
-mlx_status
-mlx_memory_zalloc(
- IN mlx_utils *utils,
- IN mlx_size size,
- OUT mlx_void **ptr
- )
-{
- mlx_status status = MLX_SUCCESS;
- *ptr = NULL;
- if ( utils == NULL || size == 0 || *ptr != NULL ){
- status = MLX_INVALID_PARAMETER;
- goto bad_param;
- }
- status = mlx_memory_zalloc_priv(utils, size, ptr);
-bad_param:
- return status;
-}
-
-mlx_status
-mlx_memory_free(
- IN mlx_utils *utils,
- IN mlx_void **ptr
- )
-{
- mlx_status status = MLX_SUCCESS;
- if ( utils == NULL || ptr == NULL || *ptr == NULL ){
- status = MLX_INVALID_PARAMETER;
- goto bad_param;
- }
- status = mlx_memory_free_priv(utils, *ptr);
- *ptr = NULL;
-bad_param:
- return status;
-}
-mlx_status
-mlx_memory_alloc_dma(
- IN mlx_utils *utils,
- IN mlx_size size ,
- IN mlx_size align,
- OUT mlx_void **ptr
- )
-{
- mlx_status status = MLX_SUCCESS;
- *ptr = NULL;
- if ( utils == NULL || size == 0 || *ptr != NULL ){
- status = MLX_INVALID_PARAMETER;
- goto bad_param;
- }
- status = mlx_memory_alloc_dma_priv(utils, size, align, ptr);
-bad_param:
- return status;
-}
-
-mlx_status
-mlx_memory_free_dma(
- IN mlx_utils *utils,
- IN mlx_size size ,
- IN mlx_void **ptr
- )
-{
- mlx_status status = MLX_SUCCESS;
- if ( utils == NULL || size == 0 || ptr == NULL || *ptr == NULL ){
- status = MLX_INVALID_PARAMETER;
- goto bad_param;
- }
- status = mlx_memory_free_dma_priv(utils, size, *ptr);
- *ptr = NULL;
-bad_param:
- return status;
-}
-
-mlx_status
-mlx_memory_map_dma(
- IN mlx_utils *utils,
- IN mlx_void *addr ,
- IN mlx_size number_of_bytes,
- OUT mlx_physical_address *phys_addr,
- OUT mlx_void **mapping
- )
-{
- mlx_status status = MLX_SUCCESS;
- if ( utils == NULL || phys_addr == NULL ){
- status = MLX_INVALID_PARAMETER;
- goto bad_param;
- }
- status = mlx_memory_map_dma_priv(utils, addr, number_of_bytes, phys_addr, mapping);
-bad_param:
- return status;
-}
-
-mlx_status
-mlx_memory_ummap_dma(
- IN mlx_utils *utils,
- IN mlx_void *mapping
- )
-{
- mlx_status status = MLX_SUCCESS;
- if ( utils == NULL){
- status = MLX_INVALID_PARAMETER;
- goto bad_param;
- }
- status = mlx_memory_ummap_dma_priv(utils, mapping);
-bad_param:
- return status;
-}
-
-mlx_status
-mlx_memory_cmp(
- IN mlx_utils *utils,
- IN mlx_void *first_block,
- IN mlx_void *second_block,
- IN mlx_size size,
- OUT mlx_uint32 *out
- )
-{
- mlx_status status = MLX_SUCCESS;
- if ( utils == NULL || first_block == NULL || second_block == NULL ||
- out == NULL){
- status = MLX_INVALID_PARAMETER;
- goto bad_param;
- }
- status = mlx_memory_cmp_priv(utils, first_block, second_block, size, out);
-bad_param:
- return status;
-}
-
-mlx_status
-mlx_memory_set(
- IN mlx_utils *utils,
- IN mlx_void *block,
- IN mlx_int32 value,
- IN mlx_size size
- )
-{
- mlx_status status = MLX_SUCCESS;
- if ( utils == NULL || block == NULL){
- status = MLX_INVALID_PARAMETER;
- goto bad_param;
- }
- status = mlx_memory_set_priv(utils, block, value, size);
-bad_param:
- return status;
-}
-
-mlx_status
-mlx_memory_cpy(
- IN mlx_utils *utils,
- OUT mlx_void *destination_buffer,
- IN mlx_void *source_buffer,
- IN mlx_size length
- )
-{
- mlx_status status = MLX_SUCCESS;
- if ( utils == NULL || destination_buffer == NULL || source_buffer == NULL){
- status = MLX_INVALID_PARAMETER;
- goto bad_param;
- }
- status = mlx_memory_cpy_priv(utils, destination_buffer, source_buffer, length);
-bad_param:
- return status;
-}
-
-mlx_status
-mlx_memory_cpu_to_be32(
- IN mlx_utils *utils,
- IN mlx_uint32 source,
- IN mlx_uint32 *destination
- )
-{
- mlx_status status = MLX_SUCCESS;
- if ( utils == NULL || destination == NULL ){
- status = MLX_INVALID_PARAMETER;
- goto bad_param;
- }
- status = mlx_memory_cpu_to_be32_priv(utils, source, destination);
-bad_param:
- return status;
-}
-
-mlx_status
-mlx_memory_be32_to_cpu(
- IN mlx_utils *utils,
- IN mlx_uint32 source,
- IN mlx_uint32 *destination
- )
-{
- mlx_status status = MLX_SUCCESS;
- if ( utils == NULL || destination == NULL ){
- status = MLX_INVALID_PARAMETER;
- goto bad_param;
- }
- status = mlx_memory_be32_to_cpu_priv(utils, source, destination);
-bad_param:
- return status;
-}
diff --git a/roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_pci.c b/roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_pci.c
deleted file mode 100644
index 91c44d991..000000000
--- a/roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_pci.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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 <stddef.h>
-#include "../../include/private/mlx_pci_priv.h"
-#include "../../include/public/mlx_pci.h"
-
-mlx_status
-mlx_pci_init(
- IN mlx_utils *utils
- )
-{
- mlx_status status = MLX_SUCCESS;
- if( utils == NULL){
- status = MLX_INVALID_PARAMETER;
- goto bail;
- }
- status = mlx_pci_init_priv(utils);
-bail:
- return status;
-}
-
-mlx_status
-mlx_pci_read(
- 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;
- if( utils == NULL || count == 0){
- status = MLX_INVALID_PARAMETER;
- goto bail;
- }
- status = mlx_pci_read_priv(utils, width, offset, count, buffer);
-bail:
- return status;
-}
-
-mlx_status
-mlx_pci_write(
- 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;
- if( utils == NULL || count == 0){
- status = MLX_INVALID_PARAMETER;
- goto bail;
- }
- status = mlx_pci_write_priv(utils, width, offset, count, buffer);
-bail:
- return status;
-}
-
-mlx_status
-mlx_pci_mem_read(
- IN mlx_utils *utils,
- IN mlx_pci_width width,
- IN mlx_uint8 bar_index,
- IN mlx_uint64 offset,
- IN mlx_uintn count,
- OUT mlx_void *buffer
- )
-{
- mlx_status status = MLX_SUCCESS;
- if( utils == NULL || count == 0){
- status = MLX_INVALID_PARAMETER;
- goto bail;
- }
- status = mlx_pci_mem_read_priv(utils, bar_index, width, offset, count, buffer);
-bail:
- return status;
-}
-
-mlx_status
-mlx_pci_mem_write(
- IN mlx_utils *utils,
- IN mlx_pci_width width,
- IN mlx_uint8 bar_index,
- IN mlx_uint64 offset,
- IN mlx_uintn count,
- IN mlx_void *buffer
- )
-{
- mlx_status status = MLX_SUCCESS;
- if( utils == NULL || count == 0){
- status = MLX_INVALID_PARAMETER;
- goto bail;
- }
- status = mlx_pci_mem_write_priv(utils, width, bar_index, offset, count, buffer);
-bail:
- return status;
-}
diff --git a/roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_pci_gw.c b/roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_pci_gw.c
deleted file mode 100644
index 30c1e644e..000000000
--- a/roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_pci_gw.c
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- * 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_pci_gw.h"
-#include "../../include/public/mlx_bail.h"
-#include "../../include/public/mlx_pci.h"
-#include "../../include/public/mlx_logging.h"
-
-/* Lock/unlock GW on each VSEC access */
-#undef VSEC_DEBUG
-
-static
-mlx_status
-mlx_pci_gw_check_capability_id(
- IN mlx_utils *utils,
- IN mlx_uint8 cap_pointer,
- OUT mlx_boolean *bool
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_uint8 offset = cap_pointer + PCI_GW_CAPABILITY_ID_OFFSET;
- mlx_uint8 id = 0;
- status = mlx_pci_read(utils, MlxPciWidthUint8, offset,
- 1, &id);
- MLX_CHECK_STATUS(utils, status, read_err,"failed to read capability id");
- *bool = ( id == PCI_GW_CAPABILITY_ID );
-read_err:
- return status;
-}
-
-static
-mlx_status
-mlx_pci_gw_get_ownership(
- IN mlx_utils *utils
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_uint32 cap_offset = utils->pci_gw.pci_cmd_offset;
- mlx_uint32 semaphore = 0;
- mlx_uint32 counter = 0;
- mlx_uint32 get_semaphore_try = 0;
- mlx_uint32 get_ownership_try = 0;
-
- for( ; get_ownership_try < PCI_GW_GET_OWNERSHIP_TRIES; get_ownership_try ++){
- for( ; get_semaphore_try <= PCI_GW_SEMPHORE_TRIES ; get_semaphore_try++){
- status = mlx_pci_read(utils, MlxPciWidthUint32, cap_offset + PCI_GW_CAPABILITY_SEMAPHORE_OFFSET,
- 1, &semaphore);
- MLX_CHECK_STATUS(utils, status, read_err,"failed to read semaphore");
- if( semaphore == 0 ){
- break;
- }
- mlx_utils_delay_in_us(10);
- }
- if( semaphore != 0 ){
- status = MLX_FAILED;
- goto semaphore_err;
- }
-
- status = mlx_pci_read(utils, MlxPciWidthUint32, cap_offset + PCI_GW_CAPABILITY_COUNTER_OFFSET,
- 1, &counter);
- MLX_CHECK_STATUS(utils, status, read_err, "failed to read counter");
-
- status = mlx_pci_write(utils, MlxPciWidthUint32, cap_offset + PCI_GW_CAPABILITY_SEMAPHORE_OFFSET,
- 1, &counter);
- MLX_CHECK_STATUS(utils, status, write_err,"failed to write semaphore");
-
- status = mlx_pci_read(utils, MlxPciWidthUint32, cap_offset + PCI_GW_CAPABILITY_SEMAPHORE_OFFSET,
- 1, &semaphore);
- MLX_CHECK_STATUS(utils, status, read_err,"failed to read semaphore");
- if( counter == semaphore ){
- break;
- }
- }
- if( counter != semaphore ){
- status = MLX_FAILED;
- }
-write_err:
-read_err:
-semaphore_err:
- return status;
-}
-
-static
-mlx_status
-mlx_pci_gw_free_ownership(
- IN mlx_utils *utils
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_uint32 cap_offset = utils->pci_gw.pci_cmd_offset;
- mlx_uint32 value = 0;
-
- status = mlx_pci_write(utils, MlxPciWidthUint32, cap_offset + PCI_GW_CAPABILITY_SEMAPHORE_OFFSET,
- 1, &value);
- MLX_CHECK_STATUS(utils, status, write_err,"failed to write semaphore");
-write_err:
- return status;
-}
-
-static
-mlx_status
-mlx_pci_gw_set_space(
- IN mlx_utils *utils,
- IN mlx_pci_gw_space space
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_uint32 cap_offset = utils->pci_gw.pci_cmd_offset;;
- mlx_uint8 space_status = 0;
-
- /* set nodnic*/
- status = mlx_pci_write(utils, MlxPciWidthUint16, cap_offset + PCI_GW_CAPABILITY_SPACE_OFFSET, 1, &space);
- MLX_CHECK_STATUS(utils, status, read_error,"failed to write capability space");
-
- status = mlx_pci_read(utils, MlxPciWidthUint8, cap_offset + PCI_GW_CAPABILITY_STATUS_OFFSET, 1, &space_status);
- MLX_CHECK_STATUS(utils, status, read_error,"failed to read capability status");
- if( (space_status & 0x20) == 0){
- status = MLX_FAILED;
- goto space_unsupported;
- }
-read_error:
-space_unsupported:
- return status;
-}
-
-static
-mlx_status
-mlx_pci_gw_wait_for_flag_value(
- IN mlx_utils *utils,
- IN mlx_boolean value
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_uint32 try = 0;
- mlx_uint32 cap_offset = utils->pci_gw.pci_cmd_offset;
- mlx_uint32 flag = 0;
-
- for(; try < PCI_GW_READ_FLAG_TRIES ; try ++ ) {
- status = mlx_pci_read(utils, MlxPciWidthUint32, cap_offset + PCI_GW_CAPABILITY_FLAG_OFFSET, 1, &flag);
- MLX_CHECK_STATUS(utils, status, read_error, "failed to read capability flag");
- if( ((flag & 0x80000000) != 0) == value ){
- goto flag_valid;
- }
- mlx_utils_delay_in_us(10);
- }
- status = MLX_FAILED;
-flag_valid:
-read_error:
- return status;
-}
-static
-mlx_status
-mlx_pci_gw_search_capability(
- IN mlx_utils *utils,
- OUT mlx_uint32 *cap_offset
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_uint8 cap_pointer = 0;
- mlx_boolean is_capability = FALSE;
-
- if( cap_offset == NULL || utils == NULL){
- status = MLX_INVALID_PARAMETER;
- goto bad_param;
- }
-
- //get first capability pointer
- status = mlx_pci_read(utils, MlxPciWidthUint8, PCI_GW_FIRST_CAPABILITY_POINTER_OFFSET,
- 1, &cap_pointer);
- MLX_CHECK_STATUS(utils, status, read_err,
- "failed to read capability pointer");
-
- //search the right capability
- while( cap_pointer != 0 ){
- status = mlx_pci_gw_check_capability_id(utils, cap_pointer, &is_capability);
- MLX_CHECK_STATUS(utils, status, check_err
- ,"failed to check capability id");
-
- if( is_capability == TRUE ){
- *cap_offset = cap_pointer;
- break;
- }
-
- status = mlx_pci_read(utils, MlxPciWidthUint8, cap_pointer +
- PCI_GW_CAPABILITY_NEXT_POINTER_OFFSET ,
- 1, &cap_pointer);
- MLX_CHECK_STATUS(utils, status, read_err,
- "failed to read capability pointer");
- }
- if( is_capability != TRUE ){
- status = MLX_NOT_FOUND;
- }
-check_err:
-read_err:
-bad_param:
- return status;
-}
-
-mlx_status
-mlx_pci_gw_init(
- IN mlx_utils *utils
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_pci_gw *pci_gw = NULL;
-
- if( utils == NULL){
- status = MLX_INVALID_PARAMETER;
- goto bad_param;
- }
-
- pci_gw = &utils->pci_gw;
-
- status = mlx_pci_gw_search_capability(utils, &pci_gw->pci_cmd_offset);
- MLX_CHECK_STATUS(utils, status, cap_err,
- "mlx_pci_gw_search_capability failed");
-
-#if ! defined ( VSEC_DEBUG )
- status = mlx_pci_gw_get_ownership(utils);
- MLX_CHECK_STATUS(utils, status, ownership_err,"failed to get ownership");
-ownership_err:
-#endif
-cap_err:
-bad_param:
- return status;
-}
-
-mlx_status
-mlx_pci_gw_teardown(
- IN mlx_utils *utils __attribute__ ((unused))
- )
-{
-#if ! defined ( VSEC_DEBUG )
- mlx_pci_gw_free_ownership(utils);
-#endif
- return MLX_SUCCESS;
-}
-
-mlx_status
-mlx_pci_gw_read(
- IN mlx_utils *utils,
- IN mlx_pci_gw_space space,
- IN mlx_uint32 address,
- OUT mlx_pci_gw_buffer *buffer
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_pci_gw *pci_gw = NULL;
- mlx_uint32 cap_offset = 0;
-
- if (utils == NULL || buffer == NULL || utils->pci_gw.pci_cmd_offset == 0) {
- status = MLX_INVALID_PARAMETER;
- goto bad_param;
- }
-
- mlx_utils_acquire_lock(utils);
-
- pci_gw = &utils->pci_gw;
- cap_offset = pci_gw->pci_cmd_offset;
-
-#if ! defined ( VSEC_DEBUG )
- if (pci_gw->space != space) {
- status = mlx_pci_gw_set_space(utils, space);
- MLX_CHECK_STATUS(utils, status, space_error,"failed to set space");
- pci_gw->space = space;
- }
-#else
- status = mlx_pci_gw_get_ownership(utils);
- MLX_CHECK_STATUS(utils, status, ownership_err,"failed to get ownership");
-
- status = mlx_pci_gw_set_space(utils, space);
- MLX_CHECK_STATUS(utils, status, space_error,"failed to set space");
- pci_gw->space = space;
-#endif
-
- status = mlx_pci_write(utils, MlxPciWidthUint32, cap_offset + PCI_GW_CAPABILITY_ADDRESS_OFFSET, 1, &address);
- MLX_CHECK_STATUS(utils, status, read_error,"failed to write capability address");
-
-#if defined ( DEVICE_CX3 )
- /* WA for PCI issue (race) */
- mlx_utils_delay_in_us ( 10 );
-#endif
-
- status = mlx_pci_gw_wait_for_flag_value(utils, TRUE);
- MLX_CHECK_STATUS(utils, status, read_error, "flag failed to change");
-
- status = mlx_pci_read(utils, MlxPciWidthUint32, cap_offset + PCI_GW_CAPABILITY_DATA_OFFSET, 1, buffer);
- MLX_CHECK_STATUS(utils, status, read_error,"failed to read capability data");
-
-#if defined ( VSEC_DEBUG )
- status = mlx_pci_gw_free_ownership(utils);
- MLX_CHECK_STATUS(utils, status, free_err,
- "mlx_pci_gw_free_ownership failed");
-free_err:
- mlx_utils_release_lock(utils);
- return status;
-#endif
-read_error:
-space_error:
-#if defined ( VSEC_DEBUG )
- mlx_pci_gw_free_ownership(utils);
-ownership_err:
-#endif
-mlx_utils_release_lock(utils);
-bad_param:
- return status;
-}
-
-mlx_status
-mlx_pci_gw_write(
- IN mlx_utils *utils,
- IN mlx_pci_gw_space space,
- IN mlx_uint32 address,
- IN mlx_pci_gw_buffer buffer
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_pci_gw *pci_gw = NULL;
- mlx_uint32 cap_offset = 0;
- mlx_uint32 fixed_address = address | PCI_GW_WRITE_FLAG;
-
- if (utils == NULL || utils->pci_gw.pci_cmd_offset == 0) {
- status = MLX_INVALID_PARAMETER;
- goto bad_param;
- }
-
- mlx_utils_acquire_lock(utils);
-
- pci_gw = &utils->pci_gw;
- cap_offset = pci_gw->pci_cmd_offset;
-
-#if ! defined ( VSEC_DEBUG )
- if (pci_gw->space != space) {
- status = mlx_pci_gw_set_space(utils, space);
- MLX_CHECK_STATUS(utils, status, space_error,"failed to set space");
- pci_gw->space = space;
- }
-#else
- status = mlx_pci_gw_get_ownership(utils);
- MLX_CHECK_STATUS(utils, status, ownership_err,"failed to get ownership");
-
- status = mlx_pci_gw_set_space(utils, space);
- MLX_CHECK_STATUS(utils, status, space_error,"failed to set space");
- pci_gw->space = space;
-#endif
- status = mlx_pci_write(utils, MlxPciWidthUint32, cap_offset + PCI_GW_CAPABILITY_DATA_OFFSET, 1, &buffer);
- MLX_CHECK_STATUS(utils, status, read_error,"failed to write capability data");
-
- status = mlx_pci_write(utils, MlxPciWidthUint32, cap_offset + PCI_GW_CAPABILITY_ADDRESS_OFFSET, 1, &fixed_address);
- MLX_CHECK_STATUS(utils, status, read_error,"failed to write capability address");
-
- status = mlx_pci_gw_wait_for_flag_value(utils, FALSE);
- MLX_CHECK_STATUS(utils, status, read_error, "flag failed to change");
-#if defined ( VSEC_DEBUG )
- status = mlx_pci_gw_free_ownership(utils);
- MLX_CHECK_STATUS(utils, status, free_err,
- "mlx_pci_gw_free_ownership failed");
-free_err:
-mlx_utils_release_lock(utils);
- return status;
-#endif
-read_error:
-space_error:
-#if defined ( VSEC_DEBUG )
- mlx_pci_gw_free_ownership(utils);
-ownership_err:
-#endif
-mlx_utils_release_lock(utils);
-bad_param:
- return status;
-}
-
-
-
diff --git a/roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_utils.c b/roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_utils.c
deleted file mode 100644
index c824b17e9..000000000
--- a/roms/ipxe/src/drivers/infiniband/mlx_utils/src/public/mlx_utils.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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 <stddef.h>
-#include "../../include/private/mlx_utils_priv.h"
-#include "../../include/public/mlx_pci.h"
-#include "../../include/public/mlx_utils.h"
-
-mlx_status
-mlx_utils_init(
- IN mlx_utils *utils,
- IN mlx_pci *pci
- )
-{
- mlx_status status = MLX_SUCCESS;
- if( pci == NULL || utils == NULL ){
- status = MLX_INVALID_PARAMETER;
- goto bail;
- }
- utils->pci = pci;
- status = mlx_pci_init(utils);
- status = mlx_utils_init_lock(utils);
-bail:
- return status;
-}
-
-mlx_status
-mlx_utils_teardown(
- IN mlx_utils *utils __attribute__ ((unused))
- )
-{
- mlx_status status = MLX_SUCCESS;
- mlx_utils_free_lock(utils);
- return status;
-}
-
-mlx_status
-mlx_utils_delay_in_ms(
- IN mlx_uint32 msecs
- )
-{
- mlx_utils_delay_in_ms_priv(msecs);
- return MLX_SUCCESS;
-}
-mlx_status
-mlx_utils_delay_in_us(
- IN mlx_uint32 usecs
- )
-{
- mlx_utils_delay_in_us_priv(usecs);
- return MLX_SUCCESS;
-}
-mlx_status
-mlx_utils_ilog2(
- IN mlx_uint32 i,
- OUT mlx_uint32 *log
- )
-{
- mlx_utils_ilog2_priv(i, log);
- return MLX_SUCCESS;
-}
-
-mlx_status
-mlx_utils_init_lock(
- IN OUT mlx_utils *utils
- )
-{
- return mlx_utils_init_lock_priv(&(utils->lock));
-
-}
-
-mlx_status
-mlx_utils_free_lock(
- IN OUT mlx_utils *utils
- )
-{
- return mlx_utils_free_lock_priv(utils->lock);
-}
-
-mlx_status
-mlx_utils_acquire_lock (
- IN OUT mlx_utils *utils
- )
-{
- return mlx_utils_acquire_lock_priv(utils->lock);
-}
-
-mlx_status
-mlx_utils_release_lock (
- IN OUT mlx_utils *utils
- )
-{
- return mlx_utils_release_lock_priv(utils->lock);
-}
-
-mlx_status
-mlx_utils_rand (
- IN mlx_utils *utils,
- OUT mlx_uint32 *rand_num
- )
-{
- return mlx_utils_rand_priv(utils, rand_num);
-}