iPXE
Defines | Functions | Variables
mlx_port.c File Reference
#include "../include/mlx_port.h"
#include "../include/mlx_cmd.h"
#include "../../mlx_utils/include/public/mlx_memory.h"
#include "../../mlx_utils/include/public/mlx_pci.h"
#include "../../mlx_utils/include/public/mlx_bail.h"

Go to the source code of this file.

Defines

#define PortDataEntry(_option, _offset, _align, _mask)
#define QpDataEntry(_type, _send_offset, _recv_offset)
#define MAX_QP_DATA_ENTRIES   5
#define MAX_NODNIC_PORTS   2
#define NODNIC_PORT_ARM_CQ_DBR_ADDR_LOW_OFFSET   0x114
#define NODNIC_PORT_ARM_CQ_DBR_ADDR_HIGH_OFFSET   0x110
#define NODIC_CQ_ADDR_HIGH   0x68
#define NODIC_CQ_ADDR_LOW   0x6c
#define NODNIC_RING_DBR_ADDR_LOW_OFFSET   0x1C
#define NODNIC_RING_DBR_ADDR_HIGH_OFFSET   0x18
#define NODIC_RING_QP_ADDR_HIGH   0x0
#define NODIC_RING_QP_ADDR_LOW   0x4
#define NODNIC_RING_QPN_OFFSET   0xc
#define NODNIC_RING_QPN_MASK   0xFFFFFF
#define NODNIC_RING_RING_OFFSET   0x8

Functions

 FILE_LICENCE (GPL2_OR_LATER)
mlx_status nodnic_port_get_state (IN nodnic_port_priv *port_priv, OUT nodnic_port_state *state)
mlx_status nodnic_port_get_type (IN nodnic_port_priv *port_priv, OUT nodnic_port_type *type)
mlx_status nodnic_port_query (IN nodnic_port_priv *port_priv, IN nodnic_port_option option, OUT mlx_uint32 *out)
mlx_status nodnic_port_set (IN nodnic_port_priv *port_priv, IN nodnic_port_option option, IN mlx_uint32 in)
mlx_status nodnic_port_set_send_uar_offset (IN nodnic_port_priv *port_priv)
mlx_status nodnic_port_read_reset_needed (IN nodnic_port_priv *port_priv, OUT mlx_boolean *reset_needed)
mlx_status nodnic_port_read_port_management_change_event (IN nodnic_port_priv *port_priv, OUT mlx_boolean *change_event)
static mlx_status nodnic_port_allocate_dbr_dma (IN nodnic_port_priv *port_priv, IN struct nodnic_doorbell *nodnic_db, IN mlx_uint32 dbr_addr_low_ofst, IN mlx_uint32 dbr_addr_high_ofst, IN void **dbr_addr, IN mlx_size size, IN void **map)
static mlx_status nodnic_port_cq_dbr_dma_init (IN nodnic_port_priv *port_priv, OUT nodnic_cq **cq)
mlx_status nodnic_port_create_cq (IN nodnic_port_priv *port_priv, IN mlx_size cq_size, OUT nodnic_cq **cq)
mlx_status nodnic_port_destroy_cq (IN nodnic_port_priv *port_priv, IN nodnic_cq *cq)
static mlx_status nodnic_port_allocate_ring_db_dma (IN nodnic_port_priv *port_priv, IN struct nodnic_ring *nodnic_ring, IN struct nodnic_doorbell *nodnic_db)
static mlx_status nodnic_port_rx_pi_dma_alloc (IN nodnic_port_priv *port_priv, OUT nodnic_qp **qp)
static mlx_status nodnic_port_send_db_dma (IN nodnic_port_priv *port_priv, IN struct nodnic_ring *ring, IN mlx_uint16 index)
static mlx_status nodnic_port_tx_dbr_dma_init (IN nodnic_port_priv *port_priv, OUT nodnic_qp **qp)
mlx_status nodnic_port_create_qp (IN nodnic_port_priv *port_priv, IN nodnic_queue_pair_type type, IN mlx_size send_wq_size, IN mlx_uint32 send_wqe_num, IN mlx_size receive_wq_size, IN mlx_uint32 recv_wqe_num, OUT nodnic_qp **qp)
mlx_status nodnic_port_destroy_qp (IN nodnic_port_priv *port_priv, IN nodnic_queue_pair_type type, IN nodnic_qp *qp)
mlx_status nodnic_port_get_qpn (IN nodnic_port_priv *port_priv, IN struct nodnic_ring *ring, OUT mlx_uint32 *qpn)
static mlx_status nodnic_port_recv_db_dma (IN nodnic_port_priv *port_priv, IN struct nodnic_ring *ring, IN mlx_uint16 index)
mlx_status nodnic_port_update_ring_doorbell (IN nodnic_port_priv *port_priv, IN struct nodnic_ring *ring, IN mlx_uint16 index)
mlx_status nodnic_port_get_cq_size (IN nodnic_port_priv *port_priv, OUT mlx_uint64 *cq_size)
mlx_status nodnic_port_allocate_eq (IN nodnic_port_priv *port_priv, IN mlx_uint8 log_eq_size)
mlx_status nodnic_port_free_eq (IN nodnic_port_priv *port_priv)
mlx_status nodnic_port_add_mac_filter (IN nodnic_port_priv *port_priv, IN mlx_mac_address mac)
mlx_status nodnic_port_remove_mac_filter (IN nodnic_port_priv *port_priv, IN mlx_mac_address mac)
static mlx_status nodnic_port_set_network (IN nodnic_port_priv *port_priv, IN mlx_boolean value)
static mlx_status nodnic_port_set_dma (IN nodnic_port_priv *port_priv, IN mlx_boolean value)
static mlx_status nodnic_port_check_and_set_dma (IN nodnic_port_priv *port_priv, IN mlx_boolean value)
mlx_status nodnic_port_set_promisc (IN nodnic_port_priv *port_priv, IN mlx_boolean value)
mlx_status nodnic_port_set_promisc_multicast (IN nodnic_port_priv *port_priv, IN mlx_boolean value)
mlx_status nodnic_port_init (IN nodnic_port_priv *port_priv)
mlx_status nodnic_port_close (IN nodnic_port_priv *port_priv)
mlx_status nodnic_port_enable_dma (IN nodnic_port_priv *port_priv)
mlx_status nodnic_port_disable_dma (IN nodnic_port_priv *port_priv)
mlx_status nodnic_port_thin_init (IN nodnic_device_priv *device_priv, IN nodnic_port_priv *port_priv, IN mlx_uint8 port_index)

Variables

struct nodnic_port_data_entry nodnic_port_data_table []
struct nodnic_qp_data_entry nodnic_qp_data_teable [MAX_QP_DATA_ENTRIES]
int nodnic_port_offset_table [MAX_NODNIC_PORTS]

Define Documentation

#define PortDataEntry (   _option,
  _offset,
  _align,
  _mask 
)
Value:
{ \
  .option = _option,                     \
  .offset = _offset,                   \
  .align = _align,                  \
  .mask = _mask,                    \
  }

Definition at line 28 of file mlx_port.c.

#define QpDataEntry (   _type,
  _send_offset,
  _recv_offset 
)
Value:
{ \
  .type = _type,                     \
  .send_offset = _send_offset,                   \
  .recv_offset = _recv_offset,                  \
  }

Definition at line 35 of file mlx_port.c.

#define MAX_QP_DATA_ENTRIES   5

Definition at line 72 of file mlx_port.c.

#define MAX_NODNIC_PORTS   2

Definition at line 81 of file mlx_port.c.

#define NODIC_CQ_ADDR_HIGH   0x68
#define NODIC_CQ_ADDR_LOW   0x6c
#define NODIC_RING_QP_ADDR_HIGH   0x0

Referenced by nodnic_port_create_qp().

#define NODIC_RING_QP_ADDR_LOW   0x4

Referenced by nodnic_port_create_qp().

#define NODNIC_RING_QPN_OFFSET   0xc

Referenced by nodnic_port_get_qpn().

