iPXE
Data Structures | Macros | Functions | Variables
golan.c File Reference
#include <errno.h>
#include <strings.h>
#include <ipxe/malloc.h>
#include <ipxe/umalloc.h>
#include <ipxe/infiniband.h>
#include <ipxe/ib_smc.h>
#include <ipxe/iobuf.h>
#include <ipxe/netdevice.h>
#include "flexboot_nodnic.h"
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <usr/ifmgmt.h>
#include <ipxe/in.h>
#include <byteswap.h>
#include "mlx_utils/include/public/mlx_pci_gw.h"
#include <config/general.h>
#include <ipxe/ipoib.h>
#include "mlx_nodnic/include/mlx_port.h"
#include "nodnic_shomron_prm.h"
#include "golan.h"
#include "mlx_utils/include/public/mlx_bail.h"
#include "mlx_utils/mlx_lib/mlx_link_speed/mlx_link_speed.h"

Go to the source code of this file.

Data Structures

struct  golan_page
 
struct  mbox
 

Macros

#define DEVICE_IS_CIB(device)   ( device == 0x1011 )
 
#define GOLAN_CHECK_RC_AND_CMD_STATUS(_lable)
 
#define GOLAN_PRINT_RC_AND_CMD_STATUS   golan_check_rc_and_cmd_status ( cmd, rc )
 
#define CTRL_SIG_SZ   (sizeof(mailbox->mblock) - sizeof(mailbox->mblock.bdata) - 2)
 
#define SHOMRON_GENERATE_CQE   0x3
 
#define SHOMRON_INLINE_HEADERS_SIZE   18
 
#define SHOMRON_INLINE_HEADERS_OFFSET   32
 
#define FLEXBOOT_NODNIC_OPCODE_CQ_SEND   0
 
#define FLEXBOOT_NODNIC_OPCODE_CQ_RECV   2
 
#define FLEXBOOT_NODNIC_OPCODE_CQ_SEND_ERR   13
 
#define FLEXBOOT_NODNIC_OPCODE_CQ_RECV_ERR   14
 

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
static void golan_free_fw_areas (struct golan *golan)
 
static int golan_init_fw_areas (struct golan *golan)
 
static int golan_check_rc_and_cmd_status (struct golan_cmd_layout *cmd, int rc)
 
static uint32_t ilog2 (uint32_t mem)
 
static u8 xor8_buf (void *buf, int len)
 
static const char * cmd_status_str (u8 status)
 
static uint16_t fw_rev_maj (struct golan *golan)
 
static u16 fw_rev_min (struct golan *golan)
 
static u16 fw_rev_sub (struct golan *golan)
 
static u16 cmdif_rev (struct golan *golan)
 
static struct golan_cmd_layoutget_cmd (struct golan *golan, int idx)
 
static void golan_calc_sig (struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx)
 
static void show_out_status (uint32_t *out)
 
static uint32_t is_command_finished (struct golan *golan, int idx)
 Check if CMD has finished. More...
 
static int golan_cmd_wait (struct golan *golan, int idx, const char *command)
 Wait for Golan command completion. More...
 
static void send_command (struct golan *golan)
 Notify the HW that commands are ready. More...
 
