iPXE
Data Structures | Macros | Functions | Variables
linda.c File Reference

QLogic Linda Infiniband HCA. More...

#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <assert.h>
#include <ipxe/io.h>
#include <ipxe/pci.h>
#include <ipxe/infiniband.h>
#include <ipxe/i2c.h>
#include <ipxe/bitbash.h>
#include <ipxe/malloc.h>
#include <ipxe/iobuf.h>
#include "linda.h"

Go to the source code of this file.

Data Structures

struct  linda_send_work_queue
 A Linda send work queue. More...
 
struct  linda_recv_work_queue
 A Linda receive work queue. More...
 
struct  linda
 A Linda HCA. More...
 
struct  linda_serdes_param
 A Linda SerDes parameter. More...
 

Macros

#define linda_readq(_linda, _ptr, _offset)   linda_readq ( (_linda), (_ptr)->u.qwords, (_offset) )
 
#define linda_readq_array8b(_linda, _ptr, _offset, _idx)   linda_readq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 8 ) ) )
 
#define linda_readq_array64k(_linda, _ptr, _offset, _idx)   linda_readq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 65536 ) ) )
 
#define linda_writeq(_linda, _ptr, _offset)   linda_writeq ( (_linda), (_ptr)->u.qwords, (_offset) )
 
#define linda_writeq_array8b(_linda, _ptr, _offset, _idx)   linda_writeq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 8 ) ) )
 
#define linda_writeq_array64k(_linda, _ptr, _offset, _idx)   linda_writeq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 65536 ) ) )
 
#define LINDA_SEND_BUF_TOGGLE   0x80
 Send buffer toggle bit. More...
 
#define LINDA_EPB_ALL_CHANNELS   31
 Magic "all channels" channel number. More...
 
#define LINDA_SERDES_PARAM_END   { 0, 0, 0 }
 End of SerDes parameter list marker. More...
 
#define LINDA_DDS_VAL(amp_d, main_d, ipst_d, ipre_d, amp_s, main_s, ipst_s, ipre_s)
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static void linda_readq (struct linda *linda, uint64_t *qword, unsigned long offset)
 Read Linda qword register. More...
 
static void linda_writeq (struct linda *linda, const uint64_t *qword, unsigned long offset)
 Write Linda qword register. More...
 
static void linda_writel (struct linda *linda, uint32_t dword, unsigned long offset)
 Write Linda dword register. More...
 
static const char * linda_link_state_text (unsigned int link_state)
 Textual representation of link state. More...
 
static void linda_link_state_changed (struct ib_device *ibdev)
 Handle link state change. More...
 
static int linda_link_state_check (struct linda *linda, unsigned int new_link_state)
 Wait for link state change to take effect. More...
 
static int linda_set_port_info (struct ib_device *ibdev, union ib_mad *mad)
 Set port information. More...
 
static int linda_set_pkey_table (struct ib_device *ibdev __unused, union ib_mad *mad __unused)
 Set partition key table. More...
 
static int linda_ctx_to_qpn (unsigned int ctx)
 Map context number to QPN. More...
 
static int linda_qpn_to_ctx (unsigned int qpn)
 Map QPN to context number. More...
 
static int linda_alloc_ctx (struct linda *linda)
 Allocate a context. More...
 
static void linda_free_ctx (struct linda *linda, unsigned int ctx)
 Free a context. More...
 
static unsigned int linda_alloc_send_buf (struct linda *linda)
 Allocate a send buffer. More...
 
static void linda_free_send_buf (struct linda *linda, unsigned int send_buf)
 Free a send buffer. More...
 
static int linda_send_buf_in_use (struct linda *linda, unsigned int send_buf)
 Check to see if send buffer is in use. More...
 
static unsigned long linda_send_buffer_offset (struct linda *linda, unsigned int send_buf)
 Calculate starting offset for send buffer. More...
 
static int linda_create_send_wq (struct linda *linda, struct ib_queue_pair *qp)
 Create send work queue. More...
 
static void linda_destroy_send_wq (struct linda *linda, struct ib_queue_pair *qp)
 Destroy send work queue. More...
 
static int linda_init_send (struct linda *linda)
 Initialise send datapath. More...
 
static void linda_fini_send (struct linda *linda)
 Shut down send datapath. More...
 
static int linda_create_recv_wq (struct linda *linda, struct ib_queue_pair *qp)
 Create receive work queue. More...
 
static void linda_destroy_recv_wq (struct linda *linda, struct ib_queue_pair *qp)
 Destroy receive work queue. More...
 
static int linda_init_recv (struct linda *linda)
 Initialise receive datapath. More...
 
static void linda_fini_recv (struct linda *linda __unused)
 Shut down receive datapath. More...
 
static int linda_create_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 Create completion queue. More...
 
static void linda_destroy_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 Destroy completion queue. More...
 
static int linda_create_qp (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Create queue pair. More...
 
static int linda_modify_qp (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Modify queue pair. More...
 
static void linda_destroy_qp (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Destroy queue pair. More...
 
static int linda_post_send (struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *dest, struct io_buffer *iobuf)
 Post send work queue entry. More...
 
static void linda_complete_send (struct ib_device *ibdev, struct ib_queue_pair *qp, unsigned int wqe_idx)
 Complete send work queue entry. More...
 
static void linda_poll_send_wq (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Poll send work queue. More...
 
static int linda_post_recv (struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf)
 Post receive work queue entry. More...
 
static void linda_complete_recv (struct ib_device *ibdev, struct ib_queue_pair *qp, unsigned int header_offs)
 Complete receive work queue entry. More...
 
static void linda_poll_recv_wq (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Poll receive work queue. More...
 
static void linda_poll_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 Poll completion queue. More...
 
static void linda_poll_eq (struct ib_device *ibdev)
 Poll event queue. More...
 
static int linda_open (struct ib_device *ibdev)
 Initialise Infiniband link. More...
 
static void linda_close (struct ib_device *ibdev)
 Close Infiniband link. More...
 
static int linda_mcast_attach (struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
 Attach to multicast group. More...
 
static void linda_mcast_detach (struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
 Detach from multicast group. More...
 
static int linda_i2c_read_bit (struct bit_basher *basher, unsigned int bit_id)
 Read Linda I2C line status. More...
 
static void linda_i2c_write_bit (struct bit_basher *basher, unsigned int bit_id, unsigned long data)
 Write Linda I2C line status. More...
 
static int linda_init_i2c (struct linda *linda)
 Initialise Linda I2C subsystem. More...
 
static int linda_read_eeprom (struct linda *linda, union ib_guid *guid)
 Read EEPROM parameters. More...
 
static int linda_ib_epb_request (struct linda *linda)
 Request ownership of the IB external parallel bus. More...
 
static int linda_ib_epb_wait (struct linda *linda, struct QIB_7220_ibsd_epb_transaction_reg *xact)
 Wait for IB external parallel bus transaction to complete. More...
 
static void linda_ib_epb_release (struct linda *linda)
 Release ownership of the IB external parallel bus. More...
 
static int linda_ib_epb_read (struct linda *linda, unsigned int location)
 Read data via IB external parallel bus. More...
 
static int linda_ib_epb_write (struct linda *linda, unsigned int location, unsigned int data)
 Write data via IB external parallel bus. More...
 
static int linda_ib_epb_mod_reg (struct linda *linda, unsigned int cs, unsigned int channel, unsigned int element, unsigned int reg, unsigned int value, unsigned int mask)
 Read/modify/write EPB register. More...
 
static int linda_ib_epb_ram_xfer (struct linda *linda, unsigned int address, const void *write, void *read, size_t len)
 Transfer data to/from microcontroller RAM. More...
 
static int linda_set_serdes_param (struct linda *linda, struct linda_serdes_param *param)
 Program IB SerDes register(s) More...
 
static int linda_set_serdes_params (struct linda *linda, struct linda_serdes_param *params)
 Program IB SerDes registers. More...
 
static int linda_program_uc_ram (struct linda *linda)
 Program the microcontroller RAM. More...
 
static int linda_verify_uc_ram (struct linda *linda)
 Verify the microcontroller RAM. More...
 
static int linda_trim_ib (struct linda *linda)
 Use the microcontroller to trim the IB link. More...
 
static int linda_init_ib_serdes (struct linda *linda)
 Initialise the IB SerDes. More...
 
static int linda_probe (struct pci_device *pci)
 Probe PCI device. More...
 
static void linda_remove (struct pci_device *pci)
 Remove PCI device. More...
 

Variables

static struct ib_device_operations linda_ib_operations
 Linda Infiniband operations. More...
 
static unsigned int linda_i2c_bits []
 Linda I2C bit to GPIO mappings. More...
 
static struct bit_basher_operations linda_i2c_basher_ops
 Linda I2C bit-bashing interface operations. More...
 
struct linda_serdes_param __packed
 
static struct linda_serdes_param linda_serdes_defaults1 []
 Linda SerDes default parameters. More...
 
static struct linda_serdes_param linda_serdes_defaults2 []
 
static struct linda_serdes_param linda_serdes_defaults3 []
 
static struct pci_device_id linda_nics []
 
struct pci_driver linda_driver __pci_driver
 

Detailed Description

QLogic Linda Infiniband HCA.

Definition in file linda.c.

Macro Definition Documentation

◆ linda_readq

#define linda_readq (   _linda,
  _ptr,
  _offset 
)    linda_readq ( (_linda), (_ptr)->u.qwords, (_offset) )

Definition at line 128 of file linda.c.

◆ linda_readq_array8b

#define linda_readq_array8b (   _linda,
  _ptr,
  _offset,
  _idx 
)    linda_readq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 8 ) ) )

Definition at line 130 of file linda.c.

◆ linda_readq_array64k

#define linda_readq_array64k (   _linda,
  _ptr,
  _offset,
  _idx 
)    linda_readq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 65536 ) ) )

Definition at line 132 of file linda.c.

◆ linda_writeq

#define linda_writeq (   _linda,
  _ptr,
  _offset 
)    linda_writeq ( (_linda), (_ptr)->u.qwords, (_offset) )

Definition at line 146 of file linda.c.

◆ linda_writeq_array8b

#define linda_writeq_array8b (   _linda,
  _ptr,
  _offset,
  _idx 
)    linda_writeq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 8 ) ) )

Definition at line 148 of file linda.c.

◆ linda_writeq_array64k

#define linda_writeq_array64k (   _linda,
  _ptr,
  _offset,
  _idx 
)    linda_writeq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 65536 ) ) )

Definition at line 150 of file linda.c.

◆ LINDA_SEND_BUF_TOGGLE

#define LINDA_SEND_BUF_TOGGLE   0x80

Send buffer toggle bit.

We encode send buffers as 7 bits of send buffer index plus a single bit which should match the "check" bit in the SendBufAvail array.

Definition at line 378 of file linda.c.

◆ LINDA_EPB_ALL_CHANNELS

#define LINDA_EPB_ALL_CHANNELS   31

Magic "all channels" channel number.

Definition at line 1985 of file linda.c.

◆ LINDA_SERDES_PARAM_END

#define LINDA_SERDES_PARAM_END   { 0, 0, 0 }

End of SerDes parameter list marker.

Definition at line 1988 of file linda.c.

◆ LINDA_DDS_VAL

#define LINDA_DDS_VAL (   amp_d,
  main_d,
  ipst_d,
  ipre_d,
  amp_s,
  main_s,
  ipst_s,
  ipre_s 
)
Value:
( ( ( amp_d & 0x1f ) << 1 ) | 1 ), 0xff }, \
( ( ( amp_s & 0x1f ) << 1 ) | 1 ), 0xff }, \
( ( main_d << 3 ) | 4 | ( ipre_d >> 2 ) ), 0xff }, \
( ( main_s << 3 ) | 4 | ( ipre_s >> 2 ) ), 0xff }, \
( ( ( ipst_d & 0xf ) << 1 ) | \
( ( ipre_d & 3 ) << 6 ) | 0x21 ), 0xff }, \
( ( ( ipst_s & 0xf ) << 1 ) | \
( ( ipre_s & 3 ) << 6) | 0x21 ), 0xff }
#define LINDA_EPB_ADDRESS(_channel, _element, _reg)
Linda external parallel bus register addresses.
Definition: linda.h:236
#define LINDA_EPB_ALL_CHANNELS
Magic "all channels" channel number.
Definition: linda.c:1985

Definition at line 2050 of file linda.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ linda_readq()

static void linda_readq ( struct linda linda,
uint64_t qword,
unsigned long  offset 
)
static

Read Linda qword register.

Parameters
lindaLinda device
qwordRegister buffer to read into
offsetRegister offset

Definition at line 124 of file linda.c.

125  {
126  *qword = readq ( linda->regs + offset );
127 }
A Linda HCA.
Definition: linda.c:76
uint64_t readq(volatile uint64_t *io_addr)
Read 64-bit qword from memory-mapped device.
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
void * regs
Registers.
Definition: linda.c:78

References offset, readq(), and linda::regs.

◆ linda_writeq()

static void linda_writeq ( struct linda linda,
const uint64_t qword,
unsigned long  offset 
)
static

Write Linda qword register.

Parameters
lindaLinda device
qwordRegister buffer to write
offsetRegister offset

Definition at line 142 of file linda.c.

143  {
144  writeq ( *qword, ( linda->regs + offset ) );
145 }
A Linda HCA.
Definition: linda.c:76
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
void * regs
Registers.
Definition: linda.c:78
void writeq(uint64_t data, volatile uint64_t *io_addr)
Write 64-bit qword to memory-mapped device.

References offset, linda::regs, and writeq().

◆ linda_writel()

static void linda_writel ( struct linda linda,
uint32_t  dword,
unsigned long  offset 
)
static

Write Linda dword register.

Parameters
lindaLinda device
dwordValue to write
offsetRegister offset

Definition at line 160 of file linda.c.

161  {
162  writel ( dword, ( linda->regs + offset ) );
163 }
A Linda HCA.
Definition: linda.c:76
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
void * regs
Registers.
Definition: linda.c:78
unsigned long int dword
Definition: smc9000.h:40

References offset, linda::regs, and writel().

Referenced by linda_post_send().

◆ linda_link_state_text()

static const char* linda_link_state_text ( unsigned int  link_state)
static

Textual representation of link state.

Parameters
link_stateLink state
Return values
link_textLink state text

Definition at line 178 of file linda.c.

178  {
179  switch ( link_state ) {
180  case LINDA_LINK_STATE_DOWN: return "DOWN";
181  case LINDA_LINK_STATE_INIT: return "INIT";
182  case LINDA_LINK_STATE_ARM: return "ARM";
183  case LINDA_LINK_STATE_ACTIVE: return "ACTIVE";
184  case LINDA_LINK_STATE_ACT_DEFER:return "ACT_DEFER";
185  default: return "UNKNOWN";
186  }
187 }

References LINDA_LINK_STATE_ACT_DEFER, LINDA_LINK_STATE_ACTIVE, LINDA_LINK_STATE_ARM, LINDA_LINK_STATE_DOWN, and LINDA_LINK_STATE_INIT.

Referenced by linda_link_state_changed(), linda_link_state_check(), and linda_set_port_info().

◆ linda_link_state_changed()

static void linda_link_state_changed ( struct ib_device ibdev)
static

Handle link state change.

Parameters
lindaLinda device

Definition at line 194 of file linda.c.

194  {
195  struct linda *linda = ib_get_drvdata ( ibdev );
196  struct QIB_7220_IBCStatus ibcstatus;
197  struct QIB_7220_EXTCtrl extctrl;
198  unsigned int link_state;
199  unsigned int link_width;
200  unsigned int link_speed;
201 
202  /* Read link state */
204  link_state = BIT_GET ( &ibcstatus, LinkState );
205  link_width = BIT_GET ( &ibcstatus, LinkWidthActive );
206  link_speed = BIT_GET ( &ibcstatus, LinkSpeedActive );
207  DBGC ( linda, "Linda %p link state %s (%s %s)\n", linda,
208  linda_link_state_text ( link_state ),
209  ( link_speed ? "DDR" : "SDR" ), ( link_width ? "x4" : "x1" ) );
210 
211  /* Set LEDs according to link state */
213  BIT_SET ( &extctrl, LEDPriPortGreenOn,
214  ( ( link_state >= LINDA_LINK_STATE_INIT ) ? 1 : 0 ) );
215  BIT_SET ( &extctrl, LEDPriPortYellowOn,
216  ( ( link_state >= LINDA_LINK_STATE_ACTIVE ) ? 1 : 0 ) );
218 
219  /* Notify Infiniband core of link state change */
220  ibdev->port_state = ( link_state + 1 );
221  ibdev->link_width_active =
222  ( link_width ? IB_LINK_WIDTH_4X : IB_LINK_WIDTH_1X );
223  ibdev->link_speed_active =
224  ( link_speed ? IB_LINK_SPEED_DDR : IB_LINK_SPEED_SDR );
225  ib_link_state_changed ( ibdev );
226 }
A Linda HCA.
Definition: linda.c:76
#define QIB_7220_EXTCtrl_offset
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
#define DBGC(...)
Definition: compiler.h:505
#define IB_LINK_SPEED_SDR
Definition: ib_mad.h:144
#define BIT_SET(_ptr, _field, _value)
Definition: pseudobit.h:238
void ib_link_state_changed(struct ib_device *ibdev)
Notify of Infiniband link state change.
Definition: infiniband.c:637
static const char * linda_link_state_text(unsigned int link_state)
Textual representation of link state.
Definition: linda.c:178
#define IB_LINK_WIDTH_4X
Definition: ib_mad.h:140
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
#define BIT_GET(_ptr, _field)
Extract value of named field (for fields up to the size of a long)
Definition: pseudobit.h:235
uint8_t link_width_active
Link width active.
Definition: infiniband.h:431
#define IB_LINK_WIDTH_1X
Definition: ib_mad.h:139
uint8_t link_speed_active
Link speed active.
Definition: infiniband.h:437
#define IB_LINK_SPEED_DDR
Definition: ib_mad.h:145
uint8_t port_state
Port state.
Definition: infiniband.h:425
#define QIB_7220_IBCStatus_offset

References BIT_GET, BIT_SET, DBGC, ib_get_drvdata(), IB_LINK_SPEED_DDR, IB_LINK_SPEED_SDR, ib_link_state_changed(), IB_LINK_WIDTH_1X, IB_LINK_WIDTH_4X, LINDA_LINK_STATE_ACTIVE, LINDA_LINK_STATE_INIT, linda_link_state_text(), linda_readq, linda_writeq, ib_device::link_speed_active, ib_device::link_width_active, ib_device::port_state, QIB_7220_EXTCtrl_offset, and QIB_7220_IBCStatus_offset.

Referenced by linda_poll_eq(), and linda_set_port_info().

◆ linda_link_state_check()

static int linda_link_state_check ( struct linda linda,
unsigned int  new_link_state 
)
static

Wait for link state change to take effect.

Parameters
lindaLinda device
new_link_stateExpected link state
Return values
rcReturn status code

Definition at line 235 of file linda.c.

236  {
237  struct QIB_7220_IBCStatus ibcstatus;
238  unsigned int link_state;
239  unsigned int i;
240 
241  for ( i = 0 ; i < LINDA_LINK_STATE_MAX_WAIT_US ; i++ ) {
243  link_state = BIT_GET ( &ibcstatus, LinkState );
244  if ( link_state == new_link_state )
245  return 0;
246  udelay ( 1 );
247  }
248 
249  DBGC ( linda, "Linda %p timed out waiting for link state %s\n",
250  linda, linda_link_state_text ( link_state ) );
251  return -ETIMEDOUT;
252 }
A Linda HCA.
Definition: linda.c:76
#define LINDA_LINK_STATE_MAX_WAIT_US
Maximum time to wait for link state changes, in us.
Definition: linda.h:279
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
#define DBGC(...)
Definition: compiler.h:505
static const char * linda_link_state_text(unsigned int link_state)
Textual representation of link state.
Definition: linda.c:178
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define BIT_GET(_ptr, _field)
Extract value of named field (for fields up to the size of a long)
Definition: pseudobit.h:235
#define QIB_7220_IBCStatus_offset
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669

References BIT_GET, DBGC, ETIMEDOUT, LINDA_LINK_STATE_MAX_WAIT_US, linda_link_state_text(), linda_readq, QIB_7220_IBCStatus_offset, and udelay().

Referenced by linda_set_port_info().