#define NODNIC_RING_QPN_MASK   0xFFFFFF

Referenced by nodnic_port_get_qpn().

#define NODNIC_RING_RING_OFFSET   0x8

Function Documentation

FILE_LICENCE ( GPL2_OR_LATER  )

Definition at line 88 of file mlx_port.c.

References MLX_CHECK_STATUS, MLX_SUCCESS, nodnic_port_option_port_state, nodnic_port_query(), out, and status.

Referenced by flexboot_nodnic_eth_open(), and flexboot_nodnic_poll_eq().

{
        mlx_status status = MLX_SUCCESS;
        mlx_uint32 out = 0;

        status = nodnic_port_query(port_priv,
                        nodnic_port_option_port_state, &out);
        MLX_CHECK_STATUS(port_priv->device, status, query_err,
                        "nodnic_port_query failed");
        *state = (nodnic_port_state)out;
query_err:
        return status;
}

Definition at line 105 of file mlx_port.c.

References MLX_FATAL_CHECK_STATUS, MLX_SUCCESS, nodnic_port_option_link_type, nodnic_port_query(), NODNIC_PORT_TYPE_UNKNOWN, out, and status.

Referenced by flexboot_nodnic_set_ports_type().

{
        mlx_status status = MLX_SUCCESS;
        mlx_uint32 out = 0;

        if ( port_priv->port_type == NODNIC_PORT_TYPE_UNKNOWN){
                status = nodnic_port_query(port_priv,
                                nodnic_port_option_link_type, &out);
                MLX_FATAL_CHECK_STATUS(status, query_err,
                                "nodnic_port_query failed");
                port_priv->port_type = (nodnic_port_type)out;
        }
        *type = port_priv->port_type;
query_err:
        return status;
}

Definition at line 126 of file mlx_port.c.

References nodnic_port_data_entry::align, buffer, nodnic_port_data_entry::mask, MLX_CHECK_STATUS, MLX_INVALID_PARAMETER, MLX_SUCCESS, nodnic_cmd_read(), NULL, nodnic_port_data_entry::offset, nodnic_port_data_entry::option, and status.

Referenced by flexboot_nodnic_create_cq(), flexboot_nodnic_register_netdev(), nodnic_port_add_mac_filter(), nodnic_port_get_cq_size(), nodnic_port_get_state(), nodnic_port_get_type(), nodnic_port_read_port_management_change_event(), nodnic_port_read_reset_needed(), nodnic_port_remove_mac_filter(), and nodnic_port_set_send_uar_offset().

{
        mlx_status                              status = MLX_SUCCESS;
        nodnic_device_priv              *device_priv = NULL;
        struct nodnic_port_data_entry *data_entry;
        mlx_uint32                              buffer = 0;
        if( port_priv == NULL || out == NULL){
                status = MLX_INVALID_PARAMETER;
                goto invalid_parm;
        }
        device_priv = port_priv->device;

        data_entry = &nodnic_port_data_table[option];

        status = nodnic_cmd_read(device_priv,
                        port_priv->port_offset + data_entry->offset , &buffer);
        MLX_CHECK_STATUS(device_priv, status, read_err,
                        "nodnic_cmd_read failed");
        *out = (buffer >> data_entry->align) & data_entry->mask;
read_err:
invalid_parm:
        return status;
}

Definition at line 155 of file mlx_port.c.

References nodnic_port_data_entry::align, buffer, nodnic_port_data_entry::mask, MLX_DEBUG_FATAL_ERROR, MLX_FATAL_CHECK_STATUS, MLX_INVALID_PARAMETER, MLX_SUCCESS, nodnic_cmd_read(), nodnic_cmd_write(), NULL, nodnic_port_data_entry::offset, nodnic_port_data_entry::option, and status.

Referenced by flexboot_nodnic_arm_cq(), nodnic_port_add_mac_filter(), nodnic_port_allocate_eq(), nodnic_port_create_cq(), nodnic_port_remove_mac_filter(), nodnic_port_set_dma(), nodnic_port_set_network(), nodnic_port_set_promisc(), nodnic_port_set_promisc_multicast(), and nodnic_port_thin_init().

{
        mlx_status                              status = MLX_SUCCESS;
        nodnic_device_priv              *device_priv = NULL;
        struct nodnic_port_data_entry *data_entry;
        mlx_uint32                              buffer = 0;

        if( port_priv == NULL ){
                MLX_DEBUG_FATAL_ERROR("port_priv is NULL\n");
                status = MLX_INVALID_PARAMETER;
                goto invalid_parm;
        }
        device_priv = port_priv->device;
        data_entry = &nodnic_port_data_table[option];

        if( in > data_entry->mask ){
                MLX_DEBUG_FATAL_ERROR("in > data_entry->mask (%d > %d)\n",
                                in, data_entry->mask);
                status = MLX_INVALID_PARAMETER;
                goto invalid_parm;
        }
        status = nodnic_cmd_read(device_priv,
                        port_priv->port_offset + data_entry->offset, &buffer);
        MLX_FATAL_CHECK_STATUS(status, read_err,
                        "nodnic_cmd_read failed");
        buffer = buffer & ~(data_entry->mask << data_entry->align);
        buffer = buffer | (in << data_entry->align);
        status = nodnic_cmd_write(device_priv,
                        port_priv->port_offset + data_entry->offset, buffer);
        MLX_FATAL_CHECK_STATUS(status, write_err,
                        "nodnic_cmd_write failed");
write_err:
read_err:
invalid_parm:
        return status;
}

Definition at line 197 of file mlx_port.c.

References MLX_CHECK_STATUS, MLX_DEBUG_INFO1, MLX_SUCCESS, MLX_UNSUPPORTED, nodnic_port_option_send_ring0_uar_index, nodnic_port_query(), out, and status.

Referenced by flexboot_nodnic_alloc_uar().

{
        mlx_status status = MLX_SUCCESS;
        mlx_uint32 out = 0;

        if  ( ! port_priv->device->device_cap.support_uar_tx_db ) {
                MLX_DEBUG_INFO1 ( port_priv, "nodnic_port_set_send_uar_offset: tx db using uar is not supported \n");
                status = MLX_UNSUPPORTED;
                goto uar_not_supported;
   }

        status = nodnic_port_query(port_priv,
                        nodnic_port_option_send_ring0_uar_index, &out);
        MLX_CHECK_STATUS(port_priv->device, status, query_err,
                        "nodnic_port_query failed");
        port_priv->device->uar.offset = out << port_priv->device->device_cap.log_uar_page_size;
uar_not_supported:
query_err:
        return status;
}

Definition at line 221 of file mlx_port.c.

References MLX_CHECK_STATUS, MLX_SUCCESS, nodnic_port_option_reset_needed, nodnic_port_query(), out, and status.

Referenced by nodnic_port_thin_init().

{
        mlx_status status = MLX_SUCCESS;
        mlx_uint32 out = 0;
        status = nodnic_port_query(port_priv,
                        nodnic_port_option_reset_needed, &out);
        MLX_CHECK_STATUS(port_priv->device, status, query_err,
                        "nodnic_port_query failed");
        *reset_needed = (mlx_boolean)out;
query_err:
        return status;
}

Definition at line 238 of file mlx_port.c.

References MLX_CHECK_STATUS, MLX_SUCCESS, nodnic_port_option_port_management_change_event, nodnic_port_query(), out, and status.

{
        mlx_status status = MLX_SUCCESS;
        mlx_uint32 out = 0;
        status = nodnic_port_query(port_priv,
                        nodnic_port_option_port_management_change_event, &out);
        MLX_CHECK_STATUS(port_priv->device, status, query_err,
                        "nodnic_port_query failed");
        *change_event = (mlx_boolean)out;
query_err:
        return status;
}
static mlx_status nodnic_port_allocate_dbr_dma ( IN nodnic_port_priv port_priv,
IN struct nodnic_doorbell nodnic_db,
IN mlx_uint32  dbr_addr_low_ofst,
IN mlx_uint32  dbr_addr_high_ofst,
IN void **  dbr_addr,
IN mlx_size  size,
IN void **  map 
) [static]

