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

QLogic Linda Infiniband HCA. More...

#include <stdint.h>
#include <stdlib.h>
#include <string.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 129 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 131 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 133 of file linda.c.

◆ linda_writeq

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

Definition at line 147 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 149 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 151 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 379 of file linda.c.

◆ LINDA_EPB_ALL_CHANNELS

#define LINDA_EPB_ALL_CHANNELS   31

Magic "all channels" channel number.

Definition at line 1986 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 1989 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:1986

Definition at line 2051 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 125 of file linda.c.

126  {
127  *qword = readq ( linda->regs + offset );
128 }
A Linda HCA.
Definition: linda.c:77
uint64_t readq(volatile uint64_t *io_addr)
Read 64-bit qword from memory-mapped device.
void * regs
Registers.
Definition: linda.c:79
uint16_t offset
Offset to command line.
Definition: bzimage.h:8

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 143 of file linda.c.

144  {
145  writeq ( *qword, ( linda->regs + offset ) );
146 }
A Linda HCA.
Definition: linda.c:77
void * regs
Registers.
Definition: linda.c:79
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
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 161 of file linda.c.

162  {
163  writel ( dword, ( linda->regs + offset ) );
164 }
A Linda HCA.
Definition: linda.c:77
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
void * regs
Registers.
Definition: linda.c:79
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
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 179 of file linda.c.

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

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 195 of file linda.c.

195  {
196  struct linda *linda = ib_get_drvdata ( ibdev );
197  struct QIB_7220_IBCStatus ibcstatus;
198  struct QIB_7220_EXTCtrl extctrl;
199  unsigned int link_state;
200  unsigned int link_width;
201  unsigned int link_speed;
202 
203  /* Read link state */
205  link_state = BIT_GET ( &ibcstatus, LinkState );
206  link_width = BIT_GET ( &ibcstatus, LinkWidthActive );
207  link_speed = BIT_GET ( &ibcstatus, LinkSpeedActive );
208  DBGC ( linda, "Linda %p link state %s (%s %s)\n", linda,
209  linda_link_state_text ( link_state ),
210  ( link_speed ? "DDR" : "SDR" ), ( link_width ? "x4" : "x1" ) );
211 
212  /* Set LEDs according to link state */
214  BIT_SET ( &extctrl, LEDPriPortGreenOn,
215  ( ( link_state >= LINDA_LINK_STATE_INIT ) ? 1 : 0 ) );
216  BIT_SET ( &extctrl, LEDPriPortYellowOn,
217  ( ( link_state >= LINDA_LINK_STATE_ACTIVE ) ? 1 : 0 ) );
219 
220  /* Notify Infiniband core of link state change */
221  ibdev->port_state = ( link_state + 1 );
222  ibdev->link_width_active =
223  ( link_width ? IB_LINK_WIDTH_4X : IB_LINK_WIDTH_1X );
224  ibdev->link_speed_active =
225  ( link_speed ? IB_LINK_SPEED_DDR : IB_LINK_SPEED_SDR );
226  ib_link_state_changed ( ibdev );
227 }
A Linda HCA.
Definition: linda.c:77
#define QIB_7220_EXTCtrl_offset
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:129
#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:179
#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 236 of file linda.c.

237  {
238  struct QIB_7220_IBCStatus ibcstatus;
239  unsigned int link_state;
240  unsigned int i;
241 
242  for ( i = 0 ; i < LINDA_LINK_STATE_MAX_WAIT_US ; i++ ) {
244  link_state = BIT_GET ( &ibcstatus, LinkState );
245  if ( link_state == new_link_state )
246  return 0;
247  udelay ( 1 );
248  }
249 
250  DBGC ( linda, "Linda %p timed out waiting for link state %s\n",
251  linda, linda_link_state_text ( link_state ) );
252  return -ETIMEDOUT;
253 }
A Linda HCA.
Definition: linda.c:77
#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:129
#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:179
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 261 of file linda.c.

261  {
262  struct linda *linda = ib_get_drvdata ( ibdev );
264  struct QIB_7220_IBCCtrl ibcctrl;
265  unsigned int port_state;
266  unsigned int link_state;
267 
268  /* Set new link state */
270  if ( port_state ) {
271  link_state = ( port_state - 1 );
272  DBGC ( linda, "Linda %p set link state to %s (%x)\n", linda,
273  linda_link_state_text ( link_state ), link_state );
275  BIT_SET ( &ibcctrl, LinkCmd, link_state );
277 
278  /* Wait for link state change to take effect. Ignore
279  * errors; the current link state will be returned via
280  * the GetResponse MAD.
281  */
282  linda_link_state_check ( linda, link_state );
283  }
284 
285  /* Detect and report link state change */
286  linda_link_state_changed ( ibdev );
287 
288  return 0;
289 }
A Linda HCA.
Definition: linda.c:77
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:129
static void linda_link_state_changed(struct ib_device *ibdev)
Handle link state change.
Definition: linda.c:195
#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:179
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:236
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 297 of file linda.c.

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

◆ 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 316 of file linda.c.

316  {
317  /* This mapping is fixed by hardware */
318  return ( ctx * 2 );
319 }
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 327 of file linda.c.

327  {
328  /* This mapping is fixed by hardware */
329  return ( qpn / 2 );
330 }
__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 338 of file linda.c.

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

361  {
362 
363  linda->used_ctx[ctx] = 0;
364  DBGC2 ( linda, "Linda %p CTX %d freed\n", linda, ctx );
365 }
A Linda HCA.
Definition: linda.c:77
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
uint8_t used_ctx[LINDA_NUM_CONTEXTS]
In-use contexts.
Definition: linda.c:82
#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 391 of file linda.c.