◆ linda_set_port_info()

static int linda_set_port_info ( struct ib_device ibdev,
union ib_mad mad 
)
static

Set port information.

Parameters
ibdevInfiniband device
madSet port information MAD

Definition at line 260 of file linda.c.

260  {
261  struct linda *linda = ib_get_drvdata ( ibdev );
263  struct QIB_7220_IBCCtrl ibcctrl;
264  unsigned int port_state;
265  unsigned int link_state;
266 
267  /* Set new link state */
269  if ( port_state ) {
270  link_state = ( port_state - 1 );
271  DBGC ( linda, "Linda %p set link state to %s (%x)\n", linda,
272  linda_link_state_text ( link_state ), link_state );
274  BIT_SET ( &ibcctrl, LinkCmd, link_state );
276 
277  /* Wait for link state change to take effect. Ignore
278  * errors; the current link state will be returned via
279  * the GetResponse MAD.
280  */
281  linda_link_state_check ( linda, link_state );
282  }
283 
284  /* Detect and report link state change */
285  linda_link_state_changed ( ibdev );
286 
287  return 0;
288 }
A Linda HCA.
Definition: linda.c:76
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
static void linda_link_state_changed(struct ib_device *ibdev)
Handle link state change.
Definition: linda.c:194
#define DBGC(...)
Definition: compiler.h:505
union ib_smp_data smp_data
Definition: ib_mad.h:590
#define BIT_SET(_ptr, _field, _value)
Definition: pseudobit.h:238
static const char * linda_link_state_text(unsigned int link_state)
Textual representation of link state.
Definition: linda.c:178
struct ib_port_info port_info
Definition: ib_mad.h:14
struct ib_port_info port_info
Definition: ib_mad.h:184
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
static int linda_link_state_check(struct linda *linda, unsigned int new_link_state)
Wait for link state change to take effect.
Definition: linda.c:235
uint8_t link_speed_supported__port_state
Definition: ib_mad.h:116
struct ib_mad_smp smp
Definition: ib_mad.h:612
u8 port_state
Definition: CIB_PRM.h:38
#define QIB_7220_IBCCtrl_offset
A Port Information attribute.
Definition: ib_mad.h:104
union ib_mad mad
Definition: arbel.h:12

References BIT_SET, DBGC, ib_get_drvdata(), linda_link_state_changed(), linda_link_state_check(), linda_link_state_text(), linda_readq, linda_writeq, ib_port_info::link_speed_supported__port_state, mad, ib_smp_data::port_info, port_info, port_state, QIB_7220_IBCCtrl_offset, ib_mad::smp, and ib_mad_smp::smp_data.

◆ linda_set_pkey_table()

static int linda_set_pkey_table ( struct ib_device *ibdev  __unused,
union ib_mad *mad  __unused 
)
static

Set partition key table.

Parameters
ibdevInfiniband device
madSet partition key table MAD

Definition at line 296 of file linda.c.

297  {
298  /* Nothing to do */
299  return 0;
300 }

◆ linda_ctx_to_qpn()

static int linda_ctx_to_qpn ( unsigned int  ctx)
static

Map context number to QPN.

Parameters
ctxContext index
Return values
qpnQueue pair number

Definition at line 315 of file linda.c.

315  {
316  /* This mapping is fixed by hardware */
317  return ( ctx * 2 );
318 }
struct golan_eq_context ctx
Definition: CIB_PRM.h:28

References ctx.

Referenced by linda_create_qp().

◆ linda_qpn_to_ctx()

static int linda_qpn_to_ctx ( unsigned int  qpn)
static

Map QPN to context number.

Parameters
qpnQueue pair number
Return values
ctxContext index

Definition at line 326 of file linda.c.

326  {
327  /* This mapping is fixed by hardware */
328  return ( qpn / 2 );
329 }
__be32 qpn
Definition: CIB_PRM.h:29

References qpn.

Referenced by linda_create_recv_wq(), linda_destroy_recv_wq(), linda_poll_recv_wq(), and linda_post_recv().

◆ linda_alloc_ctx()

static int linda_alloc_ctx ( struct linda linda)
static

Allocate a context.

Parameters
lindaLinda device
Return values
ctxContext index, or negative error

Definition at line 337 of file linda.c.

337  {
338  unsigned int ctx;
339 
340  for ( ctx = 0 ; ctx < LINDA_NUM_CONTEXTS ; ctx++ ) {
341 
342  if ( ! linda->used_ctx[ctx] ) {
343  linda->used_ctx[ctx ] = 1;
344  DBGC2 ( linda, "Linda %p CTX %d allocated\n",
345  linda, ctx );
346  return ctx;
347  }
348  }
349 
350  DBGC ( linda, "Linda %p out of available contexts\n", linda );
351  return -ENOENT;
352 }
A Linda HCA.
Definition: linda.c:76
#define DBGC(...)
Definition: compiler.h:505
#define ENOENT
No such file or directory.
Definition: errno.h:514
uint8_t used_ctx[LINDA_NUM_CONTEXTS]
In-use contexts.
Definition: linda.c:81
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define DBGC2(...)
Definition: compiler.h:522
#define LINDA_NUM_CONTEXTS
Number of contexts (including kernel context)
Definition: linda.h:158

References ctx, DBGC, DBGC2, ENOENT, LINDA_NUM_CONTEXTS, and linda::used_ctx.

Referenced by linda_create_qp().

◆ linda_free_ctx()

static void linda_free_ctx ( struct linda linda,
unsigned int  ctx 
)
static

Free a context.

Parameters
lindaLinda device
ctxContext index

Definition at line 360 of file linda.c.

360  {
361 
362  linda->used_ctx[ctx] = 0;
363  DBGC2 ( linda, "Linda %p CTX %d freed\n", linda, ctx );
364 }
A Linda HCA.
Definition: linda.c:76
uint8_t used_ctx[LINDA_NUM_CONTEXTS]
In-use contexts.
Definition: linda.c:81
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define DBGC2(...)
Definition: compiler.h:522

References ctx, DBGC2, and linda::used_ctx.

Referenced by linda_create_qp(), and linda_destroy_recv_wq().

◆ linda_alloc_send_buf()

static unsigned int linda_alloc_send_buf ( struct linda linda)
static

Allocate a send buffer.

Parameters
lindaLinda device
Return values
send_bufSend buffer

You must guarantee that a send buffer is available. This is done by refusing to allocate more TX WQEs in total than the number of available send buffers.

Definition at line 390 of file linda.c.