Definition at line 256 of file mlx_port.c.

References address, MLX_FATAL_CHECK_STATUS, MLX_INVALID_PARAMETER, mlx_memory_alloc_dma(), mlx_memory_free_dma(), mlx_memory_map_dma(), mlx_memory_ummap_dma(), MLX_SUCCESS, nodnic_cmd_write(), NODNIC_MEMORY_ALIGN, NULL, status, and _nodnic_device_priv::utils.

Referenced by nodnic_port_allocate_ring_db_dma(), and nodnic_port_cq_dbr_dma_init().

{
        mlx_status status = MLX_SUCCESS;
        mlx_uint64 address = 0;
        nodnic_device_priv *device_priv = NULL;

        if( port_priv == NULL || nodnic_db == NULL ){
                        status = MLX_INVALID_PARAMETER;
                        goto invalid_parm;
        }

        device_priv = port_priv->device;
        status = mlx_memory_alloc_dma(device_priv->utils,
                                        size,
                                        NODNIC_MEMORY_ALIGN,
                                        (void **)dbr_addr
                                        );
        MLX_FATAL_CHECK_STATUS(status, alloc_db_record_err,
                                "doorbell record dma allocation error");

        status = mlx_memory_map_dma(device_priv->utils,
                                        (void *)(*dbr_addr),
                                        size,
                                        &nodnic_db->doorbell_physical,
                                        map//nodnic_ring->map
                                        );
        MLX_FATAL_CHECK_STATUS(status, map_db_record_err,
                                "doorbell record map dma error");

        address = (mlx_uint64)nodnic_db->doorbell_physical;
        status = nodnic_cmd_write(device_priv,
                                dbr_addr_low_ofst,
                                (mlx_uint32)address);
        MLX_FATAL_CHECK_STATUS(status, set_err,
                        "failed to set doorbell addr low");

        address = address >> 32;
        status = nodnic_cmd_write(device_priv,
                                dbr_addr_high_ofst,
                                (mlx_uint32)address);
        MLX_FATAL_CHECK_STATUS(status, set_err,
                        "failed to set doorbell addr high");

        return status;

set_err:
        mlx_memory_ummap_dma(device_priv->utils, *map);
map_db_record_err:
        mlx_memory_free_dma(device_priv->utils, size,
                (void **)dbr_addr);
alloc_db_record_err:
invalid_parm:
        return status;
}
static mlx_status nodnic_port_cq_dbr_dma_init ( IN nodnic_port_priv port_priv,
OUT nodnic_cq **  cq 
) [static]

Definition at line 321 of file mlx_port.c.

References _nodnic_device_priv::device_cap, MLX_FATAL_CHECK_STATUS, MLX_INVALID_PARAMETER, MLX_SUCCESS, MLX_UNSUPPORTED, nodnic_port_allocate_dbr_dma(), NODNIC_PORT_ARM_CQ_DBR_ADDR_HIGH_OFFSET, NODNIC_PORT_ARM_CQ_DBR_ADDR_LOW_OFFSET, NULL, status, and _nodnic_device_capabilites::support_bar_cq_ctrl.

Referenced by nodnic_port_create_cq().

{
        mlx_status status = MLX_SUCCESS;
        nodnic_device_priv *device_priv = NULL;

        if( port_priv == NULL ){
                status = MLX_INVALID_PARAMETER;
                goto invalid_parm;
        }

        device_priv =  port_priv->device;
        if ( ! device_priv->device_cap.support_bar_cq_ctrl ) {
                status = MLX_UNSUPPORTED;
                goto uar_arm_cq_db_unsupported;
        }

#define NODNIC_PORT_ARM_CQ_DBR_ADDR_LOW_OFFSET 0x114
#define NODNIC_PORT_ARM_CQ_DBR_ADDR_HIGH_OFFSET 0x110

        status = nodnic_port_allocate_dbr_dma ( port_priv,&(*cq)->arm_cq_doorbell,
                        port_priv->port_offset + NODNIC_PORT_ARM_CQ_DBR_ADDR_LOW_OFFSET,
                        port_priv->port_offset + NODNIC_PORT_ARM_CQ_DBR_ADDR_HIGH_OFFSET,
                        (void **)&port_priv->arm_cq_doorbell_record ,
                        sizeof(nodnic_arm_cq_db),
                        (void **)&((*cq)->arm_cq_doorbell.map));
        MLX_FATAL_CHECK_STATUS(status, alloc_dbr_dma_err,
                                "failed to allocate doorbell record dma");
        return status;

alloc_dbr_dma_err:
uar_arm_cq_db_unsupported:
invalid_parm:
        return status;
}
mlx_status nodnic_port_create_cq ( IN nodnic_port_priv port_priv,
IN mlx_size  cq_size,
OUT nodnic_cq **  cq 
)

Definition at line 360 of file mlx_port.c.

References address, MLX_FATAL_CHECK_STATUS, MLX_INVALID_PARAMETER, mlx_memory_alloc_dma(), mlx_memory_free(), mlx_memory_free_dma(), mlx_memory_map_dma(), mlx_memory_ummap_dma(), mlx_memory_zalloc(), MLX_SUCCESS, NODNIC_MEMORY_ALIGN, nodnic_port_cq_dbr_dma_init(), nodnic_port_option_cq_addr_high, nodnic_port_option_cq_addr_low, nodnic_port_set(), NULL, status, and _nodnic_device_priv::utils.

Referenced by flexboot_nodnic_create_cq().

{
        mlx_status status = MLX_SUCCESS;
        nodnic_device_priv *device_priv = NULL;
        mlx_uint64 address = 0;
        if( port_priv == NULL || cq == NULL){
                status = MLX_INVALID_PARAMETER;
                goto invalid_parm;
        }

        device_priv =  port_priv->device;

        status = mlx_memory_zalloc(device_priv->utils,
                                sizeof(nodnic_cq),(mlx_void **)cq);
        MLX_FATAL_CHECK_STATUS(status, alloc_err,
                        "cq priv allocation error");

        (*cq)->cq_size = cq_size;
        status = mlx_memory_alloc_dma(device_priv->utils,
                        (*cq)->cq_size, NODNIC_MEMORY_ALIGN,
                                &(*cq)->cq_virt);
        MLX_FATAL_CHECK_STATUS(status, dma_alloc_err,
                                "cq allocation error");

        status = mlx_memory_map_dma(device_priv->utils,
                                                (*cq)->cq_virt,
                                                (*cq)->cq_size,
                                                &(*cq)->cq_physical,
                                                &(*cq)->map);
        MLX_FATAL_CHECK_STATUS(status, cq_map_err,
                                "cq map error");

        status = nodnic_port_cq_dbr_dma_init(port_priv,cq);

        /* update cq address */
#define NODIC_CQ_ADDR_HIGH 0x68
#define NODIC_CQ_ADDR_LOW 0x6c
        address = (mlx_uint64)(*cq)->cq_physical;
        status = nodnic_port_set(port_priv, nodnic_port_option_cq_addr_low,
                        (mlx_uint32)(address) >> 12);
        MLX_FATAL_CHECK_STATUS(status, dma_set_addr_low_err,
                                        "cq set addr low error");
        address = address >> 32;
        status = nodnic_port_set(port_priv, nodnic_port_option_cq_addr_high,
                                (mlx_uint32)address);
        MLX_FATAL_CHECK_STATUS(status, dma_set_addr_high_err,
                                                "cq set addr high error");
        return status;
dma_set_addr_high_err:
dma_set_addr_low_err:
        mlx_memory_ummap_dma(device_priv->utils, (*cq)->map);
cq_map_err:
        mlx_memory_free_dma(device_priv->utils, (*cq)->cq_size,
                        (void **)&((*cq)->cq_virt));
dma_alloc_err:
        mlx_memory_free(device_priv->utils, (void **)cq);
alloc_err:
invalid_parm:
        return status;
}

Definition at line 426 of file mlx_port.c.

