iPXE
Defines | Typedefs | Functions
mlx_pci_gw.h File Reference
#include "mlx_utils.h"

Go to the source code of this file.

Defines

#define PCI_GW_FIRST_CAPABILITY_POINTER_OFFSET   0x34
#define PCI_GW_CAPABILITY_ID   0x9
#define PCI_GW_CAPABILITY_ID_OFFSET   0x0
#define PCI_GW_CAPABILITY_NEXT_POINTER_OFFSET   0x1
#define PCI_GW_CAPABILITY_SPACE_OFFSET   0x4
#define PCI_GW_CAPABILITY_STATUS_OFFSET   0x7
#define PCI_GW_CAPABILITY_COUNTER_OFFSET   0x8
#define PCI_GW_CAPABILITY_SEMAPHORE_OFFSET   0xC
#define PCI_GW_CAPABILITY_ADDRESS_OFFSET   0x10
#define PCI_GW_CAPABILITY_FLAG_OFFSET   0x10
#define PCI_GW_CAPABILITY_DATA_OFFSET   0x14
#define PCI_GW_SEMPHORE_TRIES   3000000
#define PCI_GW_GET_OWNERSHIP_TRIES   5000
#define PCI_GW_READ_FLAG_TRIES   3000000
#define PCI_GW_WRITE_FLAG   0x80000000
#define PCI_GW_SPACE_NODNIC   0x4
#define PCI_GW_SPACE_ALL_ICMD   0x3
#define PCI_GW_SPACE_SEMAPHORE   0xa
#define PCI_GW_SPACE_CR0   0x2

Typedefs

typedef mlx_uint32 mlx_pci_gw_buffer

Functions

 FILE_LICENCE (GPL2_OR_LATER)
mlx_status mlx_pci_gw_init (IN mlx_utils *utils)
mlx_status mlx_pci_gw_teardown (IN mlx_utils *utils)
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 mlx_pci_gw_write (IN mlx_utils *utils, IN mlx_pci_gw_space space, IN mlx_uint32 address, IN mlx_pci_gw_buffer buffer)

Define Documentation

Definition at line 27 of file mlx_pci_gw.h.

Referenced by mlx_pci_gw_search_capability().

#define PCI_GW_CAPABILITY_ID   0x9

Definition at line 29 of file mlx_pci_gw.h.

Referenced by mlx_pci_gw_check_capability_id().

#define PCI_GW_CAPABILITY_ID_OFFSET   0x0

Definition at line 31 of file mlx_pci_gw.h.

Referenced by mlx_pci_gw_check_capability_id().

Definition at line 32 of file mlx_pci_gw.h.

Referenced by mlx_pci_gw_search_capability().

Definition at line 33 of file mlx_pci_gw.h.

Referenced by mlx_pci_gw_set_space().

Definition at line 34 of file mlx_pci_gw.h.

Referenced by mlx_pci_gw_set_space().

Definition at line 35 of file mlx_pci_gw.h.

Referenced by mlx_pci_gw_get_ownership().

Definition at line 36 of file mlx_pci_gw.h.

Referenced by mlx_pci_gw_free_ownership(), and mlx_pci_gw_get_ownership().

Definition at line 37 of file mlx_pci_gw.h.

Referenced by mlx_pci_gw_read(), and mlx_pci_gw_write().

#define PCI_GW_CAPABILITY_FLAG_OFFSET   0x10

Definition at line 38 of file mlx_pci_gw.h.

Referenced by mlx_pci_gw_wait_for_flag_value().

#define PCI_GW_CAPABILITY_DATA_OFFSET   0x14

Definition at line 39 of file mlx_pci_gw.h.

Referenced by mlx_pci_gw_read(), and mlx_pci_gw_write().

#define PCI_GW_SEMPHORE_TRIES   3000000

Definition at line 41 of file mlx_pci_gw.h.

Referenced by mlx_pci_gw_get_ownership().

#define PCI_GW_GET_OWNERSHIP_TRIES   5000