390  {
391  unsigned int send_buf;
392 
393  send_buf = linda->send_buf[linda->send_buf_cons];
394  send_buf ^= LINDA_SEND_BUF_TOGGLE;
395  linda->send_buf_cons = ( ( linda->send_buf_cons + 1 ) %
397  return send_buf;
398 }
A Linda HCA.
Definition: linda.c:76
uint8_t send_buf[LINDA_MAX_SEND_BUFS]
Send buffer availability (maintained by software)
Definition: linda.c:92
#define LINDA_SEND_BUF_TOGGLE
Send buffer toggle bit.
Definition: linda.c:378
#define LINDA_MAX_SEND_BUFS
Maximum number of send buffers used.
Definition: linda.h:149
unsigned int send_buf_cons
Send buffer availability consumer counter.
Definition: linda.c:96

References LINDA_MAX_SEND_BUFS, LINDA_SEND_BUF_TOGGLE, linda::send_buf, and linda::send_buf_cons.

Referenced by linda_post_send().

◆ linda_free_send_buf()

static void linda_free_send_buf ( struct linda linda,
unsigned int  send_buf 
)
static

Free a send buffer.

Parameters
lindaLinda device
send_bufSend buffer

Definition at line 406 of file linda.c.

407  {
408  linda->send_buf[linda->send_buf_prod] = send_buf;
409  linda->send_buf_prod = ( ( linda->send_buf_prod + 1 ) %
411 }
A Linda HCA.
Definition: linda.c:76
uint8_t send_buf[LINDA_MAX_SEND_BUFS]
Send buffer availability (maintained by software)
Definition: linda.c:92
unsigned int send_buf_prod
Send buffer availability producer counter.
Definition: linda.c:94
#define LINDA_MAX_SEND_BUFS
Maximum number of send buffers used.
Definition: linda.h:149

References LINDA_MAX_SEND_BUFS, linda::send_buf, and linda::send_buf_prod.

Referenced by linda_complete_send().

◆ linda_send_buf_in_use()

static int linda_send_buf_in_use ( struct linda linda,
unsigned int  send_buf 
)
static

Check to see if send buffer is in use.

Parameters
lindaLinda device
send_bufSend buffer
Return values
in_useSend buffer is in use

Definition at line 420 of file linda.c.

421  {
422  unsigned int send_idx;
423  unsigned int send_check;
424  unsigned int inusecheck;
425  unsigned int inuse;
426  unsigned int check;
427 
428  send_idx = ( send_buf & ~LINDA_SEND_BUF_TOGGLE );
429  send_check = ( !! ( send_buf & LINDA_SEND_BUF_TOGGLE ) );
430  inusecheck = BIT_GET ( linda->sendbufavail, InUseCheck[send_idx] );
431  inuse = ( !! ( inusecheck & 0x02 ) );
432  check = ( !! ( inusecheck & 0x01 ) );
433  return ( inuse || ( check != send_check ) );
434 }
A Linda HCA.
Definition: linda.c:76
#define BIT_GET(_ptr, _field)
Extract value of named field (for fields up to the size of a long)
Definition: pseudobit.h:235
#define LINDA_SEND_BUF_TOGGLE
Send buffer toggle bit.
Definition: linda.c:378
struct QIB_7220_SendBufAvail * sendbufavail
Send buffer availability (reported by hardware)
Definition: linda.c:90

References BIT_GET, LINDA_SEND_BUF_TOGGLE, and linda::sendbufavail.

Referenced by linda_poll_send_wq().

◆ linda_send_buffer_offset()

static unsigned long linda_send_buffer_offset ( struct linda linda,
unsigned int  send_buf 
)
static

Calculate starting offset for send buffer.

Parameters
lindaLinda device
send_bufSend buffer
Return values
offsetStarting offset

Definition at line 443 of file linda.c.

444  {
445  return ( linda->send_buffer_base +
446  ( ( send_buf & ~LINDA_SEND_BUF_TOGGLE ) *
448 }
unsigned long send_buffer_base
Offset within register space of the first send buffer.
Definition: linda.c:88
A Linda HCA.
Definition: linda.c:76
#define LINDA_SEND_BUF_TOGGLE
Send buffer toggle bit.
Definition: linda.c:378
#define LINDA_SEND_BUF_SIZE
Linda send buffer size.
Definition: linda.h:152

References LINDA_SEND_BUF_SIZE, LINDA_SEND_BUF_TOGGLE, and linda::send_buffer_base.

Referenced by linda_post_send().

◆ linda_create_send_wq()

static int linda_create_send_wq ( struct linda linda,
struct ib_queue_pair qp 
)
static

Create send work queue.

Parameters
lindaLinda device
qpQueue pair

Definition at line 456 of file linda.c.

457  {
458  struct ib_work_queue *wq = &qp->send;
459  struct linda_send_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
460  int rc;
461 
462  /* Reserve send buffers */
463  if ( ( linda->reserved_send_bufs + qp->send.num_wqes ) >
465  DBGC ( linda, "Linda %p out of send buffers (have %d, used "
466  "%d, need %d)\n", linda, LINDA_MAX_SEND_BUFS,
467  linda->reserved_send_bufs, qp->send.num_wqes );
468  rc = -ENOBUFS;
469  goto err_reserve_bufs;
470  }
471  linda->reserved_send_bufs += qp->send.num_wqes;
472 
473  /* Reset work queue */
474  linda_wq->prod = 0;
475  linda_wq->cons = 0;
476 
477  /* Allocate space for send buffer uasge list */
478  linda_wq->send_buf = zalloc ( qp->send.num_wqes *
479  sizeof ( linda_wq->send_buf[0] ) );
480  if ( ! linda_wq->send_buf ) {
481  rc = -ENOBUFS;
482  goto err_alloc_send_buf;
483  }
484 
485  return 0;
486 
487  free ( linda_wq->send_buf );
488  err_alloc_send_buf:
489  linda->reserved_send_bufs -= qp->send.num_wqes;
490  err_reserve_bufs:
491  return rc;
492 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A Linda HCA.
Definition: linda.c:76
#define DBGC(...)
Definition: compiler.h:505
uint8_t * send_buf
Send buffer usage.
Definition: linda.c:50
A Linda send work queue.
Definition: linda.c:48
unsigned int prod
Producer index.
Definition: linda.c:52
unsigned int cons
Consumer index.
Definition: linda.c:54
An Infiniband Work Queue.
Definition: infiniband.h:100
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
static __always_inline void * ib_wq_get_drvdata(struct ib_work_queue *wq)
Get Infiniband work queue driver-private data.
Definition: infiniband.h:620
unsigned int reserved_send_bufs
Number of reserved send buffers (across all QPs)
Definition: linda.c:98
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
#define LINDA_MAX_SEND_BUFS
Maximum number of send buffers used.
Definition: linda.h:149

References linda_send_work_queue::cons, DBGC, ENOBUFS, free, ib_wq_get_drvdata(), LINDA_MAX_SEND_BUFS, linda_send_work_queue::prod, qp, rc, linda::reserved_send_bufs, linda_send_work_queue::send_buf, and zalloc().

Referenced by linda_create_qp().

◆ linda_destroy_send_wq()

static void linda_destroy_send_wq ( struct linda linda,
struct ib_queue_pair qp 
)
static

Destroy send work queue.

Parameters
lindaLinda device
qpQueue pair

Definition at line 500 of file linda.c.

501  {
502  struct ib_work_queue *wq = &qp->send;
503  struct linda_send_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
504 
505  free ( linda_wq->send_buf );
506  linda->reserved_send_bufs -= qp->send.num_wqes;
507 }
A Linda HCA.
Definition: linda.c:76
uint8_t * send_buf
Send buffer usage.
Definition: linda.c:50
A Linda send work queue.
Definition: linda.c:48
An Infiniband Work Queue.
Definition: infiniband.h:100
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
static __always_inline void * ib_wq_get_drvdata(struct ib_work_queue *wq)
Get Infiniband work queue driver-private data.
Definition: infiniband.h:620
unsigned int reserved_send_bufs
Number of reserved send buffers (across all QPs)
Definition: linda.c:98
struct arbelprm_qp_db_record qp
Definition: arbel.h:13

References free, ib_wq_get_drvdata(), qp, linda::reserved_send_bufs, and linda_send_work_queue::send_buf.

Referenced by linda_create_qp(), and linda_destroy_qp().

◆ linda_init_send()

static int linda_init_send ( struct linda linda)
static

Initialise send datapath.

Parameters
lindaLinda device
Return values
rcReturn status code

Definition at line 515 of file linda.c.

515  {
516  struct QIB_7220_SendBufBase sendbufbase;
517  struct QIB_7220_SendBufAvailAddr sendbufavailaddr;
518  struct QIB_7220_SendCtrl sendctrl;
519  unsigned int i;
520  int rc;
521 
522  /* Retrieve SendBufBase */
523  linda_readq ( linda, &sendbufbase, QIB_7220_SendBufBase_offset );
524  linda->send_buffer_base = BIT_GET ( &sendbufbase,
525  BaseAddr_SmallPIO );
526  DBGC ( linda, "Linda %p send buffers at %lx\n",
528 
529  /* Initialise the send_buf[] array */
530  for ( i = 0 ; i < LINDA_MAX_SEND_BUFS ; i++ )
531  linda->send_buf[i] = i;
532 
533  /* Allocate space for the SendBufAvail array */
534  linda->sendbufavail = malloc_phys ( sizeof ( *linda->sendbufavail ),
536  if ( ! linda->sendbufavail ) {
537  rc = -ENOMEM;
538  goto err_alloc_sendbufavail;
539  }
540  memset ( linda->sendbufavail, 0, sizeof ( *linda->sendbufavail ) );
541 
542  /* Program SendBufAvailAddr into the hardware */
543  memset ( &sendbufavailaddr, 0, sizeof ( sendbufavailaddr ) );
544  BIT_FILL_1 ( &sendbufavailaddr, SendBufAvailAddr,
545  ( virt_to_bus ( linda->sendbufavail ) >> 6 ) );
546  linda_writeq ( linda, &sendbufavailaddr,
548 
549  /* Enable sending and DMA of SendBufAvail */
550  memset ( &sendctrl, 0, sizeof ( sendctrl ) );
551  BIT_FILL_2 ( &sendctrl,
552  SendBufAvailUpd, 1,
553  SPioEnable, 1 );
555 
556  return 0;
557 
558  free_phys ( linda->sendbufavail, sizeof ( *linda->sendbufavail ) );
559  err_alloc_sendbufavail:
560  return rc;
561 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned long send_buffer_base
Offset within register space of the first send buffer.
Definition: linda.c:88
A Linda HCA.
Definition: linda.c:76
#define QIB_7220_SendBufBase_offset
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
#define DBGC(...)
Definition: compiler.h:505
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition: malloc.h:62
#define QIB_7220_SendBufAvailAddr_offset
uint8_t send_buf[LINDA_MAX_SEND_BUFS]
Send buffer availability (maintained by software)
Definition: linda.c:92
#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
#define BIT_GET(_ptr, _field)
Extract value of named field (for fields up to the size of a long)
Definition: pseudobit.h:235
#define LINDA_SENDBUFAVAIL_ALIGN
DMA alignment for send buffer availability.
Definition: linda.h:85
#define QIB_7220_SendCtrl_offset
#define BIT_FILL_2(_ptr, _field1,...)
Definition: pseudobit.h:190
#define BIT_FILL_1(_ptr, _field1,...)
Definition: pseudobit.h:185
#define LINDA_MAX_SEND_BUFS
Maximum number of send buffers used.
Definition: linda.h:149
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.h:77
struct QIB_7220_SendBufAvail * sendbufavail
Send buffer availability (reported by hardware)
Definition: linda.c:90
void * memset(void *dest, int character, size_t len) __nonnull

References BIT_FILL_1, BIT_FILL_2, BIT_GET, DBGC, ENOMEM, free_phys(), LINDA_MAX_SEND_BUFS, linda_readq, LINDA_SENDBUFAVAIL_ALIGN, linda_writeq, malloc_phys(), memset(), QIB_7220_SendBufAvailAddr_offset, QIB_7220_SendBufBase_offset, QIB_7220_SendCtrl_offset, rc, linda::send_buf, linda::send_buffer_base, linda::sendbufavail, and virt_to_bus().

Referenced by linda_probe().

◆ linda_fini_send()

static void linda_fini_send ( struct linda linda)
static

Shut down send datapath.

Parameters
lindaLinda device

Definition at line 568 of file linda.c.

568  {
569  struct QIB_7220_SendCtrl sendctrl;
570 
571  /* Disable sending and DMA of SendBufAvail */
572  memset ( &sendctrl, 0, sizeof ( sendctrl ) );
574  mb();
575 
576  /* Ensure hardware has seen this disable */
578 
579  free_phys ( linda->sendbufavail, sizeof ( *linda->sendbufavail ) );
580 }
A Linda HCA.
Definition: linda.c:76
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
#define QIB_7220_SendCtrl_offset
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.h:77
void mb(void)
Memory barrier.
struct QIB_7220_SendBufAvail * sendbufavail
Send buffer availability (reported by hardware)
Definition: linda.c:90
void * memset(void *dest, int character, size_t len) __nonnull

References free_phys(), linda_readq, linda_writeq, mb(), memset(), QIB_7220_SendCtrl_offset, and linda::sendbufavail.

Referenced by linda_probe(), and linda_remove().

◆ linda_create_recv_wq()

static int linda_create_recv_wq ( struct linda linda,
struct ib_queue_pair qp 
)
static

Create receive work queue.

Parameters
lindaLinda device
qpQueue pair
Return values
rcReturn status code

Definition at line 596 of file linda.c.

597  {
598  struct ib_work_queue *wq = &qp->recv;
599  struct linda_recv_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
600  struct QIB_7220_RcvHdrAddr0 rcvhdraddr;
601  struct QIB_7220_RcvHdrTailAddr0 rcvhdrtailaddr;
602  struct QIB_7220_RcvHdrHead0 rcvhdrhead;
603  struct QIB_7220_scalar rcvegrindexhead;
604  struct QIB_7220_RcvCtrl rcvctrl;
605  unsigned int ctx = linda_qpn_to_ctx ( qp->qpn );
606  int rc;
607 
608  /* Reset context information */
609  memset ( &linda_wq->header_prod, 0,
610  sizeof ( linda_wq->header_prod ) );
611  linda_wq->header_cons = 0;
612  linda_wq->eager_prod = 0;
613  linda_wq->eager_cons = 0;
614 
615  /* Allocate receive header buffer */
618  if ( ! linda_wq->header ) {
619  rc = -ENOMEM;
620  goto err_alloc_header;
621  }
622 
623  /* Enable context in hardware */
624  memset ( &rcvhdraddr, 0, sizeof ( rcvhdraddr ) );
625  BIT_FILL_1 ( &rcvhdraddr, RcvHdrAddr0,
626  ( virt_to_bus ( linda_wq->header ) >> 2 ) );
627  linda_writeq_array8b ( linda, &rcvhdraddr,
629  memset ( &rcvhdrtailaddr, 0, sizeof ( rcvhdrtailaddr ) );
630  BIT_FILL_1 ( &rcvhdrtailaddr, RcvHdrTailAddr0,
631  ( virt_to_bus ( &linda_wq->header_prod ) >> 2 ) );
632  linda_writeq_array8b ( linda, &rcvhdrtailaddr,
634  memset ( &rcvhdrhead, 0, sizeof ( rcvhdrhead ) );
635  BIT_FILL_1 ( &rcvhdrhead, counter, 1 );
636  linda_writeq_array64k ( linda, &rcvhdrhead,
638  memset ( &rcvegrindexhead, 0, sizeof ( rcvegrindexhead ) );
639  BIT_FILL_1 ( &rcvegrindexhead, Value, 1 );
640  linda_writeq_array64k ( linda, &rcvegrindexhead,
643  BIT_SET ( &rcvctrl, PortEnable[ctx], 1 );
644  BIT_SET ( &rcvctrl, IntrAvail[ctx], 1 );
646 
647  DBGC ( linda, "Linda %p QPN %ld CTX %d hdrs [%lx,%lx) prod %lx\n",
648  linda, qp->qpn, ctx, virt_to_bus ( linda_wq->header ),
649  ( virt_to_bus ( linda_wq->header ) + LINDA_RECV_HEADERS_SIZE ),
650  virt_to_bus ( &linda_wq->header_prod ) );
651  return 0;
652 
654  err_alloc_header:
655  return rc;
656 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned int header_cons
Receive header consumer offset.
Definition: linda.c:64
#define QIB_7220_RcvHdrTailAddr0_offset
A Linda HCA.
Definition: linda.c:76
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
#define QIB_7220_RcvEgrIndexHead0_offset
#define DBGC(...)
Definition: compiler.h:505
#define linda_writeq_array64k(_linda, _ptr, _offset, _idx)
Definition: linda.c:150
A Linda receive work queue.
Definition: linda.c:58
static void *__malloc malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition: malloc.h:62
#define BIT_SET(_ptr, _field, _value)
Definition: pseudobit.h:238
#define LINDA_RECV_HEADERS_SIZE
Total size of an RX header ring.
Definition: linda.h:202
#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
An Infiniband Work Queue.
Definition: infiniband.h:100
#define LINDA_RECV_HEADERS_ALIGN
RX header alignment.
Definition: linda.h:206
#define QIB_7220_RcvHdrHead0_offset
void * header
Receive header ring.
Definition: linda.c:60
static __always_inline void * ib_wq_get_drvdata(struct ib_work_queue *wq)
Get Infiniband work queue driver-private data.
Definition: infiniband.h:620
unsigned int eager_prod
Eager array producer index.
Definition: linda.c:70
static int linda_qpn_to_ctx(unsigned int qpn)
Map QPN to context number.
Definition: linda.c:326
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define QIB_7220_RcvHdrAddr0_offset
#define QIB_7220_RcvCtrl_offset
#define linda_writeq_array8b(_linda, _ptr, _offset, _idx)
Definition: linda.c:148
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define BIT_FILL_1(_ptr, _field1,...)
Definition: pseudobit.h:185
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.h:77
unsigned int eager_cons
Eager array consumer index.
Definition: linda.c:72
struct QIB_7220_scalar header_prod
Receive header producer offset (written by hardware)
Definition: linda.c:62
void * memset(void *dest, int character, size_t len) __nonnull

References BIT_FILL_1, BIT_SET, ctx, DBGC, linda_recv_work_queue::eager_cons, linda_recv_work_queue::eager_prod, ENOMEM, free_phys(), linda_recv_work_queue::header, linda_recv_work_queue::header_cons, linda_recv_work_queue::header_prod, ib_wq_get_drvdata(), linda_qpn_to_ctx(), linda_readq, LINDA_RECV_HEADERS_ALIGN, LINDA_RECV_HEADERS_SIZE, linda_writeq, linda_writeq_array64k, linda_writeq_array8b, malloc_phys(), memset(), QIB_7220_RcvCtrl_offset, QIB_7220_RcvEgrIndexHead0_offset, QIB_7220_RcvHdrAddr0_offset, QIB_7220_RcvHdrHead0_offset, QIB_7220_RcvHdrTailAddr0_offset, qp, rc, and virt_to_bus().

Referenced by linda_create_qp().

◆ linda_destroy_recv_wq()

static void linda_destroy_recv_wq ( struct linda linda,
struct ib_queue_pair qp 
)
static

Destroy receive work queue.

Parameters
lindaLinda device
qpQueue pair

Definition at line 664 of file linda.c.

665  {
666  struct ib_work_queue *wq = &qp->recv;
667  struct linda_recv_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
668  struct QIB_7220_RcvCtrl rcvctrl;
669  unsigned int ctx = linda_qpn_to_ctx ( qp->qpn );
670 
671  /* Disable context in hardware */
673  BIT_SET ( &rcvctrl, PortEnable[ctx], 0 );
674  BIT_SET ( &rcvctrl, IntrAvail[ctx], 0 );
676 
677  /* Make sure the hardware has seen that the context is disabled */
679  mb();
680 
681  /* Free headers ring */
683 
684  /* Free context */
685  linda_free_ctx ( linda, ctx );
686 }
A Linda HCA.
Definition: linda.c:76
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
A Linda receive work queue.
Definition: linda.c:58
#define BIT_SET(_ptr, _field, _value)
Definition: pseudobit.h:238
#define LINDA_RECV_HEADERS_SIZE
Total size of an RX header ring.
Definition: linda.h:202
static void linda_free_ctx(struct linda *linda, unsigned int ctx)
Free a context.
Definition: linda.c:360
An Infiniband Work Queue.
Definition: infiniband.h:100
void * header
Receive header ring.
Definition: linda.c:60
static __always_inline void * ib_wq_get_drvdata(struct ib_work_queue *wq)
Get Infiniband work queue driver-private data.
Definition: infiniband.h:620
static int linda_qpn_to_ctx(unsigned int qpn)
Map QPN to context number.
Definition: linda.c:326
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define QIB_7220_RcvCtrl_offset
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
static void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.h:77
void mb(void)
Memory barrier.

References BIT_SET, ctx, free_phys(), linda_recv_work_queue::header, ib_wq_get_drvdata(), linda_free_ctx(), linda_qpn_to_ctx(), linda_readq, LINDA_RECV_HEADERS_SIZE, linda_writeq, mb(), QIB_7220_RcvCtrl_offset, and qp.

Referenced by linda_create_qp(), and linda_destroy_qp().

◆ linda_init_recv()

static int linda_init_recv ( struct linda linda)
static

Initialise receive datapath.

Parameters
lindaLinda device
Return values
rcReturn status code

Definition at line 694 of file linda.c.

694  {
695  struct QIB_7220_RcvCtrl rcvctrl;
696  struct QIB_7220_scalar rcvegrbase;
697  struct QIB_7220_scalar rcvhdrentsize;
698  struct QIB_7220_scalar rcvhdrcnt;
699  struct QIB_7220_RcvBTHQP rcvbthqp;
700  unsigned int portcfg;
701  unsigned long egrbase;
702  unsigned int eager_array_size_0;
703  unsigned int eager_array_size_other;
704  unsigned int ctx;
705 
706  /* Select configuration based on number of contexts */
707  switch ( LINDA_NUM_CONTEXTS ) {
708  case 5:
709  portcfg = LINDA_PORTCFG_5CTX;
710  eager_array_size_0 = LINDA_EAGER_ARRAY_SIZE_5CTX_0;
711  eager_array_size_other = LINDA_EAGER_ARRAY_SIZE_5CTX_OTHER;
712  break;
713  case 9:
714  portcfg = LINDA_PORTCFG_9CTX;
715  eager_array_size_0 = LINDA_EAGER_ARRAY_SIZE_9CTX_0;
716  eager_array_size_other = LINDA_EAGER_ARRAY_SIZE_9CTX_OTHER;
717  break;
718  case 17:
719  portcfg = LINDA_PORTCFG_17CTX;
720  eager_array_size_0 = LINDA_EAGER_ARRAY_SIZE_17CTX_0;
721  eager_array_size_other = LINDA_EAGER_ARRAY_SIZE_17CTX_OTHER;
722  break;
723  default:
724  build_assert ( 0 );
725  return -EINVAL;
726  }
727 
728  /* Configure number of contexts */
729  memset ( &rcvctrl, 0, sizeof ( rcvctrl ) );
730  BIT_FILL_3 ( &rcvctrl,
731  TailUpd, 1,
732  PortCfg, portcfg,
733  RcvQPMapEnable, 1 );
735 
736  /* Configure receive header buffer sizes */
737  memset ( &rcvhdrcnt, 0, sizeof ( rcvhdrcnt ) );
738  BIT_FILL_1 ( &rcvhdrcnt, Value, LINDA_RECV_HEADER_COUNT );
740  memset ( &rcvhdrentsize, 0, sizeof ( rcvhdrentsize ) );
741  BIT_FILL_1 ( &rcvhdrentsize, Value, ( LINDA_RECV_HEADER_SIZE >> 2 ) );
742  linda_writeq ( linda, &rcvhdrentsize, QIB_7220_RcvHdrEntSize_offset );
743 
744  /* Calculate eager array start addresses for each context */
745  linda_readq ( linda, &rcvegrbase, QIB_7220_RcvEgrBase_offset );
746  egrbase = BIT_GET ( &rcvegrbase, Value );
747  linda->recv_wq[0].eager_array = egrbase;
748  linda->recv_wq[0].eager_entries = eager_array_size_0;
749  egrbase += ( eager_array_size_0 * sizeof ( struct QIB_7220_RcvEgr ) );
750  for ( ctx = 1 ; ctx < LINDA_NUM_CONTEXTS ; ctx++ ) {
751  linda->recv_wq[ctx].eager_array = egrbase;
752  linda->recv_wq[ctx].eager_entries = eager_array_size_other;
753  egrbase += ( eager_array_size_other *
754  sizeof ( struct QIB_7220_RcvEgr ) );
755  }
756  for ( ctx = 0 ; ctx < LINDA_NUM_CONTEXTS ; ctx++ ) {
757  DBGC ( linda, "Linda %p CTX %d eager array at %lx (%d "
758  "entries)\n", linda, ctx,
761  }
762 
763  /* Set the BTH QP for Infinipath packets to an unused value */
764  memset ( &rcvbthqp, 0, sizeof ( rcvbthqp ) );
765  BIT_FILL_1 ( &rcvbthqp, RcvBTHQP, LINDA_QP_IDETH );
767 
768  return 0;
769 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
A Linda HCA.
Definition: linda.c:76
#define QIB_7220_RcvHdrEntSize_offset
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
#define DBGC(...)
Definition: compiler.h:505
struct linda_recv_work_queue recv_wq[LINDA_NUM_CONTEXTS]
Receive work queues.
Definition: linda.c:85
#define LINDA_EAGER_ARRAY_SIZE_17CTX_0
Definition: linda.h:172
#define QIB_7220_RcvHdrCnt_offset
#define build_assert(condition)
Assert a condition at build time (after dead code elimination)
Definition: assert.h:76
#define BIT_GET(_ptr, _field)
Extract value of named field (for fields up to the size of a long)
Definition: pseudobit.h:235
#define BIT_FILL_3(_ptr, _field1,...)
Definition: pseudobit.h:195
#define QIB_7220_RcvBTHQP_offset
unsigned int eager_entries
Number of entries in eager array.
Definition: linda.c:68
#define LINDA_QP_IDETH
QPN used for Infinipath Packets.
Definition: linda.h:219
#define LINDA_EAGER_ARRAY_SIZE_5CTX_OTHER
Definition: linda.h:169
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define QIB_7220_RcvCtrl_offset
#define LINDA_RECV_HEADER_SIZE
Maximum size of each RX header.
Definition: linda.h:199
#define LINDA_EAGER_ARRAY_SIZE_17CTX_OTHER
Definition: linda.h:173
#define LINDA_EAGER_ARRAY_SIZE_5CTX_0
PortCfg values for different numbers of contexts.
Definition: linda.h:168
unsigned long eager_array
Offset within register space of the eager array.
Definition: linda.c:66
#define BIT_FILL_1(_ptr, _field1,...)
Definition: pseudobit.h:185
#define LINDA_NUM_CONTEXTS
Number of contexts (including kernel context)
Definition: linda.h:158
#define LINDA_EAGER_ARRAY_SIZE_9CTX_OTHER
Definition: linda.h:171
#define LINDA_EAGER_ARRAY_SIZE_9CTX_0
Definition: linda.h:170
#define QIB_7220_RcvEgrBase_offset
#define LINDA_RECV_HEADER_COUNT
Number of RX headers per context.
Definition: linda.h:193
void * memset(void *dest, int character, size_t len) __nonnull

References BIT_FILL_1, BIT_FILL_3, BIT_GET, build_assert, ctx, DBGC, linda_recv_work_queue::eager_array, linda_recv_work_queue::eager_entries, EINVAL, LINDA_EAGER_ARRAY_SIZE_17CTX_0, LINDA_EAGER_ARRAY_SIZE_17CTX_OTHER, LINDA_EAGER_ARRAY_SIZE_5CTX_0, LINDA_EAGER_ARRAY_SIZE_5CTX_OTHER, LINDA_EAGER_ARRAY_SIZE_9CTX_0, LINDA_EAGER_ARRAY_SIZE_9CTX_OTHER, LINDA_NUM_CONTEXTS, LINDA_PORTCFG_17CTX, LINDA_PORTCFG_5CTX, LINDA_PORTCFG_9CTX, LINDA_QP_IDETH, linda_readq, LINDA_RECV_HEADER_COUNT, LINDA_RECV_HEADER_SIZE, linda_writeq, memset(), QIB_7220_RcvBTHQP_offset, QIB_7220_RcvCtrl_offset, QIB_7220_RcvEgrBase_offset, QIB_7220_RcvHdrCnt_offset, QIB_7220_RcvHdrEntSize_offset, and linda::recv_wq.

Referenced by linda_probe().

◆ linda_fini_recv()

static void linda_fini_recv ( struct linda *linda  __unused)
static

Shut down receive datapath.

Parameters
lindaLinda device

Definition at line 776 of file linda.c.

776  {
777  /* Nothing to do; all contexts were already disabled when the
778  * queue pairs were destroyed
779  */
780 }

Referenced by linda_probe(), and linda_remove().

◆ linda_create_cq()

static int linda_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 796 of file linda.c.

797  {
798  struct linda *linda = ib_get_drvdata ( ibdev );
799  static int cqn;
800 
801  /* The hardware has no concept of completion queues. We
802  * simply use the association between CQs and WQs (already
803  * handled by the IB core) to decide which WQs to poll.
804  *
805  * We do set a CQN, just to avoid confusing debug messages
806  * from the IB core.
807  */
808  cq->cqn = ++cqn;
809  DBGC ( linda, "Linda %p CQN %ld created\n", linda, cq->cqn );
810 
811  return 0;
812 }
A Linda HCA.
Definition: linda.c:76
#define DBGC(...)
Definition: compiler.h:505
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230
__be32 cqn
Definition: CIB_PRM.h:29

References cqn, ib_completion_queue::cqn, DBGC, and ib_get_drvdata().

◆ linda_destroy_cq()

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

Destroy completion queue.

Parameters
ibdevInfiniband device
cqCompletion queue

Definition at line 820 of file linda.c.

821  {
822  struct linda *linda = ib_get_drvdata ( ibdev );
823 
824  /* Nothing to do */
825  DBGC ( linda, "Linda %p CQN %ld destroyed\n", linda, cq->cqn );
826 }
A Linda HCA.
Definition: linda.c:76
#define DBGC(...)
Definition: compiler.h:505
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
unsigned long cqn
Completion queue number.
Definition: infiniband.h:230

References ib_completion_queue::cqn, DBGC, and ib_get_drvdata().

◆ linda_create_qp()

static int linda_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 842 of file linda.c.

843  {
844  struct linda *linda = ib_get_drvdata ( ibdev );
845  int ctx;
846  int rc;
847 
848  /* Locate an available context */
849  ctx = linda_alloc_ctx ( linda );
850  if ( ctx < 0 ) {
851  rc = ctx;
852  goto err_alloc_ctx;
853  }
854 
855  /* Set queue pair number based on context index */
856  qp->qpn = linda_ctx_to_qpn ( ctx );
857 
858  /* Set work-queue private data pointers */
859  ib_wq_set_drvdata ( &qp->send, &linda->send_wq[ctx] );
860  ib_wq_set_drvdata ( &qp->recv, &linda->recv_wq[ctx] );
861 
862  /* Create receive work queue */
863  if ( ( rc = linda_create_recv_wq ( linda, qp ) ) != 0 )
864  goto err_create_recv_wq;
865 
866  /* Create send work queue */
867  if ( ( rc = linda_create_send_wq ( linda, qp ) ) != 0 )
868  goto err_create_send_wq;
869 
870  return 0;
871 
873  err_create_send_wq:
875  err_create_recv_wq:
876  linda_free_ctx ( linda, ctx );
877  err_alloc_ctx:
878  return rc;
879 }
struct linda_send_work_queue send_wq[LINDA_NUM_CONTEXTS]
Send work queues.
Definition: linda.c:83
static int linda_ctx_to_qpn(unsigned int ctx)
Map context number to QPN.
Definition: linda.c:315
static void linda_destroy_recv_wq(struct linda *linda, struct ib_queue_pair *qp)
Destroy receive work queue.
Definition: linda.c:664
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A Linda HCA.
Definition: linda.c:76
struct linda_recv_work_queue recv_wq[LINDA_NUM_CONTEXTS]
Receive work queues.
Definition: linda.c:85
static void linda_free_ctx(struct linda *linda, unsigned int ctx)
Free a context.
Definition: linda.c:360
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
static void linda_destroy_send_wq(struct linda *linda, struct ib_queue_pair *qp)
Destroy send work queue.
Definition: linda.c:500
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
static int linda_create_recv_wq(struct linda *linda, struct ib_queue_pair *qp)
Create receive work queue.
Definition: linda.c:596
static int linda_create_send_wq(struct linda *linda, struct ib_queue_pair *qp)
Create send work queue.
Definition: linda.c:456
static int linda_alloc_ctx(struct linda *linda)
Allocate a context.
Definition: linda.c:337
static __always_inline void ib_wq_set_drvdata(struct ib_work_queue *wq, void *priv)
Set Infiniband work queue driver-private data.
Definition: infiniband.h:609

References ctx, ib_get_drvdata(), ib_wq_set_drvdata(), linda_alloc_ctx(), linda_create_recv_wq(), linda_create_send_wq(), linda_ctx_to_qpn(), linda_destroy_recv_wq(), linda_destroy_send_wq(), linda_free_ctx(), qp, rc, linda::recv_wq, and linda::send_wq.

◆ linda_modify_qp()

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

Modify queue pair.

Parameters
ibdevInfiniband device
qpQueue pair
Return values
rcReturn status code

Definition at line 888 of file linda.c.

889  {
890  struct linda *linda = ib_get_drvdata ( ibdev );
891 
892  /* Nothing to do; the hardware doesn't have a notion of queue
893  * keys
894  */
895  DBGC ( linda, "Linda %p QPN %ld modified\n", linda, qp->qpn );
896  return 0;
897 }
A Linda HCA.
Definition: linda.c:76
#define DBGC(...)
Definition: compiler.h:505
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
struct arbelprm_qp_db_record qp
Definition: arbel.h:13

References DBGC, ib_get_drvdata(), and qp.

◆ linda_destroy_qp()

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

Destroy queue pair.

Parameters
ibdevInfiniband device
qpQueue pair

Definition at line 905 of file linda.c.

906  {
907  struct linda *linda = ib_get_drvdata ( ibdev );
908 
911 }
static void linda_destroy_recv_wq(struct linda *linda, struct ib_queue_pair *qp)
Destroy receive work queue.
Definition: linda.c:664
A Linda HCA.
Definition: linda.c:76
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
static void linda_destroy_send_wq(struct linda *linda, struct ib_queue_pair *qp)
Destroy send work queue.
Definition: linda.c:500
struct arbelprm_qp_db_record qp
Definition: arbel.h:13

References ib_get_drvdata(), linda_destroy_recv_wq(), linda_destroy_send_wq(), and qp.

◆ linda_post_send()

static int linda_post_send ( struct ib_device ibdev,
struct ib_queue_pair qp,
struct ib_address_vector dest,
struct io_buffer iobuf 
)
static

Post send work queue entry.

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

Definition at line 929 of file linda.c.

932  {
933  struct linda *linda = ib_get_drvdata ( ibdev );
934  struct ib_work_queue *wq = &qp->send;
935  struct linda_send_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
936  struct QIB_7220_SendPbc sendpbc;
937  uint8_t header_buf[IB_MAX_HEADER_SIZE];
938  struct io_buffer headers;
939  unsigned int send_buf;
940  unsigned long start_offset;
941  unsigned long offset;
942  size_t len;
943  ssize_t frag_len;
944  uint32_t *data;
945 
946  /* Allocate send buffer and calculate offset */
947  send_buf = linda_alloc_send_buf ( linda );
948  start_offset = offset = linda_send_buffer_offset ( linda, send_buf );
949 
950  /* Store I/O buffer and send buffer index */
951  assert ( wq->iobufs[linda_wq->prod] == NULL );
952  wq->iobufs[linda_wq->prod] = iobuf;
953  linda_wq->send_buf[linda_wq->prod] = send_buf;
954 
955  /* Construct headers */
956  iob_populate ( &headers, header_buf, 0, sizeof ( header_buf ) );
957  iob_reserve ( &headers, sizeof ( header_buf ) );
958  ib_push ( ibdev, &headers, qp, iob_len ( iobuf ), dest );
959 
960  /* Calculate packet length */
961  len = ( ( sizeof ( sendpbc ) + iob_len ( &headers ) +
962  iob_len ( iobuf ) + 3 ) & ~3 );
963 
964  /* Construct send per-buffer control word */
965  memset ( &sendpbc, 0, sizeof ( sendpbc ) );
966  BIT_FILL_2 ( &sendpbc,
967  LengthP1_toibc, ( ( len >> 2 ) - 1 ),
968  VL15, 1 );
969 
970  /* Write SendPbc */
972  linda_writeq ( linda, &sendpbc, offset );
973  offset += sizeof ( sendpbc );
974 
975  /* Write headers */
976  for ( data = headers.data, frag_len = iob_len ( &headers ) ;
977  frag_len > 0 ; data++, offset += 4, frag_len -= 4 ) {
978  linda_writel ( linda, *data, offset );
979  }
980 
981  /* Write data */
982  for ( data = iobuf->data, frag_len = iob_len ( iobuf ) ;
983  frag_len > 0 ; data++, offset += 4, frag_len -= 4 ) {
984  linda_writel ( linda, *data, offset );
985  }
986  DBG_ENABLE ( DBGLVL_IO );
987 
988  assert ( ( start_offset + len ) == offset );
989  DBGC2 ( linda, "Linda %p QPN %ld TX %d(%d) posted [%lx,%lx)\n",
990  linda, qp->qpn, send_buf, linda_wq->prod,
991  start_offset, offset );
992 
993  /* Increment producer counter */
994  linda_wq->prod = ( ( linda_wq->prod + 1 ) & ( wq->num_wqes - 1 ) );
995 
996  return 0;
997 }
#define DBGLVL_IO
Definition: compiler.h:322
A Linda HCA.
Definition: linda.c:76
#define DBG_ENABLE(level)
Definition: compiler.h:313
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
uint8_t * send_buf
Send buffer usage.
Definition: linda.c:50
#define DBG_DISABLE(level)
Definition: compiler.h:312
A Linda send work queue.
Definition: linda.c:48
static void linda_writel(struct linda *linda, uint32_t dword, unsigned long offset)
Write Linda dword register.
Definition: linda.c:160
static void iob_populate(struct io_buffer *iobuf, void *data, size_t len, size_t max_len)
Create a temporary I/O buffer.
Definition: iobuf.h:190
unsigned int prod
Producer index.
Definition: linda.c:52
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
An Infiniband Work Queue.
Definition: infiniband.h:100
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
unsigned int num_wqes
Number of work queue entries.
Definition: infiniband.h:112
static void * dest
Definition: strings.h:176
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
static __always_inline void * ib_wq_get_drvdata(struct ib_work_queue *wq)
Get Infiniband work queue driver-private data.
Definition: infiniband.h:620
unsigned char uint8_t
Definition: stdint.h:10
uint8_t headers[IB_MAX_HEADER_SIZE]
Definition: arbel.h:14
unsigned int uint32_t
Definition: stdint.h:12
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define BIT_FILL_2(_ptr, _field1,...)
Definition: pseudobit.h:190
#define iob_reserve(iobuf, len)
Definition: iobuf.h:67
uint32_t len
Length.
Definition: ena.h:14
#define DBGC2(...)
Definition: compiler.h:522
void * data
Start of data.
Definition: iobuf.h:48
static unsigned int linda_alloc_send_buf(struct linda *linda)
Allocate a send buffer.
Definition: linda.c:390
static unsigned long linda_send_buffer_offset(struct linda *linda, unsigned int send_buf)
Calculate starting offset for send buffer.
Definition: linda.c:443
uint8_t data[48]
Additional event data.
Definition: ena.h:22
signed long ssize_t
Definition: stdint.h:7
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
int ib_push(struct ib_device *ibdev, struct io_buffer *iobuf, struct ib_queue_pair *qp, size_t payload_len, const struct ib_address_vector *dest)
Add IB headers.
Definition: ib_packet.c:52
#define IB_MAX_HEADER_SIZE
Maximum size required for IB headers.
Definition: ib_packet.h:156
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:33
struct io_buffer ** iobufs
I/O buffers assigned to work queue.
Definition: infiniband.h:124

References assert(), BIT_FILL_2, data, io_buffer::data, DBG_DISABLE, DBG_ENABLE, DBGC2, DBGLVL_IO, dest, headers, ib_get_drvdata(), IB_MAX_HEADER_SIZE, ib_push(), ib_wq_get_drvdata(), iob_len(), iob_populate(), iob_reserve, ib_work_queue::iobufs, len, linda_alloc_send_buf(), linda_send_buffer_offset(), linda_writel(), linda_writeq, memset(), NULL, ib_work_queue::num_wqes, offset, linda_send_work_queue::prod, qp, and linda_send_work_queue::send_buf.

◆ linda_complete_send()

static void linda_complete_send ( struct ib_device ibdev,
struct ib_queue_pair qp,
unsigned int  wqe_idx 
)
static

Complete send work queue entry.

Parameters
ibdevInfiniband device
qpQueue pair
wqe_idxWork queue entry index

Definition at line 1006 of file linda.c.

1008  {
1009  struct linda *linda = ib_get_drvdata ( ibdev );
1010  struct ib_work_queue *wq = &qp->send;
1011  struct linda_send_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
1012  struct io_buffer *iobuf;
1013  unsigned int send_buf;
1014 
1015  /* Parse completion */
1016  send_buf = linda_wq->send_buf[wqe_idx];
1017  DBGC2 ( linda, "Linda %p QPN %ld TX %d(%d) complete\n",
1018  linda, qp->qpn, send_buf, wqe_idx );
1019 
1020  /* Complete work queue entry */
1021  iobuf = wq->iobufs[wqe_idx];
1022  assert ( iobuf != NULL );
1023  ib_complete_send ( ibdev, qp, iobuf, 0 );
1024  wq->iobufs[wqe_idx] = NULL;
1025 
1026  /* Free send buffer */
1027  linda_free_send_buf ( linda, send_buf );
1028 }
A Linda HCA.
Definition: linda.c:76
uint8_t * send_buf
Send buffer usage.
Definition: linda.c:50
A Linda send work queue.
Definition: linda.c:48
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
An Infiniband Work Queue.
Definition: infiniband.h:100
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
static void linda_free_send_buf(struct linda *linda, unsigned int send_buf)
Free a send buffer.
Definition: linda.c:406
static __always_inline void * ib_wq_get_drvdata(struct ib_work_queue *wq)
Get Infiniband work queue driver-private data.
Definition: infiniband.h:620
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define DBGC2(...)
Definition: compiler.h:522
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A persistent I/O buffer.
Definition: iobuf.h:33
struct io_buffer ** iobufs
I/O buffers assigned to work queue.
Definition: infiniband.h:124

References assert(), DBGC2, ib_complete_send(), ib_get_drvdata(), ib_wq_get_drvdata(), ib_work_queue::iobufs, linda_free_send_buf(), NULL, qp, and linda_send_work_queue::send_buf.

Referenced by linda_poll_send_wq().

◆ linda_poll_send_wq()

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

Poll send work queue.

Parameters
ibdevInfiniband device
qpQueue pair

Definition at line 1036 of file linda.c.

1037  {
1038  struct linda *linda = ib_get_drvdata ( ibdev );
1039  struct ib_work_queue *wq = &qp->send;
1040  struct linda_send_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
1041  unsigned int send_buf;
1042 
1043  /* Look for completions */
1044  while ( wq->fill ) {
1045 
1046  /* Check to see if send buffer has completed */
1047  send_buf = linda_wq->send_buf[linda_wq->cons];
1049  break;
1050 
1051  /* Complete this buffer */
1052  linda_complete_send ( ibdev, qp, linda_wq->cons );
1053 
1054  /* Increment consumer counter */
1055  linda_wq->cons = ( ( linda_wq->cons + 1 ) &
1056  ( wq->num_wqes - 1 ) );
1057  }
1058 }
static void linda_complete_send(struct ib_device *ibdev, struct ib_queue_pair *qp, unsigned int wqe_idx)
Complete send work queue entry.
Definition: linda.c:1006
A Linda HCA.
Definition: linda.c:76
uint8_t * send_buf
Send buffer usage.
Definition: linda.c:50
A Linda send work queue.
Definition: linda.c:48
unsigned int cons
Consumer index.
Definition: linda.c:54
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
An Infiniband Work Queue.
Definition: infiniband.h:100
unsigned int num_wqes
Number of work queue entries.
Definition: infiniband.h:112
static __always_inline void * ib_wq_get_drvdata(struct ib_work_queue *wq)
Get Infiniband work queue driver-private data.
Definition: infiniband.h:620
unsigned int fill
Number of occupied work queue entries.
Definition: infiniband.h:114
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
static int linda_send_buf_in_use(struct linda *linda, unsigned int send_buf)
Check to see if send buffer is in use.
Definition: linda.c:420

References linda_send_work_queue::cons, ib_work_queue::fill, ib_get_drvdata(), ib_wq_get_drvdata(), linda_complete_send(), linda_send_buf_in_use(), ib_work_queue::num_wqes, qp, and linda_send_work_queue::send_buf.

Referenced by linda_poll_cq().

◆ linda_post_recv()

static int linda_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 1068 of file linda.c.

1070  {
1071  struct linda *linda = ib_get_drvdata ( ibdev );
1072  struct ib_work_queue *wq = &qp->recv;
1073  struct linda_recv_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
1074  struct QIB_7220_RcvEgr rcvegr;
1075  struct QIB_7220_scalar rcvegrindexhead;
1076  unsigned int ctx = linda_qpn_to_ctx ( qp->qpn );
1077  physaddr_t addr;
1078  size_t len;
1079  unsigned int wqe_idx;
1080  unsigned int bufsize;
1081 
1082  /* Sanity checks */
1083  addr = virt_to_bus ( iobuf->data );
1084  len = iob_tailroom ( iobuf );
1085  if ( addr & ( LINDA_EAGER_BUFFER_ALIGN - 1 ) ) {
1086  DBGC ( linda, "Linda %p QPN %ld misaligned RX buffer "
1087  "(%08lx)\n", linda, qp->qpn, addr );
1088  return -EINVAL;
1089  }
1090  if ( len != LINDA_RECV_PAYLOAD_SIZE ) {
1091  DBGC ( linda, "Linda %p QPN %ld wrong RX buffer size (%zd)\n",
1092  linda, qp->qpn, len );
1093  return -EINVAL;
1094  }
1095 
1096  /* Calculate eager producer index and WQE index */
1097  wqe_idx = ( linda_wq->eager_prod & ( wq->num_wqes - 1 ) );
1098  assert ( wq->iobufs[wqe_idx] == NULL );
1099 
1100  /* Store I/O buffer */
1101  wq->iobufs[wqe_idx] = iobuf;
1102 
1103  /* Calculate buffer size */
1104  switch ( LINDA_RECV_PAYLOAD_SIZE ) {
1105  case 2048: bufsize = LINDA_EAGER_BUFFER_2K; break;
1106  case 4096: bufsize = LINDA_EAGER_BUFFER_4K; break;
1107  case 8192: bufsize = LINDA_EAGER_BUFFER_8K; break;
1108  case 16384: bufsize = LINDA_EAGER_BUFFER_16K; break;
1109  case 32768: bufsize = LINDA_EAGER_BUFFER_32K; break;
1110  case 65536: bufsize = LINDA_EAGER_BUFFER_64K; break;
1111  default: build_assert ( 0 );
1113  }
1114 
1115  /* Post eager buffer */
1116  memset ( &rcvegr, 0, sizeof ( rcvegr ) );
1117  BIT_FILL_2 ( &rcvegr,
1118  Addr, ( addr >> 11 ),
1119  BufSize, bufsize );
1120  linda_writeq_array8b ( linda, &rcvegr,
1121  linda_wq->eager_array, linda_wq->eager_prod );
1122  DBGC2 ( linda, "Linda %p QPN %ld RX egr %d(%d) posted [%lx,%lx)\n",
1123  linda, qp->qpn, linda_wq->eager_prod, wqe_idx,
1124  addr, ( addr + len ) );
1125 
1126  /* Increment producer index */
1127  linda_wq->eager_prod = ( ( linda_wq->eager_prod + 1 ) &
1128  ( linda_wq->eager_entries - 1 ) );
1129 
1130  /* Update head index */
1131  memset ( &rcvegrindexhead, 0, sizeof ( rcvegrindexhead ) );
1132  BIT_FILL_1 ( &rcvegrindexhead,
1133  Value, ( ( linda_wq->eager_prod + 1 ) &
1134  ( linda_wq->eager_entries - 1 ) ) );
1135  linda_writeq_array64k ( linda, &rcvegrindexhead,
1137 
1138  return 0;
1139 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
A Linda HCA.
Definition: linda.c:76
#define QIB_7220_RcvEgrIndexHead0_offset
#define DBGC(...)
Definition: compiler.h:505
#define linda_writeq_array64k(_linda, _ptr, _offset, _idx)
Definition: linda.c:150
A Linda receive work queue.
Definition: linda.c:58
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
An Infiniband Work Queue.
Definition: infiniband.h:100
#define build_assert(condition)
Assert a condition at build time (after dead code elimination)
Definition: assert.h:76
unsigned int num_wqes
Number of work queue entries.
Definition: infiniband.h:112
unsigned int eager_entries
Number of entries in eager array.
Definition: linda.c:68
static __always_inline void * ib_wq_get_drvdata(struct ib_work_queue *wq)
Get Infiniband work queue driver-private data.
Definition: infiniband.h:620
unsigned int eager_prod
Eager array producer index.
Definition: linda.c:70
static int linda_qpn_to_ctx(unsigned int qpn)
Map QPN to context number.
Definition: linda.c:326
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
Definition: iobuf.h:175
u32 addr
Definition: sky2.h:8
#define linda_writeq_array8b(_linda, _ptr, _offset, _idx)
Definition: linda.c:148
#define LINDA_RECV_PAYLOAD_SIZE
RX payload size.
Definition: linda.h:212
unsigned long physaddr_t
Definition: stdint.h:20
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define BIT_FILL_2(_ptr, _field1,...)
Definition: pseudobit.h:190
uint32_t len
Length.
Definition: ena.h:14
#define DBGC2(...)
Definition: compiler.h:522
unsigned long eager_array
Offset within register space of the eager array.
Definition: linda.c:66
#define BIT_FILL_1(_ptr, _field1,...)
Definition: pseudobit.h:185
void * data
Start of data.
Definition: iobuf.h:48
#define LINDA_EAGER_BUFFER_ALIGN
Eager buffer required alignment.
Definition: linda.h:176
uint8_t bufsize
Size of the packet, in bytes.
Definition: int13.h:12
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
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 addr, assert(), BIT_FILL_1, BIT_FILL_2, bufsize, build_assert, ctx, io_buffer::data, DBGC, DBGC2, linda_recv_work_queue::eager_array, linda_recv_work_queue::eager_entries, linda_recv_work_queue::eager_prod, EINVAL, ib_get_drvdata(), ib_wq_get_drvdata(), iob_tailroom(), ib_work_queue::iobufs, len, LINDA_EAGER_BUFFER_16K, LINDA_EAGER_BUFFER_2K, LINDA_EAGER_BUFFER_32K, LINDA_EAGER_BUFFER_4K, LINDA_EAGER_BUFFER_64K, LINDA_EAGER_BUFFER_8K, LINDA_EAGER_BUFFER_ALIGN, LINDA_EAGER_BUFFER_NONE, linda_qpn_to_ctx(), LINDA_RECV_PAYLOAD_SIZE, linda_writeq_array64k, linda_writeq_array8b, memset(), NULL, ib_work_queue::num_wqes, QIB_7220_RcvEgrIndexHead0_offset, qp, and virt_to_bus().

◆ linda_complete_recv()

static void linda_complete_recv ( struct ib_device ibdev,
struct ib_queue_pair qp,
unsigned int  header_offs 
)
static

Complete receive work queue entry.

Parameters
ibdevInfiniband device
qpQueue pair
header_offsHeader offset

Definition at line 1148 of file linda.c.

1150  {
1151  struct linda *linda = ib_get_drvdata ( ibdev );
1152  struct ib_work_queue *wq = &qp->recv;
1153  struct linda_recv_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
1154  struct QIB_7220_RcvHdrFlags *rcvhdrflags;
1155  struct QIB_7220_RcvEgr rcvegr;
1156  struct io_buffer headers;
1157  struct io_buffer *iobuf;
1158  struct ib_queue_pair *intended_qp;
1159  struct ib_address_vector dest;
1160  struct ib_address_vector source;
1161  unsigned int rcvtype;
1162  unsigned int pktlen;
1163  unsigned int egrindex;
1164  unsigned int useegrbfr;
1165  unsigned int iberr, mkerr, tiderr, khdrerr, mtuerr;
1166  unsigned int lenerr, parityerr, vcrcerr, icrcerr;
1167  unsigned int err;
1168  unsigned int hdrqoffset;
1169  unsigned int header_len;
1170  unsigned int padded_payload_len;
1171  unsigned int wqe_idx;
1172  size_t payload_len;
1173  int qp0;
1174  int rc;
1175 
1176  /* RcvHdrFlags are at the end of the header entry */
1177  rcvhdrflags = ( linda_wq->header + header_offs +
1178  LINDA_RECV_HEADER_SIZE - sizeof ( *rcvhdrflags ) );
1179  rcvtype = BIT_GET ( rcvhdrflags, RcvType );
1180  pktlen = ( BIT_GET ( rcvhdrflags, PktLen ) << 2 );
1181  egrindex = BIT_GET ( rcvhdrflags, EgrIndex );
1182  useegrbfr = BIT_GET ( rcvhdrflags, UseEgrBfr );
1183  hdrqoffset = ( BIT_GET ( rcvhdrflags, HdrqOffset ) << 2 );
1184  iberr = BIT_GET ( rcvhdrflags, IBErr );
1185  mkerr = BIT_GET ( rcvhdrflags, MKErr );
1186  tiderr = BIT_GET ( rcvhdrflags, TIDErr );
1187  khdrerr = BIT_GET ( rcvhdrflags, KHdrErr );
1188  mtuerr = BIT_GET ( rcvhdrflags, MTUErr );
1189  lenerr = BIT_GET ( rcvhdrflags, LenErr );
1190  parityerr = BIT_GET ( rcvhdrflags, ParityErr );
1191  vcrcerr = BIT_GET ( rcvhdrflags, VCRCErr );
1192  icrcerr = BIT_GET ( rcvhdrflags, ICRCErr );
1193  header_len = ( LINDA_RECV_HEADER_SIZE - hdrqoffset -
1194  sizeof ( *rcvhdrflags ) );
1195  padded_payload_len = ( pktlen - header_len - 4 /* ICRC */ );
1196  err = ( iberr | mkerr | tiderr | khdrerr | mtuerr |
1197  lenerr | parityerr | vcrcerr | icrcerr );
1198  /* IB header is placed immediately before RcvHdrFlags */
1199  iob_populate ( &headers, ( ( ( void * ) rcvhdrflags ) - header_len ),
1200  header_len, header_len );
1201 
1202  /* Dump diagnostic information */
1203  if ( err || ( ! useegrbfr ) ) {
1204  DBGC ( linda, "Linda %p QPN %ld RX egr %d%s hdr %d type %d "
1205  "len %d(%d+%d+4)%s%s%s%s%s%s%s%s%s%s%s\n", linda,
1206  qp->qpn, egrindex, ( useegrbfr ? "" : "(unused)" ),
1207  ( header_offs / LINDA_RECV_HEADER_SIZE ), rcvtype,
1208  pktlen, header_len, padded_payload_len,
1209  ( err ? " [Err" : "" ), ( iberr ? " IB" : "" ),
1210  ( mkerr ? " MK" : "" ), ( tiderr ? " TID" : "" ),
1211  ( khdrerr ? " KHdr" : "" ), ( mtuerr ? " MTU" : "" ),
1212  ( lenerr ? " Len" : "" ), ( parityerr ? " Parity" : ""),
1213  ( vcrcerr ? " VCRC" : "" ), ( icrcerr ? " ICRC" : "" ),
1214  ( err ? "]" : "" ) );
1215  } else {
1216  DBGC2 ( linda, "Linda %p QPN %ld RX egr %d hdr %d type %d "
1217  "len %d(%d+%d+4)\n", linda, qp->qpn, egrindex,
1218  ( header_offs / LINDA_RECV_HEADER_SIZE ), rcvtype,
1219  pktlen, header_len, padded_payload_len );
1220  }
1221  DBGCP_HDA ( linda, hdrqoffset, headers.data,
1222  ( header_len + sizeof ( *rcvhdrflags ) ) );
1223 
1224  /* Parse header to generate address vector */
1225  qp0 = ( qp->qpn == 0 );
1226  intended_qp = NULL;
1227  if ( ( rc = ib_pull ( ibdev, &headers, ( qp0 ? &intended_qp : NULL ),
1228  &payload_len, &dest, &source ) ) != 0 ) {
1229  DBGC ( linda, "Linda %p could not parse headers: %s\n",
1230  linda, strerror ( rc ) );
1231  err = 1;
1232  }
1233  if ( ! intended_qp )
1234  intended_qp = qp;
1235 
1236  /* Complete this buffer and any skipped buffers. Note that
1237  * when the hardware runs out of buffers, it will repeatedly
1238  * report the same buffer (the tail) as a TID error, and that
1239  * it also has a habit of sometimes skipping over several
1240  * buffers at once.
1241  */
1242  while ( 1 ) {
1243 
1244  /* If we have caught up to the producer counter, stop.
1245  * This will happen when the hardware first runs out
1246  * of buffers and starts reporting TID errors against
1247  * the eager buffer it wants to use next.
1248  */
1249  if ( linda_wq->eager_cons == linda_wq->eager_prod )
1250  break;
1251 
1252  /* If we have caught up to where we should be after
1253  * completing this egrindex, stop. We phrase the test
1254  * this way to avoid completing the entire ring when
1255  * we receive the same egrindex twice in a row.
1256  */
1257  if ( ( linda_wq->eager_cons ==
1258  ( ( egrindex + 1 ) & ( linda_wq->eager_entries - 1 ) )))
1259  break;
1260 
1261  /* Identify work queue entry and corresponding I/O
1262  * buffer.
1263  */
1264  wqe_idx = ( linda_wq->eager_cons & ( wq->num_wqes - 1 ) );
1265  iobuf = wq->iobufs[wqe_idx];
1266  assert ( iobuf != NULL );
1267  wq->iobufs[wqe_idx] = NULL;
1268 
1269  /* Complete the eager buffer */
1270  if ( linda_wq->eager_cons == egrindex ) {
1271  /* Completing the eager buffer described in
1272  * this header entry.
1273  */
1274  if ( payload_len <= iob_tailroom ( iobuf ) ) {
1275  iob_put ( iobuf, payload_len );
1276  rc = ( err ?
1277  -EIO : ( useegrbfr ? 0 : -ECANCELED ) );
1278  } else {
1279  DBGC ( linda, "Linda %p bad payload len %zd\n",
1280  linda, payload_len );
1281  rc = -EPROTO;
1282  }
1283  /* Redirect to target QP if necessary */
1284  if ( qp != intended_qp ) {
1285  DBGC ( linda, "Linda %p redirecting QPN %ld "
1286  "=> %ld\n",
1287  linda, qp->qpn, intended_qp->qpn );
1288  /* Compensate for incorrect fill levels */
1289  qp->recv.fill--;
1290  intended_qp->recv.fill++;
1291  }
1292  ib_complete_recv ( ibdev, intended_qp, &dest, &source,
1293  iobuf, rc );
1294  } else {
1295  /* Completing on a skipped-over eager buffer */
1296  ib_complete_recv ( ibdev, qp, &dest, &source, iobuf,
1297  -ECANCELED );
1298  }
1299 
1300  /* Clear eager buffer */
1301  memset ( &rcvegr, 0, sizeof ( rcvegr ) );
1302  linda_writeq_array8b ( linda, &rcvegr, linda_wq->eager_array,
1303  linda_wq->eager_cons );
1304 
1305  /* Increment consumer index */
1306  linda_wq->eager_cons = ( ( linda_wq->eager_cons + 1 ) &
1307  ( linda_wq->eager_entries - 1 ) );
1308  }
1309 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:120
A Linda HCA.
Definition: linda.c:76
int ib_pull(struct ib_device *ibdev, struct io_buffer *iobuf, struct ib_queue_pair **qp, size_t *payload_len, struct ib_address_vector *dest, struct ib_address_vector *source)
Remove IB headers.
Definition: ib_packet.c:133
#define DBGC(...)
Definition: compiler.h:505
A Linda receive work queue.
Definition: linda.c:58
struct ib_work_queue recv
Receive queue.
Definition: infiniband.h:180
static void iob_populate(struct io_buffer *iobuf, void *data, size_t len, size_t max_len)
Create a temporary I/O buffer.
Definition: iobuf.h:190
#define ECANCELED
Operation canceled.
Definition: errno.h:343
#define DBGCP_HDA(...)
Definition: compiler.h:540
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
An Infiniband Work Queue.
Definition: infiniband.h:100
unsigned long qpn
Queue pair number.
Definition: infiniband.h:165
#define BIT_GET(_ptr, _field)
Extract value of named field (for fields up to the size of a long)
Definition: pseudobit.h:235
void * header
Receive header ring.
Definition: linda.c:60
unsigned int num_wqes
Number of work queue entries.
Definition: infiniband.h:112
static void * dest
Definition: strings.h:176
#define EPROTO
Protocol error.
Definition: errno.h:624
unsigned int eager_entries
Number of entries in eager array.
Definition: linda.c:68
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static __always_inline void * ib_wq_get_drvdata(struct ib_work_queue *wq)
Get Infiniband work queue driver-private data.
Definition: infiniband.h:620
unsigned int eager_prod
Eager array producer index.
Definition: linda.c:70
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
Definition: iobuf.h:175
unsigned int fill
Number of occupied work queue entries.
Definition: infiniband.h:114
#define LINDA_RECV_HEADER_SIZE
Maximum size of each RX header.
Definition: linda.h:199
uint8_t headers[IB_MAX_HEADER_SIZE]
Definition: arbel.h:14
#define linda_writeq_array8b(_linda, _ptr, _offset, _idx)
Definition: linda.c:148
An Infiniband Queue Pair.
Definition: infiniband.h:157
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define DBGC2(...)
Definition: compiler.h:522
unsigned long eager_array
Offset within register space of the eager array.
Definition: linda.c:66
#define EIO
Input/output error.
Definition: errno.h:433
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
An Infiniband Address Vector.
Definition: infiniband.h:72
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
unsigned int eager_cons
Eager array consumer index.
Definition: linda.c:72
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:33
struct io_buffer ** iobufs
I/O buffers assigned to work queue.
Definition: infiniband.h:124

References assert(), BIT_GET, DBGC, DBGC2, DBGCP_HDA, dest, linda_recv_work_queue::eager_array, linda_recv_work_queue::eager_cons, linda_recv_work_queue::eager_entries, linda_recv_work_queue::eager_prod, ECANCELED, EIO, EPROTO, ib_work_queue::fill, linda_recv_work_queue::header, headers, ib_complete_recv(), ib_get_drvdata(), ib_pull(), ib_wq_get_drvdata(), iob_populate(), iob_put, iob_tailroom(), ib_work_queue::iobufs, LINDA_RECV_HEADER_SIZE, linda_writeq_array8b, memset(), NULL, ib_work_queue::num_wqes, qp, ib_queue_pair::qpn, rc, ib_queue_pair::recv, and strerror().

Referenced by linda_poll_recv_wq().

◆ linda_poll_recv_wq()

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

Poll receive work queue.

Parameters
ibdevInfiniband device
qpQueue pair

Definition at line 1317 of file linda.c.

1318  {
1319  struct linda *linda = ib_get_drvdata ( ibdev );
1320  struct ib_work_queue *wq = &qp->recv;
1321  struct linda_recv_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
1322  struct QIB_7220_RcvHdrHead0 rcvhdrhead;
1323  unsigned int ctx = linda_qpn_to_ctx ( qp->qpn );
1324  unsigned int header_prod;
1325 
1326  /* Check for received packets */
1327  header_prod = ( BIT_GET ( &linda_wq->header_prod, Value ) << 2 );
1328  if ( header_prod == linda_wq->header_cons )
1329  return;
1330 
1331  /* Process all received packets */
1332  while ( linda_wq->header_cons != header_prod ) {
1333 
1334  /* Complete the receive */
1335  linda_complete_recv ( ibdev, qp, linda_wq->header_cons );
1336 
1337  /* Increment the consumer offset */
1338  linda_wq->header_cons += LINDA_RECV_HEADER_SIZE;
1339  linda_wq->header_cons %= LINDA_RECV_HEADERS_SIZE;
1340  }
1341 
1342  /* Update consumer offset */
1343  memset ( &rcvhdrhead, 0, sizeof ( rcvhdrhead ) );
1344  BIT_FILL_2 ( &rcvhdrhead,
1345  RcvHeadPointer, ( linda_wq->header_cons >> 2 ),
1346  counter, 1 );
1347  linda_writeq_array64k ( linda, &rcvhdrhead,
1349 }
unsigned int header_cons
Receive header consumer offset.
Definition: linda.c:64
A Linda HCA.
Definition: linda.c:76
static void linda_complete_recv(struct ib_device *ibdev, struct ib_queue_pair *qp, unsigned int header_offs)
Complete receive work queue entry.
Definition: linda.c:1148
#define linda_writeq_array64k(_linda, _ptr, _offset, _idx)
Definition: linda.c:150
A Linda receive work queue.
Definition: linda.c:58
#define LINDA_RECV_HEADERS_SIZE
Total size of an RX header ring.
Definition: linda.h:202
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
An Infiniband Work Queue.
Definition: infiniband.h:100
#define QIB_7220_RcvHdrHead0_offset
#define BIT_GET(_ptr, _field)
Extract value of named field (for fields up to the size of a long)
Definition: pseudobit.h:235
static __always_inline void * ib_wq_get_drvdata(struct ib_work_queue *wq)
Get Infiniband work queue driver-private data.
Definition: infiniband.h:620
static int linda_qpn_to_ctx(unsigned int qpn)
Map QPN to context number.
Definition: linda.c:326
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#define LINDA_RECV_HEADER_SIZE
Maximum size of each RX header.
Definition: linda.h:199
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define BIT_FILL_2(_ptr, _field1,...)
Definition: pseudobit.h:190
struct QIB_7220_scalar header_prod
Receive header producer offset (written by hardware)
Definition: linda.c:62
void * memset(void *dest, int character, size_t len) __nonnull

References BIT_FILL_2, BIT_GET, ctx, linda_recv_work_queue::header_cons, linda_recv_work_queue::header_prod, ib_get_drvdata(), ib_wq_get_drvdata(), linda_complete_recv(), linda_qpn_to_ctx(), LINDA_RECV_HEADER_SIZE, LINDA_RECV_HEADERS_SIZE, linda_writeq_array64k, memset(), QIB_7220_RcvHdrHead0_offset, and qp.

Referenced by linda_poll_cq().

◆ linda_poll_cq()

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

Poll completion queue.

Parameters
ibdevInfiniband device
cqCompletion queue

Definition at line 1357 of file linda.c.

1358  {
1359  struct ib_work_queue *wq;
1360 
1361  /* Poll associated send and receive queues */
1362  list_for_each_entry ( wq, &cq->work_queues, list ) {
1363  if ( wq->is_send ) {
1364  linda_poll_send_wq ( ibdev, wq->qp );
1365  } else {
1366  linda_poll_recv_wq ( ibdev, wq->qp );
1367  }
1368  }
1369 }
struct ib_completion_queue * cq
Associated completion queue.
Definition: infiniband.h:106
An Infiniband Work Queue.
Definition: infiniband.h:100
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
struct list_head work_queues
List of work queues completing to this queue.
Definition: infiniband.h:242
struct ib_queue_pair * qp
Containing queue pair.
Definition: infiniband.h:102
struct list_head list
List of work queues on this completion queue.
Definition: infiniband.h:108
static void linda_poll_recv_wq(struct ib_device *ibdev, struct ib_queue_pair *qp)
Poll receive work queue.
Definition: linda.c:1317
static void linda_poll_send_wq(struct ib_device *ibdev, struct ib_queue_pair *qp)
Poll send work queue.
Definition: linda.c:1036
int is_send
"Is a send queue" flag
Definition: infiniband.h:104

References ib_work_queue::cq, ib_work_queue::is_send, linda_poll_recv_wq(), linda_poll_send_wq(), ib_work_queue::list, list_for_each_entry, ib_work_queue::qp, and ib_completion_queue::work_queues.

◆ linda_poll_eq()

static void linda_poll_eq ( struct ib_device ibdev)
static

Poll event queue.

Parameters
ibdevInfiniband device

Definition at line 1383 of file linda.c.

1383  {
1384  struct linda *linda = ib_get_drvdata ( ibdev );
1385  struct QIB_7220_ErrStatus errstatus;
1386  struct QIB_7220_ErrClear errclear;
1387 
1388  /* Check for link status changes */
1389  DBG_DISABLE ( DBGLVL_IO );
1390  linda_readq ( linda, &errstatus, QIB_7220_ErrStatus_offset );
1391  DBG_ENABLE ( DBGLVL_IO );
1392  if ( BIT_GET ( &errstatus, IBStatusChanged ) ) {
1393  linda_link_state_changed ( ibdev );
1394  memset ( &errclear, 0, sizeof ( errclear ) );
1395  BIT_FILL_1 ( &errclear, IBStatusChangedClear, 1 );
1397  }
1398 }
#define DBGLVL_IO
Definition: compiler.h:322
A Linda HCA.
Definition: linda.c:76
#define DBG_ENABLE(level)
Definition: compiler.h:313
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
static void linda_link_state_changed(struct ib_device *ibdev)
Handle link state change.
Definition: linda.c:194
#define DBG_DISABLE(level)
Definition: compiler.h:312
#define QIB_7220_ErrClear_offset
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
#define BIT_GET(_ptr, _field)
Extract value of named field (for fields up to the size of a long)
Definition: pseudobit.h:235
#define QIB_7220_ErrStatus_offset
#define BIT_FILL_1(_ptr, _field1,...)
Definition: pseudobit.h:185
void * memset(void *dest, int character, size_t len) __nonnull

References BIT_FILL_1, BIT_GET, DBG_DISABLE, DBG_ENABLE, DBGLVL_IO, ib_get_drvdata(), linda_link_state_changed(), linda_readq, linda_writeq, memset(), QIB_7220_ErrClear_offset, and QIB_7220_ErrStatus_offset.

◆ linda_open()

static int linda_open ( struct ib_device ibdev)
static

Initialise Infiniband link.

Parameters
ibdevInfiniband device
Return values
rcReturn status code

Definition at line 1413 of file linda.c.

1413  {
1414  struct linda *linda = ib_get_drvdata ( ibdev );
1415  struct QIB_7220_Control control;
1416 
1417  /* Disable link */
1419  BIT_SET ( &control, LinkEn, 1 );
1421  return 0;
1422 }
A Linda HCA.
Definition: linda.c:76
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
#define BIT_SET(_ptr, _field, _value)
Definition: pseudobit.h:238
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
#define QIB_7220_Control_offset
Definition: qib_7220_regs.h:55
uint32_t control
Control.
Definition: myson.h:14

References BIT_SET, control, ib_get_drvdata(), linda_readq, linda_writeq, and QIB_7220_Control_offset.

◆ linda_close()

static void linda_close ( struct ib_device ibdev)
static

Close Infiniband link.

Parameters
ibdevInfiniband device

Definition at line 1429 of file linda.c.

1429  {
1430  struct linda *linda = ib_get_drvdata ( ibdev );
1431  struct QIB_7220_Control control;
1432 
1433  /* Disable link */
1435  BIT_SET ( &control, LinkEn, 0 );
1437 }
A Linda HCA.
Definition: linda.c:76
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
#define BIT_SET(_ptr, _field, _value)
Definition: pseudobit.h:238
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
#define QIB_7220_Control_offset
Definition: qib_7220_regs.h:55
uint32_t control
Control.
Definition: myson.h:14

References BIT_SET, control, ib_get_drvdata(), linda_readq, linda_writeq, and QIB_7220_Control_offset.

◆ linda_mcast_attach()

static int linda_mcast_attach ( struct ib_device ibdev,
struct ib_queue_pair qp,
union ib_gid gid 
)
static

Attach to multicast group.

Parameters
ibdevInfiniband device
qpQueue pair
gidMulticast GID
Return values
rcReturn status code

Definition at line 1454 of file linda.c.

1456  {
1457  struct linda *linda = ib_get_drvdata ( ibdev );
1458 
1459  ( void ) linda;
1460  ( void ) qp;
1461  ( void ) gid;
1462  return 0;
1463 }
A Linda HCA.
Definition: linda.c:76
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
u8 gid[16]
Definition: CIB_PRM.h:31

References gid, ib_get_drvdata(), and qp.

◆ linda_mcast_detach()

static void linda_mcast_detach ( struct ib_device ibdev,
struct ib_queue_pair qp,
union ib_gid gid 
)
static

Detach from multicast group.

Parameters
ibdevInfiniband device
qpQueue pair
gidMulticast GID

Definition at line 1472 of file linda.c.

1474  {
1475  struct linda *linda = ib_get_drvdata ( ibdev );
1476 
1477  ( void ) linda;
1478  ( void ) qp;
1479  ( void ) gid;
1480 }
A Linda HCA.
Definition: linda.c:76
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
u8 gid[16]
Definition: CIB_PRM.h:31

References gid, ib_get_drvdata(), and qp.

◆ linda_i2c_read_bit()

static int linda_i2c_read_bit ( struct bit_basher basher,
unsigned int  bit_id 
)
static

Read Linda I2C line status.

Parameters
basherBit-bashing interface
bit_idBit number
Return values
zeroInput is a logic 0
non-zeroInput is a logic 1

Definition at line 1522 of file linda.c.

1523  {
1524  struct linda *linda =
1525  container_of ( basher, struct linda, i2c.basher );
1526  struct QIB_7220_EXTStatus extstatus;
1527  unsigned int status;
1528 
1529  DBG_DISABLE ( DBGLVL_IO );
1530 
1531  linda_readq ( linda, &extstatus, QIB_7220_EXTStatus_offset );
1532  status = ( BIT_GET ( &extstatus, GPIOIn ) & linda_i2c_bits[bit_id] );
1533 
1534  DBG_ENABLE ( DBGLVL_IO );
1535 
1536  return status;
1537 }
#define DBGLVL_IO
Definition: compiler.h:322
A Linda HCA.
Definition: linda.c:76
#define DBG_ENABLE(level)
Definition: compiler.h:313
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
#define DBG_DISABLE(level)
Definition: compiler.h:312
uint8_t status
Status.
Definition: ena.h:16
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
#define BIT_GET(_ptr, _field)
Extract value of named field (for fields up to the size of a long)
Definition: pseudobit.h:235
#define QIB_7220_EXTStatus_offset
struct bit_basher basher
Bit-bashing interface.
Definition: i2c.h:95
static unsigned int linda_i2c_bits[]
Linda I2C bit to GPIO mappings.
Definition: linda.c:1509
struct i2c_bit_basher i2c
I2C bit-bashing interface.
Definition: linda.c:101

References i2c_bit_basher::basher, BIT_GET, container_of, DBG_DISABLE, DBG_ENABLE, DBGLVL_IO, linda::i2c, linda_i2c_bits, linda_readq, QIB_7220_EXTStatus_offset, and status.

◆ linda_i2c_write_bit()

static void linda_i2c_write_bit ( struct bit_basher basher,
unsigned int  bit_id,
unsigned long  data 
)
static

Write Linda I2C line status.

Parameters
basherBit-bashing interface
bit_idBit number
dataValue to write

Definition at line 1546 of file linda.c.

1547  {
1548  struct linda *linda =
1549  container_of ( basher, struct linda, i2c.basher );
1550  struct QIB_7220_EXTCtrl extctrl;
1551  struct QIB_7220_GPIO gpioout;
1552  unsigned int bit = linda_i2c_bits[bit_id];
1553  unsigned int outputs = 0;
1554  unsigned int output_enables = 0;
1555 
1556  DBG_DISABLE ( DBGLVL_IO );
1557 
1558  /* Read current GPIO mask and outputs */
1559  linda_readq ( linda, &extctrl, QIB_7220_EXTCtrl_offset );
1560  linda_readq ( linda, &gpioout, QIB_7220_GPIOOut_offset );
1561 
1562  /* Update outputs and output enables. I2C lines are tied
1563  * high, so we always set the output to 0 and use the output
1564  * enable to control the line.
1565  */
1566  output_enables = BIT_GET ( &extctrl, GPIOOe );
1567  output_enables = ( ( output_enables & ~bit ) | ( ~data & bit ) );
1568  outputs = BIT_GET ( &gpioout, GPIO );
1569  outputs = ( outputs & ~bit );
1570  BIT_SET ( &extctrl, GPIOOe, output_enables );
1571  BIT_SET ( &gpioout, GPIO, outputs );
1572 
1573  /* Write the output enable first; that way we avoid logic
1574  * hazards.
1575  */
1578  mb();
1579 
1580  DBG_ENABLE ( DBGLVL_IO );
1581 }
#define DBGLVL_IO
Definition: compiler.h:322
A Linda HCA.
Definition: linda.c:76
static unsigned int unsigned int bit
Definition: bigint.h:208
#define QIB_7220_EXTCtrl_offset
#define DBG_ENABLE(level)
Definition: compiler.h:313
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
#define DBG_DISABLE(level)
Definition: compiler.h:312
#define BIT_SET(_ptr, _field, _value)
Definition: pseudobit.h:238
#define QIB_7220_GPIOOut_offset
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
#define BIT_GET(_ptr, _field)
Extract value of named field (for fields up to the size of a long)
Definition: pseudobit.h:235
struct bit_basher basher
Bit-bashing interface.
Definition: i2c.h:95
uint8_t data[48]
Additional event data.
Definition: ena.h:22
void mb(void)
Memory barrier.
static unsigned int linda_i2c_bits[]
Linda I2C bit to GPIO mappings.
Definition: linda.c:1509
struct i2c_bit_basher i2c
I2C bit-bashing interface.
Definition: linda.c:101

References i2c_bit_basher::basher, bit, BIT_GET, BIT_SET, container_of, data, DBG_DISABLE, DBG_ENABLE, DBGLVL_IO, linda::i2c, linda_i2c_bits, linda_readq, linda_writeq, mb(), QIB_7220_EXTCtrl_offset, and QIB_7220_GPIOOut_offset.

◆ linda_init_i2c()

static int linda_init_i2c ( struct linda linda)
static

Initialise Linda I2C subsystem.

Parameters
lindaLinda device
Return values
rcReturn status code

Definition at line 1595 of file linda.c.

1595  {
1596  static int try_eeprom_address[] = { 0x51, 0x50 };
1597  unsigned int i;
1598  int rc;
1599 
1600  /* Initialise bus */
1601  if ( ( rc = init_i2c_bit_basher ( &linda->i2c,
1602  &linda_i2c_basher_ops ) ) != 0 ) {
1603  DBGC ( linda, "Linda %p could not initialise I2C bus: %s\n",
1604  linda, strerror ( rc ) );
1605  return rc;
1606  }
1607 
1608  /* Probe for devices */
1609  for ( i = 0 ; i < ( sizeof ( try_eeprom_address ) /
1610  sizeof ( try_eeprom_address[0] ) ) ; i++ ) {
1611  init_i2c_eeprom ( &linda->eeprom, try_eeprom_address[i] );
1612  if ( ( rc = i2c_check_presence ( &linda->i2c.i2c,
1613  &linda->eeprom ) ) == 0 ) {
1614  DBGC2 ( linda, "Linda %p found EEPROM at %02x\n",
1615  linda, try_eeprom_address[i] );
1616  return 0;
1617  }
1618  }
1619 
1620  DBGC ( linda, "Linda %p could not find EEPROM\n", linda );
1621  return -ENODEV;
1622 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A Linda HCA.
Definition: linda.c:76
static int i2c_check_presence(struct i2c_interface *i2c, struct i2c_device *i2cdev)
Check presence of I2C device.
Definition: i2c.h:135
#define DBGC(...)
Definition: compiler.h:505
static __always_inline void init_i2c_eeprom(struct i2c_device *i2cdev, unsigned int dev_addr)
Initialise generic I2C EEPROM device.
Definition: i2c.h:149
struct i2c_device eeprom
I2C serial EEPROM.
Definition: linda.c:103
static struct bit_basher_operations linda_i2c_basher_ops
Linda I2C bit-bashing interface operations.
Definition: linda.c:1584
struct i2c_interface i2c
I2C interface.
Definition: i2c.h:93
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define ENODEV
No such device.
Definition: errno.h:509
#define DBGC2(...)
Definition: compiler.h:522
int init_i2c_bit_basher(struct i2c_bit_basher *i2cbit, struct bit_basher_operations *bash_op)
Initialise I2C bit-bashing interface.
Definition: i2c_bit.c:387
struct i2c_bit_basher i2c
I2C bit-bashing interface.
Definition: linda.c:101

References DBGC, DBGC2, linda::eeprom, ENODEV, i2c_bit_basher::i2c, linda::i2c, i2c_check_presence(), init_i2c_bit_basher(), init_i2c_eeprom(), linda_i2c_basher_ops, rc, and strerror().

Referenced by linda_probe().

◆ linda_read_eeprom()

static int linda_read_eeprom ( struct linda linda,
union ib_guid guid 
)
static

Read EEPROM parameters.

Parameters
lindaLinda device
guidGUID to fill in
Return values
rcReturn status code

Definition at line 1631 of file linda.c.

1631  {
1632  struct i2c_interface *i2c = &linda->i2c.i2c;
1633  int rc;
1634 
1635  /* Read GUID */
1636  if ( ( rc = i2c->read ( i2c, &linda->eeprom, LINDA_EEPROM_GUID_OFFSET,
1637  guid->bytes, sizeof ( *guid ) ) ) != 0 ) {
1638  DBGC ( linda, "Linda %p could not read GUID: %s\n",
1639  linda, strerror ( rc ) );
1640  return rc;
1641  }
1642  DBGC2 ( linda, "Linda %p has GUID " IB_GUID_FMT "\n",
1643  linda, IB_GUID_ARGS ( guid ) );
1644 
1645  /* Read serial number (debug only) */
1646  if ( DBG_LOG ) {
1648 
1649  serial[ sizeof ( serial ) - 1 ] = '\0';
1650  if ( ( rc = i2c->read ( i2c, &linda->eeprom,
1652  ( sizeof ( serial ) - 1 ) ) ) != 0 ) {
1653  DBGC ( linda, "Linda %p could not read serial: %s\n",
1654  linda, strerror ( rc ) );
1655  return rc;
1656  }
1657  DBGC2 ( linda, "Linda %p has serial number \"%s\"\n",
1658  linda, serial );
1659  }
1660 
1661  return 0;
1662 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A Linda HCA.
Definition: linda.c:76
#define DBGC(...)
Definition: compiler.h:505
#define IB_GUID_ARGS(guid)
Infiniband Globally Unique Identifier debug message arguments.
Definition: ib_packet.h:29
An I2C interface.
Definition: i2c.h:57
#define IB_GUID_FMT
Infiniband Globally Unique Identifier debug message format.
Definition: ib_packet.h:26
struct i2c_device eeprom
I2C serial EEPROM.
Definition: linda.c:103
struct i2c_interface i2c
I2C interface.
Definition: i2c.h:93
#define LINDA_EEPROM_GUID_OFFSET
GUID offset within EEPROM.
Definition: linda.h:133
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define LINDA_EEPROM_SERIAL_SIZE
Board serial number size within EEPROM.
Definition: linda.h:142
uint64_t serial
Serial number.
Definition: edd.h:30
unsigned char uint8_t
Definition: stdint.h:10
int(* read)(struct i2c_interface *i2c, struct i2c_device *i2cdev, unsigned int offset, uint8_t *data, unsigned int len)
Read data from I2C device.
Definition: i2c.h:68
uint64_t guid
GUID.
Definition: edd.h:30
#define LINDA_EEPROM_SERIAL_OFFSET
Board serial number offset within EEPROM.
Definition: linda.h:139
#define DBGC2(...)
Definition: compiler.h:522
#define DBG_LOG
Definition: compiler.h:317
struct i2c_bit_basher i2c
I2C bit-bashing interface.
Definition: linda.c:101

References DBG_LOG, DBGC, DBGC2, linda::eeprom, guid, i2c_bit_basher::i2c, linda::i2c, IB_GUID_ARGS, IB_GUID_FMT, LINDA_EEPROM_GUID_OFFSET, LINDA_EEPROM_SERIAL_OFFSET, LINDA_EEPROM_SERIAL_SIZE, rc, i2c_interface::read, serial, and strerror().

Referenced by linda_probe().

◆ linda_ib_epb_request()

static int linda_ib_epb_request ( struct linda linda)
static

Request ownership of the IB external parallel bus.

Parameters
lindaLinda device
Return values
rcReturn status code

Definition at line 1677 of file linda.c.

1677  {
1678  struct QIB_7220_ibsd_epb_access_ctrl access;
1679  unsigned int i;
1680 
1681  /* Request ownership */
1682  memset ( &access, 0, sizeof ( access ) );
1683  BIT_FILL_1 ( &access, sw_ib_epb_req, 1 );
1685 
1686  /* Wait for ownership to be granted */
1687  for ( i = 0 ; i < LINDA_EPB_REQUEST_MAX_WAIT_US ; i++ ) {
1688  linda_readq ( linda, &access,
1690  if ( BIT_GET ( &access, sw_ib_epb_req_granted ) )
1691  return 0;
1692  udelay ( 1 );
1693  }
1694 
1695  DBGC ( linda, "Linda %p timed out waiting for IB EPB request\n",
1696  linda );
1697  return -ETIMEDOUT;
1698 }
A Linda HCA.
Definition: linda.c:76
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
#define DBGC(...)
Definition: compiler.h:505
#define QIB_7220_ibsd_epb_access_ctrl_offset
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define BIT_GET(_ptr, _field)
Extract value of named field (for fields up to the size of a long)
Definition: pseudobit.h:235
#define BIT_FILL_1(_ptr, _field1,...)
Definition: pseudobit.h:185
#define LINDA_EPB_REQUEST_MAX_WAIT_US
Maximum time for wait for external parallel bus request, in us.
Definition: linda.h:222
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
void * memset(void *dest, int character, size_t len) __nonnull

References BIT_FILL_1, BIT_GET, DBGC, ETIMEDOUT, LINDA_EPB_REQUEST_MAX_WAIT_US, linda_readq, linda_writeq, memset(), QIB_7220_ibsd_epb_access_ctrl_offset, and udelay().

Referenced by linda_ib_epb_mod_reg(), and linda_ib_epb_ram_xfer().

◆ linda_ib_epb_wait()

static int linda_ib_epb_wait ( struct linda linda,
struct QIB_7220_ibsd_epb_transaction_reg xact 
)
static

Wait for IB external parallel bus transaction to complete.

Parameters
lindaLinda device
xactBuffer to hold transaction result
Return values
rcReturn status code

Definition at line 1707 of file linda.c.

1708  {
1709  unsigned int i;
1710 
1711  /* Discard first read to allow for signals crossing clock domains */
1713 
1714  for ( i = 0 ; i < LINDA_EPB_XACT_MAX_WAIT_US ; i++ ) {
1715  linda_readq ( linda, xact,
1717  if ( BIT_GET ( xact, ib_epb_rdy ) ) {
1718  if ( BIT_GET ( xact, ib_epb_req_error ) ) {
1719  DBGC ( linda, "Linda %p EPB transaction "
1720  "failed\n", linda );
1721  return -EIO;
1722  } else {
1723  return 0;
1724  }
1725  }
1726  udelay ( 1 );
1727  }
1728 
1729  DBGC ( linda, "Linda %p timed out waiting for IB EPB transaction\n",
1730  linda );
1731  return -ETIMEDOUT;
1732 }
A Linda HCA.
Definition: linda.c:76
#define LINDA_EPB_XACT_MAX_WAIT_US
Maximum time for wait for external parallel bus transaction, in us.
Definition: linda.h:225
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
#define DBGC(...)
Definition: compiler.h:505
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define BIT_GET(_ptr, _field)
Extract value of named field (for fields up to the size of a long)
Definition: pseudobit.h:235
uint32_t xact
Requester transaction ID.
Definition: eth_slow.h:18
#define EIO
Input/output error.
Definition: errno.h:433
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
#define QIB_7220_ibsd_epb_transaction_reg_offset

References BIT_GET, DBGC, EIO, ETIMEDOUT, LINDA_EPB_XACT_MAX_WAIT_US, linda_readq, QIB_7220_ibsd_epb_transaction_reg_offset, udelay(), and xact.

Referenced by linda_ib_epb_read(), and linda_ib_epb_write().

◆ linda_ib_epb_release()

static void linda_ib_epb_release ( struct linda linda)
static

Release ownership of the IB external parallel bus.

Parameters
lindaLinda device

Definition at line 1739 of file linda.c.

1739  {
1740  struct QIB_7220_ibsd_epb_access_ctrl access;
1741 
1742  memset ( &access, 0, sizeof ( access ) );
1743  BIT_FILL_1 ( &access, sw_ib_epb_req, 0 );
1745 }
A Linda HCA.
Definition: linda.c:76
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define QIB_7220_ibsd_epb_access_ctrl_offset
#define BIT_FILL_1(_ptr, _field1,...)
Definition: pseudobit.h:185
void * memset(void *dest, int character, size_t len) __nonnull

References BIT_FILL_1, linda_writeq, memset(), and QIB_7220_ibsd_epb_access_ctrl_offset.

Referenced by linda_ib_epb_mod_reg(), and linda_ib_epb_ram_xfer().

◆ linda_ib_epb_read()

static int linda_ib_epb_read ( struct linda linda,
unsigned int  location 
)
static

Read data via IB external parallel bus.

Parameters
lindaLinda device
locationEPB location
Return values
dataData read, or negative error

You must have already acquired ownership of the IB external parallel bus.

Definition at line 1757 of file linda.c.

1757  {
1759  unsigned int data;
1760  int rc;
1761 
1762  /* Ensure no transaction is currently in progress */
1763  if ( ( rc = linda_ib_epb_wait ( linda, &xact ) ) != 0 )
1764  return rc;
1765 
1766  /* Process data */
1767  memset ( &xact, 0, sizeof ( xact ) );
1768  BIT_FILL_3 ( &xact,
1769  ib_epb_address, LINDA_EPB_LOC_ADDRESS ( location ),
1770  ib_epb_read_write, LINDA_EPB_READ,
1771  ib_epb_cs, LINDA_EPB_LOC_CS ( location ) );
1772  linda_writeq ( linda, &xact,
1774 
1775  /* Wait for transaction to complete */
1776  if ( ( rc = linda_ib_epb_wait ( linda, &xact ) ) != 0 )
1777  return rc;
1778 
1779  data = BIT_GET ( &xact, ib_epb_data );
1780  return data;
1781 }
#define LINDA_EPB_LOC_CS(_loc)
Definition: linda.h:250
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define LINDA_EPB_READ
Definition: linda.h:233
A Linda HCA.
Definition: linda.c:76
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define BIT_GET(_ptr, _field)
Extract value of named field (for fields up to the size of a long)
Definition: pseudobit.h:235
#define BIT_FILL_3(_ptr, _field1,...)
Definition: pseudobit.h:195
uint32_t xact
Requester transaction ID.
Definition: eth_slow.h:18
uint8_t data[48]
Additional event data.
Definition: ena.h:22
static int linda_ib_epb_wait(struct linda *linda, struct QIB_7220_ibsd_epb_transaction_reg *xact)
Wait for IB external parallel bus transaction to complete.
Definition: linda.c:1707
#define QIB_7220_ibsd_epb_transaction_reg_offset
void * memset(void *dest, int character, size_t len) __nonnull
#define LINDA_EPB_LOC_ADDRESS(_loc)
Definition: linda.h:249

References BIT_FILL_3, BIT_GET, data, LINDA_EPB_LOC_ADDRESS, LINDA_EPB_LOC_CS, LINDA_EPB_READ, linda_ib_epb_wait(), linda_writeq, memset(), QIB_7220_ibsd_epb_transaction_reg_offset, rc, and xact.

Referenced by linda_ib_epb_mod_reg(), and linda_ib_epb_ram_xfer().

◆ linda_ib_epb_write()

static int linda_ib_epb_write ( struct linda linda,
unsigned int  location,
unsigned int  data 
)
static

Write data via IB external parallel bus.

Parameters
lindaLinda device
locationEPB location
dataData to write
Return values
rcReturn status code

You must have already acquired ownership of the IB external parallel bus.

Definition at line 1794 of file linda.c.

1795  {
1797  int rc;
1798 
1799  /* Ensure no transaction is currently in progress */
1800  if ( ( rc = linda_ib_epb_wait ( linda, &xact ) ) != 0 )
1801  return rc;
1802 
1803  /* Process data */
1804  memset ( &xact, 0, sizeof ( xact ) );
1805  BIT_FILL_4 ( &xact,
1806  ib_epb_data, data,
1807  ib_epb_address, LINDA_EPB_LOC_ADDRESS ( location ),
1808  ib_epb_read_write, LINDA_EPB_WRITE,
1809  ib_epb_cs, LINDA_EPB_LOC_CS ( location ) );
1810  linda_writeq ( linda, &xact,
1812 
1813  /* Wait for transaction to complete */
1814  if ( ( rc = linda_ib_epb_wait ( linda, &xact ) ) != 0 )
1815  return rc;
1816 
1817  return 0;
1818 }
#define LINDA_EPB_LOC_CS(_loc)
Definition: linda.h:250
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A Linda HCA.
Definition: linda.c:76
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define BIT_FILL_4(_ptr, _field1,...)
Definition: pseudobit.h:200
#define LINDA_EPB_WRITE
Linda external parallel bus read/write operations.
Definition: linda.h:232
uint32_t xact
Requester transaction ID.
Definition: eth_slow.h:18
uint8_t data[48]
Additional event data.
Definition: ena.h:22
static int linda_ib_epb_wait(struct linda *linda, struct QIB_7220_ibsd_epb_transaction_reg *xact)
Wait for IB external parallel bus transaction to complete.
Definition: linda.c:1707
#define QIB_7220_ibsd_epb_transaction_reg_offset
void * memset(void *dest, int character, size_t len) __nonnull
#define LINDA_EPB_LOC_ADDRESS(_loc)
Definition: linda.h:249

References BIT_FILL_4, data, LINDA_EPB_LOC_ADDRESS, LINDA_EPB_LOC_CS, LINDA_EPB_WRITE, linda_ib_epb_wait(), linda_writeq, memset(), QIB_7220_ibsd_epb_transaction_reg_offset, rc, and xact.

Referenced by linda_ib_epb_mod_reg(), and linda_ib_epb_ram_xfer().

◆ linda_ib_epb_mod_reg()

static int linda_ib_epb_mod_reg ( struct linda linda,
unsigned int  cs,
unsigned int  channel,
unsigned int  element,
unsigned int  reg,
unsigned int  value,
unsigned int  mask 
)
static

Read/modify/write EPB register.

Parameters
lindaLinda device
csChip select
channelChannel
elementElement
regRegister
valueValue to set
maskMask to apply to old value
Return values
rcReturn status code

Definition at line 1832 of file linda.c.

1835  {
1836  unsigned int location;
1837  int old_value;
1838  int rc;
1839 
1840  DBG_DISABLE ( DBGLVL_IO );
1841 
1842  /* Sanity check */
1843  assert ( ( value & mask ) == value );
1844 
1845  /* Acquire bus ownership */
1846  if ( ( rc = linda_ib_epb_request ( linda ) ) != 0 )
1847  goto out;
1848 
1849  /* Read existing value, if necessary */
1850  location = LINDA_EPB_LOC ( cs, channel, element, reg );
1851  if ( (~mask) & 0xff ) {
1852  old_value = linda_ib_epb_read ( linda, location );
1853  if ( old_value < 0 ) {
1854  rc = old_value;
1855  goto out_release;
1856  }
1857  } else {
1858  old_value = 0;
1859  }
1860 
1861  /* Update value */
1862  value = ( ( old_value & ~mask ) | value );
1863  DBGCP ( linda, "Linda %p CS %d EPB(%d,%d,%#02x) %#02x => %#02x\n",
1864  linda, cs, channel, element, reg, old_value, value );
1865  if ( ( rc = linda_ib_epb_write ( linda, location, value ) ) != 0 )
1866  goto out_release;
1867 
1868  out_release:
1869  /* Release bus */
1871  out:
1872  DBG_ENABLE ( DBGLVL_IO );
1873  return rc;
1874 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGLVL_IO
Definition: compiler.h:322
static int linda_ib_epb_read(struct linda *linda, unsigned int location)
Read data via IB external parallel bus.
Definition: linda.c:1757
static unsigned int unsigned int reg
Definition: myson.h:162
A Linda HCA.
Definition: linda.c:76
#define DBG_ENABLE(level)
Definition: compiler.h:313
static int linda_ib_epb_write(struct linda *linda, unsigned int location, unsigned int data)
Write data via IB external parallel bus.
Definition: linda.c:1794
#define DBG_DISABLE(level)
Definition: compiler.h:312
__be32 out[4]
Definition: CIB_PRM.h:36
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
uint32_t channel
RNDIS channel.
Definition: netvsc.h:14
static void linda_ib_epb_release(struct linda *linda)
Release ownership of the IB external parallel bus.
Definition: linda.c:1739
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static int linda_ib_epb_request(struct linda *linda)
Request ownership of the IB external parallel bus.
Definition: linda.c:1677
#define DBGCP(...)
Definition: compiler.h:539
#define LINDA_EPB_LOC(_cs, _channel, _element, _reg)
Linda external parallel bus locations.
Definition: linda.h:247
uint32_t cs
Definition: librm.h:263

References assert(), channel, cs, DBG_DISABLE, DBG_ENABLE, DBGCP, DBGLVL_IO, LINDA_EPB_LOC, linda_ib_epb_read(), linda_ib_epb_release(), linda_ib_epb_request(), linda_ib_epb_write(), out, rc, reg, and value.

Referenced by linda_set_serdes_param().

◆ linda_ib_epb_ram_xfer()

static int linda_ib_epb_ram_xfer ( struct linda linda,
unsigned int  address,
const void *  write,
void *  read,
size_t  len 
)
static

Transfer data to/from microcontroller RAM.

Parameters
lindaLinda device
addressStarting address
writeData to write, or NULL
readData to read, or NULL
lenLength of data
Return values
rcReturn status code

Definition at line 1886 of file linda.c.

1888  {
1889  unsigned int control;
1890  unsigned int address_hi;
1891  unsigned int address_lo;
1892  int data;
1893  int rc;
1894 
1895  DBG_DISABLE ( DBGLVL_IO );
1896 
1897  assert ( ! ( write && read ) );
1898  assert ( ( address % LINDA_EPB_UC_CHUNK_SIZE ) == 0 );
1899  assert ( ( len % LINDA_EPB_UC_CHUNK_SIZE ) == 0 );
1900 
1901  /* Acquire bus ownership */
1902  if ( ( rc = linda_ib_epb_request ( linda ) ) != 0 )
1903  goto out;
1904 
1905  /* Process data */
1906  while ( len ) {
1907 
1908  /* Reset the address for each new chunk */
1909  if ( ( address % LINDA_EPB_UC_CHUNK_SIZE ) == 0 ) {
1910 
1911  /* Write the control register */
1914  if ( ( rc = linda_ib_epb_write ( linda,
1916  control ) ) != 0 )
1917  break;
1918 
1919  /* Write the address registers */
1920  address_hi = ( address >> 8 );
1921  if ( ( rc = linda_ib_epb_write ( linda,
1923  address_hi ) ) != 0 )
1924  break;
1925  address_lo = ( address & 0xff );
1926  if ( ( rc = linda_ib_epb_write ( linda,
1928  address_lo ) ) != 0 )
1929  break;
1930  }
1931 
1932  /* Read or write the data */
1933  if ( read ) {
1935  if ( data < 0 ) {
1936  rc = data;
1937  break;
1938  }
1939  *( ( uint8_t * ) read++ ) = data;
1940  } else {
1941  data = *( ( uint8_t * ) write++ );
1942  if ( ( rc = linda_ib_epb_write ( linda,
1944  data ) ) != 0 )
1945  break;
1946  }
1947  address++;
1948  len--;
1949 
1950  /* Reset the control byte after each chunk */
1951  if ( ( address % LINDA_EPB_UC_CHUNK_SIZE ) == 0 ) {
1952  if ( ( rc = linda_ib_epb_write ( linda,
1954  0 ) ) != 0 )
1955  break;
1956  }
1957  }
1958 
1959  /* Release bus */
1961 
1962  out:
1963  DBG_ENABLE ( DBGLVL_IO );
1964  return rc;
1965 }
struct option_descriptor read[1]
Definition: nvo_cmd.c:115
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGLVL_IO
Definition: compiler.h:322
static int linda_ib_epb_read(struct linda *linda, unsigned int location)
Read data via IB external parallel bus.
Definition: linda.c:1757
A Linda HCA.
Definition: linda.c:76
#define DBG_ENABLE(level)
Definition: compiler.h:313
uint64_t address
Base address.
Definition: ena.h:24
static int linda_ib_epb_write(struct linda *linda, unsigned int location, unsigned int data)
Write data via IB external parallel bus.
Definition: linda.c:1794
#define LINDA_EPB_UC_CTL_WRITE
Definition: linda.h:257
#define LINDA_EPB_UC_ADDR_HI
Definition: linda.h:260
#define DBG_DISABLE(level)
Definition: compiler.h:312
__be32 out[4]
Definition: CIB_PRM.h:36
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static void linda_ib_epb_release(struct linda *linda)
Release ownership of the IB external parallel bus.
Definition: linda.c:1739
static int linda_ib_epb_request(struct linda *linda)
Request ownership of the IB external parallel bus.
Definition: linda.c:1677
device nvs write
Definition: threewire.h:61
uint32_t control
Control.
Definition: myson.h:14
unsigned char uint8_t
Definition: stdint.h:10
uint32_t len
Length.
Definition: ena.h:14
#define LINDA_EPB_UC_CTL_READ
Definition: linda.h:258
uint8_t data[48]
Additional event data.
Definition: ena.h:22
#define LINDA_EPB_UC_DATA
Definition: linda.h:261
#define LINDA_EPB_UC_ADDR_LO
Definition: linda.h:259
#define LINDA_EPB_UC_CTL
Definition: linda.h:256
#define LINDA_EPB_UC_CHUNK_SIZE
Definition: linda.h:262

References address, assert(), control, data, DBG_DISABLE, DBG_ENABLE, DBGLVL_IO, len, LINDA_EPB_UC_ADDR_HI, LINDA_EPB_UC_ADDR_LO, LINDA_EPB_UC_CHUNK_SIZE, LINDA_EPB_UC_CTL, LINDA_EPB_UC_CTL_READ, LINDA_EPB_UC_CTL_WRITE, LINDA_EPB_UC_DATA, linda_ib_epb_read(), linda_ib_epb_release(), linda_ib_epb_request(), linda_ib_epb_write(), out, rc, read, and write.

Referenced by linda_program_uc_ram(), and linda_verify_uc_ram().

◆ linda_set_serdes_param()

static int linda_set_serdes_param ( struct linda linda,
struct linda_serdes_param param 
)
static

Program IB SerDes register(s)

Parameters
lindaLinda device
paramSerDes parameter
Return values
rcReturn status code

Definition at line 1997 of file linda.c.

1998  {
1999  unsigned int channel;
2000  unsigned int channel_start;
2001  unsigned int channel_end;
2002  unsigned int element;
2003  unsigned int reg;
2004  int rc;
2005 
2006  /* Break down the EPB address and determine channels */
2007  channel = LINDA_EPB_ADDRESS_CHANNEL ( param->address );
2008  element = LINDA_EPB_ADDRESS_ELEMENT ( param->address );
2009  reg = LINDA_EPB_ADDRESS_REG ( param->address );
2010  if ( channel == LINDA_EPB_ALL_CHANNELS ) {
2011  channel_start = 0;
2012  channel_end = 3;
2013  } else {
2014  channel_start = channel_end = channel;
2015  }
2016 
2017  /* Modify register for each specified channel */
2018  for ( channel = channel_start ; channel <= channel_end ; channel++ ) {
2020  channel, element, reg,
2021  param->value,
2022  param->mask ) ) != 0 )
2023  return rc;
2024  }
2025 
2026  return 0;
2027 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static unsigned int unsigned int reg
Definition: myson.h:162
A Linda HCA.
Definition: linda.c:76
#define LINDA_EPB_ADDRESS_REG(_address)
Definition: linda.h:240
#define LINDA_EPB_ALL_CHANNELS
Magic "all channels" channel number.
Definition: linda.c:1985
uint32_t channel
RNDIS channel.
Definition: netvsc.h:14
#define LINDA_EPB_ADDRESS_CHANNEL(_address)
Definition: linda.h:238
struct hv_monitor_parameter param[4][32]
Parameters.
Definition: hyperv.h:24
#define LINDA_EPB_ADDRESS_ELEMENT(_address)
Definition: linda.h:239
static int linda_ib_epb_mod_reg(struct linda *linda, unsigned int cs, unsigned int channel, unsigned int element, unsigned int reg, unsigned int value, unsigned int mask)
Read/modify/write EPB register.
Definition: linda.c:1832
#define LINDA_EPB_CS_SERDES
Linda external parallel bus chip selects.
Definition: linda.h:228

References channel, LINDA_EPB_ADDRESS_CHANNEL, LINDA_EPB_ADDRESS_ELEMENT, LINDA_EPB_ADDRESS_REG, LINDA_EPB_ALL_CHANNELS, LINDA_EPB_CS_SERDES, linda_ib_epb_mod_reg(), param, rc, and reg.

Referenced by linda_set_serdes_params().

◆ linda_set_serdes_params()

static int linda_set_serdes_params ( struct linda linda,
struct linda_serdes_param params 
)
static

Program IB SerDes registers.

Parameters
lindaLinda device
paramSerDes parameters
countNumber of parameters
Return values
rcReturn status code

Definition at line 2037 of file linda.c.

2038  {
2039  int rc;
2040 
2041  for ( ; params->mask != 0 ; params++ ){
2042  if ( ( rc = linda_set_serdes_param ( linda,
2043  params ) ) != 0 )
2044  return rc;
2045  }
2046 
2047  return 0;
2048 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A Linda HCA.
Definition: linda.c:76
static int linda_set_serdes_param(struct linda *linda, struct linda_serdes_param *param)
Program IB SerDes register(s)
Definition: linda.c:1997
uint8_t mask
Mask to apply to old value.
Definition: linda.c:1981

References linda_set_serdes_param(), linda_serdes_param::mask, and rc.

Referenced by linda_init_ib_serdes().

◆ linda_program_uc_ram()

static int linda_program_uc_ram ( struct linda linda)
static

Program the microcontroller RAM.

Parameters
lindaLinda device
Return values
rcReturn status code

Definition at line 2136 of file linda.c.

2136  {
2137  int rc;
2138 
2139  if ( ( rc = linda_ib_epb_ram_xfer ( linda, 0, linda_ib_fw, NULL,
2140  sizeof ( linda_ib_fw ) ) ) != 0 ){
2141  DBGC ( linda, "Linda %p could not load IB firmware: %s\n",
2142  linda, strerror ( rc ) );
2143  return rc;
2144  }
2145 
2146  return 0;
2147 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A Linda HCA.
Definition: linda.c:76
#define DBGC(...)
Definition: compiler.h:505
uint8_t linda_ib_fw[8192]
Definition: linda_fw.c:44
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static int linda_ib_epb_ram_xfer(struct linda *linda, unsigned int address, const void *write, void *read, size_t len)
Transfer data to/from microcontroller RAM.
Definition: linda.c:1886
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References DBGC, linda_ib_epb_ram_xfer(), linda_ib_fw, NULL, rc, and strerror().

Referenced by linda_init_ib_serdes().

◆ linda_verify_uc_ram()

static int linda_verify_uc_ram ( struct linda linda)
static

Verify the microcontroller RAM.

Parameters
lindaLinda device
Return values
rcReturn status code

Definition at line 2155 of file linda.c.

2155  {
2157  unsigned int offset;
2158  int rc;
2159 
2160  for ( offset = 0 ; offset < sizeof ( linda_ib_fw );
2161  offset += sizeof ( verify ) ) {
2162  if ( ( rc = linda_ib_epb_ram_xfer ( linda, offset,
2163  NULL, verify,
2164  sizeof (verify) )) != 0 ){
2165  DBGC ( linda, "Linda %p could not read back IB "
2166  "firmware: %s\n", linda, strerror ( rc ) );
2167  return rc;
2168  }
2169  if ( memcmp ( ( linda_ib_fw + offset ), verify,
2170  sizeof ( verify ) ) != 0 ) {
2171  DBGC ( linda, "Linda %p firmware verification failed "
2172  "at offset %#x\n", linda, offset );
2174  sizeof ( verify ) );
2175  DBGC_HDA ( linda, offset, verify, sizeof ( verify ) );
2176  return -EIO;
2177  }
2178  }
2179 
2180  DBGC2 ( linda, "Linda %p firmware verified ok\n", linda );
2181  return 0;
2182 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A Linda HCA.
Definition: linda.c:76
#define DBGC(...)
Definition: compiler.h:505
uint8_t linda_ib_fw[8192]
Definition: linda_fw.c:44
#define DBGC_HDA(...)
Definition: compiler.h:506
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static int linda_ib_epb_ram_xfer(struct linda *linda, unsigned int address, const void *write, void *read, size_t len)
Transfer data to/from microcontroller RAM.
Definition: linda.c:1886
unsigned char uint8_t
Definition: stdint.h:10
#define DBGC2(...)
Definition: compiler.h:522
#define EIO
Input/output error.
Definition: errno.h:433
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define LINDA_EPB_UC_CHUNK_SIZE
Definition: linda.h:262

References DBGC, DBGC2, DBGC_HDA, EIO, LINDA_EPB_UC_CHUNK_SIZE, linda_ib_epb_ram_xfer(), linda_ib_fw, memcmp(), NULL, offset, rc, and strerror().

Referenced by linda_init_ib_serdes().

◆ linda_trim_ib()

static int linda_trim_ib ( struct linda linda)
static

Use the microcontroller to trim the IB link.

Parameters
lindaLinda device
Return values
rcReturn status code

Definition at line 2190 of file linda.c.

2190  {
2191  struct QIB_7220_IBSerDesCtrl ctrl;
2192  struct QIB_7220_IntStatus intstatus;
2193  unsigned int i;
2194  int rc;
2195 
2196  /* Bring the microcontroller out of reset */
2198  BIT_SET ( &ctrl, ResetIB_uC_Core, 0 );
2200 
2201  /* Wait for the "trim done" signal */
2202  for ( i = 0 ; i < LINDA_TRIM_DONE_MAX_WAIT_MS ; i++ ) {
2203  linda_readq ( linda, &intstatus, QIB_7220_IntStatus_offset );
2204  if ( BIT_GET ( &intstatus, IBSerdesTrimDone ) ) {
2205  rc = 0;
2206  goto out_reset;
2207  }
2208  mdelay ( 1 );
2209  }
2210 
2211  DBGC ( linda, "Linda %p timed out waiting for trim done\n", linda );
2212  rc = -ETIMEDOUT;
2213  out_reset:
2214  /* Put the microcontroller back into reset */
2215  BIT_SET ( &ctrl, ResetIB_uC_Core, 1 );
2217 
2218  return rc;
2219 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define LINDA_TRIM_DONE_MAX_WAIT_MS
Maximum time to wait for "trim done" signal, in ms.
Definition: linda.h:267
A Linda HCA.
Definition: linda.c:76
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
#define DBGC(...)
Definition: compiler.h:505
#define BIT_SET(_ptr, _field, _value)
Definition: pseudobit.h:238
#define BIT_GET(_ptr, _field)
Extract value of named field (for fields up to the size of a long)
Definition: pseudobit.h:235
#define QIB_7220_IntStatus_offset
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
u8 ctrl
Definition: sky2.h:10
#define QIB_7220_IBSerDesCtrl_offset
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669

References BIT_GET, BIT_SET, ctrl, DBGC, ETIMEDOUT, linda_readq, LINDA_TRIM_DONE_MAX_WAIT_MS, linda_writeq, mdelay(), QIB_7220_IBSerDesCtrl_offset, QIB_7220_IntStatus_offset, and rc.

Referenced by linda_init_ib_serdes().

◆ linda_init_ib_serdes()

static int linda_init_ib_serdes ( struct linda linda)
static

Initialise the IB SerDes.

Parameters
lindaLinda device
Return values
rcReturn status code

Definition at line 2227 of file linda.c.

2227  {
2228  struct QIB_7220_Control control;
2229  struct QIB_7220_IBCCtrl ibcctrl;
2230  struct QIB_7220_IBCDDRCtrl ibcddrctrl;
2231  struct QIB_7220_XGXSCfg xgxscfg;
2232  int rc;
2233 
2234  /* Disable link */
2236  BIT_SET ( &control, LinkEn, 0 );
2238 
2239  /* Configure sensible defaults for IBC */
2240  memset ( &ibcctrl, 0, sizeof ( ibcctrl ) );
2241  BIT_FILL_6 ( &ibcctrl, /* Tuning values taken from Linux driver */
2242  FlowCtrlPeriod, 0x03,
2243  FlowCtrlWaterMark, 0x05,
2244  MaxPktLen, ( ( LINDA_RECV_HEADER_SIZE +
2246  4 /* ICRC */ ) >> 2 ),
2247  PhyerrThreshold, 0xf,
2248  OverrunThreshold, 0xf,
2249  CreditScale, 0x4 );
2251 
2252  /* Force SDR only to avoid needing all the DDR tuning,
2253  * Mellanox compatibility hacks etc. SDR is plenty for
2254  * boot-time operation.
2255  */
2256  linda_readq ( linda, &ibcddrctrl, QIB_7220_IBCDDRCtrl_offset );
2257  BIT_SET ( &ibcddrctrl, IB_ENHANCED_MODE, 0 );
2258  BIT_SET ( &ibcddrctrl, SD_SPEED_SDR, 1 );
2259  BIT_SET ( &ibcddrctrl, SD_SPEED_DDR, 0 );
2260  BIT_SET ( &ibcddrctrl, SD_SPEED_QDR, 0 );
2261  BIT_SET ( &ibcddrctrl, HRTBT_ENB, 0 );
2262  BIT_SET ( &ibcddrctrl, HRTBT_AUTO, 0 );
2263  linda_writeq ( linda, &ibcddrctrl, QIB_7220_IBCDDRCtrl_offset );
2264 
2265  /* Set default SerDes parameters */
2266  if ( ( rc = linda_set_serdes_params ( linda,
2267  linda_serdes_defaults1 ) ) != 0 )
2268  return rc;
2269  udelay ( 415 ); /* Magic delay while SerDes sorts itself out */
2270  if ( ( rc = linda_set_serdes_params ( linda,
2271  linda_serdes_defaults2 ) ) != 0 )
2272  return rc;
2273 
2274  /* Program the microcontroller RAM */
2275  if ( ( rc = linda_program_uc_ram ( linda ) ) != 0 )
2276  return rc;
2277 
2278  /* Verify the microcontroller RAM contents */
2279  if ( DBGLVL_LOG ) {
2280  if ( ( rc = linda_verify_uc_ram ( linda ) ) != 0 )
2281  return rc;
2282  }
2283 
2284  /* More SerDes tuning */
2285  if ( ( rc = linda_set_serdes_params ( linda,
2286  linda_serdes_defaults3 ) ) != 0 )
2287  return rc;
2288 
2289  /* Use the microcontroller to trim the IB link */
2290  if ( ( rc = linda_trim_ib ( linda ) ) != 0 )
2291  return rc;
2292 
2293  /* Bring XGXS out of reset */
2294  linda_readq ( linda, &xgxscfg, QIB_7220_XGXSCfg_offset );
2295  BIT_SET ( &xgxscfg, tx_rx_reset, 0 );
2296  BIT_SET ( &xgxscfg, xcv_reset, 0 );
2298 
2299  return rc;
2300 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define BIT_FILL_6(_ptr, _field1,...)
Definition: pseudobit.h:210
A Linda HCA.
Definition: linda.c:76
#define QIB_7220_XGXSCfg_offset
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:146
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
static struct linda_serdes_param linda_serdes_defaults3[]
Definition: linda.c:2123
static int linda_verify_uc_ram(struct linda *linda)
Verify the microcontroller RAM.
Definition: linda.c:2155
static struct linda_serdes_param linda_serdes_defaults2[]
Definition: linda.c:2092
#define BIT_SET(_ptr, _field, _value)
Definition: pseudobit.h:238
static int linda_program_uc_ram(struct linda *linda)
Program the microcontroller RAM.
Definition: linda.c:2136
#define DBGLVL_LOG
Definition: compiler.h:316
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define QIB_7220_Control_offset
Definition: qib_7220_regs.h:55
static int linda_trim_ib(struct linda *linda)
Use the microcontroller to trim the IB link.
Definition: linda.c:2190
uint32_t control
Control.
Definition: myson.h:14
#define LINDA_RECV_HEADER_SIZE
Maximum size of each RX header.
Definition: linda.h:199
#define LINDA_RECV_PAYLOAD_SIZE
RX payload size.
Definition: linda.h:212
#define QIB_7220_IBCDDRCtrl_offset
static struct linda_serdes_param linda_serdes_defaults1[]
Linda SerDes default parameters.
Definition: linda.c:2072
static int linda_set_serdes_params(struct linda *linda, struct linda_serdes_param *params)
Program IB SerDes registers.
Definition: linda.c:2037
#define QIB_7220_IBCCtrl_offset
void * memset(void *dest, int character, size_t len) __nonnull

References BIT_FILL_6, BIT_SET, control, DBGLVL_LOG, linda_program_uc_ram(), linda_readq, LINDA_RECV_HEADER_SIZE, LINDA_RECV_PAYLOAD_SIZE, linda_serdes_defaults1, linda_serdes_defaults2, linda_serdes_defaults3, linda_set_serdes_params(), linda_trim_ib(), linda_verify_uc_ram(), linda_writeq, memset(), QIB_7220_Control_offset, QIB_7220_IBCCtrl_offset, QIB_7220_IBCDDRCtrl_offset, QIB_7220_XGXSCfg_offset, rc, and udelay().

Referenced by linda_probe().

◆ linda_probe()

static int linda_probe ( struct pci_device pci)
static

Probe PCI device.

Parameters
pciPCI device
idPCI ID
Return values
rcReturn status code

Definition at line 2316 of file linda.c.

2316  {
2317  struct ib_device *ibdev;
2318  struct linda *linda;
2319  struct QIB_7220_Revision revision;
2320  int rc;
2321 
2322  /* Allocate Infiniband device */
2323  ibdev = alloc_ibdev ( sizeof ( *linda ) );
2324  if ( ! ibdev ) {
2325  rc = -ENOMEM;
2326  goto err_alloc_ibdev;
2327  }
2328  pci_set_drvdata ( pci, ibdev );
2329  linda = ib_get_drvdata ( ibdev );
2330  ibdev->op = &linda_ib_operations;
2331  ibdev->dev = &pci->dev;
2332  ibdev->port = 1;
2333  ibdev->ports = 1;
2334 
2335  /* Fix up PCI device */
2336  adjust_pci_device ( pci );
2337 
2338  /* Map PCI BARs */
2339  linda->regs = pci_ioremap ( pci, pci->membase, LINDA_BAR0_SIZE );
2340  DBGC2 ( linda, "Linda %p has BAR at %08lx\n", linda, pci->membase );
2341 
2342  /* Print some general data */
2344  DBGC2 ( linda, "Linda %p board %02lx v%ld.%ld.%ld.%ld\n", linda,
2345  BIT_GET ( &revision, BoardID ),
2346  BIT_GET ( &revision, R_SW ),
2347  BIT_GET ( &revision, R_Arch ),
2348  BIT_GET ( &revision, R_ChipRevMajor ),
2349  BIT_GET ( &revision, R_ChipRevMinor ) );
2350 
2351  /* Record link capabilities. Note that we force SDR only to
2352  * avoid having to carry extra code for DDR tuning etc.
2353  */
2354  ibdev->link_width_enabled = ibdev->link_width_supported =
2356  ibdev->link_speed_enabled = ibdev->link_speed_supported =
2358 
2359  /* Initialise I2C subsystem */
2360  if ( ( rc = linda_init_i2c ( linda ) ) != 0 )
2361  goto err_init_i2c;
2362 
2363  /* Read EEPROM parameters */
2364  if ( ( rc = linda_read_eeprom ( linda, &ibdev->node_guid ) ) != 0 )
2365  goto err_read_eeprom;
2366  memcpy ( &ibdev->gid.s.guid, &ibdev->node_guid,
2367  sizeof ( ibdev->gid.s.guid ) );
2368 
2369  /* Initialise send datapath */
2370  if ( ( rc = linda_init_send ( linda ) ) != 0 )
2371  goto err_init_send;
2372 
2373  /* Initialise receive datapath */
2374  if ( ( rc = linda_init_recv ( linda ) ) != 0 )
2375  goto err_init_recv;
2376 
2377  /* Initialise the IB SerDes */
2378  if ( ( rc = linda_init_ib_serdes ( linda ) ) != 0 )
2379  goto err_init_ib_serdes;
2380 
2381  /* Register Infiniband device */
2382  if ( ( rc = register_ibdev ( ibdev ) ) != 0 ) {
2383  DBGC ( linda, "Linda %p could not register IB "
2384  "device: %s\n", linda, strerror ( rc ) );
2385  goto err_register_ibdev;
2386  }
2387 
2388  return 0;
2389 
2390  unregister_ibdev ( ibdev );
2391  err_register_ibdev:
2392  linda_fini_recv ( linda );
2393  err_init_recv:
2394  linda_fini_send ( linda );
2395  err_init_send:
2396  err_init_ib_serdes:
2397  err_read_eeprom:
2398  err_init_i2c:
2399  iounmap ( linda->regs );
2400  ibdev_put ( ibdev );
2401  err_alloc_ibdev:
2402  return rc;
2403 }
void unregister_ibdev(struct ib_device *ibdev)
Unregister Infiniband device.
Definition: infiniband.c:985
unsigned long membase
Memory base.
Definition: pci.h:215
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
union ib_guid guid
Definition: ib_packet.h:40
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:441
A Linda HCA.
Definition: linda.c:76
static struct ib_device_operations linda_ib_operations
Linda Infiniband operations.
Definition: linda.c:1483
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:128
#define DBGC(...)
Definition: compiler.h:505
#define QIB_7220_Revision_offset
Definition: qib_7220_regs.h:40
#define IB_LINK_SPEED_SDR
Definition: ib_mad.h:144
struct device * dev
Underlying device.
Definition: infiniband.h:410
static void linda_fini_send(struct linda *linda)
Shut down send datapath.
Definition: linda.c:568
static void linda_fini_recv(struct linda *linda __unused)
Shut down receive datapath.
Definition: linda.c:776
uint8_t link_speed_enabled
Link speed enabled.
Definition: infiniband.h:435
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition: pci.c:154
struct device dev
Generic device.
Definition: pci.h:208
uint8_t link_width_enabled
Link width enabled.
Definition: infiniband.h:429
uint8_t link_width_supported
Link width supported.
Definition: infiniband.h:427
An Infiniband device.
Definition: infiniband.h:398
#define IB_LINK_WIDTH_4X
Definition: ib_mad.h:140
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition: pci.h:359
#define ENOMEM
Not enough space.
Definition: errno.h:534
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:708
struct ib_device_operations * op
Infiniband operations.
Definition: infiniband.h:416
static int linda_init_recv(struct linda *linda)
Initialise receive datapath.
Definition: linda.c:694
static int linda_read_eeprom(struct linda *linda, union ib_guid *guid)
Read EEPROM parameters.
Definition: linda.c:1631
struct ib_gid::@559 s
#define BIT_GET(_ptr, _field)
Extract value of named field (for fields up to the size of a long)
Definition: pseudobit.h:235
uint32_t revision
Entry point revision.
Definition: ib_mad.h:20
unsigned int port
Port number.
Definition: infiniband.h:418
static __always_inline void ibdev_put(struct ib_device *ibdev)
Drop reference to Infiniband device.
Definition: infiniband.h:598
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
void * regs
Registers.
Definition: linda.c:78
struct ib_device * alloc_ibdev(size_t priv_size)
Allocate Infiniband device.
Definition: infiniband.c:917
static int linda_init_i2c(struct linda *linda)
Initialise Linda I2C subsystem.
Definition: linda.c:1595
union ib_guid node_guid
Node GUID.
Definition: infiniband.h:439
int register_ibdev(struct ib_device *ibdev)
Register Infiniband device.
Definition: infiniband.c:944
unsigned int ports
Total ports on device.
Definition: infiniband.h:420
#define IB_LINK_WIDTH_1X
Definition: ib_mad.h:139
#define DBGC2(...)
Definition: compiler.h:522
static int linda_init_ib_serdes(struct linda *linda)
Initialise the IB SerDes.
Definition: linda.c:2227
void iounmap(volatile const void *io_addr)
Unmap I/O address.
uint8_t link_speed_supported
Link speed supported.
Definition: infiniband.h:433
static int linda_init_send(struct linda *linda)
Initialise send datapath.
Definition: linda.c:515
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
#define LINDA_BAR0_SIZE
Linda memory BAR size.
Definition: linda.h:124

References adjust_pci_device(), alloc_ibdev(), BIT_GET, DBGC, DBGC2, pci_device::dev, ib_device::dev, ENOMEM, ib_device::gid, ib_gid::guid, ib_get_drvdata(), IB_LINK_SPEED_SDR, IB_LINK_WIDTH_1X, IB_LINK_WIDTH_4X, ibdev_put(), iounmap(), LINDA_BAR0_SIZE, linda_fini_recv(), linda_fini_send(), linda_ib_operations, linda_init_i2c(), linda_init_ib_serdes(), linda_init_recv(), linda_init_send(), linda_read_eeprom(), linda_readq, ib_device::link_speed_enabled, ib_device::link_speed_supported, ib_device::link_width_enabled, ib_device::link_width_supported, pci_device::membase, memcpy(), ib_device::node_guid, ib_device::op, pci_ioremap(), pci_set_drvdata(), ib_device::port, ib_device::ports, QIB_7220_Revision_offset, rc, register_ibdev(), linda::regs, revision, ib_gid::s, strerror(), and unregister_ibdev().

◆ linda_remove()

static void linda_remove ( struct pci_device pci)
static

Remove PCI device.

Parameters
pciPCI device

Definition at line 2410 of file linda.c.

2410  {
2411  struct ib_device *ibdev = pci_get_drvdata ( pci );
2412  struct linda *linda = ib_get_drvdata ( ibdev );
2413 
2414  unregister_ibdev ( ibdev );
2415  linda_fini_recv ( linda );
2416  linda_fini_send ( linda );
2417  iounmap ( linda->regs );
2418  ibdev_put ( ibdev );
2419 }
void unregister_ibdev(struct ib_device *ibdev)
Unregister Infiniband device.
Definition: infiniband.c:985
A Linda HCA.
Definition: linda.c:76
static void linda_fini_send(struct linda *linda)
Shut down send datapath.
Definition: linda.c:568
static void linda_fini_recv(struct linda *linda __unused)
Shut down receive datapath.
Definition: linda.c:776
An Infiniband device.
Definition: infiniband.h:398
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition: infiniband.h:708
static __always_inline void ibdev_put(struct ib_device *ibdev)
Drop reference to Infiniband device.
Definition: infiniband.h:598
void * regs
Registers.
Definition: linda.c:78
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:369
void iounmap(volatile const void *io_addr)
Unmap I/O address.

References ib_get_drvdata(), ibdev_put(), iounmap(), linda_fini_recv(), linda_fini_send(), pci_get_drvdata(), linda::regs, and unregister_ibdev().

Variable Documentation

◆ linda_ib_operations

struct ib_device_operations linda_ib_operations
static
Initial value:
= {
.create_cq = linda_create_cq,
.destroy_cq = linda_destroy_cq,
.create_qp = linda_create_qp,
.modify_qp = linda_modify_qp,
.destroy_qp = linda_destroy_qp,
.post_send = linda_post_send,
.post_recv = linda_post_recv,
.poll_cq = linda_poll_cq,
.poll_eq = linda_poll_eq,
.open = linda_open,
.close = linda_close,
.mcast_attach = linda_mcast_attach,
.mcast_detach = linda_mcast_detach,
.set_port_info = linda_set_port_info,
.set_pkey_table = linda_set_pkey_table,
}
static int linda_open(struct ib_device *ibdev)
Initialise Infiniband link.
Definition: linda.c:1413
static void linda_destroy_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Destroy completion queue.
Definition: linda.c:820
static void linda_close(struct ib_device *ibdev)
Close Infiniband link.
Definition: linda.c:1429
static void linda_destroy_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Destroy queue pair.
Definition: linda.c:905
static void linda_mcast_detach(struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
Detach from multicast group.
Definition: linda.c:1472
static int linda_create_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Create queue pair.
Definition: linda.c:842
static int linda_modify_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Modify queue pair.
Definition: linda.c:888
static int linda_create_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Create completion queue.
Definition: linda.c:796
static int linda_post_send(struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *dest, struct io_buffer *iobuf)
Post send work queue entry.
Definition: linda.c:929
static void linda_poll_eq(struct ib_device *ibdev)
Poll event queue.
Definition: linda.c:1383
static int linda_post_recv(struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf)
Post receive work queue entry.
Definition: linda.c:1068
static int linda_mcast_attach(struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
Attach to multicast group.
Definition: linda.c:1454
static int linda_set_port_info(struct ib_device *ibdev, union ib_mad *mad)
Set port information.
Definition: linda.c:260
static int linda_set_pkey_table(struct ib_device *ibdev __unused, union ib_mad *mad __unused)
Set partition key table.
Definition: linda.c:296
static void linda_poll_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Poll completion queue.
Definition: linda.c:1357

Linda Infiniband operations.

Definition at line 1483 of file linda.c.

Referenced by linda_probe().

◆ linda_i2c_bits

unsigned int linda_i2c_bits[]
static
Initial value:
= {
}
Serial clock.
Definition: i2c.h:114
Serial data.
Definition: i2c.h:116
#define LINDA_GPIO_SCL
Linda I2C SCL line GPIO number.
Definition: linda.h:127
#define LINDA_GPIO_SDA
Linda I2C SDA line GPIO number.
Definition: linda.h:130

Linda I2C bit to GPIO mappings.

Definition at line 1509 of file linda.c.

Referenced by linda_i2c_read_bit(), and linda_i2c_write_bit().

◆ linda_i2c_basher_ops

struct bit_basher_operations linda_i2c_basher_ops
static
Initial value:
= {
}
static void linda_i2c_write_bit(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
Write Linda I2C line status.
Definition: linda.c:1546
static int linda_i2c_read_bit(struct bit_basher *basher, unsigned int bit_id)
Read Linda I2C line status.
Definition: linda.c:1522

Linda I2C bit-bashing interface operations.

Definition at line 1584 of file linda.c.

Referenced by linda_init_i2c().

◆ __packed

struct linda_serdes_param __packed

◆ linda_serdes_defaults1

struct linda_serdes_param linda_serdes_defaults1[]
static
Initial value:
= {
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 6, 0x00 ), 0xd4, 0xff },
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 6, 0x05 ), 0x2d, 0xff },
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 6, 0x08 ), 0x03, 0x0f },
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 7, 0x27 ), 0x10, 0xff },
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 7, 0x28 ), 0x30, 0xff },
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 6, 0x0e ), 0x40, 0xff },
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 7, 0x06 ), 0x04, 0xff },
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 6, 0x0f ), 0x04, 0xff },
}
#define LINDA_EPB_ADDRESS(_channel, _element, _reg)
Linda external parallel bus register addresses.
Definition: linda.h:236
#define LINDA_SERDES_PARAM_END
End of SerDes parameter list marker.
Definition: linda.c:1988
#define LINDA_EPB_ALL_CHANNELS
Magic "all channels" channel number.
Definition: linda.c:1985

Linda SerDes default parameters.

These magic start-of-day values are taken from the Linux driver.

Definition at line 2072 of file linda.c.

Referenced by linda_init_ib_serdes().

◆ linda_serdes_defaults2

struct linda_serdes_param linda_serdes_defaults2[]
static

Definition at line 2092 of file linda.c.

Referenced by linda_init_ib_serdes().

◆ linda_serdes_defaults3

struct linda_serdes_param linda_serdes_defaults3[]
static
Initial value:
= {
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 7, 0x27 ), 0x00, 0x38 },
}
#define LINDA_EPB_ADDRESS(_channel, _element, _reg)
Linda external parallel bus register addresses.
Definition: linda.h:236
#define LINDA_SERDES_PARAM_END
End of SerDes parameter list marker.
Definition: linda.c:1988
#define LINDA_EPB_ALL_CHANNELS
Magic "all channels" channel number.
Definition: linda.c:1985

Definition at line 2123 of file linda.c.

Referenced by linda_init_ib_serdes().

◆ linda_nics

struct pci_device_id linda_nics[]
static
Initial value:
= {
PCI_ROM ( 0x1077, 0x7220, "iba7220", "QLE7240/7280 HCA driver", 0 ),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:303

Definition at line 2421 of file linda.c.

◆ __pci_driver

struct pci_driver linda_driver __pci_driver
Initial value:
= {
.ids = linda_nics,
.id_count = ( sizeof ( linda_nics ) / sizeof ( linda_nics[0] ) ),
.probe = linda_probe,
}
static struct xen_remove_from_physmap * remove
Definition: xenmem.h:39
static struct pci_device_id linda_nics[]
Definition: linda.c:2421
static int linda_probe(struct pci_device *pci)
Probe PCI device.
Definition: linda.c:2316
static void linda_remove(struct pci_device *pci)
Remove PCI device.
Definition: linda.c:2410

Definition at line 2425 of file linda.c.