References _nodnic_device_priv::device_cap, MLX_DEBUG_ERROR, MLX_INVALID_PARAMETER, mlx_memory_free(), mlx_memory_free_dma(), mlx_memory_ummap_dma(), MLX_SUCCESS, NULL, status, _nodnic_device_capabilites::support_bar_cq_ctrl, and _nodnic_device_priv::utils.

Referenced by flexboot_nodnic_destroy_cq().

{
        mlx_status status = MLX_SUCCESS;
        nodnic_device_priv *device_priv = NULL;

        if( port_priv == NULL || cq == NULL){
                status = MLX_INVALID_PARAMETER;
                goto invalid_parm;
        }
        device_priv =  port_priv->device;

        if ( device_priv->device_cap.support_bar_cq_ctrl ){
                        status = mlx_memory_ummap_dma(device_priv->utils,
                                        cq->arm_cq_doorbell.map);
                        if( status != MLX_SUCCESS){
                                MLX_DEBUG_ERROR(device_priv, "mlx_memory_ummap_dma failed (Status = %d)\n", status);
                        }

                        status = mlx_memory_free_dma(device_priv->utils,
                                        sizeof(nodnic_arm_cq_db),
                                        (void **)&(port_priv->arm_cq_doorbell_record));
                        if( status != MLX_SUCCESS){
                                MLX_DEBUG_ERROR(device_priv, "mlx_memory_free_dma failed (Status = %d)\n", status);
                        }
                }

        mlx_memory_ummap_dma(device_priv->utils, cq->map);

        mlx_memory_free_dma(device_priv->utils, cq->cq_size,
                        (void **)&(cq->cq_virt));

        mlx_memory_free(device_priv->utils, (void **)&cq);
invalid_parm:
        return status;
}
static mlx_status nodnic_port_allocate_ring_db_dma ( IN nodnic_port_priv port_priv,
IN struct nodnic_ring nodnic_ring,
IN struct nodnic_doorbell nodnic_db 
) [static]

Definition at line 467 of file mlx_port.c.

References MLX_FATAL_CHECK_STATUS, MLX_INVALID_PARAMETER, MLX_SUCCESS, nodnic_port_allocate_dbr_dma(), NODNIC_RING_DBR_ADDR_HIGH_OFFSET, NODNIC_RING_DBR_ADDR_LOW_OFFSET, NULL, and status.

Referenced by nodnic_port_rx_pi_dma_alloc(), and nodnic_port_tx_dbr_dma_init().

{
        mlx_status status = MLX_SUCCESS;

        if( port_priv == NULL || nodnic_ring == NULL || nodnic_db == NULL ){
                        status = MLX_INVALID_PARAMETER;
                        goto invalid_parm;
        }
#define NODNIC_RING_DBR_ADDR_LOW_OFFSET 0x1C
#define NODNIC_RING_DBR_ADDR_HIGH_OFFSET 0x18
        status = nodnic_port_allocate_dbr_dma ( port_priv,nodnic_db,
                        nodnic_ring->offset + NODNIC_RING_DBR_ADDR_LOW_OFFSET,
                        nodnic_ring->offset + NODNIC_RING_DBR_ADDR_HIGH_OFFSET,
                        (void **)&nodnic_db->qp_doorbell_record,
                        sizeof(nodnic_qp_db),
                        (void **)&nodnic_ring->map );
        MLX_FATAL_CHECK_STATUS(status, alloc_dbr_dma_err,
                        "failed to allocate doorbell record dma");

        return status;
alloc_dbr_dma_err:
invalid_parm:
        return status;
}
static mlx_status nodnic_port_rx_pi_dma_alloc ( IN nodnic_port_priv port_priv,
OUT nodnic_qp **  qp 
) [static]

Definition at line 498 of file mlx_port.c.

References _nodnic_device_priv::device_cap, MLX_FATAL_CHECK_STATUS, MLX_INVALID_PARAMETER, MLX_SUCCESS, nodnic_port_allocate_ring_db_dma(), NULL, status, and _nodnic_device_capabilites::support_rx_pi_dma.

Referenced by nodnic_port_create_qp().

{
        mlx_status status = MLX_SUCCESS;
        nodnic_device_priv *device_priv = NULL;

        if( port_priv == NULL || qp == NULL){
                status = MLX_INVALID_PARAMETER;
                goto invalid_parm;
        }

        device_priv =  port_priv->device;

        if ( ! device_priv->device_cap.support_rx_pi_dma ) {
                goto rx_pi_dma_unsupported;
        }

        if ( device_priv->device_cap.support_rx_pi_dma ) {
                status = nodnic_port_allocate_ring_db_dma(port_priv,
                                &(*qp)->receive.nodnic_ring,&(*qp)->receive.nodnic_ring.recv_doorbell);
                MLX_FATAL_CHECK_STATUS(status, dma_alloc_err,
                                "rx doorbell dma allocation error");
        }

        return status;

dma_alloc_err:
rx_pi_dma_unsupported:
invalid_parm:
        return status;
}
static mlx_status nodnic_port_send_db_dma ( IN nodnic_port_priv port_priv,
IN struct nodnic_ring ring,
IN mlx_uint16  index 
) [static]

Definition at line 534 of file mlx_port.c.

References index, mlx_memory_cpu_to_be32(), and MLX_SUCCESS.

Referenced by nodnic_port_tx_dbr_dma_init().

{
        mlx_uint32 swapped = 0;
        mlx_uint32 index32 = index;
        mlx_memory_cpu_to_be32(port_priv->device->utils, index32, &swapped);
        ring->send_doorbell.qp_doorbell_record->send_db =  swapped;

        return MLX_SUCCESS;
}
static mlx_status nodnic_port_tx_dbr_dma_init ( IN nodnic_port_priv port_priv,
OUT nodnic_qp **  qp 
) [static]

Definition at line 550 of file mlx_port.c.

References _nodnic_device_priv::device_cap, MLX_FATAL_CHECK_STATUS, MLX_INVALID_PARAMETER, MLX_SUCCESS, MLX_UNSUPPORTED, nodnic_port_allocate_ring_db_dma(), nodnic_port_send_db_dma(), NULL, _nodnic_uar_priv::offset, status, _nodnic_device_capabilites::support_uar_tx_db, and _nodnic_device_priv::uar.

Referenced by nodnic_port_create_qp().

{
        mlx_status status = MLX_SUCCESS;
        nodnic_device_priv *device_priv = NULL;

        if( port_priv == NULL || qp == NULL){
                status = MLX_INVALID_PARAMETER;
                goto invalid_parm;
        }

        device_priv =  port_priv->device;

        if ( ! device_priv->device_cap.support_uar_tx_db || ! device_priv->uar.offset ) {
                status = MLX_UNSUPPORTED;
                goto uar_tx_db_unsupported;
        }
        status = nodnic_port_allocate_ring_db_dma(port_priv,
                        &(*qp)->send.nodnic_ring,&(*qp)->send.nodnic_ring.send_doorbell);
        MLX_FATAL_CHECK_STATUS(status, dma_alloc_err,
                        "tx doorbell dma allocation error");
        port_priv->send_doorbell = nodnic_port_send_db_dma;

        return status;

dma_alloc_err:
uar_tx_db_unsupported:
invalid_parm:

        return status;
}
mlx_status nodnic_port_create_qp ( IN nodnic_port_priv port_priv,
IN nodnic_queue_pair_type  type,
IN mlx_size  send_wq_size,
IN mlx_uint32  send_wqe_num,
IN mlx_size  receive_wq_size,
IN mlx_uint32  recv_wqe_num,
OUT nodnic_qp **  qp 
)

Definition at line 585 of file mlx_port.c.