Definition at line 42 of file mlx_pci_gw.h.

Referenced by mlx_pci_gw_get_ownership().

#define PCI_GW_READ_FLAG_TRIES   3000000

Definition at line 43 of file mlx_pci_gw.h.

Referenced by mlx_pci_gw_wait_for_flag_value().

#define PCI_GW_WRITE_FLAG   0x80000000

Definition at line 45 of file mlx_pci_gw.h.

Referenced by mlx_pci_gw_write().

#define PCI_GW_SPACE_NODNIC   0x4

Definition at line 47 of file mlx_pci_gw.h.

Referenced by flexboot_nodnic_is_supported(), nodnic_cmd_read(), and nodnic_cmd_write().

#define PCI_GW_SPACE_ALL_ICMD   0x3
#define PCI_GW_SPACE_SEMAPHORE   0xa

Definition at line 49 of file mlx_pci_gw.h.

Referenced by mlx_icmd_clear_semaphore(), and mlx_icmd_get_semaphore().

#define PCI_GW_SPACE_CR0   0x2

Definition at line 50 of file mlx_pci_gw.h.


Typedef Documentation

Definition at line 52 of file mlx_pci_gw.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER  )

Definition at line 218 of file mlx_pci_gw.c.

References MLX_CHECK_STATUS, MLX_INVALID_PARAMETER, mlx_pci_gw_get_ownership(), mlx_pci_gw_search_capability(), MLX_SUCCESS, NULL, mlx_pci_gw::pci_cmd_offset, and status.

Referenced by flexboot_nodnic_is_supported(), and init_mlx_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;
}

Definition at line 247 of file mlx_pci_gw.c.

References mlx_pci_gw_free_ownership(), and MLX_SUCCESS.

Referenced by flexboot_nodnic_is_supported(), free_mlx_utils(), and init_mlx_utils().

{
#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 
)

Definition at line 258 of file mlx_pci_gw.c.

References MLX_CHECK_STATUS, MLX_INVALID_PARAMETER, mlx_pci_gw_free_ownership(), mlx_pci_gw_get_ownership(), mlx_pci_gw_set_space(), mlx_pci_gw_wait_for_flag_value(), mlx_pci_read(), mlx_pci_write(), MLX_SUCCESS, mlx_utils_acquire_lock(), mlx_utils_delay_in_us(), mlx_utils_release_lock(), MlxPciWidthUint32, NULL, mlx_pci_gw::pci_cmd_offset, PCI_GW_CAPABILITY_ADDRESS_OFFSET, PCI_GW_CAPABILITY_DATA_OFFSET, mlx_pci_gw::space, status, and TRUE.

Referenced by flexboot_nodnic_is_supported(), mlx_icmd_get_semaphore(), mlx_icmd_get_status(), mlx_icmd_go(), mlx_icmd_init(), mlx_icmd_read_buffer(), mlx_icmd_set_opcode(), and nodnic_cmd_read().

{
        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;
}

Definition at line 328 of file mlx_pci_gw.c.

References FALSE, MLX_CHECK_STATUS, MLX_INVALID_PARAMETER, mlx_pci_gw_free_ownership(), mlx_pci_gw_get_ownership(), mlx_pci_gw_set_space(), mlx_pci_gw_wait_for_flag_value(), mlx_pci_write(), MLX_SUCCESS, mlx_utils_acquire_lock(), mlx_utils_release_lock(), MlxPciWidthUint32, NULL, mlx_pci_gw::pci_cmd_offset, PCI_GW_CAPABILITY_ADDRESS_OFFSET, PCI_GW_CAPABILITY_DATA_OFFSET, PCI_GW_WRITE_FLAG, mlx_pci_gw::space, and status.

Referenced by mlx_icmd_clear_semaphore(), mlx_icmd_get_semaphore(), mlx_icmd_go(), mlx_icmd_set_opcode(), mlx_icmd_write_buffer(), and nodnic_cmd_write().

{
        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;
}