391  {
392  unsigned int send_buf;
393 
394  send_buf = linda->send_buf[linda->send_buf_cons];
395  send_buf ^= LINDA_SEND_BUF_TOGGLE;
396  linda->send_buf_cons = ( ( linda->send_buf_cons + 1 ) %
398  return send_buf;
399 }
A Linda HCA.
Definition: linda.c:77
uint8_t send_buf[LINDA_MAX_SEND_BUFS]
Send buffer availability (maintained by software)
Definition: linda.c:93
#define LINDA_SEND_BUF_TOGGLE
Send buffer toggle bit.
Definition: linda.c:379
#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:97

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 407 of file linda.c.

408  {
409  linda->send_buf[linda->send_buf_prod] = send_buf;
410  linda->send_buf_prod = ( ( linda->send_buf_prod + 1 ) %
412 }
A Linda HCA.
Definition: linda.c:77
uint8_t send_buf[LINDA_MAX_SEND_BUFS]
Send buffer availability (maintained by software)
Definition: linda.c:93
unsigned int send_buf_prod
Send buffer availability producer counter.
Definition: linda.c:95
#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 421 of file linda.c.

422  {
423  unsigned int send_idx;
424  unsigned int send_check;
425  unsigned int inusecheck;
426  unsigned int inuse;
427  unsigned int check;
428 
429  send_idx = ( send_buf & ~LINDA_SEND_BUF_TOGGLE );
430  send_check = ( !! ( send_buf & LINDA_SEND_BUF_TOGGLE ) );
431  inusecheck = BIT_GET ( linda->sendbufavail, InUseCheck[send_idx] );
432  inuse = ( !! ( inusecheck & 0x02 ) );
433  check = ( !! ( inusecheck & 0x01 ) );
434  return ( inuse || ( check != send_check ) );
435 }
A Linda HCA.
Definition: linda.c:77
#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:379
struct QIB_7220_SendBufAvail * sendbufavail
Send buffer availability (reported by hardware)
Definition: linda.c:91

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 444 of file linda.c.

445  {
446  return ( linda->send_buffer_base +
447  ( ( send_buf & ~LINDA_SEND_BUF_TOGGLE ) *
449 }
unsigned long send_buffer_base
Offset within register space of the first send buffer.
Definition: linda.c:89
A Linda HCA.
Definition: linda.c:77
#define LINDA_SEND_BUF_TOGGLE
Send buffer toggle bit.
Definition: linda.c:379
#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 457 of file linda.c.

458  {
459  struct ib_work_queue *wq = &qp->send;
460  struct linda_send_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
461  int rc;
462 
463  /* Reserve send buffers */
464  if ( ( linda->reserved_send_bufs + qp->send.num_wqes ) >
466  DBGC ( linda, "Linda %p out of send buffers (have %d, used "
467  "%d, need %d)\n", linda, LINDA_MAX_SEND_BUFS,
468  linda->reserved_send_bufs, qp->send.num_wqes );
469  rc = -ENOBUFS;
470  goto err_reserve_bufs;
471  }
472  linda->reserved_send_bufs += qp->send.num_wqes;
473 
474  /* Reset work queue */
475  linda_wq->prod = 0;
476  linda_wq->cons = 0;
477 
478  /* Allocate space for send buffer uasge list */
479  linda_wq->send_buf = zalloc ( qp->send.num_wqes *
480  sizeof ( linda_wq->send_buf[0] ) );
481  if ( ! linda_wq->send_buf ) {
482  rc = -ENOBUFS;
483  goto err_alloc_send_buf;
484  }
485 
486  return 0;
487 
488  free ( linda_wq->send_buf );
489  err_alloc_send_buf:
490  linda->reserved_send_bufs -= qp->send.num_wqes;
491  err_reserve_bufs:
492  return rc;
493 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A Linda HCA.
Definition: linda.c:77
#define DBGC(...)
Definition: compiler.h:505
uint8_t * send_buf
Send buffer usage.
Definition: linda.c:51
A Linda send work queue.
Definition: linda.c:49
unsigned int prod
Producer index.
Definition: linda.c:53
unsigned int cons
Consumer index.
Definition: linda.c:55
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:661
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:99
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 501 of file linda.c.

502  {
503  struct ib_work_queue *wq = &qp->send;
504  struct linda_send_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
505 
506  free ( linda_wq->send_buf );
507  linda->reserved_send_bufs -= qp->send.num_wqes;
508 }
A Linda HCA.
Definition: linda.c:77
uint8_t * send_buf
Send buffer usage.
Definition: linda.c:51
A Linda send work queue.
Definition: linda.c:49
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:99
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 516 of file linda.c.

516  {
517  struct QIB_7220_SendBufBase sendbufbase;
518  struct QIB_7220_SendBufAvailAddr sendbufavailaddr;
519  struct QIB_7220_SendCtrl sendctrl;
520  unsigned int i;
521  int rc;
522 
523  /* Retrieve SendBufBase */
524  linda_readq ( linda, &sendbufbase, QIB_7220_SendBufBase_offset );
525  linda->send_buffer_base = BIT_GET ( &sendbufbase,
526  BaseAddr_SmallPIO );
527  DBGC ( linda, "Linda %p send buffers at %lx\n",
529 
530  /* Initialise the send_buf[] array */
531  for ( i = 0 ; i < LINDA_MAX_SEND_BUFS ; i++ )
532  linda->send_buf[i] = i;
533 
534  /* Allocate space for the SendBufAvail array */
535  linda->sendbufavail = malloc_phys ( sizeof ( *linda->sendbufavail ),
537  if ( ! linda->sendbufavail ) {
538  rc = -ENOMEM;
539  goto err_alloc_sendbufavail;
540  }
541  memset ( linda->sendbufavail, 0, sizeof ( *linda->sendbufavail ) );
542 
543  /* Program SendBufAvailAddr into the hardware */
544  memset ( &sendbufavailaddr, 0, sizeof ( sendbufavailaddr ) );
545  BIT_FILL_1 ( &sendbufavailaddr, SendBufAvailAddr,
546  ( virt_to_bus ( linda->sendbufavail ) >> 6 ) );
547  linda_writeq ( linda, &sendbufavailaddr,
549 
550  /* Enable sending and DMA of SendBufAvail */
551  memset ( &sendctrl, 0, sizeof ( sendctrl ) );
552  BIT_FILL_2 ( &sendctrl,
553  SendBufAvailUpd, 1,
554  SPioEnable, 1 );
556 
557  return 0;
558 
559  free_phys ( linda->sendbufavail, sizeof ( *linda->sendbufavail ) );
560  err_alloc_sendbufavail:
561  return rc;
562 }
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:89
A Linda HCA.
Definition: linda.c:77
#define QIB_7220_SendBufBase_offset
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:129
#define DBGC(...)
Definition: compiler.h:505
#define QIB_7220_SendBufAvailAddr_offset
uint8_t send_buf[LINDA_MAX_SEND_BUFS]
Send buffer availability (maintained by software)
Definition: linda.c:93
#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
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.c:722
#define LINDA_MAX_SEND_BUFS
Maximum number of send buffers used.
Definition: linda.h:149
struct QIB_7220_SendBufAvail * sendbufavail
Send buffer availability (reported by hardware)
Definition: linda.c:91
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition: malloc.c:706
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 569 of file linda.c.

569  {
570  struct QIB_7220_SendCtrl sendctrl;
571 
572  /* Disable sending and DMA of SendBufAvail */
573  memset ( &sendctrl, 0, sizeof ( sendctrl ) );
575  mb();
576 
577  /* Ensure hardware has seen this disable */
579 
580  free_phys ( linda->sendbufavail, sizeof ( *linda->sendbufavail ) );
581 }
A Linda HCA.
Definition: linda.c:77
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:129
#define QIB_7220_SendCtrl_offset
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.c:722
void mb(void)
Memory barrier.
struct QIB_7220_SendBufAvail * sendbufavail
Send buffer availability (reported by hardware)
Definition: linda.c:91
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 597 of file linda.c.

598  {
599  struct ib_work_queue *wq = &qp->recv;
600  struct linda_recv_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
601  struct QIB_7220_RcvHdrAddr0 rcvhdraddr;
602  struct QIB_7220_RcvHdrTailAddr0 rcvhdrtailaddr;
603  struct QIB_7220_RcvHdrHead0 rcvhdrhead;
604  struct QIB_7220_scalar rcvegrindexhead;
605  struct QIB_7220_RcvCtrl rcvctrl;
606  unsigned int ctx = linda_qpn_to_ctx ( qp->qpn );
607  int rc;
608 
609  /* Reset context information */
610  memset ( &linda_wq->header_prod, 0,
611  sizeof ( linda_wq->header_prod ) );
612  linda_wq->header_cons = 0;
613  linda_wq->eager_prod = 0;
614  linda_wq->eager_cons = 0;
615 
616  /* Allocate receive header buffer */
619  if ( ! linda_wq->header ) {
620  rc = -ENOMEM;
621  goto err_alloc_header;
622  }
623 
624  /* Enable context in hardware */
625  memset ( &rcvhdraddr, 0, sizeof ( rcvhdraddr ) );
626  BIT_FILL_1 ( &rcvhdraddr, RcvHdrAddr0,
627  ( virt_to_bus ( linda_wq->header ) >> 2 ) );
628  linda_writeq_array8b ( linda, &rcvhdraddr,
630  memset ( &rcvhdrtailaddr, 0, sizeof ( rcvhdrtailaddr ) );
631  BIT_FILL_1 ( &rcvhdrtailaddr, RcvHdrTailAddr0,
632  ( virt_to_bus ( &linda_wq->header_prod ) >> 2 ) );
633  linda_writeq_array8b ( linda, &rcvhdrtailaddr,
635  memset ( &rcvhdrhead, 0, sizeof ( rcvhdrhead ) );
636  BIT_FILL_1 ( &rcvhdrhead, counter, 1 );
637  linda_writeq_array64k ( linda, &rcvhdrhead,
639  memset ( &rcvegrindexhead, 0, sizeof ( rcvegrindexhead ) );
640  BIT_FILL_1 ( &rcvegrindexhead, Value, 1 );
641  linda_writeq_array64k ( linda, &rcvegrindexhead,
644  BIT_SET ( &rcvctrl, PortEnable[ctx], 1 );
645  BIT_SET ( &rcvctrl, IntrAvail[ctx], 1 );
647 
648  DBGC ( linda, "Linda %p QPN %ld CTX %d hdrs [%lx,%lx) prod %lx\n",
649  linda, qp->qpn, ctx, virt_to_bus ( linda_wq->header ),
650  ( virt_to_bus ( linda_wq->header ) + LINDA_RECV_HEADERS_SIZE ),
651  virt_to_bus ( &linda_wq->header_prod ) );
652  return 0;
653 
655  err_alloc_header:
656  return rc;
657 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned int header_cons
Receive header consumer offset.
Definition: linda.c:65
#define QIB_7220_RcvHdrTailAddr0_offset
A Linda HCA.
Definition: linda.c:77
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:129
#define QIB_7220_RcvEgrIndexHead0_offset
#define DBGC(...)
Definition: compiler.h:505
#define linda_writeq_array64k(_linda, _ptr, _offset, _idx)
Definition: linda.c:151
A Linda receive work queue.
Definition: linda.c:59
#define BIT_SET(_ptr, _field, _value)
Definition: pseudobit.h:238
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#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:61
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:71
static int linda_qpn_to_ctx(unsigned int qpn)
Map QPN to context number.
Definition: linda.c:327
#define QIB_7220_RcvHdrAddr0_offset
#define QIB_7220_RcvCtrl_offset
#define linda_writeq_array8b(_linda, _ptr, _offset, _idx)
Definition: linda.c:149
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
#define BIT_FILL_1(_ptr, _field1,...)
Definition: pseudobit.h:185
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.c:722
unsigned int eager_cons
Eager array consumer index.
Definition: linda.c:73
struct QIB_7220_scalar header_prod
Receive header producer offset (written by hardware)
Definition: linda.c:63
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition: malloc.c:706
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 665 of file linda.c.

666  {
667  struct ib_work_queue *wq = &qp->recv;
668  struct linda_recv_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
669  struct QIB_7220_RcvCtrl rcvctrl;
670  unsigned int ctx = linda_qpn_to_ctx ( qp->qpn );
671 
672  /* Disable context in hardware */
674  BIT_SET ( &rcvctrl, PortEnable[ctx], 0 );
675  BIT_SET ( &rcvctrl, IntrAvail[ctx], 0 );
677 
678  /* Make sure the hardware has seen that the context is disabled */
680  mb();
681 
682  /* Free headers ring */
684 
685  /* Free context */
686  linda_free_ctx ( linda, ctx );
687 }
A Linda HCA.
Definition: linda.c:77
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:129
A Linda receive work queue.
Definition: linda.c:59
#define BIT_SET(_ptr, _field, _value)
Definition: pseudobit.h:238
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#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:361
An Infiniband Work Queue.
Definition: infiniband.h:100
void * header
Receive header ring.
Definition: linda.c:61
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:327
#define QIB_7220_RcvCtrl_offset
struct arbelprm_qp_db_record qp
Definition: arbel.h:13
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition: malloc.c:722
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 695 of file linda.c.

695  {
696  struct QIB_7220_RcvCtrl rcvctrl;
697  struct QIB_7220_scalar rcvegrbase;
698  struct QIB_7220_scalar rcvhdrentsize;
699  struct QIB_7220_scalar rcvhdrcnt;
700  struct QIB_7220_RcvBTHQP rcvbthqp;
701  unsigned int portcfg;
702  unsigned long egrbase;
703  unsigned int eager_array_size_0;
704  unsigned int eager_array_size_other;
705  unsigned int ctx;
706 
707  /* Select configuration based on number of contexts */
708  switch ( LINDA_NUM_CONTEXTS ) {
709  case 5:
710  portcfg = LINDA_PORTCFG_5CTX;
711  eager_array_size_0 = LINDA_EAGER_ARRAY_SIZE_5CTX_0;
712  eager_array_size_other = LINDA_EAGER_ARRAY_SIZE_5CTX_OTHER;
713  break;
714  case 9:
715  portcfg = LINDA_PORTCFG_9CTX;
716  eager_array_size_0 = LINDA_EAGER_ARRAY_SIZE_9CTX_0;
717  eager_array_size_other = LINDA_EAGER_ARRAY_SIZE_9CTX_OTHER;
718  break;
719  case 17:
720  portcfg = LINDA_PORTCFG_17CTX;
721  eager_array_size_0 = LINDA_EAGER_ARRAY_SIZE_17CTX_0;
722  eager_array_size_other = LINDA_EAGER_ARRAY_SIZE_17CTX_OTHER;
723  break;
724  default:
725  build_assert ( 0 );
726  return -EINVAL;
727  }
728 
729  /* Configure number of contexts */
730  memset ( &rcvctrl, 0, sizeof ( rcvctrl ) );
731  BIT_FILL_3 ( &rcvctrl,
732  TailUpd, 1,
733  PortCfg, portcfg,
734  RcvQPMapEnable, 1 );
736 
737  /* Configure receive header buffer sizes */
738  memset ( &rcvhdrcnt, 0, sizeof ( rcvhdrcnt ) );
739  BIT_FILL_1 ( &rcvhdrcnt, Value, LINDA_RECV_HEADER_COUNT );
741  memset ( &rcvhdrentsize, 0, sizeof ( rcvhdrentsize ) );
742  BIT_FILL_1 ( &rcvhdrentsize, Value, ( LINDA_RECV_HEADER_SIZE >> 2 ) );
743  linda_writeq ( linda, &rcvhdrentsize, QIB_7220_RcvHdrEntSize_offset );
744 
745  /* Calculate eager array start addresses for each context */
746  linda_readq ( linda, &rcvegrbase, QIB_7220_RcvEgrBase_offset );
747  egrbase = BIT_GET ( &rcvegrbase, Value );
748  linda->recv_wq[0].eager_array = egrbase;
749  linda->recv_wq[0].eager_entries = eager_array_size_0;
750  egrbase += ( eager_array_size_0 * sizeof ( struct QIB_7220_RcvEgr ) );
751  for ( ctx = 1 ; ctx < LINDA_NUM_CONTEXTS ; ctx++ ) {
752  linda->recv_wq[ctx].eager_array = egrbase;
753  linda->recv_wq[ctx].eager_entries = eager_array_size_other;
754  egrbase += ( eager_array_size_other *
755  sizeof ( struct QIB_7220_RcvEgr ) );
756  }
757  for ( ctx = 0 ; ctx < LINDA_NUM_CONTEXTS ; ctx++ ) {
758  DBGC ( linda, "Linda %p CTX %d eager array at %lx (%d "
759  "entries)\n", linda, ctx,
762  }
763 
764  /* Set the BTH QP for Infinipath packets to an unused value */
765  memset ( &rcvbthqp, 0, sizeof ( rcvbthqp ) );
766  BIT_FILL_1 ( &rcvbthqp, RcvBTHQP, LINDA_QP_IDETH );
768 
769  return 0;
770 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
A Linda HCA.
Definition: linda.c:77
#define QIB_7220_RcvHdrEntSize_offset
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:129
#define DBGC(...)
Definition: compiler.h:505
struct linda_recv_work_queue recv_wq[LINDA_NUM_CONTEXTS]
Receive work queues.
Definition: linda.c:86
#define LINDA_EAGER_ARRAY_SIZE_17CTX_0
Definition: linda.h:172
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#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:69
#define LINDA_QP_IDETH
QPN used for Infinipath Packets.
Definition: linda.h:219
#define LINDA_EAGER_ARRAY_SIZE_5CTX_OTHER
Definition: linda.h:169
#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:67
#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 777 of file linda.c.

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

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 797 of file linda.c.

798  {
799  struct linda *linda = ib_get_drvdata ( ibdev );
800  static int cqn;
801 
802  /* The hardware has no concept of completion queues. We
803  * simply use the association between CQs and WQs (already
804  * handled by the IB core) to decide which WQs to poll.
805  *
806  * We do set a CQN, just to avoid confusing debug messages
807  * from the IB core.
808  */
809  cq->cqn = ++cqn;
810  DBGC ( linda, "Linda %p CQN %ld created\n", linda, cq->cqn );
811 
812  return 0;
813 }
A Linda HCA.
Definition: linda.c:77
#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 821 of file linda.c.

822  {
823  struct linda *linda = ib_get_drvdata ( ibdev );
824 
825  /* Nothing to do */
826  DBGC ( linda, "Linda %p CQN %ld destroyed\n", linda, cq->cqn );
827 }
A Linda HCA.
Definition: linda.c:77
#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 843 of file linda.c.

844  {
845  struct linda *linda = ib_get_drvdata ( ibdev );
846  int ctx;
847  int rc;
848 
849  /* Locate an available context */
850  ctx = linda_alloc_ctx ( linda );
851  if ( ctx < 0 ) {
852  rc = ctx;
853  goto err_alloc_ctx;
854  }
855 
856  /* Set queue pair number based on context index */
857  qp->qpn = linda_ctx_to_qpn ( ctx );
858 
859  /* Set work-queue private data pointers */
860  ib_wq_set_drvdata ( &qp->send, &linda->send_wq[ctx] );
861  ib_wq_set_drvdata ( &qp->recv, &linda->recv_wq[ctx] );
862 
863  /* Create receive work queue */
864  if ( ( rc = linda_create_recv_wq ( linda, qp ) ) != 0 )
865  goto err_create_recv_wq;
866 
867  /* Create send work queue */
868  if ( ( rc = linda_create_send_wq ( linda, qp ) ) != 0 )
869  goto err_create_send_wq;
870 
871  return 0;
872 
874  err_create_send_wq:
876  err_create_recv_wq:
877  linda_free_ctx ( linda, ctx );
878  err_alloc_ctx:
879  return rc;
880 }
struct linda_send_work_queue send_wq[LINDA_NUM_CONTEXTS]
Send work queues.
Definition: linda.c:84
static int linda_ctx_to_qpn(unsigned int ctx)
Map context number to QPN.
Definition: linda.c:316
static void linda_destroy_recv_wq(struct linda *linda, struct ib_queue_pair *qp)
Destroy receive work queue.
Definition: linda.c:665
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A Linda HCA.
Definition: linda.c:77
struct linda_recv_work_queue recv_wq[LINDA_NUM_CONTEXTS]
Receive work queues.
Definition: linda.c:86
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
static void linda_free_ctx(struct linda *linda, unsigned int ctx)
Free a context.
Definition: linda.c:361
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:501
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:597
static int linda_create_send_wq(struct linda *linda, struct ib_queue_pair *qp)
Create send work queue.
Definition: linda.c:457
static int linda_alloc_ctx(struct linda *linda)
Allocate a context.
Definition: linda.c:338
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 889 of file linda.c.

890  {
891  struct linda *linda = ib_get_drvdata ( ibdev );
892 
893  /* Nothing to do; the hardware doesn't have a notion of queue
894  * keys
895  */
896  DBGC ( linda, "Linda %p QPN %ld modified\n", linda, qp->qpn );
897  return 0;
898 }
A Linda HCA.
Definition: linda.c:77
#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 906 of file linda.c.

907  {
908  struct linda *linda = ib_get_drvdata ( ibdev );
909 
912 }
static void linda_destroy_recv_wq(struct linda *linda, struct ib_queue_pair *qp)
Destroy receive work queue.
Definition: linda.c:665
A Linda HCA.
Definition: linda.c:77
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:501
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 930 of file linda.c.

933  {
934  struct linda *linda = ib_get_drvdata ( ibdev );
935  struct ib_work_queue *wq = &qp->send;
936  struct linda_send_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
937  struct QIB_7220_SendPbc sendpbc;
938  uint8_t header_buf[IB_MAX_HEADER_SIZE];
939  struct io_buffer headers;
940  unsigned int send_buf;
941  unsigned long start_offset;
942  unsigned long offset;
943  size_t len;
944  ssize_t frag_len;
945  uint32_t *data;
946 
947  /* Allocate send buffer and calculate offset */
948  send_buf = linda_alloc_send_buf ( linda );
949  start_offset = offset = linda_send_buffer_offset ( linda, send_buf );
950 
951  /* Store I/O buffer and send buffer index */
952  assert ( wq->iobufs[linda_wq->prod] == NULL );
953  wq->iobufs[linda_wq->prod] = iobuf;
954  linda_wq->send_buf[linda_wq->prod] = send_buf;
955 
956  /* Construct headers */
957  iob_populate ( &headers, header_buf, 0, sizeof ( header_buf ) );
958  iob_reserve ( &headers, sizeof ( header_buf ) );
959  ib_push ( ibdev, &headers, qp, iob_len ( iobuf ), dest );
960 
961  /* Calculate packet length */
962  len = ( ( sizeof ( sendpbc ) + iob_len ( &headers ) +
963  iob_len ( iobuf ) + 3 ) & ~3 );
964 
965  /* Construct send per-buffer control word */
966  memset ( &sendpbc, 0, sizeof ( sendpbc ) );
967  BIT_FILL_2 ( &sendpbc,
968  LengthP1_toibc, ( ( len >> 2 ) - 1 ),
969  VL15, 1 );
970 
971  /* Write SendPbc */
973  linda_writeq ( linda, &sendpbc, offset );
974  offset += sizeof ( sendpbc );
975 
976  /* Write headers */
977  for ( data = headers.data, frag_len = iob_len ( &headers ) ;
978  frag_len > 0 ; data++, offset += 4, frag_len -= 4 ) {
979  linda_writel ( linda, *data, offset );
980  }
981 
982  /* Write data */
983  for ( data = iobuf->data, frag_len = iob_len ( iobuf ) ;
984  frag_len > 0 ; data++, offset += 4, frag_len -= 4 ) {
985  linda_writel ( linda, *data, offset );
986  }
987  DBG_ENABLE ( DBGLVL_IO );
988 
989  assert ( ( start_offset + len ) == offset );
990  DBGC2 ( linda, "Linda %p QPN %ld TX %d(%d) posted [%lx,%lx)\n",
991  linda, qp->qpn, send_buf, linda_wq->prod,
992  start_offset, offset );
993 
994  /* Increment producer counter */
995  linda_wq->prod = ( ( linda_wq->prod + 1 ) & ( wq->num_wqes - 1 ) );
996 
997  return 0;
998 }
#define DBGLVL_IO
Definition: compiler.h:322
A Linda HCA.
Definition: linda.c:77
#define DBG_ENABLE(level)
Definition: compiler.h:313
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
uint8_t * send_buf
Send buffer usage.
Definition: linda.c:51
#define DBG_DISABLE(level)
Definition: compiler.h:312
A Linda send work queue.
Definition: linda.c:49
static void linda_writel(struct linda *linda, uint32_t dword, unsigned long offset)
Write Linda dword register.
Definition: linda.c:161
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:194
unsigned int prod
Producer index.
Definition: linda.c:53
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
ring len
Length.
Definition: dwmac.h:231
unsigned int num_wqes
Number of work queue entries.
Definition: infiniband.h:112
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:159
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:71
#define DBGC2(...)
Definition: compiler.h:522
void * data
Start of data.
Definition: iobuf.h:52
static unsigned int linda_alloc_send_buf(struct linda *linda)
Allocate a send buffer.
Definition: linda.c:391
static unsigned long linda_send_buffer_offset(struct linda *linda, unsigned int send_buf)
Calculate starting offset for send buffer.
Definition: linda.c:444
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
Definition: string.h:150
uint8_t data[48]
Additional event data.
Definition: ena.h:22
signed long ssize_t
Definition: stdint.h:7
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
#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:37
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 1007 of file linda.c.

1009  {
1010  struct linda *linda = ib_get_drvdata ( ibdev );
1011  struct ib_work_queue *wq = &qp->send;
1012  struct linda_send_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
1013  struct io_buffer *iobuf;
1014  unsigned int send_buf;
1015 
1016  /* Parse completion */
1017  send_buf = linda_wq->send_buf[wqe_idx];
1018  DBGC2 ( linda, "Linda %p QPN %ld TX %d(%d) complete\n",
1019  linda, qp->qpn, send_buf, wqe_idx );
1020 
1021  /* Complete work queue entry */
1022  iobuf = wq->iobufs[wqe_idx];
1023  assert ( iobuf != NULL );
1024  ib_complete_send ( ibdev, qp, iobuf, 0 );
1025  wq->iobufs[wqe_idx] = NULL;
1026 
1027  /* Free send buffer */
1028  linda_free_send_buf ( linda, send_buf );
1029 }
A Linda HCA.
Definition: linda.c:77
uint8_t * send_buf
Send buffer usage.
Definition: linda.c:51
A Linda send work queue.
Definition: linda.c:49
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:407
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:37
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 1037 of file linda.c.

1038  {
1039  struct linda *linda = ib_get_drvdata ( ibdev );
1040  struct ib_work_queue *wq = &qp->send;
1041  struct linda_send_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
1042  unsigned int send_buf;
1043 
1044  /* Look for completions */
1045  while ( wq->fill ) {
1046 
1047  /* Check to see if send buffer has completed */
1048  send_buf = linda_wq->send_buf[linda_wq->cons];
1050  break;
1051 
1052  /* Complete this buffer */
1053  linda_complete_send ( ibdev, qp, linda_wq->cons );
1054 
1055  /* Increment consumer counter */
1056  linda_wq->cons = ( ( linda_wq->cons + 1 ) &
1057  ( wq->num_wqes - 1 ) );
1058  }
1059 }
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:1007
A Linda HCA.
Definition: linda.c:77
uint8_t * send_buf
Send buffer usage.
Definition: linda.c:51
A Linda send work queue.
Definition: linda.c:49
unsigned int cons
Consumer index.
Definition: linda.c:55
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:421

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 1069 of file linda.c.

1071  {
1072  struct linda *linda = ib_get_drvdata ( ibdev );
1073  struct ib_work_queue *wq = &qp->recv;
1074  struct linda_recv_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
1075  struct QIB_7220_RcvEgr rcvegr;
1076  struct QIB_7220_scalar rcvegrindexhead;
1077  unsigned int ctx = linda_qpn_to_ctx ( qp->qpn );
1078  physaddr_t addr;
1079  size_t len;
1080  unsigned int wqe_idx;
1081  unsigned int bufsize;
1082 
1083  /* Sanity checks */
1084  addr = virt_to_bus ( iobuf->data );
1085  len = iob_tailroom ( iobuf );
1086  if ( addr & ( LINDA_EAGER_BUFFER_ALIGN - 1 ) ) {
1087  DBGC ( linda, "Linda %p QPN %ld misaligned RX buffer "
1088  "(%08lx)\n", linda, qp->qpn, addr );
1089  return -EINVAL;
1090  }
1091  if ( len != LINDA_RECV_PAYLOAD_SIZE ) {
1092  DBGC ( linda, "Linda %p QPN %ld wrong RX buffer size (%zd)\n",
1093  linda, qp->qpn, len );
1094  return -EINVAL;
1095  }
1096 
1097  /* Calculate eager producer index and WQE index */
1098  wqe_idx = ( linda_wq->eager_prod & ( wq->num_wqes - 1 ) );
1099  assert ( wq->iobufs[wqe_idx] == NULL );
1100 
1101  /* Store I/O buffer */
1102  wq->iobufs[wqe_idx] = iobuf;
1103 
1104  /* Calculate buffer size */
1105  switch ( LINDA_RECV_PAYLOAD_SIZE ) {
1106  case 2048: bufsize = LINDA_EAGER_BUFFER_2K; break;
1107  case 4096: bufsize = LINDA_EAGER_BUFFER_4K; break;
1108  case 8192: bufsize = LINDA_EAGER_BUFFER_8K; break;
1109  case 16384: bufsize = LINDA_EAGER_BUFFER_16K; break;
1110  case 32768: bufsize = LINDA_EAGER_BUFFER_32K; break;
1111  case 65536: bufsize = LINDA_EAGER_BUFFER_64K; break;
1112  default: build_assert ( 0 );
1114  }
1115 
1116  /* Post eager buffer */
1117  memset ( &rcvegr, 0, sizeof ( rcvegr ) );
1118  BIT_FILL_2 ( &rcvegr,
1119  Addr, ( addr >> 11 ),
1120  BufSize, bufsize );
1121  linda_writeq_array8b ( linda, &rcvegr,
1122  linda_wq->eager_array, linda_wq->eager_prod );
1123  DBGC2 ( linda, "Linda %p QPN %ld RX egr %d(%d) posted [%lx,%lx)\n",
1124  linda, qp->qpn, linda_wq->eager_prod, wqe_idx,
1125  addr, ( addr + len ) );
1126 
1127  /* Increment producer index */
1128  linda_wq->eager_prod = ( ( linda_wq->eager_prod + 1 ) &
1129  ( linda_wq->eager_entries - 1 ) );
1130 
1131  /* Update head index */
1132  memset ( &rcvegrindexhead, 0, sizeof ( rcvegrindexhead ) );
1133  BIT_FILL_1 ( &rcvegrindexhead,
1134  Value, ( ( linda_wq->eager_prod + 1 ) &
1135  ( linda_wq->eager_entries - 1 ) ) );
1136  linda_writeq_array64k ( linda, &rcvegrindexhead,
1138 
1139  return 0;
1140 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
A Linda HCA.
Definition: linda.c:77
#define QIB_7220_RcvEgrIndexHead0_offset
#define DBGC(...)
Definition: compiler.h:505
#define linda_writeq_array64k(_linda, _ptr, _offset, _idx)
Definition: linda.c:151
A Linda receive work queue.
Definition: linda.c:59
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
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
ring len
Length.
Definition: dwmac.h:231
#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:69
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:71
static int linda_qpn_to_ctx(unsigned int qpn)
Map QPN to context number.
Definition: linda.c:327
uint32_t addr
Buffer address.
Definition: dwmac.h:20
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
Definition: iobuf.h:179
#define linda_writeq_array8b(_linda, _ptr, _offset, _idx)
Definition: linda.c:149
#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
#define DBGC2(...)
Definition: compiler.h:522
unsigned long eager_array
Offset within register space of the eager array.
Definition: linda.c:67
#define BIT_FILL_1(_ptr, _field1,...)
Definition: pseudobit.h:185
void * data
Start of data.
Definition: iobuf.h:52
#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 1149 of file linda.c.

1151  {
1152  struct linda *linda = ib_get_drvdata ( ibdev );
1153  struct ib_work_queue *wq = &qp->recv;
1154  struct linda_recv_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
1155  struct QIB_7220_RcvHdrFlags *rcvhdrflags;
1156  struct QIB_7220_RcvEgr rcvegr;
1157  struct io_buffer headers;
1158  struct io_buffer *iobuf;
1159  struct ib_queue_pair *intended_qp;
1160  struct ib_address_vector dest;
1161  struct ib_address_vector source;
1162  unsigned int rcvtype;
1163  unsigned int pktlen;
1164  unsigned int egrindex;
1165  unsigned int useegrbfr;
1166  unsigned int iberr, mkerr, tiderr, khdrerr, mtuerr;
1167  unsigned int lenerr, parityerr, vcrcerr, icrcerr;
1168  unsigned int err;
1169  unsigned int hdrqoffset;
1170  unsigned int header_len;
1171  unsigned int padded_payload_len;
1172  unsigned int wqe_idx;
1173  size_t payload_len;
1174  int qp0;
1175  int rc;
1176 
1177  /* RcvHdrFlags are at the end of the header entry */
1178  rcvhdrflags = ( linda_wq->header + header_offs +
1179  LINDA_RECV_HEADER_SIZE - sizeof ( *rcvhdrflags ) );
1180  rcvtype = BIT_GET ( rcvhdrflags, RcvType );
1181  pktlen = ( BIT_GET ( rcvhdrflags, PktLen ) << 2 );
1182  egrindex = BIT_GET ( rcvhdrflags, EgrIndex );
1183  useegrbfr = BIT_GET ( rcvhdrflags, UseEgrBfr );
1184  hdrqoffset = ( BIT_GET ( rcvhdrflags, HdrqOffset ) << 2 );
1185  iberr = BIT_GET ( rcvhdrflags, IBErr );
1186  mkerr = BIT_GET ( rcvhdrflags, MKErr );
1187  tiderr = BIT_GET ( rcvhdrflags, TIDErr );
1188  khdrerr = BIT_GET ( rcvhdrflags, KHdrErr );
1189  mtuerr = BIT_GET ( rcvhdrflags, MTUErr );
1190  lenerr = BIT_GET ( rcvhdrflags, LenErr );
1191  parityerr = BIT_GET ( rcvhdrflags, ParityErr );
1192  vcrcerr = BIT_GET ( rcvhdrflags, VCRCErr );
1193  icrcerr = BIT_GET ( rcvhdrflags, ICRCErr );
1194  header_len = ( LINDA_RECV_HEADER_SIZE - hdrqoffset -
1195  sizeof ( *rcvhdrflags ) );
1196  padded_payload_len = ( pktlen - header_len - 4 /* ICRC */ );
1197  err = ( iberr | mkerr | tiderr | khdrerr | mtuerr |
1198  lenerr | parityerr | vcrcerr | icrcerr );
1199  /* IB header is placed immediately before RcvHdrFlags */
1200  iob_populate ( &headers, ( ( ( void * ) rcvhdrflags ) - header_len ),
1201  header_len, header_len );
1202 
1203  /* Dump diagnostic information */
1204  if ( err || ( ! useegrbfr ) ) {
1205  DBGC ( linda, "Linda %p QPN %ld RX egr %d%s hdr %d type %d "
1206  "len %d(%d+%d+4)%s%s%s%s%s%s%s%s%s%s%s\n", linda,
1207  qp->qpn, egrindex, ( useegrbfr ? "" : "(unused)" ),
1208  ( header_offs / LINDA_RECV_HEADER_SIZE ), rcvtype,
1209  pktlen, header_len, padded_payload_len,
1210  ( err ? " [Err" : "" ), ( iberr ? " IB" : "" ),
1211  ( mkerr ? " MK" : "" ), ( tiderr ? " TID" : "" ),
1212  ( khdrerr ? " KHdr" : "" ), ( mtuerr ? " MTU" : "" ),
1213  ( lenerr ? " Len" : "" ), ( parityerr ? " Parity" : ""),
1214  ( vcrcerr ? " VCRC" : "" ), ( icrcerr ? " ICRC" : "" ),
1215  ( err ? "]" : "" ) );
1216  } else {
1217  DBGC2 ( linda, "Linda %p QPN %ld RX egr %d hdr %d type %d "
1218  "len %d(%d+%d+4)\n", linda, qp->qpn, egrindex,
1219  ( header_offs / LINDA_RECV_HEADER_SIZE ), rcvtype,
1220  pktlen, header_len, padded_payload_len );
1221  }
1222  DBGCP_HDA ( linda, hdrqoffset, headers.data,
1223  ( header_len + sizeof ( *rcvhdrflags ) ) );
1224 
1225  /* Parse header to generate address vector */
1226  qp0 = ( qp->qpn == 0 );
1227  intended_qp = NULL;
1228  if ( ( rc = ib_pull ( ibdev, &headers, ( qp0 ? &intended_qp : NULL ),
1229  &payload_len, &dest, &source ) ) != 0 ) {
1230  DBGC ( linda, "Linda %p could not parse headers: %s\n",
1231  linda, strerror ( rc ) );
1232  err = 1;
1233  }
1234  if ( ! intended_qp )
1235  intended_qp = qp;
1236 
1237  /* Complete this buffer and any skipped buffers. Note that
1238  * when the hardware runs out of buffers, it will repeatedly
1239  * report the same buffer (the tail) as a TID error, and that
1240  * it also has a habit of sometimes skipping over several
1241  * buffers at once.
1242  */
1243  while ( 1 ) {
1244 
1245  /* If we have caught up to the producer counter, stop.
1246  * This will happen when the hardware first runs out
1247  * of buffers and starts reporting TID errors against
1248  * the eager buffer it wants to use next.
1249  */
1250  if ( linda_wq->eager_cons == linda_wq->eager_prod )
1251  break;
1252 
1253  /* If we have caught up to where we should be after
1254  * completing this egrindex, stop. We phrase the test
1255  * this way to avoid completing the entire ring when
1256  * we receive the same egrindex twice in a row.
1257  */
1258  if ( ( linda_wq->eager_cons ==
1259  ( ( egrindex + 1 ) & ( linda_wq->eager_entries - 1 ) )))
1260  break;
1261 
1262  /* Identify work queue entry and corresponding I/O
1263  * buffer.
1264  */
1265  wqe_idx = ( linda_wq->eager_cons & ( wq->num_wqes - 1 ) );
1266  iobuf = wq->iobufs[wqe_idx];
1267  assert ( iobuf != NULL );
1268  wq->iobufs[wqe_idx] = NULL;
1269 
1270  /* Complete the eager buffer */
1271  if ( linda_wq->eager_cons == egrindex ) {
1272  /* Completing the eager buffer described in
1273  * this header entry.
1274  */
1275  if ( payload_len <= iob_tailroom ( iobuf ) ) {
1276  iob_put ( iobuf, payload_len );
1277  rc = ( err ?
1278  -EIO : ( useegrbfr ? 0 : -ECANCELED ) );
1279  } else {
1280  DBGC ( linda, "Linda %p bad payload len %zd\n",
1281  linda, payload_len );
1282  rc = -EPROTO;
1283  }
1284  /* Redirect to target QP if necessary */
1285  if ( qp != intended_qp ) {
1286  DBGC ( linda, "Linda %p redirecting QPN %ld "
1287  "=> %ld\n",
1288  linda, qp->qpn, intended_qp->qpn );
1289  /* Compensate for incorrect fill levels */
1290  qp->recv.fill--;
1291  intended_qp->recv.fill++;
1292  }
1293  ib_complete_recv ( ibdev, intended_qp, &dest, &source,
1294  iobuf, rc );
1295  } else {
1296  /* Completing on a skipped-over eager buffer */
1297  ib_complete_recv ( ibdev, qp, &dest, &source, iobuf,
1298  -ECANCELED );
1299  }
1300 
1301  /* Clear eager buffer */
1302  memset ( &rcvegr, 0, sizeof ( rcvegr ) );
1303  linda_writeq_array8b ( linda, &rcvegr, linda_wq->eager_array,
1304  linda_wq->eager_cons );
1305 
1306  /* Increment consumer index */
1307  linda_wq->eager_cons = ( ( linda_wq->eager_cons + 1 ) &
1308  ( linda_wq->eager_entries - 1 ) );
1309  }
1310 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:124
A Linda HCA.
Definition: linda.c:77
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:59
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:194
#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:61
unsigned int num_wqes
Number of work queue entries.
Definition: infiniband.h:112
#define EPROTO
Protocol error.
Definition: errno.h:624
unsigned int eager_entries
Number of entries in eager array.
Definition: linda.c:69
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:71
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
Definition: iobuf.h:179
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:149
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:67
#define EIO
Input/output error.
Definition: errno.h:433
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
Definition: string.h:150
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:73
void * memset(void *dest, int character, size_t len) __nonnull
A persistent I/O buffer.
Definition: iobuf.h:37
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 1318 of file linda.c.

1319  {
1320  struct linda *linda = ib_get_drvdata ( ibdev );
1321  struct ib_work_queue *wq = &qp->recv;
1322  struct linda_recv_work_queue *linda_wq = ib_wq_get_drvdata ( wq );
1323  struct QIB_7220_RcvHdrHead0 rcvhdrhead;
1324  unsigned int ctx = linda_qpn_to_ctx ( qp->qpn );
1325  unsigned int header_prod;
1326 
1327  /* Check for received packets */
1328  header_prod = ( BIT_GET ( &linda_wq->header_prod, Value ) << 2 );
1329  if ( header_prod == linda_wq->header_cons )
1330  return;
1331 
1332  /* Process all received packets */
1333  while ( linda_wq->header_cons != header_prod ) {
1334 
1335  /* Complete the receive */
1336  linda_complete_recv ( ibdev, qp, linda_wq->header_cons );
1337 
1338  /* Increment the consumer offset */
1339  linda_wq->header_cons += LINDA_RECV_HEADER_SIZE;
1340  linda_wq->header_cons %= LINDA_RECV_HEADERS_SIZE;
1341  }
1342 
1343  /* Update consumer offset */
1344  memset ( &rcvhdrhead, 0, sizeof ( rcvhdrhead ) );
1345  BIT_FILL_2 ( &rcvhdrhead,
1346  RcvHeadPointer, ( linda_wq->header_cons >> 2 ),
1347  counter, 1 );
1348  linda_writeq_array64k ( linda, &rcvhdrhead,
1350 }
unsigned int header_cons
Receive header consumer offset.
Definition: linda.c:65
A Linda HCA.
Definition: linda.c:77
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:1149
#define linda_writeq_array64k(_linda, _ptr, _offset, _idx)
Definition: linda.c:151
A Linda receive work queue.
Definition: linda.c:59
struct golan_eq_context ctx
Definition: CIB_PRM.h:28
#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:327
#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:63
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 1358 of file linda.c.

1359  {
1360  struct ib_work_queue *wq;
1361 
1362  /* Poll associated send and receive queues */
1363  list_for_each_entry ( wq, &cq->work_queues, list ) {
1364  if ( wq->is_send ) {
1365  linda_poll_send_wq ( ibdev, wq->qp );
1366  } else {
1367  linda_poll_recv_wq ( ibdev, wq->qp );
1368  }
1369  }
1370 }
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:1318
static void linda_poll_send_wq(struct ib_device *ibdev, struct ib_queue_pair *qp)
Poll send work queue.
Definition: linda.c:1037
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 1384 of file linda.c.

1384  {
1385  struct linda *linda = ib_get_drvdata ( ibdev );
1386  struct QIB_7220_ErrStatus errstatus;
1387  struct QIB_7220_ErrClear errclear;
1388 
1389  /* Check for link status changes */
1390  DBG_DISABLE ( DBGLVL_IO );
1391  linda_readq ( linda, &errstatus, QIB_7220_ErrStatus_offset );
1392  DBG_ENABLE ( DBGLVL_IO );
1393  if ( BIT_GET ( &errstatus, IBStatusChanged ) ) {
1394  linda_link_state_changed ( ibdev );
1395  memset ( &errclear, 0, sizeof ( errclear ) );
1396  BIT_FILL_1 ( &errclear, IBStatusChangedClear, 1 );
1398  }
1399 }
#define DBGLVL_IO
Definition: compiler.h:322
A Linda HCA.
Definition: linda.c:77
#define DBG_ENABLE(level)
Definition: compiler.h:313
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:129
static void linda_link_state_changed(struct ib_device *ibdev)
Handle link state change.
Definition: linda.c:195
#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 1414 of file linda.c.

1414  {
1415  struct linda *linda = ib_get_drvdata ( ibdev );
1416  struct QIB_7220_Control control;
1417 
1418  /* Disable link */
1420  BIT_SET ( &control, LinkEn, 1 );
1422  return 0;
1423 }
A Linda HCA.
Definition: linda.c:77
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:129
#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 1430 of file linda.c.

1430  {
1431  struct linda *linda = ib_get_drvdata ( ibdev );
1432  struct QIB_7220_Control control;
1433 
1434  /* Disable link */
1436  BIT_SET ( &control, LinkEn, 0 );
1438 }
A Linda HCA.
Definition: linda.c:77
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:129
#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 1455 of file linda.c.

1457  {
1458  struct linda *linda = ib_get_drvdata ( ibdev );
1459 
1460  ( void ) linda;
1461  ( void ) qp;
1462  ( void ) gid;
1463  return 0;
1464 }
A Linda HCA.
Definition: linda.c:77
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 1473 of file linda.c.

1475  {
1476  struct linda *linda = ib_get_drvdata ( ibdev );
1477 
1478  ( void ) linda;
1479  ( void ) qp;
1480  ( void ) gid;
1481 }
A Linda HCA.
Definition: linda.c:77
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 1523 of file linda.c.

1524  {
1525  struct linda *linda =
1526  container_of ( basher, struct linda, i2c.basher );
1527  struct QIB_7220_EXTStatus extstatus;
1528  unsigned int status;
1529 
1530  DBG_DISABLE ( DBGLVL_IO );
1531 
1532  linda_readq ( linda, &extstatus, QIB_7220_EXTStatus_offset );
1533  status = ( BIT_GET ( &extstatus, GPIOIn ) & linda_i2c_bits[bit_id] );
1534 
1535  DBG_ENABLE ( DBGLVL_IO );
1536 
1537  return status;
1538 }
#define DBGLVL_IO
Definition: compiler.h:322
A Linda HCA.
Definition: linda.c:77
#define DBG_ENABLE(level)
Definition: compiler.h:313
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:129
#define DBG_DISABLE(level)
Definition: compiler.h:312
#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
uint8_t status
Status.
Definition: ena.h:16
static unsigned int linda_i2c_bits[]
Linda I2C bit to GPIO mappings.
Definition: linda.c:1510
struct i2c_bit_basher i2c
I2C bit-bashing interface.
Definition: linda.c:102

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 1547 of file linda.c.

1548  {
1549  struct linda *linda =
1550  container_of ( basher, struct linda, i2c.basher );
1551  struct QIB_7220_EXTCtrl extctrl;
1552  struct QIB_7220_GPIO gpioout;
1553  unsigned int bit = linda_i2c_bits[bit_id];
1554  unsigned int outputs = 0;
1555  unsigned int output_enables = 0;
1556 
1557  DBG_DISABLE ( DBGLVL_IO );
1558 
1559  /* Read current GPIO mask and outputs */
1560  linda_readq ( linda, &extctrl, QIB_7220_EXTCtrl_offset );
1561  linda_readq ( linda, &gpioout, QIB_7220_GPIOOut_offset );
1562 
1563  /* Update outputs and output enables. I2C lines are tied
1564  * high, so we always set the output to 0 and use the output
1565  * enable to control the line.
1566  */
1567  output_enables = BIT_GET ( &extctrl, GPIOOe );
1568  output_enables = ( ( output_enables & ~bit ) | ( ~data & bit ) );
1569  outputs = BIT_GET ( &gpioout, GPIO );
1570  outputs = ( outputs & ~bit );
1571  BIT_SET ( &extctrl, GPIOOe, output_enables );
1572  BIT_SET ( &gpioout, GPIO, outputs );
1573 
1574  /* Write the output enable first; that way we avoid logic
1575  * hazards.
1576  */
1579  mb();
1580 
1581  DBG_ENABLE ( DBGLVL_IO );
1582 }
#define DBGLVL_IO
Definition: compiler.h:322
A Linda HCA.
Definition: linda.c:77
#define QIB_7220_EXTCtrl_offset
#define DBG_ENABLE(level)
Definition: compiler.h:313
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:129
#define DBG_DISABLE(level)
Definition: compiler.h:312
#define BIT_SET(_ptr, _field, _value)
Definition: pseudobit.h:238
static unsigned int unsigned int bit
Definition: bigint.h:391
#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:1510
struct i2c_bit_basher i2c
I2C bit-bashing interface.
Definition: linda.c:102

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 1596 of file linda.c.

1596  {
1597  static int try_eeprom_address[] = { 0x51, 0x50 };
1598  unsigned int i;
1599  int rc;
1600 
1601  /* Initialise bus */
1602  if ( ( rc = init_i2c_bit_basher ( &linda->i2c,
1603  &linda_i2c_basher_ops ) ) != 0 ) {
1604  DBGC ( linda, "Linda %p could not initialise I2C bus: %s\n",
1605  linda, strerror ( rc ) );
1606  return rc;
1607  }
1608 
1609  /* Probe for devices */
1610  for ( i = 0 ; i < ( sizeof ( try_eeprom_address ) /
1611  sizeof ( try_eeprom_address[0] ) ) ; i++ ) {
1612  init_i2c_eeprom ( &linda->eeprom, try_eeprom_address[i] );
1613  if ( ( rc = i2c_check_presence ( &linda->i2c.i2c,
1614  &linda->eeprom ) ) == 0 ) {
1615  DBGC2 ( linda, "Linda %p found EEPROM at %02x\n",
1616  linda, try_eeprom_address[i] );
1617  return 0;
1618  }
1619  }
1620 
1621  DBGC ( linda, "Linda %p could not find EEPROM\n", linda );
1622  return -ENODEV;
1623 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A Linda HCA.
Definition: linda.c:77
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:104
static struct bit_basher_operations linda_i2c_basher_ops
Linda I2C bit-bashing interface operations.
Definition: linda.c:1585
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:102

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 1632 of file linda.c.

1632  {
1633  struct i2c_interface *i2c = &linda->i2c.i2c;
1634  int rc;
1635 
1636  /* Read GUID */
1637  if ( ( rc = i2c->read ( i2c, &linda->eeprom, LINDA_EEPROM_GUID_OFFSET,
1638  guid->bytes, sizeof ( *guid ) ) ) != 0 ) {
1639  DBGC ( linda, "Linda %p could not read GUID: %s\n",
1640  linda, strerror ( rc ) );
1641  return rc;
1642  }
1643  DBGC2 ( linda, "Linda %p has GUID " IB_GUID_FMT "\n",
1644  linda, IB_GUID_ARGS ( guid ) );
1645 
1646  /* Read serial number (debug only) */
1647  if ( DBG_LOG ) {
1649 
1650  serial[ sizeof ( serial ) - 1 ] = '\0';
1651  if ( ( rc = i2c->read ( i2c, &linda->eeprom,
1653  ( sizeof ( serial ) - 1 ) ) ) != 0 ) {
1654  DBGC ( linda, "Linda %p could not read serial: %s\n",
1655  linda, strerror ( rc ) );
1656  return rc;
1657  }
1658  DBGC2 ( linda, "Linda %p has serial number \"%s\"\n",
1659  linda, serial );
1660  }
1661 
1662  return 0;
1663 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A Linda HCA.
Definition: linda.c:77
#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:104
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:102

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 1678 of file linda.c.

1678  {
1679  struct QIB_7220_ibsd_epb_access_ctrl access;
1680  unsigned int i;
1681 
1682  /* Request ownership */
1683  memset ( &access, 0, sizeof ( access ) );
1684  BIT_FILL_1 ( &access, sw_ib_epb_req, 1 );
1686 
1687  /* Wait for ownership to be granted */
1688  for ( i = 0 ; i < LINDA_EPB_REQUEST_MAX_WAIT_US ; i++ ) {
1689  linda_readq ( linda, &access,
1691  if ( BIT_GET ( &access, sw_ib_epb_req_granted ) )
1692  return 0;
1693  udelay ( 1 );
1694  }
1695 
1696  DBGC ( linda, "Linda %p timed out waiting for IB EPB request\n",
1697  linda );
1698  return -ETIMEDOUT;
1699 }
A Linda HCA.
Definition: linda.c:77
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:129
#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 1708 of file linda.c.

1709  {
1710  unsigned int i;
1711 
1712  /* Discard first read to allow for signals crossing clock domains */
1714 
1715  for ( i = 0 ; i < LINDA_EPB_XACT_MAX_WAIT_US ; i++ ) {
1716  linda_readq ( linda, xact,
1718  if ( BIT_GET ( xact, ib_epb_rdy ) ) {
1719  if ( BIT_GET ( xact, ib_epb_req_error ) ) {
1720  DBGC ( linda, "Linda %p EPB transaction "
1721  "failed\n", linda );
1722  return -EIO;
1723  } else {
1724  return 0;
1725  }
1726  }
1727  udelay ( 1 );
1728  }
1729 
1730  DBGC ( linda, "Linda %p timed out waiting for IB EPB transaction\n",
1731  linda );
1732  return -ETIMEDOUT;
1733 }
A Linda HCA.
Definition: linda.c:77
#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:129
#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 1740 of file linda.c.

1740  {
1741  struct QIB_7220_ibsd_epb_access_ctrl access;
1742 
1743  memset ( &access, 0, sizeof ( access ) );
1744  BIT_FILL_1 ( &access, sw_ib_epb_req, 0 );
1746 }
A Linda HCA.
Definition: linda.c:77
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#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 1758 of file linda.c.

1758  {
1760  unsigned int data;
1761  int rc;
1762 
1763  /* Ensure no transaction is currently in progress */
1764  if ( ( rc = linda_ib_epb_wait ( linda, &xact ) ) != 0 )
1765  return rc;
1766 
1767  /* Process data */
1768  memset ( &xact, 0, sizeof ( xact ) );
1769  BIT_FILL_3 ( &xact,
1770  ib_epb_address, LINDA_EPB_LOC_ADDRESS ( location ),
1771  ib_epb_read_write, LINDA_EPB_READ,
1772  ib_epb_cs, LINDA_EPB_LOC_CS ( location ) );
1773  linda_writeq ( linda, &xact,
1775 
1776  /* Wait for transaction to complete */
1777  if ( ( rc = linda_ib_epb_wait ( linda, &xact ) ) != 0 )
1778  return rc;
1779 
1780  data = BIT_GET ( &xact, ib_epb_data );
1781  return data;
1782 }
#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:77
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#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:1708
#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 1795 of file linda.c.

1796  {
1798  int rc;
1799 
1800  /* Ensure no transaction is currently in progress */
1801  if ( ( rc = linda_ib_epb_wait ( linda, &xact ) ) != 0 )
1802  return rc;
1803 
1804  /* Process data */
1805  memset ( &xact, 0, sizeof ( xact ) );
1806  BIT_FILL_4 ( &xact,
1807  ib_epb_data, data,
1808  ib_epb_address, LINDA_EPB_LOC_ADDRESS ( location ),
1809  ib_epb_read_write, LINDA_EPB_WRITE,
1810  ib_epb_cs, LINDA_EPB_LOC_CS ( location ) );
1811  linda_writeq ( linda, &xact,
1813 
1814  /* Wait for transaction to complete */
1815  if ( ( rc = linda_ib_epb_wait ( linda, &xact ) ) != 0 )
1816  return rc;
1817 
1818  return 0;
1819 }
#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:77
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#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:1708
#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 1833 of file linda.c.

1836  {
1837  unsigned int location;
1838  int old_value;
1839  int rc;
1840 
1841  DBG_DISABLE ( DBGLVL_IO );
1842 
1843  /* Sanity check */
1844  assert ( ( value & mask ) == value );
1845 
1846  /* Acquire bus ownership */
1847  if ( ( rc = linda_ib_epb_request ( linda ) ) != 0 )
1848  goto out;
1849 
1850  /* Read existing value, if necessary */
1851  location = LINDA_EPB_LOC ( cs, channel, element, reg );
1852  if ( (~mask) & 0xff ) {
1853  old_value = linda_ib_epb_read ( linda, location );
1854  if ( old_value < 0 ) {
1855  rc = old_value;
1856  goto out_release;
1857  }
1858  } else {
1859  old_value = 0;
1860  }
1861 
1862  /* Update value */
1863  value = ( ( old_value & ~mask ) | value );
1864  DBGCP ( linda, "Linda %p CS %d EPB(%d,%d,%#02x) %#02x => %#02x\n",
1865  linda, cs, channel, element, reg, old_value, value );
1866  if ( ( rc = linda_ib_epb_write ( linda, location, value ) ) != 0 )
1867  goto out_release;
1868 
1869  out_release:
1870  /* Release bus */
1872  out:
1873  DBG_ENABLE ( DBGLVL_IO );
1874  return rc;
1875 }
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:1758
static unsigned int unsigned int reg
Definition: myson.h:162
A Linda HCA.
Definition: linda.c:77
#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:1795
#define DBG_DISABLE(level)
Definition: compiler.h:312
value element[index]
Definition: bigint.h:397
__be32 out[4]
Definition: CIB_PRM.h:36
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
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:1740
static int linda_ib_epb_request(struct linda *linda)
Request ownership of the IB external parallel bus.
Definition: linda.c:1678
#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:149

References assert(), channel, cs, DBG_DISABLE, DBG_ENABLE, DBGCP, DBGLVL_IO, element, 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 1887 of file linda.c.

1889  {
1890  unsigned int control;
1891  unsigned int address_hi;
1892  unsigned int address_lo;
1893  int data;
1894  int rc;
1895 
1896  DBG_DISABLE ( DBGLVL_IO );
1897 
1898  assert ( ! ( write && read ) );
1899  assert ( ( address % LINDA_EPB_UC_CHUNK_SIZE ) == 0 );
1900  assert ( ( len % LINDA_EPB_UC_CHUNK_SIZE ) == 0 );
1901 
1902  /* Acquire bus ownership */
1903  if ( ( rc = linda_ib_epb_request ( linda ) ) != 0 )
1904  goto out;
1905 
1906  /* Process data */
1907  while ( len ) {
1908 
1909  /* Reset the address for each new chunk */
1910  if ( ( address % LINDA_EPB_UC_CHUNK_SIZE ) == 0 ) {
1911 
1912  /* Write the control register */
1915  if ( ( rc = linda_ib_epb_write ( linda,
1917  control ) ) != 0 )
1918  break;
1919 
1920  /* Write the address registers */
1921  address_hi = ( address >> 8 );
1922  if ( ( rc = linda_ib_epb_write ( linda,
1924  address_hi ) ) != 0 )
1925  break;
1926  address_lo = ( address & 0xff );
1927  if ( ( rc = linda_ib_epb_write ( linda,
1929  address_lo ) ) != 0 )
1930  break;
1931  }
1932 
1933  /* Read or write the data */
1934  if ( read ) {
1936  if ( data < 0 ) {
1937  rc = data;
1938  break;
1939  }
1940  *( ( uint8_t * ) read++ ) = data;
1941  } else {
1942  data = *( ( uint8_t * ) write++ );
1943  if ( ( rc = linda_ib_epb_write ( linda,
1945  data ) ) != 0 )
1946  break;
1947  }
1948  address++;
1949  len--;
1950 
1951  /* Reset the control byte after each chunk */
1952  if ( ( address % LINDA_EPB_UC_CHUNK_SIZE ) == 0 ) {
1953  if ( ( rc = linda_ib_epb_write ( linda,
1955  0 ) ) != 0 )
1956  break;
1957  }
1958  }
1959 
1960  /* Release bus */
1962 
1963  out:
1964  DBG_ENABLE ( DBGLVL_IO );
1965  return rc;
1966 }
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:1758
A Linda HCA.
Definition: linda.c:77
#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:1795
#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)
ring len
Length.
Definition: dwmac.h:231
static void linda_ib_epb_release(struct linda *linda)
Release ownership of the IB external parallel bus.
Definition: linda.c:1740
static int linda_ib_epb_request(struct linda *linda)
Request ownership of the IB external parallel bus.
Definition: linda.c:1678
device nvs write
Definition: threewire.h:61
uint32_t control
Control.
Definition: myson.h:14
unsigned char uint8_t
Definition: stdint.h:10
#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 1998 of file linda.c.

1999  {
2000  unsigned int channel;
2001  unsigned int channel_start;
2002  unsigned int channel_end;
2003  unsigned int element;
2004  unsigned int reg;
2005  int rc;
2006 
2007  /* Break down the EPB address and determine channels */
2008  channel = LINDA_EPB_ADDRESS_CHANNEL ( param->address );
2009  element = LINDA_EPB_ADDRESS_ELEMENT ( param->address );
2010  reg = LINDA_EPB_ADDRESS_REG ( param->address );
2011  if ( channel == LINDA_EPB_ALL_CHANNELS ) {
2012  channel_start = 0;
2013  channel_end = 3;
2014  } else {
2015  channel_start = channel_end = channel;
2016  }
2017 
2018  /* Modify register for each specified channel */
2019  for ( channel = channel_start ; channel <= channel_end ; channel++ ) {
2021  channel, element, reg,
2022  param->value,
2023  param->mask ) ) != 0 )
2024  return rc;
2025  }
2026 
2027  return 0;
2028 }
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:77
#define LINDA_EPB_ADDRESS_REG(_address)
Definition: linda.h:240
value element[index]
Definition: bigint.h:397
#define LINDA_EPB_ALL_CHANNELS
Magic "all channels" channel number.
Definition: linda.c:1986
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:1833
#define LINDA_EPB_CS_SERDES
Linda external parallel bus chip selects.
Definition: linda.h:228

References channel, element, 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 2038 of file linda.c.

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

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 2137 of file linda.c.

2137  {
2138  int rc;
2139 
2140  if ( ( rc = linda_ib_epb_ram_xfer ( linda, 0, linda_ib_fw, NULL,
2141  sizeof ( linda_ib_fw ) ) ) != 0 ){
2142  DBGC ( linda, "Linda %p could not load IB firmware: %s\n",
2143  linda, strerror ( rc ) );
2144  return rc;
2145  }
2146 
2147  return 0;
2148 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A Linda HCA.
Definition: linda.c:77
#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:1887
#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 2156 of file linda.c.

2156  {
2158  unsigned int offset;
2159  int rc;
2160 
2161  for ( offset = 0 ; offset < sizeof ( linda_ib_fw );
2162  offset += sizeof ( verify ) ) {
2163  if ( ( rc = linda_ib_epb_ram_xfer ( linda, offset,
2164  NULL, verify,
2165  sizeof (verify) )) != 0 ){
2166  DBGC ( linda, "Linda %p could not read back IB "
2167  "firmware: %s\n", linda, strerror ( rc ) );
2168  return rc;
2169  }
2170  if ( memcmp ( ( linda_ib_fw + offset ), verify,
2171  sizeof ( verify ) ) != 0 ) {
2172  DBGC ( linda, "Linda %p firmware verification failed "
2173  "at offset %#x\n", linda, offset );
2175  sizeof ( verify ) );
2176  DBGC_HDA ( linda, offset, verify, sizeof ( verify ) );
2177  return -EIO;
2178  }
2179  }
2180 
2181  DBGC2 ( linda, "Linda %p firmware verified ok\n", linda );
2182  return 0;
2183 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A Linda HCA.
Definition: linda.c:77
#define DBGC(...)
Definition: compiler.h:505
uint8_t linda_ib_fw[8192]
Definition: linda_fw.c:44
#define DBGC_HDA(...)
Definition: compiler.h:506
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:1887
unsigned char uint8_t
Definition: stdint.h:10
#define DBGC2(...)
Definition: compiler.h:522
#define EIO
Input/output error.
Definition: errno.h:433
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
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 2191 of file linda.c.

2191  {
2192  struct QIB_7220_IBSerDesCtrl ctrl;
2193  struct QIB_7220_IntStatus intstatus;
2194  unsigned int i;
2195  int rc;
2196 
2197  /* Bring the microcontroller out of reset */
2199  BIT_SET ( &ctrl, ResetIB_uC_Core, 0 );
2201 
2202  /* Wait for the "trim done" signal */
2203  for ( i = 0 ; i < LINDA_TRIM_DONE_MAX_WAIT_MS ; i++ ) {
2204  linda_readq ( linda, &intstatus, QIB_7220_IntStatus_offset );
2205  if ( BIT_GET ( &intstatus, IBSerdesTrimDone ) ) {
2206  rc = 0;
2207  goto out_reset;
2208  }
2209  mdelay ( 1 );
2210  }
2211 
2212  DBGC ( linda, "Linda %p timed out waiting for trim done\n", linda );
2213  rc = -ETIMEDOUT;
2214  out_reset:
2215  /* Put the microcontroller back into reset */
2216  BIT_SET ( &ctrl, ResetIB_uC_Core, 1 );
2218 
2219  return rc;
2220 }
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:77
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:129
#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
uint8_t ctrl
Ring control.
Definition: dwmac.h:18
#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 2228 of file linda.c.

2228  {
2229  struct QIB_7220_Control control;
2230  struct QIB_7220_IBCCtrl ibcctrl;
2231  struct QIB_7220_IBCDDRCtrl ibcddrctrl;
2232  struct QIB_7220_XGXSCfg xgxscfg;
2233  int rc;
2234 
2235  /* Disable link */
2237  BIT_SET ( &control, LinkEn, 0 );
2239 
2240  /* Configure sensible defaults for IBC */
2241  memset ( &ibcctrl, 0, sizeof ( ibcctrl ) );
2242  BIT_FILL_6 ( &ibcctrl, /* Tuning values taken from Linux driver */
2243  FlowCtrlPeriod, 0x03,
2244  FlowCtrlWaterMark, 0x05,
2245  MaxPktLen, ( ( LINDA_RECV_HEADER_SIZE +
2247  4 /* ICRC */ ) >> 2 ),
2248  PhyerrThreshold, 0xf,
2249  OverrunThreshold, 0xf,
2250  CreditScale, 0x4 );
2252 
2253  /* Force SDR only to avoid needing all the DDR tuning,
2254  * Mellanox compatibility hacks etc. SDR is plenty for
2255  * boot-time operation.
2256  */
2257  linda_readq ( linda, &ibcddrctrl, QIB_7220_IBCDDRCtrl_offset );
2258  BIT_SET ( &ibcddrctrl, IB_ENHANCED_MODE, 0 );
2259  BIT_SET ( &ibcddrctrl, SD_SPEED_SDR, 1 );
2260  BIT_SET ( &ibcddrctrl, SD_SPEED_DDR, 0 );
2261  BIT_SET ( &ibcddrctrl, SD_SPEED_QDR, 0 );
2262  BIT_SET ( &ibcddrctrl, HRTBT_ENB, 0 );
2263  BIT_SET ( &ibcddrctrl, HRTBT_AUTO, 0 );
2264  linda_writeq ( linda, &ibcddrctrl, QIB_7220_IBCDDRCtrl_offset );
2265 
2266  /* Set default SerDes parameters */
2267  if ( ( rc = linda_set_serdes_params ( linda,
2268  linda_serdes_defaults1 ) ) != 0 )
2269  return rc;
2270  udelay ( 415 ); /* Magic delay while SerDes sorts itself out */
2271  if ( ( rc = linda_set_serdes_params ( linda,
2272  linda_serdes_defaults2 ) ) != 0 )
2273  return rc;
2274 
2275  /* Program the microcontroller RAM */
2276  if ( ( rc = linda_program_uc_ram ( linda ) ) != 0 )
2277  return rc;
2278 
2279  /* Verify the microcontroller RAM contents */
2280  if ( DBGLVL_LOG ) {
2281  if ( ( rc = linda_verify_uc_ram ( linda ) ) != 0 )
2282  return rc;
2283  }
2284 
2285  /* More SerDes tuning */
2286  if ( ( rc = linda_set_serdes_params ( linda,
2287  linda_serdes_defaults3 ) ) != 0 )
2288  return rc;
2289 
2290  /* Use the microcontroller to trim the IB link */
2291  if ( ( rc = linda_trim_ib ( linda ) ) != 0 )
2292  return rc;
2293 
2294  /* Bring XGXS out of reset */
2295  linda_readq ( linda, &xgxscfg, QIB_7220_XGXSCfg_offset );
2296  BIT_SET ( &xgxscfg, tx_rx_reset, 0 );
2297  BIT_SET ( &xgxscfg, xcv_reset, 0 );
2299 
2300  return rc;
2301 }
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:77
#define QIB_7220_XGXSCfg_offset
#define linda_writeq(_linda, _ptr, _offset)
Definition: linda.c:147
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:129
static struct linda_serdes_param linda_serdes_defaults3[]
Definition: linda.c:2124
static int linda_verify_uc_ram(struct linda *linda)
Verify the microcontroller RAM.
Definition: linda.c:2156
static struct linda_serdes_param linda_serdes_defaults2[]
Definition: linda.c:2093
#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:2137
#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:2191
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:2073
static int linda_set_serdes_params(struct linda *linda, struct linda_serdes_param *params)
Program IB SerDes registers.
Definition: linda.c:2038
#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 2317 of file linda.c.

2317  {
2318  struct ib_device *ibdev;
2319  struct linda *linda;
2320  struct QIB_7220_Revision revision;
2321  int rc;
2322 
2323  /* Allocate Infiniband device */
2324  ibdev = alloc_ibdev ( sizeof ( *linda ) );
2325  if ( ! ibdev ) {
2326  rc = -ENOMEM;
2327  goto err_alloc_ibdev;
2328  }
2329  pci_set_drvdata ( pci, ibdev );
2330  linda = ib_get_drvdata ( ibdev );
2331  ibdev->op = &linda_ib_operations;
2332  ibdev->dev = &pci->dev;
2333  ibdev->port = 1;
2334  ibdev->ports = 1;
2335 
2336  /* Fix up PCI device */
2337  adjust_pci_device ( pci );
2338 
2339  /* Map PCI BARs */
2340  linda->regs = pci_ioremap ( pci, pci->membase, LINDA_BAR0_SIZE );
2341  DBGC2 ( linda, "Linda %p has BAR at %08lx\n", linda, pci->membase );
2342 
2343  /* Print some general data */
2345  DBGC2 ( linda, "Linda %p board %02lx v%ld.%ld.%ld.%ld\n", linda,
2346  BIT_GET ( &revision, BoardID ),
2347  BIT_GET ( &revision, R_SW ),
2348  BIT_GET ( &revision, R_Arch ),
2349  BIT_GET ( &revision, R_ChipRevMajor ),
2350  BIT_GET ( &revision, R_ChipRevMinor ) );
2351 
2352  /* Record link capabilities. Note that we force SDR only to
2353  * avoid having to carry extra code for DDR tuning etc.
2354  */
2355  ibdev->link_width_enabled = ibdev->link_width_supported =
2357  ibdev->link_speed_enabled = ibdev->link_speed_supported =
2359 
2360  /* Initialise I2C subsystem */
2361  if ( ( rc = linda_init_i2c ( linda ) ) != 0 )
2362  goto err_init_i2c;
2363 
2364  /* Read EEPROM parameters */
2365  if ( ( rc = linda_read_eeprom ( linda, &ibdev->node_guid ) ) != 0 )
2366  goto err_read_eeprom;
2367  memcpy ( &ibdev->gid.s.guid, &ibdev->node_guid,
2368  sizeof ( ibdev->gid.s.guid ) );
2369 
2370  /* Initialise send datapath */
2371  if ( ( rc = linda_init_send ( linda ) ) != 0 )
2372  goto err_init_send;
2373 
2374  /* Initialise receive datapath */
2375  if ( ( rc = linda_init_recv ( linda ) ) != 0 )
2376  goto err_init_recv;
2377 
2378  /* Initialise the IB SerDes */
2379  if ( ( rc = linda_init_ib_serdes ( linda ) ) != 0 )
2380  goto err_init_ib_serdes;
2381 
2382  /* Register Infiniband device */
2383  if ( ( rc = register_ibdev ( ibdev ) ) != 0 ) {
2384  DBGC ( linda, "Linda %p could not register IB "
2385  "device: %s\n", linda, strerror ( rc ) );
2386  goto err_register_ibdev;
2387  }
2388 
2389  return 0;
2390 
2391  unregister_ibdev ( ibdev );
2392  err_register_ibdev:
2393  linda_fini_recv ( linda );
2394  err_init_recv:
2395  linda_fini_send ( linda );
2396  err_init_send:
2397  err_init_ib_serdes:
2398  err_read_eeprom:
2399  err_init_i2c:
2400  iounmap ( linda->regs );
2401  ibdev_put ( ibdev );
2402  err_alloc_ibdev:
2403  return rc;
2404 }
void unregister_ibdev(struct ib_device *ibdev)
Unregister Infiniband device.
Definition: infiniband.c:985
unsigned long membase
Memory base.
Definition: pci.h:219
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:77
static struct ib_device_operations linda_ib_operations
Linda Infiniband operations.
Definition: linda.c:1484
#define linda_readq(_linda, _ptr, _offset)
Definition: linda.c:129
#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:569
static void linda_fini_recv(struct linda *linda __unused)
Shut down receive datapath.
Definition: linda.c:777
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:240
struct device dev
Generic device.
Definition: pci.h:212
uint8_t link_width_enabled
Link width enabled.
Definition: infiniband.h:429
uint8_t link_width_supported
Link width supported.
Definition: infiniband.h:427
struct ib_gid::@622 s
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:365
#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:695
static int linda_read_eeprom(struct linda *linda, union ib_guid *guid)
Read EEPROM parameters.
Definition: linda.c:1632
#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:79
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:1596
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:2228
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:516
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 2411 of file linda.c.

2411  {
2412  struct ib_device *ibdev = pci_get_drvdata ( pci );
2413  struct linda *linda = ib_get_drvdata ( ibdev );
2414 
2415  unregister_ibdev ( ibdev );
2416  linda_fini_recv ( linda );
2417  linda_fini_send ( linda );
2418  iounmap ( linda->regs );
2419  ibdev_put ( ibdev );
2420 }
void unregister_ibdev(struct ib_device *ibdev)
Unregister Infiniband device.
Definition: infiniband.c:985
A Linda HCA.
Definition: linda.c:77
static void linda_fini_send(struct linda *linda)
Shut down send datapath.
Definition: linda.c:569
static void linda_fini_recv(struct linda *linda __unused)
Shut down receive datapath.
Definition: linda.c:777
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:79
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition: pci.h:375
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:1414
static void linda_destroy_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Destroy completion queue.
Definition: linda.c:821
static void linda_close(struct ib_device *ibdev)
Close Infiniband link.
Definition: linda.c:1430
static void linda_destroy_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Destroy queue pair.
Definition: linda.c:906
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:1473
static int linda_create_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Create queue pair.
Definition: linda.c:843
static int linda_modify_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Modify queue pair.
Definition: linda.c:889
static int linda_create_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Create completion queue.
Definition: linda.c:797
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:930
static void linda_poll_eq(struct ib_device *ibdev)
Poll event queue.
Definition: linda.c:1384
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:1069
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:1455
static int linda_set_port_info(struct ib_device *ibdev, union ib_mad *mad)
Set port information.
Definition: linda.c:261
static int linda_set_pkey_table(struct ib_device *ibdev __unused, union ib_mad *mad __unused)
Set partition key table.
Definition: linda.c:297
static void linda_poll_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Poll completion queue.
Definition: linda.c:1358

Linda Infiniband operations.

Definition at line 1484 of file linda.c.

Referenced by linda_probe().

◆ linda_i2c_bits

unsigned int linda_i2c_bits[]
static
Initial value:
= {
}
#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
Serial data.
Definition: i2c.h:116
Serial clock.
Definition: i2c.h:114

Linda I2C bit to GPIO mappings.

Definition at line 1510 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:1547
static int linda_i2c_read_bit(struct bit_basher *basher, unsigned int bit_id)
Read Linda I2C line status.
Definition: linda.c:1523

Linda I2C bit-bashing interface operations.

Definition at line 1585 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:1989
#define LINDA_EPB_ALL_CHANNELS
Magic "all channels" channel number.
Definition: linda.c:1986

Linda SerDes default parameters.

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

Definition at line 2073 of file linda.c.

Referenced by linda_init_ib_serdes().

◆ linda_serdes_defaults2

struct linda_serdes_param linda_serdes_defaults2[]
static

Definition at line 2093 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:1989
#define LINDA_EPB_ALL_CHANNELS
Magic "all channels" channel number.
Definition: linda.c:1986

Definition at line 2124 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:307

Definition at line 2422 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:2422
static int linda_probe(struct pci_device *pci)
Probe PCI device.
Definition: linda.c:2317
static void linda_remove(struct pci_device *pci)
Remove PCI device.
Definition: linda.c:2411

Definition at line 2426 of file linda.c.