References address, _nodnic_device_priv::device_cap, _nodnic_device_capabilites::log_max_ring_size, MLX_FATAL_CHECK_STATUS, MLX_INVALID_PARAMETER, mlx_memory_alloc_dma(), mlx_memory_free(), mlx_memory_free_dma(), mlx_memory_map_dma(), mlx_memory_set(), mlx_memory_ummap_dma(), mlx_memory_zalloc(), MLX_SUCCESS, mlx_utils_ilog2(), NODIC_RING_QP_ADDR_HIGH, NODIC_RING_QP_ADDR_LOW, nodnic_cmd_write(), NODNIC_MEMORY_ALIGN, nodnic_port_rx_pi_dma_alloc(), nodnic_port_tx_dbr_dma_init(), NULL, nodnic_qp_data_entry::recv_offset, nodnic_qp_data_entry::send_offset, status, type, and _nodnic_device_priv::utils.

Referenced by flexboot_nodnic_create_qp().

{
        mlx_status status = MLX_SUCCESS;
        nodnic_device_priv *device_priv = NULL;
        mlx_uint32 max_ring_size = 0;
        mlx_uint64 address = 0;
        mlx_uint32 log_size = 0;
        if( port_priv == NULL || qp == NULL){
                status = MLX_INVALID_PARAMETER;
                goto invalid_parm;
        }

        device_priv =  port_priv->device;
        max_ring_size = (1 << device_priv->device_cap.log_max_ring_size);
        if( send_wq_size > max_ring_size ||
                        receive_wq_size > max_ring_size ){
                status = MLX_INVALID_PARAMETER;
                goto invalid_parm;
        }

        status = mlx_memory_zalloc(device_priv->utils,
                        sizeof(nodnic_qp),(mlx_void **)qp);
        MLX_FATAL_CHECK_STATUS(status, alloc_err,
                        "qp allocation error");

        if( nodnic_qp_data_teable[type].send_offset == 0 ||
                        nodnic_qp_data_teable[type].recv_offset == 0){
                status = MLX_INVALID_PARAMETER;
                goto invalid_type;
        }

        (*qp)->send.nodnic_ring.offset = port_priv->port_offset +
                                nodnic_qp_data_teable[type].send_offset;
        (*qp)->receive.nodnic_ring.offset = port_priv->port_offset +
                        nodnic_qp_data_teable[type].recv_offset;

        status = mlx_memory_alloc_dma(device_priv->utils,
                        send_wq_size, NODNIC_MEMORY_ALIGN,
                        (void*)&(*qp)->send.wqe_virt);
        MLX_FATAL_CHECK_STATUS(status, send_alloc_err,
                                "send wq allocation error");

        status = mlx_memory_alloc_dma(device_priv->utils,
                                receive_wq_size, NODNIC_MEMORY_ALIGN,
                                &(*qp)->receive.wqe_virt);
        MLX_FATAL_CHECK_STATUS(status, receive_alloc_err,
                                "receive wq allocation error");

        status = mlx_memory_map_dma(device_priv->utils,
                                                (*qp)->send.wqe_virt,
                                                send_wq_size,
                                                &(*qp)->send.nodnic_ring.wqe_physical,
                                                &(*qp)->send.nodnic_ring.map);
        MLX_FATAL_CHECK_STATUS(status, send_map_err,
                                "send wq map error");

        status = mlx_memory_map_dma(device_priv->utils,
                                                (*qp)->receive.wqe_virt,
                                                receive_wq_size,
                                                &(*qp)->receive.nodnic_ring.wqe_physical,
                                                &(*qp)->receive.nodnic_ring.map);
        MLX_FATAL_CHECK_STATUS(status, receive_map_err,
                                "receive wq map error");

        status = nodnic_port_rx_pi_dma_alloc(port_priv,qp);
        MLX_FATAL_CHECK_STATUS(status, rx_pi_dma_alloc_err,
                                "receive db dma error");

        status = nodnic_port_tx_dbr_dma_init(port_priv,qp);


        (*qp)->send.nodnic_ring.wq_size = send_wq_size;
        (*qp)->send.nodnic_ring.num_wqes = send_wqe_num;
        (*qp)->receive.nodnic_ring.wq_size = receive_wq_size;
        (*qp)->receive.nodnic_ring.num_wqes = recv_wqe_num;

        /* Set Ownership bit in Send/receive queue (0 - recv ; 1 - send) */
        mlx_memory_set(device_priv->utils, (*qp)->send.wqe_virt, 0xff, send_wq_size );
        mlx_memory_set(device_priv->utils, (*qp)->receive.wqe_virt, 0, recv_wqe_num );

        /* update send ring */
#define NODIC_RING_QP_ADDR_HIGH 0x0
#define NODIC_RING_QP_ADDR_LOW 0x4
        address = (mlx_uint64)(*qp)->send.nodnic_ring.wqe_physical;
        status = nodnic_cmd_write(device_priv, (*qp)->send.nodnic_ring.offset +
                        NODIC_RING_QP_ADDR_HIGH,
                        (mlx_uint32)(address >> 32));
        MLX_FATAL_CHECK_STATUS(status, write_send_addr_err,
                                        "send address write error 1");
        mlx_utils_ilog2((*qp)->send.nodnic_ring.wq_size, &log_size);
        address = address | log_size;
        status = nodnic_cmd_write(device_priv, (*qp)->send.nodnic_ring.offset +
                        NODIC_RING_QP_ADDR_LOW,
                                (mlx_uint32)address);
        MLX_FATAL_CHECK_STATUS(status, write_send_addr_err,
                                                "send address write error 2");
        /* update receive ring */
        address = (mlx_uint64)(*qp)->receive.nodnic_ring.wqe_physical;
        status = nodnic_cmd_write(device_priv, (*qp)->receive.nodnic_ring.offset +
                        NODIC_RING_QP_ADDR_HIGH,
                        (mlx_uint32)(address >> 32));
        MLX_FATAL_CHECK_STATUS(status, write_recv_addr_err,
                                                "receive address write error 1");
        mlx_utils_ilog2((*qp)->receive.nodnic_ring.wq_size, &log_size);
        address = address | log_size;
        status = nodnic_cmd_write(device_priv, (*qp)->receive.nodnic_ring.offset +
                        NODIC_RING_QP_ADDR_LOW,
                                (mlx_uint32)address);
        MLX_FATAL_CHECK_STATUS(status, write_recv_addr_err,
                                                "receive address write error 2");

        return status;
write_recv_addr_err:
write_send_addr_err:
        mlx_memory_ummap_dma(device_priv->utils, (*qp)->receive.nodnic_ring.map);
rx_pi_dma_alloc_err:
receive_map_err:
        mlx_memory_ummap_dma(device_priv->utils, (*qp)->send.nodnic_ring.map);
send_map_err:
        mlx_memory_free_dma(device_priv->utils, receive_wq_size,
                        &((*qp)->receive.wqe_virt));
receive_alloc_err:
        mlx_memory_free_dma(device_priv->utils, send_wq_size,
                        (void **)&((*qp)->send.wqe_virt));
send_alloc_err:
invalid_type:
        mlx_memory_free(device_priv->utils, (void **)qp);
alloc_err:
invalid_parm:
        return status;
}

Definition at line 726 of file mlx_port.c.

References _nodnic_device_priv::device_cap, MLX_DEBUG_ERROR, mlx_memory_free(), mlx_memory_free_dma(), mlx_memory_ummap_dma(), MLX_SUCCESS, _nodnic_uar_priv::offset, status, _nodnic_device_capabilites::support_rx_pi_dma, _nodnic_device_capabilites::support_uar_tx_db, _nodnic_device_priv::uar, and _nodnic_device_priv::utils.

Referenced by flexboot_nodnic_destroy_qp().