static int send_command_and_wait (struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
 
static struct golan_cmd_layoutwrite_cmd (struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
 Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters. More...
 
static int golan_core_enable_hca (struct golan *golan)
 
static void golan_disable_hca (struct golan *golan)
 
static int golan_set_hca_cap (struct golan *golan)
 
static int golan_qry_hca_cap (struct golan *golan)
 
static int golan_take_pages (struct golan *golan, uint32_t pages, __be16 func_id)
 
static int golan_provide_pages (struct golan *golan, uint32_t pages, __be16 func_id, struct golan_firmware_area *fw_area)
 
static int golan_handle_pages (struct golan *golan, enum golan_qry_pages_mode qry, enum golan_manage_pages_mode mode)
 
static int golan_set_access_reg (struct golan *golan, uint32_t reg)
 
static void golan_cmd_uninit (struct golan *golan)
 
static int golan_cmd_init (struct golan *golan)
 Initialise Golan Command Q parameters – Alocate a 4kb page for the Command Q – Read the stride and log num commands available – Write the address to cmdq_phy_addr in iseg. More...
 
static int golan_hca_init (struct golan *golan)
 
static void golan_teardown_hca (struct golan *golan, enum golan_teardown op_mod)
 
static int golan_alloc_uar (struct golan *golan)
 
static void golan_dealloc_uar (struct golan *golan)
 
static void golan_eq_update_ci (struct golan_event_queue *eq, int arm)
 
static int golan_create_eq (struct golan *golan)
 
static void golan_destory_eq (struct golan *golan)
 
static int golan_alloc_pd (struct golan *golan)
 
static void golan_dealloc_pd (struct golan *golan)
 
static int golan_create_mkey (struct golan *golan)
 
static void golan_destroy_mkey (struct golan *golan)
 
static void golan_pci_init (struct golan *golan)
 Initialise Golan PCI parameters. More...
 
static struct golangolan_alloc ()
 
static int golan_create_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 Create completion queue. More...
 
static void golan_destroy_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 Destroy completion queue. More...
 
static void golan_cq_clean (struct ib_completion_queue *cq)
 
static int golan_qp_type_to_st (enum ib_queue_pair_type type)
 
static int golan_create_qp_aux (struct ib_device *ibdev, struct ib_queue_pair *qp, int *qpn)
 
static int golan_create_qp (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Create queue pair. More...
 
static int golan_modify_qp_rst_to_init (struct ib_device *ibdev, struct ib_queue_pair *qp __attribute__((unused)), struct golan_modify_qp_mbox_in_data *in)
 
static int golan_modify_qp_init_to_rtr (struct ib_device *ibdev __attribute__((unused)), struct ib_queue_pair *qp __attribute__((unused)), struct golan_modify_qp_mbox_in_data *in)
 
static int golan_modify_qp_rtr_to_rts (struct ib_device *ibdev __attribute__((unused)), struct ib_queue_pair *qp __attribute__((unused)), struct golan_modify_qp_mbox_in_data *in __attribute__((unused)))
 
static int golan_modify_qp_to_rst (struct ib_device *ibdev, struct ib_queue_pair *qp)
 
static int golan_modify_qp (struct ib_device *ibdev, struct ib_queue_pair *qp)
 
static void golan_destroy_qp (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Destroy queue pair. More...
 
static unsigned int golan_rate (enum ib_rate rate)
 Calculate transmission rate. More...
 
static int golan_post_send (struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *av, struct io_buffer *iobuf)
 Post send work queue entry. More...
 
static int golan_post_recv (struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf)
 Post receive work queue entry. More...
 
static int golan_query_vport_context (struct ib_device *ibdev)
 
static int golan_query_vport_gid (struct ib_device *ibdev)
 
static int golan_query_vport_pkey (struct ib_device *ibdev)
 
static int golan_get_ib_info (struct ib_device *ibdev)
 
static int golan_complete (struct ib_device *ibdev, struct ib_completion_queue *cq, struct golan_cqe64 *cqe64)
 
static int golan_is_hw_ownership (struct ib_completion_queue *cq, struct golan_cqe64 *cqe64)
 
static void golan_poll_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 
static const char * golan_eqe_type_str (u8 type)
 
static const char * golan_eqe_port_subtype_str (u8 subtype)
 
static int golan_ib_update (struct ib_device *ibdev)
 Update Infiniband parameters using Commands. More...
 
static void golan_handle_port_event (struct golan *golan, struct golan_eqe *eqe)
 
static struct golan_eqegolan_next_eqe_sw (struct golan_event_queue *eq)
 
static void golan_poll_eq (struct ib_device *ibdev)
 Poll event queue. More...
 
static int golan_mcast_attach (struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
 Attach to multicast group. More...
 
static void golan_mcast_detach (struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
 Detach from multicast group. More...
 
static int golan_inform_sma (struct ib_device *ibdev, union ib_mad *mad)
 Inform embedded subnet management agent of a received MAD. More...
 
static int golan_register_ibdev (struct golan_port *port)
 
static void golan_bring_down (struct golan *golan)
 
static int golan_set_link_speed (struct golan *golan)
 
static int golan_bring_up (struct golan *golan)
 
static void golan_ib_close (struct ib_device *ibdev)
 Close Infiniband link. More...
 
static int golan_ib_open (struct ib_device *ibdev)
 Initialise Infiniband link. More...
 
static int golan_probe_normal (struct pci_device *pci)
 
static void golan_remove_normal (struct pci_device *pci)
 
static mlx_status shomron_tx_uar_send_db (struct ib_device *ibdev, struct nodnic_send_wqbb *wqbb)
 
static mlx_status shomron_fill_eth_send_wqe (struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *av __attribute__((unused)), struct io_buffer *iobuf, struct nodnic_send_wqbb *wqbb, unsigned long wqe_index)
 
static mlx_status shomron_fill_completion (void *cqe, struct cqe_data *cqe_data)
 
static mlx_status shomron_cqe_set_owner (void *cq, unsigned int num_cqes)
 
static mlx_size shomron_get_cqe_size ()
 
static int shomron_nodnic_is_supported (struct pci_device *pci)
 
static int golan_probe (struct pci_device *pci)
 
static void golan_remove (struct pci_device *pci)
 

Variables

const char * golan_qp_state_as_string []
 
static int(* golan_modify_qp_methods [])(struct ib_device *ibdev, struct ib_queue_pair *qp, struct golan_modify_qp_mbox_in_data *in)
 
static struct ib_device_operations golan_ib_operations
 Golan Infiniband operations. More...
 
struct flexboot_nodnic_callbacks shomron_nodnic_callbacks
 
static struct pci_device_id golan_nics []
 
struct pci_driver golan_driver __pci_driver
 

Macro Definition Documentation

◆ DEVICE_IS_CIB

#define DEVICE_IS_CIB (   device)    ( device == 0x1011 )

Definition at line 46 of file golan.c.

◆ GOLAN_CHECK_RC_AND_CMD_STATUS

#define GOLAN_CHECK_RC_AND_CMD_STATUS (   _lable)
Value:
do { \
if ( ( rc = golan_check_rc_and_cmd_status ( cmd, rc ) ) ) \
goto _lable; \
} while (0)
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int golan_check_rc_and_cmd_status(struct golan_cmd_layout *cmd, int rc)
Definition: golan.c:98
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

Definition at line 111 of file golan.c.

◆ GOLAN_PRINT_RC_AND_CMD_STATUS

#define GOLAN_PRINT_RC_AND_CMD_STATUS   golan_check_rc_and_cmd_status ( cmd, rc )

Definition at line 117 of file golan.c.

◆ CTRL_SIG_SZ

#define CTRL_SIG_SZ   (sizeof(mailbox->mblock) - sizeof(mailbox->mblock.bdata) - 2)

Definition at line 133 of file golan.c.

◆ SHOMRON_GENERATE_CQE

#define SHOMRON_GENERATE_CQE   0x3

◆ SHOMRON_INLINE_HEADERS_SIZE

#define SHOMRON_INLINE_HEADERS_SIZE   18

◆ SHOMRON_INLINE_HEADERS_OFFSET

#define SHOMRON_INLINE_HEADERS_OFFSET   32

◆ FLEXBOOT_NODNIC_OPCODE_CQ_SEND

#define FLEXBOOT_NODNIC_OPCODE_CQ_SEND   0

◆ FLEXBOOT_NODNIC_OPCODE_CQ_RECV

#define FLEXBOOT_NODNIC_OPCODE_CQ_RECV   2

◆ FLEXBOOT_NODNIC_OPCODE_CQ_SEND_ERR

#define FLEXBOOT_NODNIC_OPCODE_CQ_SEND_ERR   13

◆ FLEXBOOT_NODNIC_OPCODE_CQ_RECV_ERR

#define FLEXBOOT_NODNIC_OPCODE_CQ_RECV_ERR   14

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ golan_free_fw_areas()

static void golan_free_fw_areas ( struct golan golan)
static

Definition at line 58 of file golan.c.

58  {
59  int i;
60 
61  for (i = 0; i < GOLAN_FW_AREAS_NUM; i++) {
62  if ( golan->fw_areas[i].area ) {
63  ufree ( golan->fw_areas[i].area );
64  golan->fw_areas[i].area = UNULL;
65  }
66  }
67 }
struct golan_firmware_area fw_areas[GOLAN_FW_AREAS_NUM]
Definition: golan.h:341
#define GOLAN_FW_AREAS_NUM
Definition: golan.h:340
Definition: golan.h:323
#define UNULL
Equivalent of NULL for user pointers.
Definition: uaccess.h:36
static __always_inline void ufree(userptr_t userptr)
Free external memory.
Definition: umalloc.h:65
userptr_t area
Firmware area in external memory.
Definition: golan.h:124

References golan_firmware_area::area, golan::fw_areas, GOLAN_FW_AREAS_NUM, ufree(), and UNULL.

Referenced by golan_probe_normal(), and golan_remove_normal().

◆ golan_init_fw_areas()

static int golan_init_fw_areas ( struct golan golan)
static

Definition at line 69 of file golan.c.

69  {
70  int rc = 0, i = 0;
71 
72  if ( ! golan ) {
73  rc = -EINVAL;
74  goto err_golan_init_fw_areas_bad_param;
75  }
76 
77  for (i = 0; i < GOLAN_FW_AREAS_NUM; i++)
78  golan->fw_areas[i].area = UNULL;
79 
80  return rc;
81 
82  err_golan_init_fw_areas_bad_param:
83  return rc;
84 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct golan_firmware_area fw_areas[GOLAN_FW_AREAS_NUM]
Definition: golan.h:341
#define GOLAN_FW_AREAS_NUM
Definition: golan.h:340
Definition: golan.h:323
#define UNULL
Equivalent of NULL for user pointers.
Definition: uaccess.h:36
userptr_t area
Firmware area in external memory.
Definition: golan.h:124

References golan_firmware_area::area, EINVAL, golan::fw_areas, GOLAN_FW_AREAS_NUM, rc, and UNULL.

Referenced by golan_probe_normal().

◆ golan_check_rc_and_cmd_status()

static int golan_check_rc_and_cmd_status ( struct golan_cmd_layout cmd,
int  rc 
)
inlinestatic

Definition at line 98 of file golan.c.

98  {
99  struct golan_outbox_hdr *out_hdr = ( struct golan_outbox_hdr * ) ( cmd->out );
100  if ( rc == -EBUSY ) {
101  DBG ( "HCA is busy (rc = -EBUSY)\n" );
102  return rc;
103  } else if ( out_hdr->status ) {
104  DBG("%s status = 0x%x - syndrom = 0x%x\n", __FUNCTION__,
105  out_hdr->status, be32_to_cpu(out_hdr->syndrome));
106  return out_hdr->status;
107  }
108  return 0;
109 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EBUSY
Device or resource busy.
Definition: errno.h:338
__be32 syndrome
Definition: CIB_PRM.h:205
#define be32_to_cpu(value)
Definition: byteswap.h:116
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References be32_to_cpu, cmd, DBG, EBUSY, rc, golan_outbox_hdr::status, and golan_outbox_hdr::syndrome.

◆ ilog2()

static uint32_t ilog2 ( uint32_t  mem)
inlinestatic

Definition at line 128 of file golan.c.

129 {
130  return ( fls ( mem ) - 1 );
131 }
#define fls(x)
Find last (i.e.
Definition: strings.h:166
static unsigned int unsigned int mem
Definition: intel.h:271

References fls, and mem.

Referenced by golan_create_cq(), golan_create_eq(), golan_create_qp_aux(), golan_is_hw_ownership(), and golan_next_eqe_sw().

◆ xor8_buf()

static u8 xor8_buf ( void *  buf,
int  len 
)
inlinestatic

Definition at line 135 of file golan.c.

136 {
137  u8 sum = 0;
138  int i;
139  u8 *ptr = buf;
140 
141  for (i = 0; i < len; ++i)
142  sum ^= ptr[i];
143 
144  return sum;
145 }
uint32_t len
Length.
Definition: ena.h:14
uint8_t u8
Definition: stdint.h:19

References len.

Referenced by golan_calc_sig().

◆ cmd_status_str()

static const char* cmd_status_str ( u8  status)
inlinestatic

Definition at line 147 of file golan.c.

148 {
149  switch (status) {
150  case 0x0: return "OK";
151  case 0x1: return "internal error";
152  case 0x2: return "bad operation";
153  case 0x3: return "bad parameter";
154  case 0x4: return "bad system state";
155  case 0x5: return "bad resource";
156  case 0x6: return "resource busy";
157  case 0x8: return "limits exceeded";
158  case 0x9: return "bad resource state";
159  case 0xa: return "bad index";
160  case 0xf: return "no resources";
161  case 0x50: return "bad input length";
162  case 0x51: return "bad output length";
163  case 0x10: return "bad QP state";
164  case 0x30: return "bad packet (discarded)";
165  case 0x40: return "bad size too many outstanding CQEs";
166  case 0xff: return "Command Timed Out";
167  default: return "unknown status";
168  }
169 }
uint8_t status
Status.
Definition: ena.h:16

References status.

Referenced by golan_cmd_wait(), golan_provide_pages(), and golan_take_pages().

◆ fw_rev_maj()

static uint16_t fw_rev_maj ( struct golan golan)
inlinestatic

Definition at line 171 of file golan.c.

172 {
173  return be32_to_cpu(readl(&golan->iseg->fw_rev)) & 0xffff;
174 }
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
Definition: golan.h:323
#define be32_to_cpu(value)
Definition: byteswap.h:116
struct golan_hca_init_seg * iseg
Definition: golan.h:325

References be32_to_cpu, golan_hca_init_seg::fw_rev, golan::iseg, and readl().

◆ fw_rev_min()

static u16 fw_rev_min ( struct golan golan)
inlinestatic

Definition at line 176 of file golan.c.

177 {
178  return be32_to_cpu(readl(&golan->iseg->fw_rev)) >> 16;
179 }
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
Definition: golan.h:323
#define be32_to_cpu(value)
Definition: byteswap.h:116
struct golan_hca_init_seg * iseg
Definition: golan.h:325

References be32_to_cpu, golan_hca_init_seg::fw_rev, golan::iseg, and readl().

◆ fw_rev_sub()

static u16 fw_rev_sub ( struct golan golan)
inlinestatic

Definition at line 181 of file golan.c.

182 {
183  return be32_to_cpu(readl(&golan->iseg->cmdif_rev_fw_sub)) & 0xffff;
184 }
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
Definition: golan.h:323
#define be32_to_cpu(value)
Definition: byteswap.h:116
struct golan_hca_init_seg * iseg
Definition: golan.h:325
__be32 cmdif_rev_fw_sub
Definition: CIB_PRM.h:55

References be32_to_cpu, golan_hca_init_seg::cmdif_rev_fw_sub, golan::iseg, and readl().

◆ cmdif_rev()

static u16 cmdif_rev ( struct golan golan)
inlinestatic

Definition at line 186 of file golan.c.

187 {
188  return be32_to_cpu(readl(&golan->iseg->cmdif_rev_fw_sub)) >> 16;
189 }
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
Definition: golan.h:323
#define be32_to_cpu(value)
Definition: byteswap.h:116
struct golan_hca_init_seg * iseg
Definition: golan.h:325
__be32 cmdif_rev_fw_sub
Definition: CIB_PRM.h:55

References be32_to_cpu, golan_hca_init_seg::cmdif_rev_fw_sub, golan::iseg, and readl().

◆ get_cmd()

static struct golan_cmd_layout* get_cmd ( struct golan golan,
int  idx 
)
inlinestatic

Definition at line 192 of file golan.c.

193 {
194  return golan->cmd.addr + (idx << golan->cmd.log_stride);
195 }
Definition: golan.h:323
u16 log_stride
Definition: golan.h:104
struct golan_cmdq_md cmd
Definition: golan.h:326
void * addr
Definition: golan.h:103

References golan_cmdq_md::addr, golan::cmd, and golan_cmdq_md::log_stride.

Referenced by golan_calc_sig(), golan_provide_pages(), golan_take_pages(), is_command_finished(), and write_cmd().

◆ golan_calc_sig()

static void golan_calc_sig ( struct golan golan,
uint32_t  cmd_idx,
uint32_t  inbox_idx,
uint32_t  outbox_idx 
)
inlinestatic

Definition at line 197 of file golan.c.

199 {
200  struct golan_cmd_layout *cmd = get_cmd(golan, cmd_idx);
201  struct mbox *mailbox = NULL;
202 
203  if (inbox_idx != NO_MBOX) {
204  mailbox = GET_INBOX(golan, inbox_idx);
205  mailbox->mblock.token = cmd->token;
206  mailbox->mblock.ctrl_sig = ~xor8_buf(mailbox->mblock.rsvd0,
207  CTRL_SIG_SZ);
208  }
209  if (outbox_idx != NO_MBOX) {
210  mailbox = GET_OUTBOX(golan, outbox_idx);
211  mailbox->mblock.token = cmd->token;
212  mailbox->mblock.ctrl_sig = ~xor8_buf(mailbox->mblock.rsvd0,
213  CTRL_SIG_SZ);
214  }
215  cmd->sig = ~xor8_buf(cmd, sizeof(*cmd));
216 }
#define GET_OUTBOX(golan, idx)
Definition: golan.h:76
struct golan_cmd_prot_block mblock
Definition: golan.c:122
#define CTRL_SIG_SZ
Definition: golan.c:133
#define NO_MBOX
Definition: golan.h:58
Definition: golan.h:323
Definition: golan.c:120
static struct golan_cmd_layout * get_cmd(struct golan *golan, int idx)
Definition: golan.c:192
static u8 xor8_buf(void *buf, int len)
Definition: golan.c:135
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
#define GET_INBOX(golan, idx)
Definition: golan.h:75

References cmd, golan_cmd_prot_block::ctrl_sig, CTRL_SIG_SZ, get_cmd(), GET_INBOX, GET_OUTBOX, mbox::mblock, NO_MBOX, NULL, golan_cmd_prot_block::rsvd0, golan_cmd_prot_block::token, and xor8_buf().

Referenced by send_command_and_wait().

◆ show_out_status()

static void show_out_status ( uint32_t out)
inlinestatic

Definition at line 218 of file golan.c.

219 {
220  DBG("%x\n", be32_to_cpu(out[0]));
221  DBG("%x\n", be32_to_cpu(out[1]));
222  DBG("%x\n", be32_to_cpu(out[2]));
223  DBG("%x\n", be32_to_cpu(out[3]));
224 }
#define be32_to_cpu(value)
Definition: byteswap.h:116
__be32 out[4]
Definition: CIB_PRM.h:36
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References be32_to_cpu, DBG, and out.

◆ is_command_finished()

static uint32_t is_command_finished ( struct golan golan,
int  idx 
)
inlinestatic

Check if CMD has finished.

Definition at line 228 of file golan.c.

229 {
230  wmb();
231  return !(get_cmd( golan , idx )->status_own & CMD_OWNER_HW);
232 }
wmb()
#define CMD_OWNER_HW
Definition: CIB_PRM.h:35
Definition: golan.h:323
static struct golan_cmd_layout * get_cmd(struct golan *golan, int idx)
Definition: golan.c:192
volatile u8 status_own
Definition: CIB_PRM.h:199

References CMD_OWNER_HW, get_cmd(), golan_cmd_layout::status_own, and wmb().

Referenced by golan_cmd_wait().

◆ golan_cmd_wait()

static int golan_cmd_wait ( struct golan golan,
int  idx,
const char *  command 
)
inlinestatic

Wait for Golan command completion.

Parameters
golanGolan device
Return values
rcReturn status code

Definition at line 240 of file golan.c.

241 {
242  unsigned int wait;
243  int rc = -EBUSY;
244 
245  for ( wait = GOLAN_HCR_MAX_WAIT_MS ; wait ; --wait ) {
246  if (is_command_finished(golan, idx)) {
247  rc = CMD_STATUS(golan, idx);
248  rmb();
249  break;
250  } else {
251  mdelay ( 1 );
252  }
253  }
254  if (rc) {
255  DBGC (golan ,"[%s]RC is %s[%x]\n", command, cmd_status_str(rc), rc);
256  }
257 
258  golan->cmd_bm &= ~(1 << idx);
259  return rc;
260 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EBUSY
Device or resource busy.
Definition: errno.h:338
A command-line command.
Definition: command.h:9
#define DBGC(...)
Definition: compiler.h:505
uint32_t cmd_bm
Definition: golan.h:330
#define rmb()
Definition: io.h:484
Definition: golan.h:323
static uint32_t is_command_finished(struct golan *golan, int idx)
Check if CMD has finished.
Definition: golan.c:228
#define CMD_STATUS(golan, idx)
Definition: golan.h:66
#define GOLAN_HCR_MAX_WAIT_MS
Definition: golan.h:47
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
static const char * cmd_status_str(u8 status)
Definition: golan.c:147

References golan::cmd_bm, CMD_STATUS, cmd_status_str(), DBGC, EBUSY, GOLAN_HCR_MAX_WAIT_MS, is_command_finished(), mdelay(), rc, and rmb.

Referenced by send_command_and_wait().

◆ send_command()

static void send_command ( struct golan golan)
inlinestatic

Notify the HW that commands are ready.

Definition at line 265 of file golan.c.

266 {
267  wmb(); //Make sure the command is visible in "memory".
269 }
wmb()
uint32_t cmd_bm
Definition: golan.h:330
Definition: golan.h:323
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
struct golan_hca_init_seg * iseg
Definition: golan.h:325
__be32 cmd_dbell
Definition: CIB_PRM.h:59
#define cpu_to_be32(value)
Definition: byteswap.h:110

References golan::cmd_bm, golan_hca_init_seg::cmd_dbell, cpu_to_be32, golan::iseg, wmb(), and writel().

Referenced by send_command_and_wait().

◆ send_command_and_wait()

static int send_command_and_wait ( struct golan golan,
uint32_t  cmd_idx,
uint32_t  inbox_idx,
uint32_t  outbox_idx,
const char *  command 
)
inlinestatic

Definition at line 271 of file golan.c.

273 {
274  golan_calc_sig(golan, cmd_idx, inbox_idx, outbox_idx);
276  return golan_cmd_wait(golan, cmd_idx, command);
277 }
static int golan_cmd_wait(struct golan *golan, int idx, const char *command)
Wait for Golan command completion.
Definition: golan.c:240
A command-line command.
Definition: command.h:9
Definition: golan.h:323
static void send_command(struct golan *golan)
Notify the HW that commands are ready.
Definition: golan.c:265
static void golan_calc_sig(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx)
Definition: golan.c:197

References golan_calc_sig(), golan_cmd_wait(), and send_command().

Referenced by golan_alloc_pd(), golan_alloc_uar(), golan_core_enable_hca(), golan_create_cq(), golan_create_eq(), golan_create_mkey(), golan_create_qp_aux(), golan_dealloc_pd(), golan_dealloc_uar(), golan_destory_eq(), golan_destroy_cq(), golan_destroy_mkey(), golan_destroy_qp(), golan_disable_hca(), golan_handle_pages(), golan_hca_init(), golan_mcast_attach(), golan_mcast_detach(), golan_modify_qp(), golan_modify_qp_to_rst(), golan_provide_pages(), golan_qry_hca_cap(), golan_query_vport_context(), golan_query_vport_gid(), golan_query_vport_pkey(), golan_set_hca_cap(), golan_take_pages(), and golan_teardown_hca().

◆ write_cmd()

static struct golan_cmd_layout* write_cmd ( struct golan golan,
int  idx,
uint16_t  opcode,
uint16_t  opmod,
uint16_t  inbox_idx,
uint16_t  outbox_idx,
uint16_t  inlen,
uint16_t  outlen 
)
inlinestatic

Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.

Definition at line 284 of file golan.c.

289 {
290  struct golan_cmd_layout *cmd = get_cmd(golan , idx);
291  struct golan_inbox_hdr *hdr = (struct golan_inbox_hdr *)cmd->in;
292  static uint8_t token;
293 
294  memset(cmd, 0, sizeof(*cmd));
295 
296  cmd->type = GOLAN_PCI_CMD_XPORT;
297  cmd->status_own = CMD_OWNER_HW;
298  cmd->outlen = cpu_to_be32(outlen);
299  cmd->inlen = cpu_to_be32(inlen);
300  hdr->opcode = cpu_to_be16(opcode);
301  hdr->opmod = cpu_to_be16(opmod);
302 
303  if (inbox_idx != NO_MBOX) {
304  memset(GET_INBOX(golan, inbox_idx), 0, MAILBOX_SIZE);
305  cmd->in_ptr = VIRT_2_BE64_BUS(GET_INBOX(golan, inbox_idx));
306  cmd->token = ++token;
307  }
308  if (outbox_idx != NO_MBOX) {
309  memset(GET_OUTBOX(golan, outbox_idx), 0, MAILBOX_SIZE);
310  cmd->out_ptr = VIRT_2_BE64_BUS(GET_OUTBOX(golan, outbox_idx));
311  }
312 
313  golan->cmd_bm |= 1 << idx;
314 
315  assert ( cmd != NULL );
316  return cmd;
317 }
#define cpu_to_be16(value)
Definition: byteswap.h:109
#define GET_OUTBOX(golan, idx)
Definition: golan.h:76
__be16 opmod
Definition: CIB_PRM.h:30
uint8_t opcode
Opcode.
Definition: ena.h:16
__be32 outlen
Definition: CIB_PRM.h:41
uint32_t cmd_bm
Definition: golan.h:330
#define CMD_OWNER_HW
Definition: CIB_PRM.h:35
#define NO_MBOX
Definition: golan.h:58
Definition: golan.h:323
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static struct golan_cmd_layout * get_cmd(struct golan *golan, int idx)
Definition: golan.c:192
unsigned char uint8_t
Definition: stdint.h:10
#define VIRT_2_BE64_BUS(addr)
Definition: golan.h:70
u8 token
Definition: CIB_PRM.h:42
uint32_t hdr
Message header.
Definition: intelvf.h:12
#define cpu_to_be32(value)
Definition: byteswap.h:110
#define MAILBOX_SIZE
Definition: CIB_PRM.h:1165
__be32 inlen
Definition: CIB_PRM.h:30
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
#define GET_INBOX(golan, idx)
Definition: golan.h:75
void * memset(void *dest, int character, size_t len) __nonnull
#define GOLAN_PCI_CMD_XPORT
Definition: CIB_PRM.h:34

References assert(), cmd, golan::cmd_bm, CMD_OWNER_HW, cpu_to_be16, cpu_to_be32, get_cmd(), GET_INBOX, GET_OUTBOX, GOLAN_PCI_CMD_XPORT, hdr, inlen, MAILBOX_SIZE, memset(), NO_MBOX, NULL, opcode, opmod, outlen, token, and VIRT_2_BE64_BUS.

Referenced by golan_alloc_pd(), golan_alloc_uar(), golan_core_enable_hca(), golan_create_cq(), golan_create_eq(), golan_create_mkey(), golan_create_qp_aux(), golan_dealloc_pd(), golan_dealloc_uar(), golan_destory_eq(), golan_destroy_cq(), golan_destroy_mkey(), golan_destroy_qp(), golan_disable_hca(), golan_handle_pages(), golan_hca_init(), golan_mcast_attach(), golan_mcast_detach(), golan_modify_qp(), golan_modify_qp_to_rst(), golan_provide_pages(), golan_qry_hca_cap(), golan_query_vport_context(), golan_query_vport_gid(), golan_query_vport_pkey(), golan_set_access_reg(), golan_set_hca_cap(), golan_take_pages(), and golan_teardown_hca().

◆ golan_core_enable_hca()

static int golan_core_enable_hca ( struct golan golan)
inlinestatic

Definition at line 319 of file golan.c.

320 {
321  struct golan_cmd_layout *cmd;
322  int rc = 0;
323 
324  DBGC(golan, "%s\n", __FUNCTION__);
325 
327  NO_MBOX, NO_MBOX,
328  sizeof(struct golan_enable_hca_mbox_in),
329  sizeof(struct golan_enable_hca_mbox_out));
330 
333  return rc;
334 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
#define GOLAN_PRINT_RC_AND_CMD_STATUS
Definition: golan.c:117
#define NO_MBOX
Definition: golan.h:58
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define DEF_CMD_IDX
Definition: golan.h:56
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References cmd, DBGC, DEF_CMD_IDX, GOLAN_CMD_OP_ENABLE_HCA, GOLAN_PRINT_RC_AND_CMD_STATUS, NO_MBOX, rc, send_command_and_wait(), and write_cmd().

Referenced by golan_bring_up().

◆ golan_disable_hca()

static void golan_disable_hca ( struct golan golan)
inlinestatic

Definition at line 336 of file golan.c.

337 {
338  struct golan_cmd_layout *cmd;
339  int rc;
340 
342  NO_MBOX, NO_MBOX,
343  sizeof(struct golan_disable_hca_mbox_in),
344  sizeof(struct golan_disable_hca_mbox_out));
347 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define GOLAN_PRINT_RC_AND_CMD_STATUS
Definition: golan.c:117
#define NO_MBOX
Definition: golan.h:58
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define DEF_CMD_IDX
Definition: golan.h:56
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References cmd, DEF_CMD_IDX, GOLAN_CMD_OP_DISABLE_HCA, GOLAN_PRINT_RC_AND_CMD_STATUS, NO_MBOX, rc, send_command_and_wait(), and write_cmd().

Referenced by golan_bring_down(), and golan_bring_up().

◆ golan_set_hca_cap()

static int golan_set_hca_cap ( struct golan golan)
inlinestatic

Definition at line 349 of file golan.c.

350 {
351  struct golan_cmd_layout *cmd;
352  int rc;
353 
354  DBGC(golan, "%s\n", __FUNCTION__);
355 
357  GEN_MBOX, NO_MBOX,
358  sizeof(struct golan_cmd_set_hca_cap_mbox_in),
359  sizeof(struct golan_cmd_set_hca_cap_mbox_out));
360 
362  DBGC( golan , "%s caps.uar_sz = %d\n", __FUNCTION__, golan->caps.uar_sz);
363  DBGC( golan , "%s caps.log_pg_sz = %d\n", __FUNCTION__, golan->caps.log_pg_sz);
364  DBGC( golan , "%s caps.log_uar_sz = %d\n", __FUNCTION__, be32_to_cpu(golan->caps.uar_page_sz));
365  golan->caps.uar_page_sz = 0;
367 
369  &(golan->caps),
370  sizeof(struct golan_hca_cap));
371 
372  //if command failed we should reset the caps in golan->caps
375  return rc;
376 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
#define GEN_MBOX
Definition: golan.h:60
struct golan_hca_cap caps
Definition: golan.h:327
#define GOLAN_PRINT_RC_AND_CMD_STATUS
Definition: golan.c:117
#define NO_MBOX
Definition: golan.h:58
void * memcpy(void *dest, const void *src, size_t len) __nonnull
Definition: golan.h:323
#define be32_to_cpu(value)
Definition: byteswap.h:116
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
#define GOLAN_LOG_MAX_QP
Definition: CIB_PRM.h:36
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
__be16 log_max_qp
Definition: CIB_PRM.h:232
__be64 flags
Definition: CIB_PRM.h:267
#define DEF_CMD_IDX
Definition: golan.h:56
__be32 uar_page_sz
Definition: CIB_PRM.h:288
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
#define GET_INBOX(golan, idx)
Definition: golan.h:75

References be32_to_cpu, golan::caps, cmd, DBGC, DEF_CMD_IDX, golan_hca_cap::flags, GEN_MBOX, GET_INBOX, GOLAN_CMD_OP_SET_HCA_CAP, GOLAN_DEV_CAP_FLAG_CMDIF_CSUM, GOLAN_LOG_MAX_QP, GOLAN_PRINT_RC_AND_CMD_STATUS, golan_hca_cap::log_max_qp, golan_hca_cap::log_pg_sz, memcpy(), NO_MBOX, rc, send_command_and_wait(), golan_hca_cap::uar_page_sz, golan_hca_cap::uar_sz, and write_cmd().

Referenced by golan_bring_up().

◆ golan_qry_hca_cap()

static int golan_qry_hca_cap ( struct golan golan)
inlinestatic

Definition at line 378 of file golan.c.

379 {
380  struct golan_cmd_layout *cmd;
381  int rc = 0;
382 
384  NO_MBOX, GEN_MBOX,
385  sizeof(struct golan_cmd_query_hca_cap_mbox_in),
386  sizeof(struct golan_cmd_query_hca_cap_mbox_out));
387 
389  GOLAN_CHECK_RC_AND_CMD_STATUS( err_query_hca_cap );
390 
391  memcpy(&(golan->caps),
392  ((struct golan_hca_cap *)GET_OUTBOX(golan, GEN_MBOX)),
393  sizeof(struct golan_hca_cap));
394 err_query_hca_cap:
395  return rc;
396 }
#define GET_OUTBOX(golan, idx)
Definition: golan.h:76
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define GEN_MBOX
Definition: golan.h:60
struct golan_hca_cap caps
Definition: golan.h:327
#define NO_MBOX
Definition: golan.h:58
void * memcpy(void *dest, const void *src, size_t len) __nonnull
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define GOLAN_CHECK_RC_AND_CMD_STATUS(_lable)
Definition: golan.c:111
#define DEF_CMD_IDX
Definition: golan.h:56
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References golan::caps, cmd, DEF_CMD_IDX, GEN_MBOX, GET_OUTBOX, GOLAN_CHECK_RC_AND_CMD_STATUS, GOLAN_CMD_OP_QUERY_HCA_CAP, memcpy(), NO_MBOX, rc, send_command_and_wait(), and write_cmd().

Referenced by golan_bring_up().

◆ golan_take_pages()

static int golan_take_pages ( struct golan golan,
uint32_t  pages,
__be16  func_id 
)
inlinestatic

Definition at line 398 of file golan.c.

398  {
399  uint32_t out_num_entries = 0;
400  int size_ibox = 0;
401  int size_obox = 0;
402  int rc = 0;
403 
404  DBGC(golan, "%s\n", __FUNCTION__);
405 
406  while ( pages > 0 ) {
407  uint32_t pas_num = min(pages, MAX_PASE_MBOX);
408  struct golan_cmd_layout *cmd;
410 
411  size_ibox = sizeof(struct golan_manage_pages_inbox) + (pas_num * GOLAN_PAS_SIZE);
412  size_obox = sizeof(struct golan_manage_pages_outbox) + (pas_num * GOLAN_PAS_SIZE);
413 
416  size_ibox,
417  size_obox);
418 
419  in = (struct golan_manage_pages_inbox *)cmd->in; /* Warning (WE CANT USE THE LAST 2 FIELDS) */
420 
421  in->func_id = func_id; /* Already BE */
422  in->num_entries = cpu_to_be32(pas_num);
423 
424  if ( ( rc = send_command_and_wait(golan, MEM_CMD_IDX, MEM_MBOX, MEM_MBOX, __FUNCTION__) ) == 0 ) {
425  out_num_entries = be32_to_cpu(((struct golan_manage_pages_outbox *)(cmd->out))->num_entries);
426  } else {
427  if ( rc == -EBUSY ) {
428  DBGC (golan ,"HCA is busy (rc = -EBUSY)\n" );
429  } else {
430  DBGC (golan ,"%s: rc =0x%x[%s]<%x> syn 0x%x[0x%x] for %d pages\n",
431  __FUNCTION__, rc, cmd_status_str(rc),
434  be32_to_cpu(CMD_SYND(golan, MEM_CMD_IDX)), pas_num);
435  }
436  return rc;
437  }
438 
439  pages -= out_num_entries;
440  }
441  DBGC( golan , "%s Pages handled\n", __FUNCTION__);
442  return rc;
443 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MEM_CMD_IDX
Definition: golan.h:57
#define EBUSY
Device or resource busy.
Definition: errno.h:338
__be16 func_id
Definition: CIB_PRM.h:30
__be32 in[4]
Definition: CIB_PRM.h:35
#define DBGC(...)
Definition: compiler.h:505
#define min(x, y)
Definition: ath.h:34
#define MEM_MBOX
Definition: golan.h:59
#define GOLAN_PAS_SIZE
Definition: golan.h:37
volatile u8 status_own
Definition: CIB_PRM.h:45
Definition: golan.h:323
#define be32_to_cpu(value)
Definition: byteswap.h:116
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
static struct golan_cmd_layout * get_cmd(struct golan *golan, int idx)
Definition: golan.c:192
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
unsigned int uint32_t
Definition: stdint.h:12
#define MAX_PASE_MBOX
Definition: golan.h:64
#define cpu_to_be32(value)
Definition: byteswap.h:110
#define CMD_SYND(golan, idx)
Definition: golan.h:67
static const char * cmd_status_str(u8 status)
Definition: golan.c:147
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References be32_to_cpu, cmd, cmd_status_str(), CMD_SYND, cpu_to_be32, DBGC, EBUSY, func_id, get_cmd(), GOLAN_CMD_OP_MANAGE_PAGES, GOLAN_PAGES_TAKE, GOLAN_PAS_SIZE, in, MAX_PASE_MBOX, MEM_CMD_IDX, MEM_MBOX, min, rc, send_command_and_wait(), status_own, and write_cmd().

Referenced by golan_handle_pages().

◆ golan_provide_pages()

static int golan_provide_pages ( struct golan golan,
uint32_t  pages,
__be16  func_id,
struct golan_firmware_area fw_area 
)
inlinestatic

Definition at line 445 of file golan.c.

446  {
447  struct mbox *mailbox;
448  int size_ibox = 0;
449  int size_obox = 0;
450  int rc = 0;
451  userptr_t next_page_addr = UNULL;
452 
453  DBGC(golan, "%s\n", __FUNCTION__);
454  if ( ! fw_area->area ) {
455  fw_area->area = umalloc ( GOLAN_PAGE_SIZE * pages );
456  if ( fw_area->area == UNULL ) {
457  rc = -ENOMEM;
458  DBGC (golan ,"Failed to allocated %d pages \n",pages);
459  goto err_golan_alloc_fw_area;
460  }
461  fw_area->npages = pages;
462  }
463  assert ( fw_area->npages == pages );
464  next_page_addr = fw_area->area;
465  while ( pages > 0 ) {
466  uint32_t pas_num = min(pages, MAX_PASE_MBOX);
467  unsigned i, j;
468  struct golan_cmd_layout *cmd;
470  userptr_t addr = 0;
471 
472  mailbox = GET_INBOX(golan, MEM_MBOX);
473  size_ibox = sizeof(struct golan_manage_pages_inbox) + (pas_num * GOLAN_PAS_SIZE);
474  size_obox = sizeof(struct golan_manage_pages_outbox) + (pas_num * GOLAN_PAS_SIZE);
475 
478  size_ibox,
479  size_obox);
480 
481  in = (struct golan_manage_pages_inbox *)cmd->in; /* Warning (WE CANT USE THE LAST 2 FIELDS) */
482 
483  in->func_id = func_id; /* Already BE */
484  in->num_entries = cpu_to_be32(pas_num);
485 
486  for ( i = 0 , j = MANAGE_PAGES_PSA_OFFSET; i < pas_num; ++i ,++j,
487  next_page_addr += GOLAN_PAGE_SIZE ) {
488  addr = next_page_addr;
489  if (GOLAN_PAGE_MASK & user_to_phys(addr, 0)) {
490  DBGC (golan ,"Addr not Page alligned [%lx %lx]\n", user_to_phys(addr, 0), addr);
491  }
492  mailbox->mblock.data[j] = USR_2_BE64_BUS(addr);
493  }
494 
495  if ( ( rc = send_command_and_wait(golan, MEM_CMD_IDX, MEM_MBOX, MEM_MBOX, __FUNCTION__) ) == 0 ) {
496  pages -= pas_num;
497  golan->total_dma_pages += pas_num;
498  } else {
499  if ( rc == -EBUSY ) {
500  DBGC (golan ,"HCA is busy (rc = -EBUSY)\n" );
501  } else {
502  DBGC (golan ,"%s: rc =0x%x[%s]<%x> syn 0x%x[0x%x] for %d pages\n",
503  __FUNCTION__, rc, cmd_status_str(rc),
506  be32_to_cpu(CMD_SYND(golan, MEM_CMD_IDX)), pas_num);
507  }
508  goto err_send_command;
509  }
510  }
511  DBGC( golan , "%s Pages handled\n", __FUNCTION__);
512  return 0;
513 
514 err_send_command:
515 err_golan_alloc_fw_area:
516  /* Go over In box and free pages */
517  /* Send Error to FW */
518  /* What is next - Disable HCA? */
519  DBGC (golan ,"%s Failed (rc = 0x%x)\n", __FUNCTION__, rc);
520  return rc;
521 }
struct golan_cmd_prot_block mblock
Definition: golan.c:122
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MEM_CMD_IDX
Definition: golan.h:57
#define EBUSY
Device or resource busy.
Definition: errno.h:338
__be16 func_id
Definition: CIB_PRM.h:30
__be32 in[4]
Definition: CIB_PRM.h:35
unsigned long user_to_phys(userptr_t userptr, off_t offset)
Convert user pointer to physical address.
#define DBGC(...)
Definition: compiler.h:505
#define min(x, y)
Definition: ath.h:34
#define MEM_MBOX
Definition: golan.h:59
#define GOLAN_PAS_SIZE
Definition: golan.h:37
volatile u8 status_own
Definition: CIB_PRM.h:45
#define ENOMEM
Not enough space.
Definition: errno.h:534
Definition: golan.h:323
#define be32_to_cpu(value)
Definition: byteswap.h:116
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
__be64 data[GOLAN_CMD_PAS_CNT]
Definition: CIB_PRM.h:410
Definition: golan.c:120
static struct golan_cmd_layout * get_cmd(struct golan *golan, int idx)
Definition: golan.c:192
#define GOLAN_PAGE_MASK
Definition: golan.h:53
#define MANAGE_PAGES_PSA_OFFSET
Definition: golan.h:195
u32 addr
Definition: sky2.h:8
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
unsigned int uint32_t
Definition: stdint.h:12
uint32_t total_dma_pages
Definition: golan.h:331
#define MAX_PASE_MBOX
Definition: golan.h:64
uint32_t npages
Definition: golan.h:117
#define cpu_to_be32(value)
Definition: byteswap.h:110
#define UNULL
Equivalent of NULL for user pointers.
Definition: uaccess.h:36
static __always_inline userptr_t umalloc(size_t size)
Allocate external memory.
Definition: umalloc.h:54
#define USR_2_BE64_BUS(addr)
Definition: golan.h:72
#define CMD_SYND(golan, idx)
Definition: golan.h:67
static const char * cmd_status_str(u8 status)
Definition: golan.c:147
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
userptr_t area
Firmware area in external memory.
Definition: golan.h:124
#define GOLAN_PAGE_SIZE
Definition: golan.h:52
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33
#define GET_INBOX(golan, idx)
Definition: golan.h:75

References addr, golan_firmware_area::area, assert(), be32_to_cpu, cmd, cmd_status_str(), CMD_SYND, cpu_to_be32, golan_cmd_prot_block::data, DBGC, EBUSY, ENOMEM, func_id, get_cmd(), GET_INBOX, GOLAN_CMD_OP_MANAGE_PAGES, GOLAN_PAGE_MASK, GOLAN_PAGE_SIZE, GOLAN_PAGES_GIVE, GOLAN_PAS_SIZE, in, MANAGE_PAGES_PSA_OFFSET, MAX_PASE_MBOX, mbox::mblock, MEM_CMD_IDX, MEM_MBOX, min, golan_firmware_area::npages, rc, send_command_and_wait(), status_own, golan::total_dma_pages, umalloc(), UNULL, user_to_phys(), USR_2_BE64_BUS, and write_cmd().

Referenced by golan_handle_pages().

◆ golan_handle_pages()

static int golan_handle_pages ( struct golan golan,
enum golan_qry_pages_mode  qry,
enum golan_manage_pages_mode  mode 
)
inlinestatic

Definition at line 523 of file golan.c.

526 {
527  struct golan_cmd_layout *cmd;
528 
529  int rc = 0;
530  int32_t pages;
531  uint16_t total_pages;
532  __be16 func_id;
533 
534  DBGC(golan, "%s\n", __FUNCTION__);
535 
537  NO_MBOX, NO_MBOX,
538  sizeof(struct golan_query_pages_inbox),
539  sizeof(struct golan_query_pages_outbox));
540 
542  GOLAN_CHECK_RC_AND_CMD_STATUS( err_handle_pages_query );
543 
545 
546  DBGC( golan , "%s pages needed: %d\n", __FUNCTION__, pages);
547 
548  func_id = QRY_PAGES_OUT(golan, MEM_CMD_IDX)->func_id;
549 
550  total_pages = (( pages >= 0 ) ? pages : ( pages * ( -1 ) ));
551 
552  if ( mode == GOLAN_PAGES_GIVE ) {
553  rc = golan_provide_pages(golan, total_pages, func_id, & ( golan->fw_areas[qry-1] ));
554  } else {
556  golan->total_dma_pages = 0;
557  }
558 
559  if ( rc ) {
560  DBGC (golan , "Failed to %s pages (rc = %d) - DMA pages allocated = %d\n",
561  ( ( mode == GOLAN_PAGES_GIVE ) ? "give" : "take" ), rc , golan->total_dma_pages );
562  return rc;
563  }
564 
565  return 0;
566 
567 err_handle_pages_query:
568  DBGC (golan ,"%s Qyery pages failed (rc = 0x%x)\n", __FUNCTION__, rc);
569  return rc;
570 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define MEM_CMD_IDX
Definition: golan.h:57
unsigned short uint16_t
Definition: stdint.h:11
struct golan_firmware_area fw_areas[GOLAN_FW_AREAS_NUM]
Definition: golan.h:341
__be16 func_id
Definition: CIB_PRM.h:30
static int golan_take_pages(struct golan *golan, uint32_t pages, __be16 func_id)
Definition: golan.c:398
#define DBGC(...)
Definition: compiler.h:505
#define NO_MBOX
Definition: golan.h:58
#define QRY_PAGES_OUT(golan, idx)
Definition: golan.h:68
Definition: golan.h:323
#define be32_to_cpu(value)
Definition: byteswap.h:116
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
__be32 num_pages
Definition: CIB_PRM.h:31
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define GOLAN_CHECK_RC_AND_CMD_STATUS(_lable)
Definition: golan.c:111
uint32_t total_dma_pages
Definition: golan.h:331
static int golan_provide_pages(struct golan *golan, uint32_t pages, __be16 func_id, struct golan_firmware_area *fw_area)
Definition: golan.c:445
signed int int32_t
Definition: stdint.h:17
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
uint16_t __be16
Definition: CIB_PRM.h:27

References be32_to_cpu, cmd, DBGC, func_id, golan::fw_areas, GOLAN_CHECK_RC_AND_CMD_STATUS, GOLAN_CMD_OP_QUERY_PAGES, GOLAN_PAGES_GIVE, golan_provide_pages(), golan_take_pages(), MEM_CMD_IDX, NO_MBOX, num_pages, QRY_PAGES_OUT, rc, send_command_and_wait(), golan::total_dma_pages, and write_cmd().

Referenced by golan_bring_down(), and golan_bring_up().

◆ golan_set_access_reg()

static int golan_set_access_reg ( struct golan golan,
uint32_t  reg 
)
inlinestatic

Definition at line 572 of file golan.c.

573 {
574 #if 0
575  write_cmd(golan, _CMD_IDX, GOLAN_CMD_OP_QUERY_PAGES, 0x0,
576  NO_MBOX, NO_MBOX,
577  sizeof(struct golan_reg_host_endianess),
578  sizeof(struct golan_reg_host_endianess));
579  in->arg = cpu_to_be32(arg);
580  in->register_id = cpu_to_be16(reg_num);
581 #endif
582  DBGC (golan ," %s Not implemented yet\n", __FUNCTION__);
583  return 0;
584 }
#define cpu_to_be16(value)
Definition: byteswap.h:109
__be32 in[4]
Definition: CIB_PRM.h:35
#define DBGC(...)
Definition: compiler.h:505
#define NO_MBOX
Definition: golan.h:58
Definition: golan.h:323
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define cpu_to_be32(value)
Definition: byteswap.h:110

References cpu_to_be16, cpu_to_be32, DBGC, GOLAN_CMD_OP_QUERY_PAGES, in, NO_MBOX, and write_cmd().

◆ golan_cmd_uninit()

static void golan_cmd_uninit ( struct golan golan)
inlinestatic

Definition at line 586 of file golan.c.

587 {
591 }
Definition: golan.h:323
void * outbox
Definition: golan.h:318
struct golan_mboxes mboxes
Definition: golan.h:328
void * inbox
Definition: golan.h:317
struct golan_cmdq_md cmd
Definition: golan.h:326
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
void * addr
Definition: golan.h:103
#define GOLAN_PAGE_SIZE
Definition: golan.h:52

References golan_cmdq_md::addr, golan::cmd, free_dma(), GOLAN_PAGE_SIZE, golan_mboxes::inbox, golan::mboxes, and golan_mboxes::outbox.

Referenced by golan_bring_down(), and golan_bring_up().

◆ golan_cmd_init()

static int golan_cmd_init ( struct golan golan)
inlinestatic

Initialise Golan Command Q parameters – Alocate a 4kb page for the Command Q – Read the stride and log num commands available – Write the address to cmdq_phy_addr in iseg.

Parameters
golanGolan device

Definition at line 600 of file golan.c.

601 {
602  int rc = 0;
603  uint32_t addr_l_sz;
604 
606  rc = -ENOMEM;
607  goto malloc_dma_failed;
608  }
610  rc = -ENOMEM;
611  goto malloc_dma_inbox_failed;
612  }
614  rc = -ENOMEM;
615  goto malloc_dma_outbox_failed;
616  }
617  addr_l_sz = be32_to_cpu(readl(&golan->iseg->cmdq_addr_l_sz));
618 
619  golan->cmd.log_stride = addr_l_sz & 0xf;
620  golan->cmd.size = 1 << (( addr_l_sz >> 4 ) & 0xf);
621 
622  addr_l_sz = virt_to_bus(golan->cmd.addr);
623  writel(0 /* cpu_to_be32(golan->cmd.addr) >> 32 */, &golan->iseg->cmdq_addr_h);
624  writel(cpu_to_be32(addr_l_sz), &golan->iseg->cmdq_addr_l_sz);
625  wmb(); //Make sure the addr is visible in "memory".
626 
627  addr_l_sz = be32_to_cpu(readl(&golan->iseg->cmdq_addr_l_sz));
628 
629  DBGC( golan , "%s Command interface was initialized\n", __FUNCTION__);
630  return 0;
631 
632 malloc_dma_outbox_failed:
634 malloc_dma_inbox_failed:
636 malloc_dma_failed:
637  DBGC (golan ,"%s Failed to initialize command interface (rc = 0x%x)\n",
638  __FUNCTION__, rc);
639  return rc;
640 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
wmb()
__be32 cmdq_addr_h
Definition: CIB_PRM.h:57
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
#define DBGC(...)
Definition: compiler.h:505
#define ENOMEM
Not enough space.
Definition: errno.h:534
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
Definition: golan.h:323
#define be32_to_cpu(value)
Definition: byteswap.h:116
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
struct golan_hca_init_seg * iseg
Definition: golan.h:325
void * outbox
Definition: golan.h:318
struct golan_mboxes mboxes
Definition: golan.h:328
unsigned int uint32_t
Definition: stdint.h:12
__be32 cmdq_addr_l_sz
Definition: CIB_PRM.h:58
#define cpu_to_be32(value)
Definition: byteswap.h:110
u16 log_stride
Definition: golan.h:104
static void *__malloc malloc_dma(size_t size, size_t phys_align)
Allocate memory for DMA.
Definition: malloc.h:66
void * inbox
Definition: golan.h:317
struct golan_cmdq_md cmd
Definition: golan.h:326
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
u16 size
Definition: golan.h:105
void * addr
Definition: golan.h:103
#define GOLAN_PAGE_SIZE
Definition: golan.h:52

References golan_cmdq_md::addr, be32_to_cpu, golan::cmd, golan_hca_init_seg::cmdq_addr_h, golan_hca_init_seg::cmdq_addr_l_sz, cpu_to_be32, DBGC, ENOMEM, free_dma(), GOLAN_PAGE_SIZE, golan_mboxes::inbox, golan::iseg, golan_cmdq_md::log_stride, malloc_dma(), golan::mboxes, golan_mboxes::outbox, rc, readl(), golan_cmdq_md::size, virt_to_bus(), wmb(), and writel().

Referenced by golan_bring_up().

◆ golan_hca_init()

static int golan_hca_init ( struct golan golan)
inlinestatic

Definition at line 642 of file golan.c.

643 {
644  struct golan_cmd_layout *cmd;
645  int rc = 0;
646 
647  DBGC(golan, "%s\n", __FUNCTION__);
648 
650  NO_MBOX, NO_MBOX,
651  sizeof(struct golan_cmd_init_hca_mbox_in),
652  sizeof(struct golan_cmd_init_hca_mbox_out));
653 
656  return rc;
657 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
#define GOLAN_PRINT_RC_AND_CMD_STATUS
Definition: golan.c:117
#define NO_MBOX
Definition: golan.h:58
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define DEF_CMD_IDX
Definition: golan.h:56
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References cmd, DBGC, DEF_CMD_IDX, GOLAN_CMD_OP_INIT_HCA, GOLAN_PRINT_RC_AND_CMD_STATUS, NO_MBOX, rc, send_command_and_wait(), and write_cmd().

Referenced by golan_bring_up().

◆ golan_teardown_hca()

static void golan_teardown_hca ( struct golan golan,
enum golan_teardown  op_mod 
)
inlinestatic

Definition at line 659 of file golan.c.

660 {
661  struct golan_cmd_layout *cmd;
662  int rc;
663 
664  DBGC (golan, "%s in\n", __FUNCTION__);
665 
667  NO_MBOX, NO_MBOX,
668  sizeof(struct golan_cmd_teardown_hca_mbox_in),
669  sizeof(struct golan_cmd_teardown_hca_mbox_out));
670 
673 
674  DBGC (golan, "%s HCA teardown compleated\n", __FUNCTION__);
675 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
#define GOLAN_PRINT_RC_AND_CMD_STATUS
Definition: golan.c:117
#define NO_MBOX
Definition: golan.h:58
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define DEF_CMD_IDX
Definition: golan.h:56
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References cmd, DBGC, DEF_CMD_IDX, GOLAN_CMD_OP_TEARDOWN_HCA, GOLAN_PRINT_RC_AND_CMD_STATUS, NO_MBOX, rc, send_command_and_wait(), and write_cmd().

Referenced by golan_bring_down(), and golan_bring_up().

◆ golan_alloc_uar()

static int golan_alloc_uar ( struct golan golan)
inlinestatic

Definition at line 677 of file golan.c.

678 {
679  struct golan_uar *uar = &golan->uar;
680  struct golan_cmd_layout *cmd;
682  int rc;
683 
685  NO_MBOX, NO_MBOX,
686  sizeof(struct golan_alloc_uar_mbox_in),
687  sizeof(struct golan_alloc_uar_mbox_out));
688 
690  GOLAN_CHECK_RC_AND_CMD_STATUS( err_alloc_uar_cmd );
691  out = (struct golan_alloc_uar_mbox_out *) ( cmd->out );
692 
693  uar->index = be32_to_cpu(out->uarn) & 0xffffff;
694 
696  uar->virt = (void *)(ioremap(uar->phys, GOLAN_PAGE_SIZE));
697 
698  DBGC( golan , "%s: UAR allocated with index 0x%x\n", __FUNCTION__, uar->index);
699  return 0;
700 
701 err_alloc_uar_cmd:
702  DBGC (golan ,"%s [%d] out\n", __FUNCTION__, rc);
703  return rc;
704 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
#define GOLAN_HCA_BAR
Definition: golan.h:45
struct pci_device * pci
Definition: golan.h:324
#define NO_MBOX
Definition: golan.h:58
Definition: golan.h:323
#define be32_to_cpu(value)
Definition: byteswap.h:116
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
uint32_t index
Definition: golan.h:109
__be32 out[4]
Definition: CIB_PRM.h:36
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
Definition: pci.c:96
#define GOLAN_PAGE_SHIFT
Definition: golan.h:51
void * virt
Definition: golan.h:110
struct golan_uar uar
Definition: golan.h:332
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define GOLAN_CHECK_RC_AND_CMD_STATUS(_lable)
Definition: golan.c:111
#define DEF_CMD_IDX
Definition: golan.h:56
unsigned long phys
Definition: golan.h:111
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
#define GOLAN_PAGE_SIZE
Definition: golan.h:52

References be32_to_cpu, cmd, DBGC, DEF_CMD_IDX, GOLAN_CHECK_RC_AND_CMD_STATUS, GOLAN_CMD_OP_ALLOC_UAR, GOLAN_HCA_BAR, GOLAN_PAGE_SHIFT, GOLAN_PAGE_SIZE, golan_uar::index, ioremap(), NO_MBOX, out, golan::pci, pci_bar_start(), golan_uar::phys, rc, send_command_and_wait(), golan::uar, golan_uar::virt, and write_cmd().

Referenced by golan_bring_up().

◆ golan_dealloc_uar()

static void golan_dealloc_uar ( struct golan golan)
static

Definition at line 706 of file golan.c.

707 {
708  struct golan_cmd_layout *cmd;
709  uint32_t uar_index = golan->uar.index;
710  int rc;
711 
712  DBGC (golan, "%s in\n", __FUNCTION__);
713 
715  NO_MBOX, NO_MBOX,
716  sizeof(struct golan_free_uar_mbox_in),
717  sizeof(struct golan_free_uar_mbox_out));
718 
719  ((struct golan_free_uar_mbox_in *)(cmd->in))->uarn = cpu_to_be32(uar_index);
722  golan->uar.index = 0;
723 
724  DBGC (golan, "%s UAR (0x%x) was destroyed\n", __FUNCTION__, uar_index);
725 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
#define GOLAN_PRINT_RC_AND_CMD_STATUS
Definition: golan.c:117
#define NO_MBOX
Definition: golan.h:58
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
uint32_t index
Definition: golan.h:109
struct golan_uar uar
Definition: golan.h:332
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
__be32 uarn
Definition: CIB_PRM.h:29
unsigned int uint32_t
Definition: stdint.h:12
#define cpu_to_be32(value)
Definition: byteswap.h:110
#define DEF_CMD_IDX
Definition: golan.h:56
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References cmd, cpu_to_be32, DBGC, DEF_CMD_IDX, GOLAN_CMD_OP_DEALLOC_UAR, GOLAN_PRINT_RC_AND_CMD_STATUS, golan_uar::index, NO_MBOX, rc, send_command_and_wait(), golan::uar, uarn, and write_cmd().

Referenced by golan_bring_down(), and golan_bring_up().

◆ golan_eq_update_ci()

static void golan_eq_update_ci ( struct golan_event_queue eq,
int  arm 
)
static

Definition at line 727 of file golan.c.

728 {
729  __be32 *addr = eq->doorbell + (arm ? 0 : 2);
730  u32 val = (eq->cons_index & 0xffffff) | (eq->eqn << 24);
732  /* We still want ordering, just not swabbing, so add a barrier */
733  wmb();
734 }
wmb()
uint8_t eqn
Definition: golan.h:299
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
uint32_t cons_index
Definition: golan.h:304
u32 addr
Definition: sky2.h:8
void __asmcall int val
Definition: setjmp.h:28
#define cpu_to_be32(value)
Definition: byteswap.h:110
uint32_t __be32
Definition: CIB_PRM.h:26
uint32_t u32
Definition: stdint.h:23
__be32 * doorbell
Definition: golan.h:303

References addr, golan_event_queue::cons_index, cpu_to_be32, golan_event_queue::doorbell, golan_event_queue::eqn, val, wmb(), and writel().

Referenced by golan_create_eq(), and golan_poll_eq().

◆ golan_create_eq()

static int golan_create_eq ( struct golan golan)
static

Definition at line 736 of file golan.c.

737 {
738  struct golan_event_queue *eq = &golan->eq;
740  struct golan_cmd_layout *cmd;
742  int rc, i;
743 
744  eq->cons_index = 0;
745  eq->size = GOLAN_NUM_EQES * sizeof(eq->eqes[0]);
747  if (!eq->eqes) {
748  rc = -ENOMEM;
749  goto err_create_eq_eqe_alloc;
750  }
751 
752  /* Set EQEs ownership bit to HW ownership */
753  for (i = 0; i < GOLAN_NUM_EQES; ++i) {
755  }
756 
758  GEN_MBOX, NO_MBOX,
759  sizeof(struct golan_create_eq_mbox_in) + GOLAN_PAS_SIZE,
760  sizeof(struct golan_create_eq_mbox_out));
761 
763 
764  /* Fill the physical address of the page */
765  in->pas[0] = VIRT_2_BE64_BUS( eq->eqes );
766  in->ctx.log_sz_usr_page = cpu_to_be32((ilog2(GOLAN_NUM_EQES)) << 24 | golan->uar.index);
767  DBGC( golan , "UAR idx %x (BE %x)\n", golan->uar.index, in->ctx.log_sz_usr_page);
768  in->events_mask = cpu_to_be64(1 << GOLAN_EVENT_TYPE_PORT_CHANGE);
769 
771  GOLAN_CHECK_RC_AND_CMD_STATUS( err_create_eq_cmd );
772  out = (struct golan_create_eq_mbox_out *)cmd->out;
773 
774  eq->eqn = out->eq_number;
775  eq->doorbell = ((void *)golan->uar.virt) + GOLAN_EQ_DOORBELL_OFFSET;
776 
777  /* EQs are created in ARMED state */
779 
780  DBGC( golan , "%s: Event queue created (EQN = 0x%x)\n", __FUNCTION__, eq->eqn);
781  return 0;
782 
783 err_create_eq_cmd:
784  free_dma ( eq->eqes , GOLAN_PAGE_SIZE );
785 err_create_eq_eqe_alloc:
786  DBGC (golan ,"%s [%d] out\n", __FUNCTION__, rc);
787  return rc;
788 }
#define GOLAN_NUM_EQES
Definition: golan.h:217
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
u8 owner
Definition: CIB_PRM.h:700
__be32 in[4]
Definition: CIB_PRM.h:35
#define DBGC(...)
Definition: compiler.h:505
#define GEN_MBOX
Definition: golan.h:60
static uint32_t ilog2(uint32_t mem)
Definition: golan.c:128
#define GOLAN_PAS_SIZE
Definition: golan.h:37
#define NO_MBOX
Definition: golan.h:58
#define ENOMEM
Not enough space.
Definition: errno.h:534
uint8_t eqn
Definition: golan.h:299
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
uint32_t cons_index
Definition: golan.h:304
uint32_t index
Definition: golan.h:109
__be32 out[4]
Definition: CIB_PRM.h:36
void * virt
Definition: golan.h:110
struct golan_uar uar
Definition: golan.h:332
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define GOLAN_CHECK_RC_AND_CMD_STATUS(_lable)
Definition: golan.c:111
#define VIRT_2_BE64_BUS(addr)
Definition: golan.h:70
struct golan_event_queue eq
Definition: golan.h:333
#define cpu_to_be32(value)
Definition: byteswap.h:110
#define GOLAN_EQ_DOORBELL_OFFSET
Definition: golan.h:218
#define DEF_CMD_IDX
Definition: golan.h:56
static void *__malloc malloc_dma(size_t size, size_t phys_align)
Allocate memory for DMA.
Definition: malloc.h:66
#define cpu_to_be64(value)
Definition: byteswap.h:111
static void golan_eq_update_ci(struct golan_event_queue *eq, int arm)
Definition: golan.c:727
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
struct golan_eqe * eqes
Definition: golan.h:301
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
#define GOLAN_PAGE_SIZE
Definition: golan.h:52
__be32 * doorbell
Definition: golan.h:303
#define GET_INBOX(golan, idx)
Definition: golan.h:75

References cmd, golan_event_queue::cons_index, cpu_to_be32, cpu_to_be64, DBGC, DEF_CMD_IDX, golan_event_queue::doorbell, ENOMEM, golan::eq, golan_event_queue::eqes, golan_event_queue::eqn, free_dma(), GEN_MBOX, GET_INBOX, GOLAN_CHECK_RC_AND_CMD_STATUS, GOLAN_CMD_OP_CREATE_EQ, GOLAN_EQ_DOORBELL_OFFSET, GOLAN_EQ_UNARMED, golan_eq_update_ci(), GOLAN_EQE_HW_OWNERSHIP, GOLAN_EVENT_TYPE_PORT_CHANGE, GOLAN_NUM_EQES, GOLAN_PAGE_SIZE, GOLAN_PAS_SIZE, ilog2(), in, golan_uar::index, malloc_dma(), NO_MBOX, out, golan_eqe::owner, rc, send_command_and_wait(), golan_event_queue::size, golan::uar, golan_uar::virt, VIRT_2_BE64_BUS, and write_cmd().

Referenced by golan_bring_up().

◆ golan_destory_eq()

static void golan_destory_eq ( struct golan golan)
static

Definition at line 790 of file golan.c.

791 {
792  struct golan_cmd_layout *cmd;
794  uint8_t eqn = golan->eq.eqn;
795  int rc;
796 
797  DBGC (golan, "%s in\n", __FUNCTION__);
798 
800  NO_MBOX, NO_MBOX,
801  sizeof(struct golan_destroy_eq_mbox_in),
802  sizeof(struct golan_destroy_eq_mbox_out));
803 
804  in = GOLAN_MBOX_IN ( cmd, in );
805  in->eqn = eqn;
808 
810  golan->eq.eqn = 0;
811 
812  DBGC( golan, "%s Event queue (0x%x) was destroyed\n", __FUNCTION__, eqn);
813 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
__be32 in[4]
Definition: CIB_PRM.h:35
#define DBGC(...)
Definition: compiler.h:505
#define GOLAN_PRINT_RC_AND_CMD_STATUS
Definition: golan.c:117
#define NO_MBOX
Definition: golan.h:58
uint8_t eqn
Definition: golan.h:299
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
unsigned char uint8_t
Definition: stdint.h:10
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
struct golan_event_queue eq
Definition: golan.h:333
#define DEF_CMD_IDX
Definition: golan.h:56
u8 eqn
Definition: CIB_PRM.h:30
#define GOLAN_MBOX_IN(cmd_ptr, in_ptr)
Definition: golan.h:78
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
struct golan_eqe * eqes
Definition: golan.h:301
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
#define GOLAN_PAGE_SIZE
Definition: golan.h:52

References cmd, DBGC, DEF_CMD_IDX, golan::eq, golan_event_queue::eqes, eqn, golan_event_queue::eqn, free_dma(), GOLAN_CMD_OP_DESTROY_EQ, GOLAN_MBOX_IN, GOLAN_PAGE_SIZE, GOLAN_PRINT_RC_AND_CMD_STATUS, in, NO_MBOX, rc, send_command_and_wait(), and write_cmd().

Referenced by golan_bring_down(), and golan_bring_up().

◆ golan_alloc_pd()

static int golan_alloc_pd ( struct golan golan)
static

Definition at line 815 of file golan.c.

816 {
817  struct golan_cmd_layout *cmd;
819  int rc;
820 
822  NO_MBOX, NO_MBOX,
823  sizeof(struct golan_alloc_pd_mbox_in),
824  sizeof(struct golan_alloc_pd_mbox_out));
825 
827  GOLAN_CHECK_RC_AND_CMD_STATUS( err_alloc_pd_cmd );
828  out = (struct golan_alloc_pd_mbox_out *) ( cmd->out );
829 
830  golan->pdn = (be32_to_cpu(out->pdn) & 0xffffff);
831  DBGC( golan , "%s: Protection domain created (PDN = 0x%x)\n", __FUNCTION__,
832  golan->pdn);
833  return 0;
834 
835 err_alloc_pd_cmd:
836  DBGC (golan ,"%s [%d] out\n", __FUNCTION__, rc);
837  return rc;
838 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint32_t pdn
Definition: golan.h:334
#define DBGC(...)
Definition: compiler.h:505
#define NO_MBOX
Definition: golan.h:58
Definition: golan.h:323
#define be32_to_cpu(value)
Definition: byteswap.h:116
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
__be32 out[4]
Definition: CIB_PRM.h:36
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define GOLAN_CHECK_RC_AND_CMD_STATUS(_lable)
Definition: golan.c:111
#define DEF_CMD_IDX
Definition: golan.h:56
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References be32_to_cpu, cmd, DBGC, DEF_CMD_IDX, GOLAN_CHECK_RC_AND_CMD_STATUS, GOLAN_CMD_OP_ALLOC_PD, NO_MBOX, out, golan::pdn, rc, send_command_and_wait(), and write_cmd().

Referenced by golan_bring_up().

◆ golan_dealloc_pd()

static void golan_dealloc_pd ( struct golan golan)
static

Definition at line 840 of file golan.c.

841 {
842  struct golan_cmd_layout *cmd;
843  uint32_t pdn = golan->pdn;
844  int rc;
845 
846  DBGC (golan,"%s in\n", __FUNCTION__);
847 
849  NO_MBOX, NO_MBOX,
850  sizeof(struct golan_alloc_pd_mbox_in),
851  sizeof(struct golan_alloc_pd_mbox_out));
852 
853  ((struct golan_dealloc_pd_mbox_in *)(cmd->in))->pdn = cpu_to_be32(pdn);
856  golan->pdn = 0;
857 
858  DBGC (golan ,"%s Protection domain (0x%x) was destroyed\n", __FUNCTION__, pdn);
859 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint32_t pdn
Definition: golan.h:334
#define DBGC(...)
Definition: compiler.h:505
#define GOLAN_PRINT_RC_AND_CMD_STATUS
Definition: golan.c:117
#define NO_MBOX
Definition: golan.h:58
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
unsigned int uint32_t
Definition: stdint.h:12
#define cpu_to_be32(value)
Definition: byteswap.h:110
#define DEF_CMD_IDX
Definition: golan.h:56
__be32 pdn
Definition: CIB_PRM.h:29
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References cmd, cpu_to_be32, DBGC, DEF_CMD_IDX, GOLAN_CMD_OP_DEALLOC_PD, GOLAN_PRINT_RC_AND_CMD_STATUS, NO_MBOX, pdn, golan::pdn, rc, send_command_and_wait(), and write_cmd().

Referenced by golan_bring_down(), and golan_bring_up().

◆ golan_create_mkey()

static int golan_create_mkey ( struct golan golan)
static

Definition at line 861 of file golan.c.

862 {
864  struct golan_cmd_layout *cmd;
866  int rc;
867 
869  GEN_MBOX, NO_MBOX,
870  sizeof(struct golan_create_mkey_mbox_in),
871  sizeof(struct golan_create_mkey_mbox_out));
872 
874 
876  in->seg.flags_pd = cpu_to_be32(golan->pdn | GOLAN_MKEY_LEN64);
877  in->seg.qpn_mkey7_0 = cpu_to_be32(0xffffff << GOLAN_CREATE_MKEY_SEG_QPN_BIT);
878 
880  GOLAN_CHECK_RC_AND_CMD_STATUS( err_create_mkey_cmd );
881  out = (struct golan_create_mkey_mbox_out *) ( cmd->out );
882 
883  golan->mkey = ((be32_to_cpu(out->mkey) & 0xffffff) << 8);
884  DBGC( golan , "%s: Got DMA Key for local access read/write (MKEY = 0x%x)\n",
885  __FUNCTION__, golan->mkey);
886  return 0;
887 err_create_mkey_cmd:
888  DBGC (golan ,"%s [%d] out\n", __FUNCTION__, rc);
889  return rc;
890 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
__be32 in[4]
Definition: CIB_PRM.h:35
uint32_t pdn
Definition: golan.h:334
#define DBGC(...)
Definition: compiler.h:505
#define GEN_MBOX
Definition: golan.h:60
#define GOLAN_CREATE_MKEY_SEG_QPN_BIT
Definition: CIB_PRM.h:730
u32 mkey
Definition: golan.h:335
#define NO_MBOX
Definition: golan.h:58
#define GOLAN_MKEY_LEN64
Definition: CIB_PRM.h:729
#define GOLAN_IB_ACCESS_LOCAL_READ
Definition: CIB_PRM.h:727
Definition: golan.h:323
#define be32_to_cpu(value)
Definition: byteswap.h:116
#define GOLAN_IB_ACCESS_LOCAL_WRITE
Definition: CIB_PRM.h:728
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
__be32 out[4]
Definition: CIB_PRM.h:36
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define GOLAN_CHECK_RC_AND_CMD_STATUS(_lable)
Definition: golan.c:111
#define cpu_to_be32(value)
Definition: byteswap.h:110
#define DEF_CMD_IDX
Definition: golan.h:56
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
#define GET_INBOX(golan, idx)
Definition: golan.h:75

References be32_to_cpu, cmd, cpu_to_be32, DBGC, DEF_CMD_IDX, GEN_MBOX, GET_INBOX, GOLAN_CHECK_RC_AND_CMD_STATUS, GOLAN_CMD_OP_CREATE_MKEY, GOLAN_CREATE_MKEY_SEG_QPN_BIT, GOLAN_IB_ACCESS_LOCAL_READ, GOLAN_IB_ACCESS_LOCAL_WRITE, GOLAN_MKEY_LEN64, in, golan::mkey, NO_MBOX, out, golan::pdn, rc, send_command_and_wait(), and write_cmd().

Referenced by golan_bring_up().

◆ golan_destroy_mkey()

static void golan_destroy_mkey ( struct golan golan)
static

Definition at line 892 of file golan.c.

893 {
894  struct golan_cmd_layout *cmd;
895  u32 mkey = golan->mkey;
896  int rc;
897 
899  NO_MBOX, NO_MBOX,
900  sizeof(struct golan_destroy_mkey_mbox_in),
901  sizeof(struct golan_destroy_mkey_mbox_out));
902  ((struct golan_destroy_mkey_mbox_in *)(cmd->in))->mkey = cpu_to_be32(mkey >> 8);
905  golan->mkey = 0;
906 
907  DBGC( golan , "%s DMA Key (0x%x) for local access write was destroyed\n"
908  , __FUNCTION__, mkey);
909 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
u32 mkey
Definition: golan.h:335
#define GOLAN_PRINT_RC_AND_CMD_STATUS
Definition: golan.c:117
#define NO_MBOX
Definition: golan.h:58
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
__be32 mkey
Definition: CIB_PRM.h:29
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define cpu_to_be32(value)
Definition: byteswap.h:110
#define DEF_CMD_IDX
Definition: golan.h:56
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
uint32_t u32
Definition: stdint.h:23

References cmd, cpu_to_be32, DBGC, DEF_CMD_IDX, GOLAN_CMD_OP_DESTROY_MKEY, GOLAN_PRINT_RC_AND_CMD_STATUS, mkey, golan::mkey, NO_MBOX, rc, send_command_and_wait(), and write_cmd().

Referenced by golan_bring_down(), and golan_bring_up().

◆ golan_pci_init()

static void golan_pci_init ( struct golan golan)
inlinestatic

Initialise Golan PCI parameters.

Parameters
golanGolan device

Definition at line 917 of file golan.c.

918 {
919  struct pci_device *pci = golan->pci;
920 
921  /* Fix up PCI device */
922  adjust_pci_device ( pci );
923 
924  /* Get HCA BAR */
927 }
#define GOLAN_HCA_BAR
Definition: golan.h:45
struct pci_device * pci
Definition: golan.h:324
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:149
Definition: golan.h:323
struct golan_hca_init_seg * iseg
Definition: golan.h:325
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
Definition: pci.c:96
A PCI device.
Definition: pci.h:187
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.
#define GOLAN_PCI_CONFIG_BAR_SIZE
Definition: golan.h:35

References adjust_pci_device(), GOLAN_HCA_BAR, GOLAN_PCI_CONFIG_BAR_SIZE, ioremap(), golan::iseg, golan::pci, and pci_bar_start().

Referenced by golan_probe_normal().

◆ golan_alloc()

static struct golan* golan_alloc ( )
inlinestatic

Definition at line 929 of file golan.c.

930 {
931  void *golan = zalloc(sizeof(struct golan));
932  if ( !golan )
933  goto err_zalloc;
934 
935  return golan;
936 
937 err_zalloc:
938  return NULL;
939 }
Definition: golan.h:323
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References NULL, and zalloc().

Referenced by golan_probe_normal().

◆ golan_create_cq()

static int golan_create_cq ( struct ib_device ibdev,
struct ib_completion_queue cq 
)
static

Create completion queue.

Parameters
ibdevInfiniband device
cqCompletion queue
Return values
rcReturn status code

Definition at line 948 of file golan.c.

950 {
951  struct golan *golan = ib_get_drvdata(ibdev);
952  struct golan_completion_queue *golan_cq;
953  struct golan_cmd_layout *cmd;
956  int rc;
957  unsigned int i;
958 
959  golan_cq = zalloc(sizeof(*golan_cq));
960  if (!golan_cq) {
961  rc = -ENOMEM;
962  goto err_create_cq;
963  }
964  golan_cq->size = sizeof(golan_cq->cqes[0]) * cq->num_cqes;
967  if (!golan_cq->doorbell_record) {
968  rc = -ENOMEM;
969  goto err_create_cq_db_alloc;
970  }
971 
973  if (!golan_cq->cqes) {
974  rc = -ENOMEM;
975  goto err_create_cq_cqe_alloc;
976  }
977 
978  /* Set CQEs ownership bit to HW ownership */
979  for (i = 0; i < cq->num_cqes; ++i) {
980  golan_cq->cqes[i].op_own = ((GOLAN_CQE_OPCODE_NOT_VALID <<
983  }
984 
986  GEN_MBOX, NO_MBOX,
987  sizeof(struct golan_create_cq_mbox_in) + GOLAN_PAS_SIZE,
988  sizeof(struct golan_create_cq_mbox_out));
989 
991 
992  /* Fill the physical address of the page */
993  in->pas[0] = VIRT_2_BE64_BUS( golan_cq->cqes );
994  in->ctx.cqe_sz_flags = GOLAN_CQE_SIZE_64 << 5;
995  in->ctx.log_sz_usr_page = cpu_to_be32(((ilog2(cq->num_cqes)) << 24) | golan->uar.index);
996  in->ctx.c_eqn = cpu_to_be16(golan->eq.eqn);
997  in->ctx.db_record_addr = VIRT_2_BE64_BUS(golan_cq->doorbell_record);
998 
1000  GOLAN_CHECK_RC_AND_CMD_STATUS( err_create_cq_cmd );
1001  out = (struct golan_create_cq_mbox_out *) ( cmd->out );
1002 
1003  cq->cqn = (be32_to_cpu(out->cqn) & 0xffffff);
1004 
1005  ib_cq_set_drvdata(cq, golan_cq);
1006 
1007  DBGC( golan , "%s CQ created successfully (CQN = 0x%lx)\n", __FUNCTION__, cq->cqn);
1008  return 0;
1009 
1010 err_create_cq_cmd:
1011  free_dma( golan_cq->cqes , GOLAN_PAGE_SIZE );
1012 err_create_cq_cqe_alloc:
1014 err_create_cq_db_alloc:
1015  free ( golan_cq );
1016 err_create_cq:
1017  DBGC (golan ,"%s out rc = 0x%x\n", __FUNCTION__, rc);
1018  return rc;
1019 }
#define cpu_to_be16(value)
Definition: byteswap.h:109
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
__be32 in[4]
Definition: CIB_PRM.h:35
#define GOLAN_CQ_DB_RECORD_SIZE
Definition: golan.h:192
#define DBGC(...)
Definition: compiler.h:505
#define GEN_MBOX
Definition: golan.h:60
static uint32_t ilog2(uint32_t mem)
Definition: golan.c:128
#define GOLAN_PAS_SIZE
Definition: golan.h:37
#define NO_MBOX
Definition: golan.h:58
#define ENOMEM
Not enough space.
Definition: errno.h:534
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
uint8_t eqn
Definition: golan.h:299
Definition: golan.h:323
#define be32_to_cpu(value)
Definition: byteswap.h:116
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
uint32_t index
Definition: golan.h:109
__be32 out[4]
Definition: CIB_PRM.h:36
#define GOLAN_CQE_OPCODE_NOT_VALID
Definition: golan.h:190
static __always_inline void ib_cq_set_drvdata(struct ib_completion_queue *cq, void *priv)
Set Infiniband completion queue driver-private data.
Definition: infiniband.h:674
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
#define GOLAN_CQE_OPCODE_BIT
Definition: golan.h:191
struct golan_uar uar
Definition: golan.h:332
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define GOLAN_CHECK_RC_AND_CMD_STATUS(_lable)
Definition: golan.c:111
#define VIRT_2_BE64_BUS(addr)
Definition: golan.h:70
struct golan_event_queue eq
Definition: golan.h:333
#define cpu_to_be32(value)
Definition: byteswap.h:110
__be64 * doorbell_record
Definition: golan.h:211
#define DEF_CMD_IDX
Definition: golan.h:56
struct golan_cqe64 * cqes
Definition: golan.h:209
static void *__malloc malloc_dma(size_t size, size_t phys_align)
Allocate memory for DMA.
Definition: malloc.h:66
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
unsigned int num_cqes
Number of completion queue entries.
Definition: infiniband.h:232
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
#define GOLAN_PAGE_SIZE
Definition: golan.h:52
#define GET_INBOX(golan, idx)
Definition: golan.h:75

References be32_to_cpu, cmd, cpu_to_be16, cpu_to_be32, golan_completion_queue::cqes, ib_completion_queue::cqn, DBGC, DEF_CMD_IDX, golan_completion_queue::doorbell_record, ENOMEM, golan::eq, golan_event_queue::eqn, free, free_dma(), GEN_MBOX, GET_INBOX, GOLAN_CHECK_RC_AND_CMD_STATUS, GOLAN_CMD_OP_CREATE_CQ, GOLAN_CQ_DB_RECORD_SIZE, GOLAN_CQE_HW_OWNERSHIP, GOLAN_CQE_OPCODE_BIT, GOLAN_CQE_OPCODE_NOT_VALID, GOLAN_CQE_SIZE_64, GOLAN_PAGE_SIZE, GOLAN_PAS_SIZE, ib_cq_set_drvdata(), ib_get_drvdata(), ilog2(), in, golan_uar::index, malloc_dma(), NO_MBOX, ib_completion_queue::num_cqes, golan_cqe64::op_own, out, rc, send_command_and_wait(), golan_completion_queue::size, golan::uar, VIRT_2_BE64_BUS, write_cmd(), and zalloc().

◆ golan_destroy_cq()

static void golan_destroy_cq ( struct ib_device ibdev,
struct ib_completion_queue cq 
)
static

Destroy completion queue.

Parameters
ibdevInfiniband device
cqCompletion queue

Definition at line 1027 of file golan.c.

1029 {
1030  struct golan *golan = ib_get_drvdata(ibdev);
1031  struct golan_completion_queue *golan_cq = ib_cq_get_drvdata(cq);
1032  struct golan_cmd_layout *cmd;
1033  uint32_t cqn = cq->cqn;
1034  int rc;
1035 
1036  DBGC (golan, "%s in\n", __FUNCTION__);
1037 
1039  NO_MBOX, NO_MBOX,
1040  sizeof(struct golan_destroy_cq_mbox_in),
1041  sizeof(struct golan_destroy_cq_mbox_out));
1042  ((struct golan_destroy_cq_mbox_in *)(cmd->in))->cqn = cpu_to_be32(cqn);
1045  cq->cqn = 0;
1046 
1047  ib_cq_set_drvdata(cq, NULL);
1048  free_dma ( golan_cq->cqes , GOLAN_PAGE_SIZE );
1050  free(golan_cq);
1051 
1052  DBGC (golan, "%s CQ number 0x%x was destroyed\n", __FUNCTION__, cqn);
1053 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define GOLAN_CQ_DB_RECORD_SIZE
Definition: golan.h:192
#define DBGC(...)
Definition: compiler.h:505
#define GOLAN_PRINT_RC_AND_CMD_STATUS
Definition: golan.c:117
#define NO_MBOX
Definition: golan.h:58
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
static __always_inline void ib_cq_set_drvdata(struct ib_completion_queue *cq, void *priv)
Set Infiniband completion queue driver-private data.
Definition: infiniband.h:674
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
unsigned int uint32_t
Definition: stdint.h:12
#define cpu_to_be32(value)
Definition: byteswap.h:110
__be64 * doorbell_record
Definition: golan.h:211
#define DEF_CMD_IDX
Definition: golan.h:56
struct golan_cqe64 * cqes
Definition: golan.h:209
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
__be32 cqn
Definition: CIB_PRM.h:29
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
static __always_inline void * ib_cq_get_drvdata(struct ib_completion_queue *cq)
Get Infiniband completion queue driver-private data.
Definition: infiniband.h:685
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
#define GOLAN_PAGE_SIZE
Definition: golan.h:52

References cmd, cpu_to_be32, golan_completion_queue::cqes, cqn, ib_completion_queue::cqn, DBGC, DEF_CMD_IDX, golan_completion_queue::doorbell_record, free, free_dma(), GOLAN_CMD_OP_DESTROY_CQ, GOLAN_CQ_DB_RECORD_SIZE, GOLAN_PAGE_SIZE, GOLAN_PRINT_RC_AND_CMD_STATUS, ib_cq_get_drvdata(), ib_cq_set_drvdata(), ib_get_drvdata(), NO_MBOX, NULL, rc, send_command_and_wait(), and write_cmd().

◆ golan_cq_clean()

static void golan_cq_clean ( struct ib_completion_queue cq)
static

Definition at line 1055 of file golan.c.

1056 {
1057  ib_poll_cq(cq->ibdev, cq);
1058 }
void ib_poll_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Poll completion queue.
Definition: infiniband.c:161
struct ib_device * ibdev
Containing Infiniband device.
Definition: infiniband.h:226

References ib_poll_cq(), and ib_completion_queue::ibdev.

Referenced by golan_destroy_qp().

◆ golan_qp_type_to_st()

static int golan_qp_type_to_st ( enum ib_queue_pair_type  type)
static

Definition at line 1060 of file golan.c.

1061 {
1062  int qpt = type;
1063 
1064  switch (qpt) {
1065  case IB_QPT_RC:
1066  return GOLAN_QP_ST_RC;
1067  case IB_QPT_UD:
1068  return GOLAN_QP_ST_UD;
1069  case IB_QPT_SMI:
1070  return GOLAN_QP_ST_QP0;
1071  case IB_QPT_GSI:
1072  return GOLAN_QP_ST_QP1;
1073  case IB_QPT_ETH:
1074  default:
1075  return -EINVAL;
1076  }
1077 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
uint8_t type
Type.
Definition: ena.h:16

References EINVAL, GOLAN_QP_ST_QP0, GOLAN_QP_ST_QP1, GOLAN_QP_ST_RC, GOLAN_QP_ST_UD, IB_QPT_ETH, IB_QPT_GSI, IB_QPT_RC, IB_QPT_SMI, IB_QPT_UD, and type.

Referenced by golan_create_qp_aux().

◆ golan_create_qp_aux()

static int golan_create_qp_aux ( struct ib_device ibdev,
struct ib_queue_pair qp,
int *  qpn 
)
static

Definition at line 1084 of file golan.c.

1087 {
1088  struct golan *golan = ib_get_drvdata(ibdev);
1089  struct golan_queue_pair *golan_qp;
1091  struct golan_cmd_layout *cmd;
1092  struct golan_wqe_data_seg *data;
1093  struct golan_create_qp_mbox_out *out;
1094  uint32_t wqe_size_in_bytes;
1095  uint32_t max_qp_size_in_wqes;
1096  unsigned int i;
1097  int rc;
1098 
1099  golan_qp = zalloc(sizeof(*golan_qp));
1100  if (!golan_qp) {
1101  rc = -ENOMEM;
1102  goto err_create_qp;
1103  }
1104 
1105  if ( ( qp->type == IB_QPT_SMI ) || ( qp->type == IB_QPT_GSI ) ||
1106  ( qp->type == IB_QPT_UD ) ) {
1107  golan_qp->rq.grh_size = ( qp->recv.num_wqes *
1108  sizeof ( golan_qp->rq.grh[0] ));
1109  }
1110 
1111  /* Calculate receive queue size */
1112  golan_qp->rq.size = qp->recv.num_wqes * GOLAN_RECV_WQE_SIZE;
1114  DBGC (golan ,"%s receive wqe size [%zd] > max wqe size [%d]\n", __FUNCTION__,
1116  rc = -EINVAL;
1117  goto err_create_qp_rq_size;
1118  }
1119 
1120  wqe_size_in_bytes = sizeof(golan_qp->sq.wqes[0]);
1121  /* Calculate send queue size */
1122  if (wqe_size_in_bytes > be16_to_cpu(golan->caps.max_wqe_sz_sq)) {
1123  DBGC (golan ,"%s send WQE size [%d] > max WQE size [%d]\n", __FUNCTION__,
1124  wqe_size_in_bytes,
1126  rc = -EINVAL;
1127  goto err_create_qp_sq_wqe_size;
1128  }
1129  golan_qp->sq.size = (qp->send.num_wqes * wqe_size_in_bytes);
1130  max_qp_size_in_wqes = (1 << ((uint32_t)(golan->caps.log_max_qp_sz)));
1131  if (qp->send.num_wqes > max_qp_size_in_wqes) {
1132  DBGC (golan ,"%s send wq size [%d] > max wq size [%d]\n", __FUNCTION__,
1133  golan_qp->sq.size, max_qp_size_in_wqes);
1134  rc = -EINVAL;
1135  goto err_create_qp_sq_size;
1136  }
1137 
1138  golan_qp->size = golan_qp->sq.size + golan_qp->rq.size;
1139 
1140  /* allocate dma memory for WQEs (1 page is enough) - should change it */
1142  if (!golan_qp->wqes) {
1143  rc = -ENOMEM;
1144  goto err_create_qp_wqe_alloc;
1145  }
1146  golan_qp->rq.wqes = golan_qp->wqes;
1147  golan_qp->sq.wqes = golan_qp->wqes + golan_qp->rq.size;//(union golan_send_wqe *)&
1148  //(((struct golan_recv_wqe_ud *)(golan_qp->wqes))[qp->recv.num_wqes]);
1149 
1150  if ( golan_qp->rq.grh_size ) {
1151  golan_qp->rq.grh = ( golan_qp->wqes +
1152  golan_qp->sq.size +
1153  golan_qp->rq.size );
1154  }
1155 
1156  /* Invalidate all WQEs */
1157  data = &golan_qp->rq.wqes[0].data[0];
1158  for ( i = 0 ; i < ( golan_qp->rq.size / sizeof ( *data ) ); i++ ){
1159  data->lkey = cpu_to_be32 ( GOLAN_INVALID_LKEY );
1160  data++;
1161  }
1162 
1163  golan_qp->doorbell_record = malloc_dma(sizeof(struct golan_qp_db),
1164  sizeof(struct golan_qp_db));
1165  if (!golan_qp->doorbell_record) {
1166  rc = -ENOMEM;
1167  goto err_create_qp_db_alloc;
1168  }
1169  memset(golan_qp->doorbell_record, 0, sizeof(struct golan_qp_db));
1170 
1172  GEN_MBOX, NO_MBOX,
1173  sizeof(struct golan_create_qp_mbox_in) + GOLAN_PAS_SIZE,
1174  sizeof(struct golan_create_qp_mbox_out));
1175 
1177 
1178  /* Fill the physical address of the page */
1179  in->pas[0] = VIRT_2_BE64_BUS(golan_qp->wqes);
1180  in->ctx.qp_counter_set_usr_page = cpu_to_be32(golan->uar.index);
1181 
1182  in->ctx.flags_pd = cpu_to_be32(golan->pdn);
1183  in->ctx.flags = cpu_to_be32((golan_qp_type_to_st(qp->type)
1184  << GOLAN_QP_CTX_ST_BIT) |
1187 // cgs set to 0, initialy.
1188 // atomic mode
1189  in->ctx.rq_size_stride = ((ilog2(qp->recv.num_wqes) <<
1191  (sizeof(golan_qp->rq.wqes[0]) / GOLAN_RECV_WQE_SIZE));
1192  in->ctx.sq_crq_size = cpu_to_be16(ilog2(golan_qp->sq.size / GOLAN_SEND_WQE_BB_SIZE)
1194  in->ctx.cqn_send = cpu_to_be32(qp->send.cq->cqn);
1195  in->ctx.cqn_recv = cpu_to_be32(qp->recv.cq->cqn);
1196  in->ctx.db_rec_addr = VIRT_2_BE64_BUS(golan_qp->doorbell_record);
1197 
1199  GOLAN_CHECK_RC_AND_CMD_STATUS( err_create_qp_cmd );
1200  out = (struct golan_create_qp_mbox_out *)cmd->out;
1201 
1202  *qpn = (be32_to_cpu(out->qpn) & 0xffffff);
1203  /*
1204  * Hardware wants QPN written in big-endian order (after
1205  * shifting) for send doorbell. Precompute this value to save
1206  * a little bit when posting sends.
1207  */
1208  golan_qp->doorbell_qpn = cpu_to_be32(*qpn << 8);
1209  golan_qp->state = GOLAN_IB_QPS_RESET;
1210 
1211  ib_qp_set_drvdata(qp, golan_qp);
1212 
1213  return 0;
1214 
1215 err_create_qp_cmd:
1216  free_dma(golan_qp->doorbell_record, sizeof(struct golan_qp_db));
1217 err_create_qp_db_alloc:
1218  free_dma ( golan_qp->wqes, GOLAN_PAGE_SIZE );
1219 err_create_qp_wqe_alloc:
1220 err_create_qp_sq_size:
1221 err_create_qp_sq_wqe_size:
1222 err_create_qp_rq_size:
1223  free ( golan_qp );
1224 err_create_qp:
1225  return rc;
1226 }
#define cpu_to_be16(value)
Definition: byteswap.h:109
#define EINVAL
Invalid argument.
Definition: errno.h:428
u32 doorbell_qpn
Definition: golan.h:185
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct golan_wqe_data_seg data[2]
Definition: golan.h:156
__be16 max_wqe_sz_rq
Definition: CIB_PRM.h:276
__be32 in[4]
Definition: CIB_PRM.h:35
uint32_t pdn
Definition: golan.h:334
#define GOLAN_INVALID_LKEY
Definition: golan.h:39
#define DBGC(...)
Definition: compiler.h:505
#define GEN_MBOX
Definition: golan.h:60
__be16 max_wqe_sz_sq
Definition: CIB_PRM.h:274
static uint32_t ilog2(uint32_t mem)
Definition: golan.c:128
#define GOLAN_QP_CTX_PM_STATE_BIT
Definition: CIB_PRM.h:893
#define GOLAN_QP_CTX_RQ_SIZE_BIT
Definition: CIB_PRM.h:896
struct golan_hca_cap caps
Definition: golan.h:327
#define GOLAN_PAS_SIZE
Definition: golan.h:37
__be32 qpn
Definition: CIB_PRM.h:29
#define GOLAN_QP_CTX_ST_BIT
Definition: CIB_PRM.h:892
#define NO_MBOX
Definition: golan.h:58
#define ENOMEM
Not enough space.
Definition: errno.h:534
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
Definition: golan.h:323
#define be32_to_cpu(value)
Definition: byteswap.h:116
union golan_send_wqe * wqes
Definition: golan.h:172
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
uint32_t index
Definition: golan.h:109
#define be16_to_cpu(value)
Definition: byteswap.h:115
__be32 out[4]
Definition: CIB_PRM.h:36
void * wqes
Definition: golan.h:180
static int golan_qp_type_to_st(enum ib_queue_pair_type type)
Definition: golan.c:1060
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
size_t grh_size
Size of GRH buffers.
Definition: golan.h:168
struct golan_uar uar
Definition: golan.h:332
#define GOLAN_RECV_WQE_SIZE
Definition: golan.h:129
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define GOLAN_CHECK_RC_AND_CMD_STATUS(_lable)
Definition: golan.c:111
#define VIRT_2_BE64_BUS(addr)
Definition: golan.h:70
unsigned int uint32_t
Definition: stdint.h:12
struct ib_global_route_header * grh
GRH buffers (if applicable)
Definition: golan.h:166
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define cpu_to_be32(value)
Definition: byteswap.h:110
struct golan_send_wq sq
Definition: golan.h:183
#define DEF_CMD_IDX
Definition: golan.h:56
struct golan_recv_wqe_ud * wqes
Definition: golan.h:160
u8 log_max_qp_sz
Definition: CIB_PRM.h:231
int size
Definition: golan.h:162
int size
Definition: golan.h:174
static void *__malloc malloc_dma(size_t size, size_t phys_align)
Allocate memory for DMA.
Definition: malloc.h:66
struct golan_recv_wq rq
Definition: golan.h:182
#define GOLAN_QP_CTX_SQ_SIZE_BIT
Definition: CIB_PRM.h:897
struct golan_qp_db * doorbell_record
Definition: golan.h:184
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define GOLAN_SEND_WQE_BB_SIZE
Definition: golan.h:127
enum golan_ib_qp_state state
Definition: golan.h:186
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
static __always_inline void ib_qp_set_drvdata(struct ib_queue_pair *qp, void *priv)
Set Infiniband queue pair driver-private data.
Definition: infiniband.h:630
#define GOLAN_PAGE_SIZE
Definition: golan.h:52
#define GET_INBOX(golan, idx)
Definition: golan.h:75
void * memset(void *dest, int character, size_t len) __nonnull

References be16_to_cpu, be32_to_cpu, golan::caps, cmd, cpu_to_be16, cpu_to_be32, data, golan_recv_wqe_ud::data, DBGC, DEF_CMD_IDX, golan_queue_pair::doorbell_qpn, golan_queue_pair::doorbell_record, EINVAL, ENOMEM, free, free_dma(), GEN_MBOX, GET_INBOX, GOLAN_CHECK_RC_AND_CMD_STATUS, GOLAN_CMD_OP_CREATE_QP, GOLAN_IB_QPS_RESET, GOLAN_INVALID_LKEY, GOLAN_PAGE_SIZE, GOLAN_PAS_SIZE, GOLAN_QP_CTX_PM_STATE_BIT, GOLAN_QP_CTX_RQ_SIZE_BIT, GOLAN_QP_CTX_SQ_SIZE_BIT, GOLAN_QP_CTX_ST_BIT, GOLAN_QP_PM_MIGRATED, golan_qp_type_to_st(), GOLAN_RECV_WQE_SIZE, GOLAN_SEND_WQE_BB_SIZE, golan_recv_wq::grh, golan_recv_wq::grh_size, ib_get_drvdata(), ib_qp_set_drvdata(), IB_QPT_GSI, IB_QPT_SMI, IB_QPT_UD, ilog2(), in, golan_uar::index, golan_hca_cap::log_max_qp_sz, malloc_dma(), golan_hca_cap::max_wqe_sz_rq, golan_hca_cap::max_wqe_sz_sq, memset(), NO_MBOX, out, golan::pdn, qp, qpn, rc, golan_queue_pair::rq, send_command_and_wait(), golan_recv_wq::size, golan_send_wq::size, golan_queue_pair::size, golan_queue_pair::sq, golan_queue_pair::state, golan::uar, VIRT_2_BE64_BUS, golan_recv_wq::wqes, golan_send_wq::wqes, golan_queue_pair::wqes, write_cmd(), and zalloc().

Referenced by golan_create_qp().

◆ golan_create_qp()

static int golan_create_qp ( struct ib_device ibdev,
struct ib_queue_pair qp 
)
static

Create queue pair.

Parameters
ibdevInfiniband device
qpQueue pair
Return values
rcReturn status code

Definition at line 1235 of file golan.c.

1237 {
1238  int rc, qpn = -1;
1239 
1240  switch (qp->type) {
1241  case IB_QPT_UD:
1242  case IB_QPT_SMI:
1243  case IB_QPT_GSI:
1244  rc = golan_create_qp_aux(ibdev, qp, &qpn);
1245  if (rc) {
1246  DBG ( "%s Failed to create QP (rc = 0x%x)\n", __FUNCTION__, rc);
1247  return rc;
1248  }
1249  qp->qpn = qpn;
1250 
1251  break;
1252  case IB_QPT_ETH:
1253  case IB_QPT_RC:
1254  default:
1255  DBG ( "%s unsupported QP type (0x%x)\n", __FUNCTION__, qp->type);
1256  return -EINVAL;
1257  }
1258 
1259  return 0;
1260 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int golan_create_qp_aux(struct ib_device *ibdev, struct ib_queue_pair *qp, int *qpn)
Definition: golan.c:1084
__be32 qpn
Definition: CIB_PRM.h:29
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References DBG, EINVAL, golan_create_qp_aux(), IB_QPT_ETH, IB_QPT_GSI, IB_QPT_RC, IB_QPT_SMI, IB_QPT_UD, qp, qpn, and rc.

◆ golan_modify_qp_rst_to_init()

static int golan_modify_qp_rst_to_init ( struct ib_device ibdev,
struct ib_queue_pair *qp   __attribute__(unused),
struct golan_modify_qp_mbox_in_data in 
)
static

Definition at line 1262 of file golan.c.

1265 {
1266  int rc = 0;
1267 
1268  in->ctx.qkey = cpu_to_be32((uint32_t)(qp->qkey));
1269 
1270  in->ctx.pri_path.port = ibdev->port;
1272  in->ctx.pri_path.pkey_index = 0;
1273  /* QK is 0 */
1274  /* QP cntr set 0 */
1275  return rc;
1276 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
__be32 in[4]
Definition: CIB_PRM.h:35
#define GOLAN_QP_CTX_PM_STATE_BIT
Definition: CIB_PRM.h:893
unsigned int port
Port number.
Definition: infiniband.h:418
unsigned int uint32_t
Definition: stdint.h:12
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define cpu_to_be32(value)
Definition: byteswap.h:110

References cpu_to_be32, GOLAN_QP_CTX_PM_STATE_BIT, GOLAN_QP_PM_MIGRATED, in, ib_device::port, qp, and rc.

◆ golan_modify_qp_init_to_rtr()

static int golan_modify_qp_init_to_rtr ( struct ib_device *ibdev   __attribute__(unused),
struct ib_queue_pair *qp   __attribute__(unused),
struct golan_modify_qp_mbox_in_data in 
)
static

Definition at line 1278 of file golan.c.

1281 {
1282  int rc = 0;
1283 
1284  in->optparam = 0;
1285  return rc;
1286 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
__be32 in[4]
Definition: CIB_PRM.h:35

References in, and rc.

◆ golan_modify_qp_rtr_to_rts()

static int golan_modify_qp_rtr_to_rts ( struct ib_device *ibdev   __attribute__(unused),
struct ib_queue_pair *qp   __attribute__(unused),
struct golan_modify_qp_mbox_in_data *in   __attribute__(unused) 
)
static

Definition at line 1288 of file golan.c.

1291 {
1292  int rc = 0;
1293 
1294  in->optparam = 0;
1295  /* In good flow psn in 0 */
1296  return rc;
1297 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
__be32 in[4]
Definition: CIB_PRM.h:35

References in, and rc.

◆ golan_modify_qp_to_rst()

static int golan_modify_qp_to_rst ( struct ib_device ibdev,
struct ib_queue_pair qp 
)
static

Definition at line 1299 of file golan.c.

1301 {
1302  struct golan *golan = ib_get_drvdata(ibdev);
1303  struct golan_queue_pair *golan_qp = ib_qp_get_drvdata(qp);
1304  struct golan_cmd_layout *cmd;
1305  int rc;
1306 
1308  NO_MBOX, NO_MBOX,
1309  sizeof(struct golan_modify_qp_mbox_in),
1310  sizeof(struct golan_modify_qp_mbox_out));
1311  ((struct golan_modify_qp_mbox_in *)(cmd->in))->qpn = cpu_to_be32(qp->qpn);
1313  GOLAN_CHECK_RC_AND_CMD_STATUS( err_modify_qp_2rst_cmd );
1314 
1315  golan_qp->state = GOLAN_IB_QPS_RESET;
1316  DBGC( golan , "%s QP number 0x%lx was modified to RESET\n",
1317  __FUNCTION__, qp->qpn);
1318 
1319  return 0;
1320 
1321 err_modify_qp_2rst_cmd:
1322  DBGC (golan ,"%s Failed to modify QP number 0x%lx (rc = 0x%x)\n",
1323  __FUNCTION__, qp->qpn, rc);
1324  return rc;
1325 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
static __always_inline void * ib_qp_get_drvdata(struct ib_queue_pair *qp)
Get Infiniband queue pair driver-private data.
Definition: infiniband.h:641
__be32 qpn
Definition: CIB_PRM.h:29
#define NO_MBOX
Definition: golan.h:58
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define GOLAN_CHECK_RC_AND_CMD_STATUS(_lable)
Definition: golan.c:111
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define cpu_to_be32(value)
Definition: byteswap.h:110
#define DEF_CMD_IDX
Definition: golan.h:56
enum golan_ib_qp_state state
Definition: golan.h:186
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References cmd, cpu_to_be32, DBGC, DEF_CMD_IDX, GOLAN_CHECK_RC_AND_CMD_STATUS, GOLAN_CMD_OP_2RST_QP, GOLAN_IB_QPS_RESET, ib_get_drvdata(), ib_qp_get_drvdata(), NO_MBOX, qp, qpn, rc, send_command_and_wait(), golan_queue_pair::state, and write_cmd().

Referenced by golan_destroy_qp().

◆ golan_modify_qp()

static int golan_modify_qp ( struct ib_device ibdev,
struct ib_queue_pair qp 
)
static

Definition at line 1336 of file golan.c.

1338 {
1339  struct golan *golan = ib_get_drvdata(ibdev);
1340  struct golan_queue_pair *golan_qp = ib_qp_get_drvdata(qp);
1342  struct golan_cmd_layout *cmd;
1343  enum golan_ib_qp_state prev_state;
1344  int rc;
1345  int modify_cmd[] = {GOLAN_CMD_OP_RST2INIT_QP,
1348 
1349  while (golan_qp->state < GOLAN_IB_QPS_RTS) {
1350  prev_state = golan_qp->state;
1351  cmd = write_cmd(golan, DEF_CMD_IDX, modify_cmd[golan_qp->state], 0x0,
1352  GEN_MBOX, NO_MBOX,
1353  sizeof(struct golan_modify_qp_mbox_in),
1354  sizeof(struct golan_modify_qp_mbox_out));
1355 
1357  ((struct golan_modify_qp_mbox_in *)(cmd->in))->qpn = cpu_to_be32(qp->qpn);
1358  rc = golan_modify_qp_methods[golan_qp->state](ibdev, qp, in);
1359  if (rc) {
1360  goto err_modify_qp_fill_inbox;
1361  }
1362 // in->ctx.qp_counter_set_usr_page = cpu_to_be32(golan->uar.index);
1364  GOLAN_CHECK_RC_AND_CMD_STATUS( err_modify_qp_cmd );
1365 
1366  ++(golan_qp->state);
1367 
1368  DBGC( golan , "%s QP number 0x%lx was modified from %s to %s\n",
1369  __FUNCTION__, qp->qpn, golan_qp_state_as_string[prev_state],
1370  golan_qp_state_as_string[golan_qp->state]);
1371  }
1372 
1373  DBGC( golan , "%s QP number 0x%lx is ready to receive/send packets.\n",
1374  __FUNCTION__, qp->qpn);
1375  return 0;
1376 
1377 err_modify_qp_cmd:
1378 err_modify_qp_fill_inbox:
1379  DBGC (golan ,"%s Failed to modify QP number 0x%lx (rc = 0x%x)\n",
1380  __FUNCTION__, qp->qpn, rc);
1381  return rc;
1382 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
__be32 in[4]
Definition: CIB_PRM.h:35
static int(* golan_modify_qp_methods[])(struct ib_device *ibdev, struct ib_queue_pair *qp, struct golan_modify_qp_mbox_in_data *in)
Definition: golan.c:1327
#define DBGC(...)
Definition: compiler.h:505
#define GEN_MBOX
Definition: golan.h:60
static __always_inline void * ib_qp_get_drvdata(struct ib_queue_pair *qp)
Get Infiniband queue pair driver-private data.
Definition: infiniband.h:641
const char * golan_qp_state_as_string[]
Definition: golan.c:88
__be32 qpn
Definition: CIB_PRM.h:29
#define NO_MBOX
Definition: golan.h:58
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define GOLAN_CHECK_RC_AND_CMD_STATUS(_lable)
Definition: golan.c:111
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define cpu_to_be32(value)
Definition: byteswap.h:110
#define DEF_CMD_IDX
Definition: golan.h:56
enum golan_ib_qp_state state
Definition: golan.h:186
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
#define GET_INBOX(golan, idx)
Definition: golan.h:75
golan_ib_qp_state
Definition: golan.h:134

References cmd, cpu_to_be32, DBGC, DEF_CMD_IDX, GEN_MBOX, GET_INBOX, GOLAN_CHECK_RC_AND_CMD_STATUS, GOLAN_CMD_OP_INIT2RTR_QP, GOLAN_CMD_OP_RST2INIT_QP, GOLAN_CMD_OP_RTR2RTS_QP, GOLAN_IB_QPS_RTS, golan_modify_qp_methods, golan_qp_state_as_string, ib_get_drvdata(), ib_qp_get_drvdata(), in, NO_MBOX, qp, qpn, rc, send_command_and_wait(), golan_queue_pair::state, and write_cmd().

◆ golan_destroy_qp()

static void golan_destroy_qp ( struct ib_device ibdev,
struct ib_queue_pair qp 
)
static

Destroy queue pair.

Parameters
ibdevInfiniband device
qpQueue pair

Definition at line 1390 of file golan.c.

1392 {
1393  struct golan *golan = ib_get_drvdata(ibdev);
1394  struct golan_queue_pair *golan_qp = ib_qp_get_drvdata(qp);
1395  struct golan_cmd_layout *cmd;
1396  unsigned long qpn = qp->qpn;
1397  int rc;
1398 
1399  DBGC (golan, "%s in\n", __FUNCTION__);
1400 
1401  if (golan_qp->state != GOLAN_IB_QPS_RESET) {
1402  if (golan_modify_qp_to_rst(ibdev, qp)) {
1403  DBGC (golan ,"%s Failed to modify QP 0x%lx to RESET\n", __FUNCTION__,
1404  qp->qpn);
1405  }
1406  }
1407 
1408  if (qp->recv.cq) {
1409  golan_cq_clean(qp->recv.cq);
1410  }
1411  if (qp->send.cq && (qp->send.cq != qp->recv.cq)) {
1412  golan_cq_clean(qp->send.cq);
1413  }
1414 
1416  NO_MBOX, NO_MBOX,
1417  sizeof(struct golan_destroy_qp_mbox_in),
1418  sizeof(struct golan_destroy_qp_mbox_out));
1419  ((struct golan_destroy_qp_mbox_in *)(cmd->in))->qpn = cpu_to_be32(qpn);
1422  qp->qpn = 0;
1423 
1425  free_dma(golan_qp->doorbell_record, sizeof(struct golan_qp_db));
1426  free_dma ( golan_qp->wqes, GOLAN_PAGE_SIZE );
1427  free(golan_qp);
1428 
1429  DBGC( golan ,"%s QP 0x%lx was destroyed\n", __FUNCTION__, qpn);
1430 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void golan_cq_clean(struct ib_completion_queue *cq)
Definition: golan.c:1055
#define DBGC(...)
Definition: compiler.h:505
static __always_inline void * ib_qp_get_drvdata(struct ib_queue_pair *qp)
Get Infiniband queue pair driver-private data.
Definition: infiniband.h:641
static int golan_modify_qp_to_rst(struct ib_device *ibdev, struct ib_queue_pair *qp)
Definition: golan.c:1299
#define GOLAN_PRINT_RC_AND_CMD_STATUS
Definition: golan.c:117
__be32 qpn
Definition: CIB_PRM.h:29
#define NO_MBOX
Definition: golan.h:58
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
void * wqes
Definition: golan.h:180
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define cpu_to_be32(value)
Definition: byteswap.h:110
#define DEF_CMD_IDX
Definition: golan.h:56
struct golan_qp_db * doorbell_record
Definition: golan.h:184
enum golan_ib_qp_state state
Definition: golan.h:186
static void free_dma(void *ptr, size_t size)
Free memory allocated with malloc_dma()
Definition: malloc.h:81
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
static __always_inline void ib_qp_set_drvdata(struct ib_queue_pair *qp, void *priv)
Set Infiniband queue pair driver-private data.
Definition: infiniband.h:630
#define GOLAN_PAGE_SIZE
Definition: golan.h:52

References cmd, cpu_to_be32, DBGC, DEF_CMD_IDX, golan_queue_pair::doorbell_record, free, free_dma(), GOLAN_CMD_OP_DESTROY_QP, golan_cq_clean(), GOLAN_IB_QPS_RESET, golan_modify_qp_to_rst(), GOLAN_PAGE_SIZE, GOLAN_PRINT_RC_AND_CMD_STATUS, ib_get_drvdata(), ib_qp_get_drvdata(), ib_qp_set_drvdata(), NO_MBOX, NULL, qp, qpn, rc, send_command_and_wait(), golan_queue_pair::state, golan_queue_pair::wqes, and write_cmd().

◆ golan_rate()

static unsigned int golan_rate ( enum ib_rate  rate)
static

Calculate transmission rate.

Parameters
avAddress vector
Return values
golan_rateGolan rate

Definition at line 1438 of file golan.c.

1438  {
1439  return (((rate >= IB_RATE_2_5) && (rate <= IB_RATE_120)) ? (rate + 5) : 0);
1440 }

References IB_RATE_120, and IB_RATE_2_5.

Referenced by golan_post_send().

◆ golan_post_send()

static int golan_post_send ( struct ib_device ibdev,
struct ib_queue_pair qp,
struct ib_address_vector av,
struct io_buffer iobuf 
)
static

Post send work queue entry.

Parameters
ibdevInfiniband device
qpQueue pair
avAddress vector
iobufI/O buffer
Return values
rcReturn status code

Definition at line 1451 of file golan.c.

1455 {
1456  struct golan *golan = ib_get_drvdata(ibdev);
1457  struct golan_queue_pair *golan_qp = ib_qp_get_drvdata(qp);
1458  struct golan_send_wqe_ud *wqe = NULL;
1459  struct golan_av *datagram = NULL;
1460  unsigned long wqe_idx_mask;
1461  unsigned long wqe_idx;
1462  struct golan_wqe_data_seg *data = NULL;
1463  struct golan_wqe_ctrl_seg *ctrl = NULL;
1464 
1465 
1466  wqe_idx_mask = (qp->send.num_wqes - 1);
1467  wqe_idx = (qp->send.next_idx & wqe_idx_mask);
1468  if (qp->send.iobufs[wqe_idx]) {
1469  DBGC (golan ,"%s Send queue of QPN 0x%lx is full\n", __FUNCTION__, qp->qpn);
1470  return -ENOMEM;
1471  }
1472 
1473  qp->send.iobufs[wqe_idx] = iobuf;
1474 
1475  // change to this
1476  //wqe_size_in_octa_words = golan_qp->sq.wqe_size_in_wqebb >> 4;
1477 
1478  wqe = &golan_qp->sq.wqes[wqe_idx].ud;
1479 
1480  //CHECK HW OWNERSHIP BIT ???
1481 
1482  memset(wqe, 0, sizeof(*wqe));
1483 
1484  ctrl = &wqe->ctrl;
1485  ctrl->opmod_idx_opcode = cpu_to_be32(GOLAN_SEND_OPCODE |
1486  ((u32)(golan_qp->sq.next_idx) <<
1488  ctrl->qpn_ds = cpu_to_be32(GOLAN_SEND_UD_WQE_SIZE >> 4) |
1489  golan_qp->doorbell_qpn;
1490  ctrl->fm_ce_se = 0x8;//10 - 0 - 0
1491  data = &wqe->data;
1492  data->byte_count = cpu_to_be32(iob_len(iobuf));
1493  data->lkey = cpu_to_be32(golan->mkey);
1494  data->addr = VIRT_2_BE64_BUS(iobuf->data);
1495 
1496  datagram = &wqe->datagram;
1497  datagram->key.qkey.qkey = cpu_to_be32(av->qkey);
1498  datagram->dqp_dct = cpu_to_be32((1 << 31) | av->qpn);
1499  datagram->stat_rate_sl = ((golan_rate(av->rate) << 4) | av->sl);
1500  datagram->fl_mlid = (ibdev->lid & 0x007f); /* take only the 7 low bits of the LID */
1501  datagram->rlid = cpu_to_be16(av->lid);
1502  datagram->grh_gid_fl = cpu_to_be32(av->gid_present << 30);
1503  memcpy(datagram->rgid, av->gid.bytes, 16 /* sizeof(datagram->rgid) */);
1504 
1505  /*
1506  * Make sure that descriptors are written before
1507  * updating doorbell record and ringing the doorbell
1508  */
1509  ++(qp->send.next_idx);
1510  golan_qp->sq.next_idx = (golan_qp->sq.next_idx + GOLAN_WQEBBS_PER_SEND_UD_WQE);
1511  golan_qp->doorbell_record->send_db = cpu_to_be16(golan_qp->sq.next_idx);
1512  wmb();
1513  writeq(*((__be64 *)ctrl), golan->uar.virt
1514  + ( ( golan_qp->sq.next_idx & 0x1 ) ? DB_BUFFER0_EVEN_OFFSET
1515  : DB_BUFFER0_ODD_OFFSET ) );
1516  return 0;
1517 }
#define cpu_to_be16(value)
Definition: byteswap.h:109
u32 doorbell_qpn
Definition: golan.h:185
wmb()
u16 next_idx
Definition: golan.h:176
#define DB_BUFFER0_EVEN_OFFSET
Definition: golan.h:219
__be16 send_db
Definition: CIB_PRM.h:978
uint16_t lid
Port LID.
Definition: infiniband.h:441
struct golan_wqe_ctrl_seg ctrl
Definition: golan.h:145
#define DBGC(...)
Definition: compiler.h:505
static __always_inline void * ib_qp_get_drvdata(struct ib_queue_pair *qp)
Get Infiniband queue pair driver-private data.
Definition: infiniband.h:641
#define GOLAN_WQEBBS_PER_SEND_UD_WQE
Definition: golan.h:130
u32 mkey
Definition: golan.h:335
unsigned int gid_present
GID is present.
Definition: infiniband.h:90
unsigned long long __be64
Definition: CIB_PRM.h:25
enum ib_rate rate
Rate.
Definition: infiniband.h:86
u8 fl_mlid
Definition: CIB_PRM.h:1005
#define ENOMEM
Not enough space.
Definition: errno.h:534
uint8_t bytes[16]
Definition: ib_packet.h:34
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
unsigned long qkey
Queue key.
Definition: infiniband.h:79
Definition: golan.h:323
union golan_send_wqe * wqes
Definition: golan.h:172
struct golan_av datagram
Definition: golan.h:146
static unsigned int golan_rate(enum ib_rate rate)
Calculate transmission rate.
Definition: golan.c:1438
__be32 qkey
Definition: CIB_PRM.h:998
#define GOLAN_WQE_CTRL_WQE_IDX_BIT
Definition: golan.h:132
#define GOLAN_SEND_UD_WQE_SIZE
Definition: golan.h:128
struct golan_wqe_data_seg data
Definition: golan.h:147
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
void * virt
Definition: golan.h:110
struct golan_uar uar
Definition: golan.h:332
unsigned long qpn
Queue Pair Number.
Definition: infiniband.h:74
#define VIRT_2_BE64_BUS(addr)
Definition: golan.h:70
__be32 grh_gid_fl
Definition: CIB_PRM.h:1010
unsigned int sl
Service level.
Definition: infiniband.h:88
u8 rgid[16]
Definition: CIB_PRM.h:1011
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define cpu_to_be32(value)
Definition: byteswap.h:110
struct golan_send_wq sq
Definition: golan.h:183
__be32 dqp_dct
Definition: CIB_PRM.h:1003
static unsigned int ctrl
Definition: intel.h:270
#define GOLAN_SEND_OPCODE
Definition: golan.h:131
void * data
Start of data.
Definition: iobuf.h:44
union ib_gid gid
GID, if present.
Definition: infiniband.h:92
__be16 rlid
Definition: CIB_PRM.h:1006
struct golan_send_wqe_ud ud
Definition: golan.h:151
union golan_av::@373 key
u8 stat_rate_sl
Definition: CIB_PRM.h:1004
struct golan_qp_db * doorbell_record
Definition: golan.h:184
unsigned int lid
Local ID.
Definition: infiniband.h:81
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.
uint32_t u32
Definition: stdint.h:23
#define DB_BUFFER0_ODD_OFFSET
Definition: golan.h:220
void * memset(void *dest, int character, size_t len) __nonnull

References ib_gid::bytes, cpu_to_be16, cpu_to_be32, golan_send_wqe_ud::ctrl, ctrl, data, io_buffer::data, golan_send_wqe_ud::data, golan_send_wqe_ud::datagram, DB_BUFFER0_EVEN_OFFSET, DB_BUFFER0_ODD_OFFSET, DBGC, golan_queue_pair::doorbell_qpn, golan_queue_pair::doorbell_record, golan_av::dqp_dct, ENOMEM, golan_av::fl_mlid, ib_address_vector::gid, ib_address_vector::gid_present, golan_rate(), GOLAN_SEND_OPCODE, GOLAN_SEND_UD_WQE_SIZE, GOLAN_WQE_CTRL_WQE_IDX_BIT, GOLAN_WQEBBS_PER_SEND_UD_WQE, golan_av::grh_gid_fl, ib_get_drvdata(), ib_qp_get_drvdata(), iob_len(), golan_av::key, ib_address_vector::lid, ib_device::lid, memcpy(), memset(), golan::mkey, golan_send_wq::next_idx, NULL, ib_address_vector::qkey, golan_av::qkey, qp, ib_address_vector::qpn, ib_address_vector::rate, golan_av::rgid, golan_av::rlid, golan_qp_db::send_db, ib_address_vector::sl, golan_queue_pair::sq, golan_av::stat_rate_sl, golan::uar, golan_send_wqe::ud, golan_uar::virt, VIRT_2_BE64_BUS, wmb(), golan_send_wq::wqes, and writeq().

◆ golan_post_recv()

static int golan_post_recv ( struct ib_device ibdev,
struct ib_queue_pair qp,
struct io_buffer iobuf 
)
static

Post receive work queue entry.

Parameters
ibdevInfiniband device
qpQueue pair
iobufI/O buffer
Return values
rcReturn status code

Definition at line 1527 of file golan.c.

1530 {
1531  struct golan *golan = ib_get_drvdata(ibdev);
1532  struct golan_queue_pair *golan_qp = ib_qp_get_drvdata(qp);
1533  struct ib_work_queue *wq = &qp->recv;
1534  struct golan_recv_wqe_ud *wqe;
1535  struct ib_global_route_header *grh;
1536  struct golan_wqe_data_seg *data;
1537  unsigned int wqe_idx_mask;
1538 
1539  /* Allocate work queue entry */
1540  wqe_idx_mask = (wq->num_wqes - 1);
1541  if (wq->iobufs[wq->next_idx & wqe_idx_mask]) {
1542  DBGC (golan ,"%s Receive queue of QPN 0x%lx is full\n", __FUNCTION__, qp->qpn);
1543  return -ENOMEM;
1544  }
1545 
1546  wq->iobufs[wq->next_idx & wqe_idx_mask] = iobuf;
1547  wqe = & golan_qp->rq.wqes[wq->next_idx & wqe_idx_mask];
1548 
1549  memset(wqe, 0, sizeof(*wqe));
1550  data = &wqe->data[0];
1551  if ( golan_qp->rq.grh ) {
1552  grh = &golan_qp->rq.grh[wq->next_idx & wqe_idx_mask];
1553  data->byte_count = cpu_to_be32 ( sizeof ( *grh ) );
1554  data->lkey = cpu_to_be32 ( golan->mkey );
1555  data->addr = VIRT_2_BE64_BUS ( grh );
1556  data++;
1557  }
1558 
1559  data->byte_count = cpu_to_be32(iob_tailroom(iobuf));
1560  data->lkey = cpu_to_be32(golan->mkey);
1561  data->addr = VIRT_2_BE64_BUS(iobuf->data);
1562 
1563  ++wq->next_idx;
1564 
1565  /*
1566  * Make sure that descriptors are written before
1567  * updating doorbell record and ringing the doorbell
1568  */
1569  wmb();
1570  golan_qp->doorbell_record->recv_db = cpu_to_be16(qp->recv.next_idx & 0xffff);
1571 
1572  return 0;
1573 }
#define cpu_to_be16(value)
Definition: byteswap.h:109
wmb()
struct golan_wqe_data_seg data[2]
Definition: golan.h:156
#define DBGC(...)
Definition: compiler.h:505
static __always_inline void * ib_qp_get_drvdata(struct ib_queue_pair *qp)
Get Infiniband queue pair driver-private data.
Definition: infiniband.h:641
struct ib_global_route_header grh
Definition: ib_packet.h:16
u32 mkey
Definition: golan.h:335
#define ENOMEM
Not enough space.
Definition: errno.h:534
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
Definition: golan.h:323
An Infiniband Work Queue.
Definition: infiniband.h:100
An Infiniband Global Route Header.
Definition: ib_packet.h:89
__be16 recv_db
Definition: CIB_PRM.h:976
unsigned int num_wqes
Number of work queue entries.
Definition: infiniband.h:112
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
Definition: iobuf.h:171
#define VIRT_2_BE64_BUS(addr)
Definition: golan.h:70
unsigned long next_idx
Next work queue entry index.
Definition: infiniband.h:122
struct ib_global_route_header * grh
GRH buffers (if applicable)
Definition: golan.h:166
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define cpu_to_be32(value)
Definition: byteswap.h:110
struct golan_recv_wqe_ud * wqes
Definition: golan.h:160
void * data
Start of data.
Definition: iobuf.h:44
struct golan_recv_wq rq
Definition: golan.h:182
struct golan_qp_db * doorbell_record
Definition: golan.h:184
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
void * memset(void *dest, int character, size_t len) __nonnull
struct io_buffer ** iobufs
I/O buffers assigned to work queue.
Definition: infiniband.h:124

References cpu_to_be16, cpu_to_be32, data, io_buffer::data, golan_recv_wqe_ud::data, DBGC, golan_queue_pair::doorbell_record, ENOMEM, grh, golan_recv_wq::grh, ib_get_drvdata(), ib_qp_get_drvdata(), iob_tailroom(), ib_work_queue::iobufs, memset(), golan::mkey, ib_work_queue::next_idx, ib_work_queue::num_wqes, qp, golan_qp_db::recv_db, golan_queue_pair::rq, VIRT_2_BE64_BUS, wmb(), and golan_recv_wq::wqes.

◆ golan_query_vport_context()

static int golan_query_vport_context ( struct ib_device ibdev)
static

Definition at line 1575 of file golan.c.

1575  {
1576  struct golan *golan = ib_get_drvdata ( ibdev );
1577  struct golan_cmd_layout *cmd;
1580  int rc;
1581 
1583  0x0, GEN_MBOX, GEN_MBOX,
1584  sizeof(struct golan_query_hca_vport_context_inbox),
1585  sizeof(struct golan_query_hca_vport_context_outbox) );
1586 
1587  in = GOLAN_MBOX_IN ( cmd, in );
1588  in->port_num = (u8)ibdev->port;
1589 
1590  rc = send_command_and_wait ( golan, DEF_CMD_IDX, GEN_MBOX, GEN_MBOX, __FUNCTION__ );
1591  GOLAN_CHECK_RC_AND_CMD_STATUS( err_query_vport_context_cmd );
1592 
1594 
1595  ibdev->node_guid.dwords[0] = context_data->node_guid[0];
1596  ibdev->node_guid.dwords[1] = context_data->node_guid[1];
1597  ibdev->lid = be16_to_cpu( context_data->lid );
1598  ibdev->sm_lid = be16_to_cpu( context_data->sm_lid );
1599  ibdev->sm_sl = context_data->sm_sl;
1601 
1602  return 0;
1603 err_query_vport_context_cmd:
1604  DBGC (golan ,"%s [%d] out\n", __FUNCTION__, rc);
1605  return rc;
1606 }
#define GET_OUTBOX(golan, idx)
Definition: golan.h:76
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
__be32 in[4]
Definition: CIB_PRM.h:35
uint16_t lid
Port LID.
Definition: infiniband.h:441
#define DBGC(...)
Definition: compiler.h:505
#define GEN_MBOX
Definition: golan.h:60
uint32_t dwords[2]
Definition: ib_packet.h:21
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
struct golan_query_hca_vport_context_data context_data
Definition: CIB_PRM.h:30
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
#define be16_to_cpu(value)
Definition: byteswap.h:115
uint16_t sm_lid
Subnet manager LID.
Definition: infiniband.h:443
#define u8
Definition: igbvf_osdep.h:38
uint8_t sm_sl
Subnet manager SL.
Definition: infiniband.h:445
unsigned int port
Port number.
Definition: infiniband.h:418
union ib_guid node_guid
Node GUID.
Definition: infiniband.h:437
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define GOLAN_CHECK_RC_AND_CMD_STATUS(_lable)
Definition: golan.c:111
#define DEF_CMD_IDX
Definition: golan.h:56
uint8_t port_state
Port state.
Definition: infiniband.h:423
#define GOLAN_MBOX_IN(cmd_ptr, in_ptr)
Definition: golan.h:78
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References be16_to_cpu, cmd, context_data, DBGC, DEF_CMD_IDX, ib_guid::dwords, GEN_MBOX, GET_OUTBOX, GOLAN_CHECK_RC_AND_CMD_STATUS, GOLAN_CMD_OP_QUERY_HCA_VPORT_CONTEXT, GOLAN_MBOX_IN, ib_get_drvdata(), in, ib_device::lid, golan_query_hca_vport_context_data::lid, ib_device::node_guid, golan_query_hca_vport_context_data::node_guid, ib_device::port, ib_device::port_state, golan_query_hca_vport_context_data::port_state, rc, send_command_and_wait(), ib_device::sm_lid, golan_query_hca_vport_context_data::sm_lid, ib_device::sm_sl, golan_query_hca_vport_context_data::sm_sl, u8, and write_cmd().

Referenced by golan_get_ib_info().

◆ golan_query_vport_gid()

static int golan_query_vport_gid ( struct ib_device ibdev)
static

Definition at line 1609 of file golan.c.

1609  {
1610  struct golan *golan = ib_get_drvdata( ibdev );
1611  struct golan_cmd_layout *cmd;
1613  union ib_gid *ib_gid;
1614  int rc;
1615 
1617  0x0, GEN_MBOX, GEN_MBOX,
1618  sizeof(struct golan_query_hca_vport_gid_inbox),
1619  sizeof(struct golan_query_hca_vport_gid_outbox) );
1620 
1621  in = GOLAN_MBOX_IN ( cmd, in );
1622  in->port_num = (u8)ibdev->port;
1623  in->gid_index = 0;
1624  rc = send_command_and_wait ( golan, DEF_CMD_IDX, GEN_MBOX, GEN_MBOX, __FUNCTION__ );
1625  GOLAN_CHECK_RC_AND_CMD_STATUS( err_query_vport_gid_cmd );
1626 
1627  ib_gid = (union ib_gid *)( GET_OUTBOX ( golan, GEN_MBOX ) );
1628 
1629  memcpy ( &ibdev->gid, ib_gid, sizeof(ibdev->gid) );
1630 
1631  return 0;
1632 err_query_vport_gid_cmd:
1633  DBGC ( golan, "%s [%d] out\n", __FUNCTION__, rc);
1634  return rc;
1635 }
#define GET_OUTBOX(golan, idx)
Definition: golan.h:76
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:439
__be32 in[4]
Definition: CIB_PRM.h:35
#define DBGC(...)
Definition: compiler.h:505
#define GEN_MBOX
Definition: golan.h:60
An Infiniband Global Identifier.
Definition: ib_packet.h:33
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
#define u8
Definition: igbvf_osdep.h:38
unsigned int port
Port number.
Definition: infiniband.h:418
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define GOLAN_CHECK_RC_AND_CMD_STATUS(_lable)
Definition: golan.c:111
#define DEF_CMD_IDX
Definition: golan.h:56
#define GOLAN_MBOX_IN(cmd_ptr, in_ptr)
Definition: golan.h:78
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References cmd, DBGC, DEF_CMD_IDX, GEN_MBOX, GET_OUTBOX, ib_device::gid, GOLAN_CHECK_RC_AND_CMD_STATUS, GOLAN_CMD_OP_QUERY_HCA_VPORT_GID, GOLAN_MBOX_IN, ib_get_drvdata(), in, memcpy(), ib_device::port, rc, send_command_and_wait(), u8, and write_cmd().

Referenced by golan_get_ib_info().

◆ golan_query_vport_pkey()

static int golan_query_vport_pkey ( struct ib_device ibdev)
static

Definition at line 1637 of file golan.c.

1637  {
1638  struct golan *golan = ib_get_drvdata ( ibdev );
1639  struct golan_cmd_layout *cmd;
1641  int pkey_table_size_in_entries = (1 << (7 + golan->caps.pkey_table_size));
1642  int rc;
1643 
1645  0x0, GEN_MBOX, GEN_MBOX,
1646  sizeof(struct golan_query_hca_vport_pkey_inbox),
1647  sizeof(struct golan_outbox_hdr) + 8 +
1648  sizeof(struct golan_query_hca_vport_pkey_data) * pkey_table_size_in_entries );
1649 
1650  in = GOLAN_MBOX_IN ( cmd, in );
1651  in->port_num = (u8)ibdev->port;
1652  in->pkey_index = 0xffff;
1653  rc = send_command_and_wait ( golan, DEF_CMD_IDX, GEN_MBOX, GEN_MBOX, __FUNCTION__ );
1654  GOLAN_CHECK_RC_AND_CMD_STATUS( err_query_vport_pkey_cmd );
1655 
1656  return 0;
1657 err_query_vport_pkey_cmd:
1658  DBGC (golan ,"%s [%d] out\n", __FUNCTION__, rc);
1659  return rc;
1660 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
__be32 in[4]
Definition: CIB_PRM.h:35
#define DBGC(...)
Definition: compiler.h:505
#define GEN_MBOX
Definition: golan.h:60
struct golan_hca_cap caps
Definition: golan.h:327
__be16 pkey_table_size
Definition: CIB_PRM.h:258
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
Definition: golan.h:323
static int send_command_and_wait(struct golan *golan, uint32_t cmd_idx, uint32_t inbox_idx, uint32_t outbox_idx, const char *command)
Definition: golan.c:271
#define u8
Definition: igbvf_osdep.h:38
unsigned int port
Port number.
Definition: infiniband.h:418
static struct golan_cmd_layout * write_cmd(struct golan *golan, int idx, uint16_t opcode, uint16_t opmod, uint16_t inbox_idx, uint16_t outbox_idx, uint16_t inlen, uint16_t outlen)
Prepare a FW command, In - comamnd idx (Must be valid) writes the command parameters.
Definition: golan.c:284
#define GOLAN_CHECK_RC_AND_CMD_STATUS(_lable)
Definition: golan.c:111
#define DEF_CMD_IDX
Definition: golan.h:56
#define GOLAN_MBOX_IN(cmd_ptr, in_ptr)
Definition: golan.h:78
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29

References golan::caps, cmd, DBGC, DEF_CMD_IDX, GEN_MBOX, GOLAN_CHECK_RC_AND_CMD_STATUS, GOLAN_CMD_OP_QUERY_HCA_VPORT_PKEY, GOLAN_MBOX_IN, ib_get_drvdata(), in, golan_hca_cap::pkey_table_size, ib_device::port, rc, send_command_and_wait(), u8, and write_cmd().

Referenced by golan_get_ib_info().

◆ golan_get_ib_info()

static int golan_get_ib_info ( struct ib_device ibdev)
static

Definition at line 1662 of file golan.c.

1662  {
1663  int rc;
1664 
1665  rc = golan_query_vport_context ( ibdev );
1666  if ( rc != 0 ) {
1667  DBG ( "golan_get_ib_info: golan_query_vport_context Failed (rc = %d)\n",rc );
1668  goto err_query_vport_context;
1669  }
1670 
1671  rc = golan_query_vport_gid ( ibdev );
1672  if ( rc != 0 ) {
1673  DBG ( "golan_get_ib_info: golan_query_vport_gid Failed (rc = %d)\n",rc );
1674  goto err_query_vport_gid;
1675  }
1676 
1677  rc = golan_query_vport_pkey ( ibdev );
1678  if ( rc != 0 ) {
1679  DBG ( "golan_get_ib_info: golan_query_vport_pkey Failed (rc = %d)\n",rc );
1680  goto err_query_vport_pkey;
1681  }
1682  return rc;
1683 err_query_vport_pkey:
1684 err_query_vport_gid:
1685 err_query_vport_context:
1686  DBG ( "%s [%d] out\n", __FUNCTION__, rc);
1687  return rc;
1688 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int golan_query_vport_context(struct ib_device *ibdev)
Definition: golan.c:1575
static int golan_query_vport_gid(struct ib_device *ibdev)
Definition: golan.c:1609
static int golan_query_vport_pkey(struct ib_device *ibdev)
Definition: golan.c:1637
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References DBG, golan_query_vport_context(), golan_query_vport_gid(), golan_query_vport_pkey(), and rc.

Referenced by golan_ib_update(), and golan_register_ibdev().

◆ golan_complete()

static int golan_complete ( struct ib_device ibdev,
struct ib_completion_queue cq,
struct golan_cqe64 cqe64 
)
static

Definition at line 1690 of file golan.c.

1693 {
1694  struct golan *golan = ib_get_drvdata(ibdev);
1695  struct ib_work_queue *wq;
1696  struct golan_queue_pair *golan_qp;
1697  struct ib_queue_pair *qp;
1698  struct io_buffer *iobuf = NULL;
1699  struct ib_address_vector recv_dest;
1700  struct ib_address_vector recv_source;
1701  struct ib_global_route_header *grh;
1702  struct golan_err_cqe *err_cqe64;
1703  int gid_present, idx;
1704  u16 wqe_ctr;
1705  uint8_t opcode;
1706  static int error_state;
1707  uint32_t qpn = be32_to_cpu(cqe64->sop_drop_qpn) & 0xffffff;
1708  int is_send = 0;
1709  size_t len;
1710 
1711  opcode = cqe64->op_own >> GOLAN_CQE_OPCODE_BIT;
1712  DBGC2( golan , "%s completion with opcode 0x%x\n", __FUNCTION__, opcode);
1713 
1715  is_send = 1;
1716  } else {
1717  is_send = 0;
1718  }
1720  err_cqe64 = (struct golan_err_cqe *)cqe64;
1721  int i = 0;
1722  if (!error_state++) {
1723  DBGC (golan ,"\n");
1724  for ( i = 0 ; i < 16 ; i += 2 ) {
1725  DBGC (golan ,"%x %x\n",
1726  be32_to_cpu(((uint32_t *)(err_cqe64))[i]),
1727  be32_to_cpu(((uint32_t *)(err_cqe64))[i + 1]));
1728  }
1729  DBGC (golan ,"CQE with error: Syndrome(0x%x), VendorSynd(0x%x), HW_SYN(0x%x)\n",
1730  err_cqe64->syndrome, err_cqe64->vendor_err_synd,
1731  err_cqe64->hw_syndrom);
1732  }
1733  }
1734  /* Identify work queue */
1735  wq = ib_find_wq(cq, qpn, is_send);
1736  if (!wq) {
1737  DBGC (golan ,"%s unknown %s QPN 0x%x in CQN 0x%lx\n",
1738  __FUNCTION__, (is_send ? "send" : "recv"), qpn, cq->cqn);
1739  return -EINVAL;
1740  }
1741 
1742  qp = wq->qp;
1743  golan_qp = ib_qp_get_drvdata ( qp );
1744 
1745  wqe_ctr = be16_to_cpu(cqe64->wqe_counter);
1746  if (is_send) {
1747  wqe_ctr &= ((GOLAN_WQEBBS_PER_SEND_UD_WQE * wq->num_wqes) - 1);
1748  idx = wqe_ctr / GOLAN_WQEBBS_PER_SEND_UD_WQE;
1749  } else {
1750  idx = wqe_ctr & (wq->num_wqes - 1);
1751  }
1752 
1753  iobuf = wq->iobufs[idx];
1754  if (!iobuf) {
1755  DBGC (golan ,"%s IO Buffer 0x%x not found in QPN 0x%x\n",
1756  __FUNCTION__, idx, qpn);
1757  return -EINVAL;
1758  }
1759  wq->iobufs[idx] = NULL;
1760 
1761  if (is_send) {
1762  ib_complete_send(ibdev, qp, iobuf, (opcode == GOLAN_CQE_REQ_ERR));
1763  } else {
1764  len = be32_to_cpu(cqe64->byte_cnt);
1765  memset(&recv_dest, 0, sizeof(recv_dest));
1766  recv_dest.qpn = qpn;
1767  /* Construct address vector */
1768  memset(&recv_source, 0, sizeof(recv_source));
1769  switch (qp->type) {
1770  case IB_QPT_SMI:
1771  case IB_QPT_GSI:
1772  case IB_QPT_UD:
1773  /* Locate corresponding GRH */
1774  assert ( golan_qp->rq.grh != NULL );
1775  grh = &golan_qp->rq.grh[ idx ];
1776 
1777  recv_source.qpn = be32_to_cpu(cqe64->flags_rqpn) & 0xffffff;
1778  recv_source.lid = be16_to_cpu(cqe64->slid);
1779  recv_source.sl = (be32_to_cpu(cqe64->flags_rqpn) >> 24) & 0xf;
1780  gid_present = (be32_to_cpu(cqe64->flags_rqpn) >> 28) & 3;
1781  if (!gid_present) {
1782  recv_dest.gid_present = recv_source.gid_present = 0;
1783  } else {
1784  recv_dest.gid_present = recv_source.gid_present = 1;
1785  //if (recv_source.gid_present == 0x1) {
1786  memcpy(&recv_source.gid, &grh->sgid, sizeof(recv_source.gid));
1787  memcpy(&recv_dest.gid, &grh->dgid, sizeof(recv_dest.gid));
1788  //} else { // recv_source.gid_present = 0x3
1789  /* GRH is located in the upper 64 byte of the CQE128
1790  * currently not supported */
1791  //;
1792  //}
1793  }
1794  len -= sizeof ( *grh );
1795  break;
1796  case IB_QPT_RC:
1797  case IB_QPT_ETH:
1798  default:
1799  DBGC (golan ,"%s Unsupported QP type (0x%x)\n", __FUNCTION__, qp->type);
1800  return -EINVAL;
1801  }
1802  assert(len <= iob_tailroom(iobuf));
1803  iob_put(iobuf, len);
1804  ib_complete_recv(ibdev, qp, &recv_dest, &recv_source, iobuf, (opcode == GOLAN_CQE_RESP_ERR));
1805  }
1806  return 0;
1807 }
uint16_t u16
Definition: stdint.h:21
#define EINVAL
Invalid argument.
Definition: errno.h:428
#define iob_put(iobuf, len)
Definition: iobuf.h:116
uint8_t opcode
Opcode.
Definition: ena.h:16
__be16 slid
Definition: CIB_PRM.h:877
#define DBGC(...)
Definition: compiler.h:505
static __always_inline void * ib_qp_get_drvdata(struct ib_queue_pair *qp)
Get Infiniband queue pair driver-private data.
Definition: infiniband.h:641
#define GOLAN_WQEBBS_PER_SEND_UD_WQE
Definition: golan.h:130
struct ib_global_route_header grh
Definition: ib_packet.h:16
__be16 wqe_counter
Definition: CIB_PRM.h:886
__be32 qpn
Definition: CIB_PRM.h:29
union ib_gid dgid
Destiniation GID.
Definition: ib_packet.h:106
__be32 flags_rqpn
Definition: CIB_PRM.h:878
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
u8 vendor_err_synd
Definition: CIB_PRM.h:865
Definition: golan.h:323
#define be32_to_cpu(value)
Definition: byteswap.h:116
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
An Infiniband Work Queue.
Definition: infiniband.h:100
__be32 sop_drop_qpn
Definition: CIB_PRM.h:885
void ib_complete_send(struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf, int rc)
Complete send work queue entry.
Definition: infiniband.c:515
#define be16_to_cpu(value)
Definition: byteswap.h:115
An Infiniband Global Route Header.
Definition: ib_packet.h:89
struct ib_work_queue * ib_find_wq(struct ib_completion_queue *cq, unsigned long qpn, int is_send)
Find work queue belonging to completion queue.
Definition: infiniband.c:396
unsigned int num_wqes
Number of work queue entries.
Definition: infiniband.h:112
union ib_gid sgid
Source GID.
Definition: ib_packet.h:104
#define GOLAN_CQE_OPCODE_BIT
Definition: golan.h:191
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
Definition: iobuf.h:171
unsigned char uint8_t
Definition: stdint.h:10
struct ib_queue_pair * qp
Containing queue pair.
Definition: infiniband.h:102
unsigned int uint32_t
Definition: stdint.h:12
struct ib_global_route_header * grh
GRH buffers (if applicable)
Definition: golan.h:166
An Infiniband Queue Pair.
Definition: infiniband.h:157
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
uint32_t len
Length.
Definition: ena.h:14
#define DBGC2(...)
Definition: compiler.h:522
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
void ib_complete_recv(struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *dest, struct ib_address_vector *source, struct io_buffer *iobuf, int rc)
Complete receive work queue entry.
Definition: infiniband.c:536
struct golan_recv_wq rq
Definition: golan.h:182
An Infiniband Address Vector.
Definition: infiniband.h:72
__be32 byte_cnt
Definition: CIB_PRM.h:883
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:32
struct io_buffer ** iobufs
I/O buffers assigned to work queue.
Definition: infiniband.h:124

References assert(), be16_to_cpu, be32_to_cpu, golan_cqe64::byte_cnt, ib_completion_queue::cqn, DBGC, DBGC2, ib_global_route_header::dgid, EINVAL, golan_cqe64::flags_rqpn, ib_address_vector::gid, ib_address_vector::gid_present, GOLAN_CQE_OPCODE_BIT, GOLAN_CQE_REQ, GOLAN_CQE_REQ_ERR, GOLAN_CQE_RESP_ERR, GOLAN_WQEBBS_PER_SEND_UD_WQE, grh, golan_recv_wq::grh, golan_err_cqe::hw_syndrom, ib_complete_recv(), ib_complete_send(), ib_find_wq(), ib_get_drvdata(), ib_qp_get_drvdata(), IB_QPT_ETH, IB_QPT_GSI, IB_QPT_RC, IB_QPT_SMI, IB_QPT_UD, iob_put, iob_tailroom(), ib_work_queue::iobufs, len, ib_address_vector::lid, memcpy(), memset(), NULL, ib_work_queue::num_wqes, golan_cqe64::op_own, opcode, qp, ib_work_queue::qp, qpn, ib_address_vector::qpn, golan_queue_pair::rq, ib_global_route_header::sgid, ib_address_vector::sl, golan_cqe64::slid, golan_cqe64::sop_drop_qpn, golan_err_cqe::syndrome, golan_err_cqe::vendor_err_synd, and golan_cqe64::wqe_counter.

Referenced by golan_poll_cq().

◆ golan_is_hw_ownership()

static int golan_is_hw_ownership ( struct ib_completion_queue cq,
struct golan_cqe64 cqe64 
)
static

Definition at line 1809 of file golan.c.

1811 {
1812  return ((cqe64->op_own & GOLAN_CQE_OWNER_MASK) !=
1813  ((cq->next_idx >> ilog2(cq->num_cqes)) & 1));
1814 }
static uint32_t ilog2(uint32_t mem)
Definition: golan.c:128
unsigned long next_idx
Next completion queue entry index.
Definition: infiniband.h:240
unsigned int num_cqes
Number of completion queue entries.
Definition: infiniband.h:232
#define GOLAN_CQE_OWNER_MASK
Definition: golan.h:193

References GOLAN_CQE_OWNER_MASK, ilog2(), ib_completion_queue::next_idx, ib_completion_queue::num_cqes, and golan_cqe64::op_own.

Referenced by golan_poll_cq().

◆ golan_poll_cq()

static void golan_poll_cq ( struct ib_device ibdev,
struct ib_completion_queue cq 
)
static

Definition at line 1815 of file golan.c.

1817 {
1818  unsigned int i;
1819  int rc = 0;
1820  unsigned int cqe_idx_mask;
1821  struct golan_cqe64 *cqe64;
1822  struct golan_completion_queue *golan_cq = ib_cq_get_drvdata(cq);
1823  struct golan *golan = ib_get_drvdata(ibdev);
1824 
1825  for (i = 0; i < cq->num_cqes; ++i) {
1826  /* Look for completion entry */
1827  cqe_idx_mask = (cq->num_cqes - 1);
1828  cqe64 = &golan_cq->cqes[cq->next_idx & cqe_idx_mask];
1829  /* temporary valid only for 64 byte CQE */
1830  if (golan_is_hw_ownership(cq, cqe64) ||
1831  ((cqe64->op_own >> GOLAN_CQE_OPCODE_BIT) ==
1833  break; /* HW ownership */
1834  }
1835 
1836  DBGC2( golan , "%s CQN 0x%lx [%ld] \n", __FUNCTION__, cq->cqn, cq->next_idx);
1837  /*
1838  * Make sure we read CQ entry contents after we've checked the
1839  * ownership bit. (PRM - 6.5.3.2)
1840  */
1841  rmb();
1842  rc = golan_complete(ibdev, cq, cqe64);
1843  if (rc != 0) {
1844  DBGC (golan ,"%s CQN 0x%lx failed to complete\n", __FUNCTION__, cq->cqn);
1845  }
1846 
1847  /* Update completion queue's index */
1848  cq->next_idx++;
1849 
1850  /* Update doorbell record */
1851  *(golan_cq->doorbell_record) = cpu_to_be32(cq->next_idx & 0xffffff);
1852  }
1853 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int golan_is_hw_ownership(struct ib_completion_queue *cq, struct golan_cqe64 *cqe64)
Definition: golan.c:1809
#define DBGC(...)
Definition: compiler.h:505
#define rmb()
Definition: io.h:484
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:707
Definition: golan.h:323
static int golan_complete(struct ib_device *ibdev, struct ib_completion_queue *cq, struct golan_cqe64 *cqe64)
Definition: golan.c:1690
#define GOLAN_CQE_OPCODE_NOT_VALID
Definition: golan.h:190
#define GOLAN_CQE_OPCODE_BIT
Definition: golan.h:191
unsigned long next_idx
Next completion queue entry index.
Definition: infiniband.h:240
#define cpu_to_be32(value)
Definition: byteswap.h:110
__be64 * doorbell_record
Definition: golan.h:211
#define DBGC2(...)
Definition: compiler.h:522
struct golan_cqe64 * cqes
Definition: golan.h:209
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
unsigned int num_cqes
Number of completion queue entries.
Definition: infiniband.h:232
static __always_inline void * ib_cq_get_drvdata(struct ib_completion_queue *cq)
Get Infiniband completion queue driver-private data.
Definition: infiniband.h:685

References cpu_to_be32, golan_completion_queue::cqes, ib_completion_queue::cqn, DBGC, DBGC2, golan_completion_queue::doorbell_record, golan_complete(), GOLAN_CQE_OPCODE_BIT, GOLAN_CQE_OPCODE_NOT_VALID, golan_is_hw_ownership(), ib_cq_get_drvdata(), ib_get_drvdata(), ib_completion_queue::next_idx, ib_completion_queue::num_cqes, golan_cqe64::op_own, rc, and rmb.

◆ golan_eqe_type_str()

static const char* golan_eqe_type_str ( u8  type)
static

Definition at line 1855 of file golan.c.

1856 {
1857  switch (type) {
1858  case GOLAN_EVENT_TYPE_COMP:
1859  return "GOLAN_EVENT_TYPE_COMP";
1861  return "GOLAN_EVENT_TYPE_PATH_MIG";
1863  return "GOLAN_EVENT_TYPE_COMM_EST";
1865  return "GOLAN_EVENT_TYPE_SQ_DRAINED";
1867  return "GOLAN_EVENT_TYPE_SRQ_LAST_WQE";
1869  return "GOLAN_EVENT_TYPE_SRQ_RQ_LIMIT";
1871  return "GOLAN_EVENT_TYPE_CQ_ERROR";
1873  return "GOLAN_EVENT_TYPE_WQ_CATAS_ERROR";
1875  return "GOLAN_EVENT_TYPE_PATH_MIG_FAILED";
1877  return "GOLAN_EVENT_TYPE_WQ_INVAL_REQ_ERROR";
1879  return "GOLAN_EVENT_TYPE_WQ_ACCESS_ERROR";
1881  return "GOLAN_EVENT_TYPE_SRQ_CATAS_ERROR";
1883  return "GOLAN_EVENT_TYPE_INTERNAL_ERROR";
1885  return "GOLAN_EVENT_TYPE_PORT_CHANGE";
1887  return "GOLAN_EVENT_TYPE_GPIO_EVENT";
1889  return "GOLAN_EVENT_TYPE_REMOTE_CONFIG";
1891  return "GOLAN_EVENT_TYPE_DB_BF_CONGESTION";
1893  return "GOLAN_EVENT_TYPE_STALL_EVENT";
1894  case GOLAN_EVENT_TYPE_CMD:
1895  return "GOLAN_EVENT_TYPE_CMD";
1897  return "GOLAN_EVENT_TYPE_PAGE_REQUEST";
1898  default:
1899  return "Unrecognized event";
1900  }
1901 }
uint8_t type
Type.
Definition: ena.h:16

References GOLAN_EVENT_TYPE_CMD, GOLAN_EVENT_TYPE_COMM_EST, GOLAN_EVENT_TYPE_COMP, GOLAN_EVENT_TYPE_CQ_ERROR, GOLAN_EVENT_TYPE_DB_BF_CONGESTION, GOLAN_EVENT_TYPE_GPIO_EVENT, GOLAN_EVENT_TYPE_INTERNAL_ERROR, GOLAN_EVENT_TYPE_PAGE_REQUEST, GOLAN_EVENT_TYPE_PATH_MIG, GOLAN_EVENT_TYPE_PATH_MIG_FAILED, GOLAN_EVENT_TYPE_PORT_CHANGE, GOLAN_EVENT_TYPE_REMOTE_CONFIG, GOLAN_EVENT_TYPE_SQ_DRAINED, GOLAN_EVENT_TYPE_SRQ_CATAS_ERROR, GOLAN_EVENT_TYPE_SRQ_LAST_WQE, GOLAN_EVENT_TYPE_SRQ_RQ_LIMIT, GOLAN_EVENT_TYPE_STALL_EVENT, GOLAN_EVENT_TYPE_WQ_ACCESS_ERROR, GOLAN_EVENT_TYPE_WQ_CATAS_ERROR, GOLAN_EVENT_TYPE_WQ_INVAL_REQ_ERROR, and type.

Referenced by golan_handle_port_event(), and golan_poll_eq().

◆ golan_eqe_port_subtype_str()

static const char* golan_eqe_port_subtype_str ( u8  subtype)
static

Definition at line 1903 of file golan.c.

1904 {
1905  switch (subtype) {
1907  return "GOLAN_PORT_CHANGE_SUBTYPE_DOWN";
1909  return "GOLAN_PORT_CHANGE_SUBTYPE_ACTIVE";
1911  return "GOLAN_PORT_CHANGE_SUBTYPE_INITIALIZED";
1913  return "GOLAN_PORT_CHANGE_SUBTYPE_LID";
1915  return "GOLAN_PORT_CHANGE_SUBTYPE_PKEY";
1917  return "GOLAN_PORT_CHANGE_SUBTYPE_GUID";
1919  return "GOLAN_PORT_CHANGE_SUBTYPE_CLIENT_REREG";
1920  default:
1921  return "Unrecognized event";
1922  }
1923 }
uint8_t subtype
Slow protocols subtype.
Definition: eth_slow.h:12

References GOLAN_PORT_CHANGE_SUBTYPE_ACTIVE, GOLAN_PORT_CHANGE_SUBTYPE_CLIENT_REREG, GOLAN_PORT_CHANGE_SUBTYPE_DOWN, GOLAN_PORT_CHANGE_SUBTYPE_GUID, GOLAN_PORT_CHANGE_SUBTYPE_INITIALIZED, GOLAN_PORT_CHANGE_SUBTYPE_LID, GOLAN_PORT_CHANGE_SUBTYPE_PKEY, and subtype.

Referenced by golan_handle_port_event().

◆ golan_ib_update()

static int golan_ib_update ( struct ib_device ibdev)
static

Update Infiniband parameters using Commands.

Parameters
ibdevInfiniband device
Return values
rcReturn status code

Definition at line 1931 of file golan.c.

1931  {
1932  int rc;
1933 
1934  /* Get IB parameters */
1935  if ( ( rc = golan_get_ib_info ( ibdev ) ) != 0 )
1936  return rc;
1937 
1938  /* Notify Infiniband core of potential link state change */
1939  ib_link_state_changed ( ibdev );
1940 
1941  return 0;
1942 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int golan_get_ib_info(struct ib_device *ibdev)
Definition: golan.c:1662
void ib_link_state_changed(struct ib_device *ibdev)
Notify of Infiniband link state change.
Definition: infiniband.c:637

References golan_get_ib_info(), ib_link_state_changed(), and rc.

Referenced by golan_handle_port_event(), and golan_ib_open().

◆ golan_handle_port_event()

static void golan_handle_port_event ( struct golan golan,
struct golan_eqe eqe 
)
inlinestatic

Definition at line 1944 of file golan.c.

1945 {
1946  struct ib_device *ibdev;
1947  u8 port;
1948 
1949  port = (eqe->data.port.port >> 4) & 0xf;
1950  ibdev = golan->ports[port - 1].ibdev;
1951 
1952  if ( ! ib_is_open ( ibdev ) )
1953  return;
1954 
1955  switch (eqe->sub_type) {
1958  golan_ib_update ( ibdev );
1959  /* Fall through */
1965  DBGC( golan , "%s event %s(%d) (sub event %s(%d))arrived on port %d\n",
1966  __FUNCTION__, golan_eqe_type_str(eqe->type), eqe->type,
1968  eqe->sub_type, port);
1969  break;
1970  default:
1971  DBGC (golan ,"%s Port event with unrecognized subtype: port %d, sub_type %d\n",
1972  __FUNCTION__, port, eqe->sub_type);
1973  }
1974 }
static int ib_is_open(struct ib_device *ibdev)
Check whether or not Infiniband device is open.
Definition: infiniband.h:575
#define DBGC(...)
Definition: compiler.h:505
An Infiniband device.
Definition: infiniband.h:398
u8 port
Port number.
Definition: CIB_PRM.h:31
Definition: golan.h:323
struct golan_port ports[GOLAN_MAX_PORTS]
Definition: golan.h:339
u8 sub_type
Definition: CIB_PRM.h:695
u8 type
Definition: CIB_PRM.h:693
static const char * golan_eqe_type_str(u8 type)
Definition: golan.c:1855
struct ib_device * ibdev
Infiniband device.
Definition: golan.h:309
union ev_data data
Definition: CIB_PRM.h:697
static const char * golan_eqe_port_subtype_str(u8 subtype)
Definition: golan.c:1903
struct golan_eqe_port_state port
Definition: CIB_PRM.h:684
static int golan_ib_update(struct ib_device *ibdev)
Update Infiniband parameters using Commands.
Definition: golan.c:1931
uint8_t u8
Definition: stdint.h:19

References golan_eqe::data, DBGC, golan_eqe_port_subtype_str(), golan_eqe_type_str(), golan_ib_update(), GOLAN_PORT_CHANGE_SUBTYPE_ACTIVE, GOLAN_PORT_CHANGE_SUBTYPE_CLIENT_REREG, GOLAN_PORT_CHANGE_SUBTYPE_DOWN, GOLAN_PORT_CHANGE_SUBTYPE_GUID, GOLAN_PORT_CHANGE_SUBTYPE_INITIALIZED, GOLAN_PORT_CHANGE_SUBTYPE_LID, GOLAN_PORT_CHANGE_SUBTYPE_PKEY, ib_is_open(), golan_port::ibdev, port, golan_eqe_port_state::port, ev_data::port, golan::ports, golan_eqe::sub_type, and golan_eqe::type.

Referenced by golan_poll_eq().

◆ golan_next_eqe_sw()

static struct golan_eqe* golan_next_eqe_sw ( struct golan_event_queue eq)