{
        mlx_status status = MLX_SUCCESS;
        nodnic_device_priv *device_priv = port_priv->device;

        status = mlx_memory_ummap_dma(device_priv->utils,
                        qp->receive.nodnic_ring.map);
        if( status != MLX_SUCCESS){
                MLX_DEBUG_ERROR(device_priv, "mlx_memory_ummap_dma failed (Status = %d)\n", status);
        }

        status = mlx_memory_ummap_dma(device_priv->utils, qp->send.nodnic_ring.map);
        if( status != MLX_SUCCESS){
                MLX_DEBUG_ERROR(device_priv, "mlx_memory_ummap_dma failed (Status = %d)\n", status);
        }

        if ( device_priv->device_cap.support_rx_pi_dma ){
                status = mlx_memory_ummap_dma(device_priv->utils,
                                        qp->receive.nodnic_ring.recv_doorbell.map);
                if( status != MLX_SUCCESS){
                        MLX_DEBUG_ERROR(device_priv, "mlx_memory_ummap_dma failed (Status = %d)\n", status);
                }

                status = mlx_memory_free_dma(device_priv->utils,
                                sizeof(nodnic_qp_db),
                                (void **)&(qp->receive.nodnic_ring.recv_doorbell.qp_doorbell_record));
                if( status != MLX_SUCCESS){
                        MLX_DEBUG_ERROR(device_priv, "mlx_memory_free_dma failed (Status = %d)\n", status);
                }
        }

        if ( device_priv->device_cap.support_uar_tx_db || ! device_priv->uar.offset){
                status = mlx_memory_ummap_dma(device_priv->utils,
                                        qp->send.nodnic_ring.send_doorbell.map);
                if( status != MLX_SUCCESS){
                        MLX_DEBUG_ERROR(device_priv, "mlx_memory_ummap_dma failed (Status = %d)\n", status);
                }

                status = mlx_memory_free_dma(device_priv->utils,
                                sizeof(nodnic_qp_db),
                                (void **)&(qp->send.nodnic_ring.send_doorbell.qp_doorbell_record));
                if( status != MLX_SUCCESS){
                        MLX_DEBUG_ERROR(device_priv, "mlx_memory_free_dma failed (Status = %d)\n", status);
                }
        }

        status = mlx_memory_free_dma(device_priv->utils,
                        qp->receive.nodnic_ring.wq_size,
                        (void **)&(qp->receive.wqe_virt));
        if( status != MLX_SUCCESS){
                MLX_DEBUG_ERROR(device_priv, "mlx_memory_free_dma failed (Status = %d)\n", status);
        }
        status = mlx_memory_free_dma(device_priv->utils,
                        qp->send.nodnic_ring.wq_size,
                        (void **)&(qp->send.wqe_virt));
        if( status != MLX_SUCCESS){
                MLX_DEBUG_ERROR(device_priv, "mlx_memory_free_dma failed (Status = %d)\n", status);
        }
        status = mlx_memory_free(device_priv->utils, (void **)&qp);
        if( status != MLX_SUCCESS){
                MLX_DEBUG_ERROR(device_priv, "mlx_memory_free failed (Status = %d)\n", status);
        }
        return status;
}
mlx_status nodnic_port_get_qpn ( IN nodnic_port_priv port_priv,
IN struct nodnic_ring ring,
OUT mlx_uint32 qpn 
)

Definition at line 796 of file mlx_port.c.

References buffer, MLX_FATAL_CHECK_STATUS, MLX_INVALID_PARAMETER, MLX_SUCCESS, nodnic_cmd_read(), NODNIC_RING_QPN_MASK, NODNIC_RING_QPN_OFFSET, NULL, and status.

Referenced by flexboot_nodnic_eth_open(), flexboot_nodnic_find_wq(), and shomron_fill_eth_send_wqe().

{
        mlx_status status = MLX_SUCCESS;
        mlx_uint32 buffer = 0;
        if( ring == NULL || qpn == NULL){
                status = MLX_INVALID_PARAMETER;
                goto bad_param;
        }
        if( ring->qpn != 0 ){
                *qpn = ring->qpn;
                goto success;
        }
#define NODNIC_RING_QPN_OFFSET 0xc
#define NODNIC_RING_QPN_MASK 0xFFFFFF
        status = nodnic_cmd_read(port_priv->device,
                        ring->offset + NODNIC_RING_QPN_OFFSET,
                        &buffer);
        MLX_FATAL_CHECK_STATUS(status, read_err,
                        "nodnic_cmd_read failed");
        ring->qpn = buffer & NODNIC_RING_QPN_MASK;
        *qpn = ring->qpn;
read_err:
success:
bad_param:
        return status;
}
static mlx_status nodnic_port_recv_db_dma ( IN nodnic_port_priv port_priv,
IN struct nodnic_ring ring,
IN mlx_uint16  index 
) [static]

Definition at line 860 of file mlx_port.c.

References index, mlx_memory_cpu_to_be32(), and MLX_SUCCESS.

Referenced by nodnic_port_thin_init().

{
        mlx_uint32 swapped = 0;
        mlx_uint32 index32 = index;
        mlx_memory_cpu_to_be32(port_priv->device->utils, index32, &swapped);
        ring->recv_doorbell.qp_doorbell_record->recv_db =  swapped;
        return MLX_SUCCESS;
}

Definition at line 874 of file mlx_port.c.

References buffer, MLX_CHECK_STATUS, MLX_INVALID_PARAMETER, MLX_SUCCESS, nodnic_cmd_write(), NODNIC_RING_RING_OFFSET, NULL, and status.

Referenced by nodnic_port_thin_init().

{
        mlx_status status = MLX_SUCCESS;
        mlx_uint32 buffer = 0;
        if( ring == NULL ){
                status = MLX_INVALID_PARAMETER;
                goto bad_param;
        }
#define NODNIC_RING_RING_OFFSET 0x8
        buffer = (mlx_uint32)((index & 0xFFFF)<< 8);
        status = nodnic_cmd_write(port_priv->device,
                                ring->offset + NODNIC_RING_RING_OFFSET,
                                buffer);
        MLX_CHECK_STATUS(port_priv->device, status, write_err,
                                "nodnic_cmd_write failed");
write_err:
bad_param:
        return status;
}

Definition at line 899 of file mlx_port.c.

References MLX_FATAL_CHECK_STATUS, MLX_SUCCESS, nodnic_port_option_log_cq_size, nodnic_port_query(), out, and status.

Referenced by flexboot_nodnic_eth_open().

{
        mlx_status status = MLX_SUCCESS;
        mlx_uint32 out = 0;
        status = nodnic_port_query(port_priv, nodnic_port_option_log_cq_size, &out);
        MLX_FATAL_CHECK_STATUS(status, query_err,
                        "nodnic_port_query failed");
        *cq_size = 1 << out;
query_err:
        return status;
}
mlx_status nodnic_port_allocate_eq ( IN nodnic_port_priv port_priv,
IN mlx_uint8  log_eq_size 
)

Definition at line 915 of file mlx_port.c.

References address, MLX_FATAL_CHECK_STATUS, MLX_INVALID_PARAMETER, mlx_memory_alloc_dma(), mlx_memory_free_dma(), mlx_memory_map_dma(), mlx_memory_ummap_dma(), MLX_SUCCESS, NODNIC_MEMORY_ALIGN, nodnic_port_option_eq_addr_high, nodnic_port_option_eq_addr_low, nodnic_port_set(), NULL, status, and _nodnic_device_priv::utils.

Referenced by flexboot_nodnic_eth_open().

{
        mlx_status status = MLX_SUCCESS;
        nodnic_device_priv *device_priv = NULL;
        mlx_uint64 address = 0;

        if( port_priv == NULL ){
                status = MLX_INVALID_PARAMETER;
                goto bad_param;
        }

        device_priv = port_priv->device;
        port_priv->eq.eq_size = ( ( 1 << log_eq_size ) * 1024 ); /* Size is in KB */
        status = mlx_memory_alloc_dma(device_priv->utils,
                                                                port_priv->eq.eq_size,
                                                                NODNIC_MEMORY_ALIGN,
                                                                &port_priv->eq.eq_virt);
        MLX_FATAL_CHECK_STATUS(status, alloc_err,
                                                        "eq allocation error");

        status = mlx_memory_map_dma(device_priv->utils,
                                                        port_priv->eq.eq_virt,
                                                        port_priv->eq.eq_size,
                                                        &port_priv->eq.eq_physical,
                                                        &port_priv->eq.map);
        MLX_FATAL_CHECK_STATUS(status, map_err,
                                                                "eq map error");

        address = port_priv->eq.eq_physical;
        status = nodnic_port_set(port_priv, nodnic_port_option_eq_addr_low,
                                                (mlx_uint32)address);
        MLX_FATAL_CHECK_STATUS(status, set_err,
                        "failed to set eq addr low");
        address = (address >> 32);
        status = nodnic_port_set(port_priv, nodnic_port_option_eq_addr_high,
                                                (mlx_uint32)address);
        MLX_FATAL_CHECK_STATUS(status, set_err,
                                "failed to set eq addr high");
        return status;
set_err:
        mlx_memory_ummap_dma(device_priv->utils, port_priv->eq.map);
map_err:
        mlx_memory_free_dma(device_priv->utils,
                        port_priv->eq.eq_size,
                        (void **)&(port_priv->eq.eq_virt));
alloc_err:
bad_param:
        return status;
}

Definition at line 968 of file mlx_port.c.

References MLX_INVALID_PARAMETER, mlx_memory_free_dma(), mlx_memory_ummap_dma(), MLX_SUCCESS, NULL, status, and _nodnic_device_priv::utils.

Referenced by flexboot_nodnic_eth_close(), and flexboot_nodnic_eth_open().

{
        mlx_status status = MLX_SUCCESS;
        nodnic_device_priv *device_priv = NULL;

        if( port_priv == NULL ){
                status = MLX_INVALID_PARAMETER;
                goto bad_param;
        }

        device_priv = port_priv->device;
        mlx_memory_ummap_dma(device_priv->utils, port_priv->eq.map);

        mlx_memory_free_dma(device_priv->utils,
                        port_priv->eq.eq_size,
                        (void **)&(port_priv->eq.eq_virt));

bad_param:
        return status;
}

Definition at line 992 of file mlx_port.c.

References address, index, mac, MLX_CHECK_STATUS, MLX_FAILED, MLX_INVALID_PARAMETER, mlx_memory_cmp(), mlx_memory_set(), MLX_SUCCESS, nodnic_cmd_write(), NODNIC_MAX_MAC_FILTERS, NODNIC_PORT_MAC_FILTERS_OFFSET, nodnic_port_option_mac_filters_en, nodnic_port_query(), nodnic_port_set(), NULL, out, status, and _nodnic_device_priv::utils.

Referenced by flexboot_nodnic_mcast_attach().

{
        mlx_status status = MLX_SUCCESS;
        nodnic_device_priv *device= NULL;;
        mlx_uint8 index = 0;
        mlx_uint32 out = 0;
        mlx_uint32 mac_filters_en = 0;
        mlx_uint32 address = 0;
        mlx_mac_address zero_mac;
        mlx_utils *utils = NULL;

        if( port_priv == NULL){
                status = MLX_INVALID_PARAMETER;
                goto bad_param;
        }

        device = port_priv->device;
        utils = device->utils;

        mlx_memory_set(utils, &zero_mac, 0, sizeof(zero_mac));
        /* check if mac already exists */
        for( ; index < NODNIC_MAX_MAC_FILTERS ; index ++) {
                mlx_memory_cmp(utils, &port_priv->mac_filters[index], &mac,
                                sizeof(mac), &out);
                if ( out == 0 ){
                        status = MLX_FAILED;
                        goto already_exists;
                }
        }

        /* serch for available mac filter slot */
        for (index = 0 ; index < NODNIC_MAX_MAC_FILTERS ; index ++) {
                mlx_memory_cmp(utils, &port_priv->mac_filters[index], &zero_mac,
                                sizeof(zero_mac), &out);
                if ( out == 0 ){
                        break;
                }
        }
        if ( index >= NODNIC_MAX_MAC_FILTERS ){
                status = MLX_FAILED;
                goto mac_list_full;
        }

        status = nodnic_port_query(port_priv, nodnic_port_option_mac_filters_en,
                        &mac_filters_en);
        MLX_CHECK_STATUS(device, status , query_err,
                        "nodnic_port_query failed");
        if(mac_filters_en & (1 << index)){
                status = MLX_FAILED;
                goto mac_list_full;
        }
        port_priv->mac_filters[index] = mac;

        // set mac filter
        address = port_priv->port_offset + NODNIC_PORT_MAC_FILTERS_OFFSET +
                                (0x8 * index);

        status = nodnic_cmd_write(device, address, mac.high );
        MLX_CHECK_STATUS(device, status, write_err,     "set mac high failed");
        status = nodnic_cmd_write(device, address + 0x4, mac.low );
        MLX_CHECK_STATUS(device, status, write_err, "set mac low failed");

        // enable mac filter
        mac_filters_en = mac_filters_en | (1 << index);
        status = nodnic_port_set(port_priv, nodnic_port_option_mac_filters_en,
                                mac_filters_en);
        MLX_CHECK_STATUS(device, status , set_err,
                        "nodnic_port_set failed");
set_err:
write_err:
query_err:
mac_list_full:
already_exists:
bad_param:
        return status;
}

Definition at line 1073 of file mlx_port.c.

References index, MLX_CHECK_STATUS, MLX_FAILED, MLX_INVALID_PARAMETER, mlx_memory_cmp(), mlx_memory_set(), MLX_SUCCESS, NODNIC_MAX_MAC_FILTERS, nodnic_port_option_mac_filters_en, nodnic_port_query(), nodnic_port_set(), NULL, out, status, and _nodnic_device_priv::utils.

Referenced by flexboot_nodnic_mcast_detach().

{
        mlx_status status = MLX_SUCCESS;
        nodnic_device_priv *device= NULL;;
        mlx_uint8 index = 0;
        mlx_uint32 out = 0;
        mlx_uint32 mac_filters_en = 0;
        mlx_mac_address zero_mac;
        mlx_utils *utils = NULL;

        if( port_priv == NULL){
                status = MLX_INVALID_PARAMETER;
                goto bad_param;
        }

        device = port_priv->device;
        utils = device->utils;

        mlx_memory_set(utils, &zero_mac, 0, sizeof(zero_mac));
        /* serch for mac filter */
        for( ; index < NODNIC_MAX_MAC_FILTERS ; index ++) {
                mlx_memory_cmp(utils, &port_priv->mac_filters[index], &mac,
                                sizeof(mac), &out);
                if ( out == 0 ){
                        break;
                }
        }
        if ( index == NODNIC_MAX_MAC_FILTERS ){
                status = MLX_FAILED;
                goto mac_not_found;
        }

        status = nodnic_port_query(port_priv, nodnic_port_option_mac_filters_en,
                        &mac_filters_en);
        MLX_CHECK_STATUS(device, status , query_err,
                        "nodnic_port_query failed");
        if((mac_filters_en & (1 << index)) == 0){
                status = MLX_FAILED;
                goto mac_not_en;
        }
        port_priv->mac_filters[index] = zero_mac;

        // disable mac filter
        mac_filters_en = mac_filters_en & ~(1 << index);
        status = nodnic_port_set(port_priv, nodnic_port_option_mac_filters_en,
                                mac_filters_en);
        MLX_CHECK_STATUS(device, status , set_err,
                        "nodnic_port_set failed");
set_err:
query_err:
mac_not_en:
mac_not_found:
bad_param:
        return status;
}
static mlx_status nodnic_port_set_network ( IN nodnic_port_priv port_priv,
IN mlx_boolean  value 
) [static]

Definition at line 1134 of file mlx_port.c.

References MLX_CHECK_STATUS, MLX_SUCCESS, nodnic_port_option_network_en, nodnic_port_set(), status, and value.

Referenced by nodnic_port_close(), and nodnic_port_init().

{
        mlx_status status = MLX_SUCCESS;
        /*mlx_uint32 network_valid = 0;
        mlx_uint8 try = 0;*/

        status = nodnic_port_set(port_priv, nodnic_port_option_network_en, value);
        MLX_CHECK_STATUS(port_priv->device, status, set_err,
                        "nodnic_port_set failed");
        port_priv->network_state = value;
set_err:
        return status;
}
static mlx_status nodnic_port_set_dma ( IN nodnic_port_priv port_priv,
IN mlx_boolean  value 
) [static]

Definition at line 1170 of file mlx_port.c.

References nodnic_port_option_dma_en, and nodnic_port_set().

Referenced by nodnic_port_thin_init().

static mlx_status nodnic_port_check_and_set_dma ( IN nodnic_port_priv port_priv,
IN mlx_boolean  value 
) [static]

Definition at line 1180 of file mlx_port.c.

References MLX_CHECK_STATUS, MLX_DEBUG_WARN, MLX_SUCCESS, status, and value.

Referenced by nodnic_port_disable_dma(), and nodnic_port_enable_dma().

{
        mlx_status status = MLX_SUCCESS;
        if ( port_priv->dma_state == value ) {
                MLX_DEBUG_WARN(port_priv->device,
                                "nodnic_port_check_and_set_dma: already %s\n",
                                (value ? "enabled" : "disabled"));
                status = MLX_SUCCESS;
                goto set_out;
        }

        status = port_priv->set_dma(port_priv, value);
        MLX_CHECK_STATUS(port_priv->device, status, set_err,
                        "nodnic_port_set failed");
        port_priv->dma_state = value;
set_err:
set_out:
        return status;
}

Definition at line 1205 of file mlx_port.c.

References buffer, MLX_CHECK_STATUS, MLX_SUCCESS, nodnic_port_option_port_promisc_en, nodnic_port_set(), status, and value.

Referenced by flexboot_nodnic_eth_close(), and flexboot_nodnic_eth_open().

                 {
        mlx_status status = MLX_SUCCESS;
        mlx_uint32      buffer = value;

        status = nodnic_port_set(port_priv, nodnic_port_option_port_promisc_en, buffer);
        MLX_CHECK_STATUS(port_priv->device, status, set_err,
                        "nodnic_port_set failed");
set_err:
        return status;
}

Definition at line 1220 of file mlx_port.c.

References buffer, MLX_CHECK_STATUS, MLX_SUCCESS, nodnic_port_option_port_promisc_multicast_en, nodnic_port_set(), status, and value.

                 {
        mlx_status status = MLX_SUCCESS;
        mlx_uint32      buffer = value;

        status = nodnic_port_set(port_priv, nodnic_port_option_port_promisc_multicast_en, buffer);
        MLX_CHECK_STATUS(port_priv->device, status, set_err,
                        "nodnic_port_set failed");
set_err:
        return status;
}

Definition at line 1235 of file mlx_port.c.

References MLX_FATAL_CHECK_STATUS, MLX_INVALID_PARAMETER, MLX_SUCCESS, nodnic_port_set_network(), NULL, status, and TRUE.

Referenced by flexboot_nodnic_eth_open().

{
        mlx_status status = MLX_SUCCESS;

        if( port_priv == NULL ){
                status = MLX_INVALID_PARAMETER;
                goto bad_param;
        }

        status = nodnic_port_set_network(port_priv, TRUE);
        MLX_FATAL_CHECK_STATUS(status, set_err,
                                        "nodnic_port_set_network failed");
set_err:
bad_param:
        return status;
}

Definition at line 1255 of file mlx_port.c.

References FALSE, MLX_FATAL_CHECK_STATUS, MLX_INVALID_PARAMETER, MLX_SUCCESS, nodnic_port_set_network(), NULL, and status.

Referenced by flexboot_nodnic_eth_close(), and flexboot_nodnic_eth_open().

{
        mlx_status status = MLX_SUCCESS;

        if( port_priv == NULL ){
                status = MLX_INVALID_PARAMETER;
                goto bad_param;
        }

        status = nodnic_port_set_network(port_priv, FALSE);
        MLX_FATAL_CHECK_STATUS(status, set_err,
                                        "nodnic_port_set_network failed");
set_err:
bad_param:
        return status;
}

Definition at line 1275 of file mlx_port.c.

References MLX_CHECK_STATUS, MLX_INVALID_PARAMETER, MLX_SUCCESS, nodnic_port_check_and_set_dma(), NULL, status, and TRUE.

Referenced by __attribute__(), and flexboot_nodnic_eth_open().

{
        mlx_status status = MLX_SUCCESS;

        if( port_priv == NULL ){
                status = MLX_INVALID_PARAMETER;
                goto bad_param;
        }

        status = nodnic_port_check_and_set_dma(port_priv, TRUE);
        MLX_CHECK_STATUS(port_priv->device, status, set_err,
                                        "nodnic_port_check_and_set_dma failed");
set_err:
bad_param:
        return status;
}

Definition at line 1295 of file mlx_port.c.

References FALSE, MLX_CHECK_STATUS, MLX_INVALID_PARAMETER, MLX_SUCCESS, nodnic_port_check_and_set_dma(), NULL, and status.

Referenced by flexboot_nodnic_port_disable_dma().

{
        mlx_status status = MLX_SUCCESS;

        if( port_priv == NULL ){
                status = MLX_INVALID_PARAMETER;
                goto bad_param;
        }

        status = nodnic_port_check_and_set_dma(port_priv, FALSE);
        MLX_CHECK_STATUS(port_priv->device, status, set_err,
                                        "nodnic_port_check_and_set_dma failed");
set_err:
bad_param:
        return status;
}
mlx_status nodnic_port_thin_init ( IN nodnic_device_priv device_priv,
IN nodnic_port_priv port_priv,
IN mlx_uint8  port_index 
)

Definition at line 1315 of file mlx_port.c.

References MLX_FAILED, MLX_INVALID_PARAMETER, MLX_SUCCESS, nodnic_cmd_read(), nodnic_port_offset_table, nodnic_port_read_reset_needed(), nodnic_port_recv_db_dma(), nodnic_port_set(), nodnic_port_set_dma(), NODNIC_PORT_TYPE_UNKNOWN, nodnic_port_update_ring_doorbell(), NULL, offset, and status.

Referenced by flexboot_nodnic_thin_init_ports().

{
        mlx_status status = MLX_SUCCESS;
        mlx_boolean     reset_needed = 0;
#ifdef DEVICE_CX3
        mlx_uint32 offset;
#endif

        if( device_priv == NULL || port_priv == NULL || port_index > 1){
                status = MLX_INVALID_PARAMETER;
                goto invalid_parm;
        }

        port_priv->device = device_priv;

        port_priv->port_offset = device_priv->device_offset +
                        nodnic_port_offset_table[port_index];

        port_priv->port_num = port_index + 1;

        port_priv->send_doorbell = nodnic_port_update_ring_doorbell;
        port_priv->recv_doorbell = nodnic_port_update_ring_doorbell;
        port_priv->set_dma = nodnic_port_set_dma;
#ifdef DEVICE_CX3
        if (device_priv->device_cap.crspace_doorbells) {
                status = nodnic_cmd_read(device_priv, (port_priv->port_offset + 0x100),
                                &offset);
                if (status != MLX_SUCCESS) {
                        return status;
                } else {
                        port_priv->data_flow_gw = (nodnic_port_data_flow_gw *)
                                        (device_priv->utils->config + offset);
                }
                if ( nodnic_port_set ( port_priv, nodnic_port_option_crspace_en, 1 ) ) {
                        return MLX_FAILED;
                }
                port_priv->send_doorbell = nodnic_port_send_db_connectx3;
                port_priv->recv_doorbell = nodnic_port_recv_db_connectx3;
                port_priv->set_dma = nodnic_port_set_dma_connectx3;
        }
#endif
        if ( device_priv->device_cap.support_rx_pi_dma ) {
                port_priv->recv_doorbell = nodnic_port_recv_db_dma;
        }

        /* clear reset_needed */
        nodnic_port_read_reset_needed(port_priv, &reset_needed);

        port_priv->port_type = NODNIC_PORT_TYPE_UNKNOWN;
invalid_parm:
        return status;
}

Variable Documentation

Initial value:

Definition at line 73 of file mlx_port.c.

Initial value:
 {
        0x100, 
        0x280, 
}

Definition at line 82 of file mlx_port.c.

Referenced by nodnic_port_thin_init().