iPXE
qib7322.c File Reference

QLogic QIB7322 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 <ipxe/pcibackup.h>
#include "qib7322.h"

Go to the source code of this file.

Data Structures

struct  qib7322_send_buffers
 A QIB7322 send buffer set. More...
struct  qib7322_send_work_queue
 A QIB7322 send work queue. More...
struct  qib7322_recv_work_queue
 A QIB7322 receive work queue. More...
struct  qib7322
 A QIB7322 HCA. More...

Macros

#define qib7322_readq(_qib7322, _ptr, _offset)
#define qib7322_readq_array8b(_qib7322, _ptr, _offset, _idx)
#define qib7322_readq_array64k(_qib7322, _ptr, _offset, _idx)
#define qib7322_readq_port(_qib7322, _ptr, _offset, _port)
#define qib7322_writeq(_qib7322, _ptr, _offset)
#define qib7322_writeq_array8b(_qib7322, _ptr, _offset, _idx)
#define qib7322_writeq_array64k(_qib7322, _ptr, _offset, _idx)
#define qib7322_writeq_port(_qib7322, _ptr, _offset, _port)
#define QIB7322_SEND_BUF_TOGGLE   0x8000
 Send buffer toggle bit.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static void qib7322_readq (struct qib7322 *qib7322, uint64_t *qword, unsigned long offset)
 Read QIB7322 qword register.
static void qib7322_writeq (struct qib7322 *qib7322, const uint64_t *qword, unsigned long offset)
 Write QIB7322 qword register.
static void qib7322_writel (struct qib7322 *qib7322, uint32_t dword, unsigned long offset)
 Write QIB7322 dword register.
static const char * qib7322_link_state_text (unsigned int link_state)
 Textual representation of link state.
static void qib7322_link_state_changed (struct ib_device *ibdev)
 Handle link state change.
static int qib7322_link_state_check (struct ib_device *ibdev, unsigned int new_link_state)
 Wait for link state change to take effect.
static int qib7322_set_port_info (struct ib_device *ibdev, union ib_mad *mad)
 Set port information.
static int qib7322_set_pkey_table (struct ib_device *ibdev __unused, union ib_mad *mad __unused)
 Set partition key table.
static int qib7322_alloc_ctx (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Allocate a context and set queue pair number.
static unsigned int qib7322_ctx (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Get queue pair context number.
static void qib7322_free_ctx (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Free a context.
static struct qib7322_send_buffersqib7322_create_send_bufs (struct qib7322 *qib7322, unsigned long base, unsigned int size, unsigned int start, unsigned int count)
 Create send buffer set.
static void qib7322_destroy_send_bufs (struct qib7322 *qib7322 __unused, struct qib7322_send_buffers *send_bufs)
 Destroy send buffer set.
static int qib7322_alloc_send_buf (struct qib7322 *qib7322, struct qib7322_send_buffers *send_bufs)
 Allocate a send buffer.
static void qib7322_free_send_buf (struct qib7322 *qib7322 __unused, struct qib7322_send_buffers *send_bufs, unsigned int send_buf)
 Free a send buffer.
static int qib7322_send_buf_in_use (struct qib7322 *qib7322, unsigned int send_buf)
 Check to see if send buffer is in use.
static unsigned long qib7322_send_buffer_offset (struct qib7322 *qib7322 __unused, struct qib7322_send_buffers *send_bufs, unsigned int send_buf)
 Calculate starting offset for send buffer.
static int qib7322_create_send_wq (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Create send work queue.
static void qib7322_destroy_send_wq (struct ib_device *ibdev __unused, struct ib_queue_pair *qp)
 Destroy send work queue.
static int qib7322_init_send (struct qib7322 *qib7322)
 Initialise send datapath.
static void qib7322_fini_send (struct qib7322 *qib7322)
 Shut down send datapath.
static int qib7322_create_recv_wq (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Create receive work queue.
static void qib7322_destroy_recv_wq (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Destroy receive work queue.
static int qib7322_init_recv (struct qib7322 *qib7322)
 Initialise receive datapath.
static void qib7322_fini_recv (struct qib7322 *qib7322 __unused)
 Shut down receive datapath.
static int qib7322_create_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 Create completion queue.
static void qib7322_destroy_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 Destroy completion queue.
static int qib7322_create_qp (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Create queue pair.
static int qib7322_modify_qp (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Modify queue pair.
static void qib7322_destroy_qp (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Destroy queue pair.
static int qib7322_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.
static void qib7322_complete_send (struct ib_device *ibdev, struct ib_queue_pair *qp, unsigned int wqe_idx)
 Complete send work queue entry.
static void qib7322_poll_send_wq (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Poll send work queue.
static int qib7322_post_recv (struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf)
 Post receive work queue entry.
static void qib7322_complete_recv (struct ib_device *ibdev, struct ib_queue_pair *qp, unsigned int header_offs)
 Complete receive work queue entry.
static void qib7322_poll_recv_wq (struct ib_device *ibdev, struct ib_queue_pair *qp)
 Poll receive work queue.
static void qib7322_poll_cq (struct ib_device *ibdev, struct ib_completion_queue *cq)
 Poll completion queue.
static void qib7322_poll_eq (struct ib_device *ibdev)
 Poll event queue.
static unsigned int qib7322_link_speed_supported (struct qib7322 *qib7322, unsigned int port)
 Determine supported link speeds.
static int qib7322_open (struct ib_device *ibdev)
 Initialise Infiniband link.
static void qib7322_close (struct ib_device *ibdev)
 Close Infiniband link.
static int qib7322_mcast_attach (struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
 Attach to multicast group.
static void qib7322_mcast_detach (struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
 Detach from multicast group.
static int qib7322_i2c_read_bit (struct bit_basher *basher, unsigned int bit_id)
 Read QIB7322 I2C line status.
static void qib7322_i2c_write_bit (struct bit_basher *basher, unsigned int bit_id, unsigned long data)
 Write QIB7322 I2C line status.
static int qib7322_init_i2c (struct qib7322 *qib7322)
 Initialise QIB7322 I2C subsystem.
static int qib7322_read_eeprom (struct qib7322 *qib7322)
 Read EEPROM parameters.
static int qib7322_ahb_wait (struct qib7322 *qib7322)
 Wait for AHB transaction to complete.
static int qib7322_ahb_request (struct qib7322 *qib7322, unsigned int location)
 Request ownership of the AHB.
static void qib7322_ahb_release (struct qib7322 *qib7322)
 Release ownership of the AHB.
static int qib7322_ahb_read (struct qib7322 *qib7322, unsigned int location, uint32_t *data)
 Read data via AHB.
static int qib7322_ahb_write (struct qib7322 *qib7322, unsigned int location, uint32_t data)
 Write data via AHB.
static int qib7322_ahb_mod_reg (struct qib7322 *qib7322, unsigned int location, uint32_t value, uint32_t mask)
 Read/modify/write AHB register.
static int qib7322_ahb_mod_reg_all (struct qib7322 *qib7322, unsigned int reg, uint32_t value, uint32_t mask)
 Read/modify/write AHB register across all ports and channels.
static int qib7322_init_ib_serdes (struct qib7322 *qib7322)
 Initialise the IB SerDes.
static void qib7322_reset (struct qib7322 *qib7322, struct pci_device *pci)
 Reset QIB7322.
static int qib7322_probe (struct pci_device *pci)
 Probe PCI device.
static void qib7322_remove (struct pci_device *pci)
 Remove PCI device.

Variables

static struct ib_device_operations qib7322_ib_operations
 QIB7322 Infiniband operations.
static unsigned int qib7322_i2c_bits []
 QIB7322 I2C bit to GPIO mappings.
static struct bit_basher_operations qib7322_i2c_basher_ops
 QIB7322 I2C bit-bashing interface operations.
static struct pci_device_id qib7322_nics []
struct pci_driver qib7322_driver __pci_driver

Detailed Description

QLogic QIB7322 Infiniband HCA.

Definition in file qib7322.c.

Macro Definition Documentation

◆ qib7322_readq

#define qib7322_readq ( _qib7322,
_ptr,
_offset )
Value:
qib7322_readq ( (_qib7322), (_ptr)->u.qwords, (_offset) )
union @104331263140136355135267063077374276003064103115 u
#define qib7322_readq(_qib7322, _ptr, _offset)
Definition qib7322.c:154

Definition at line 154 of file qib7322.c.

154#define qib7322_readq( _qib7322, _ptr, _offset ) \
155 qib7322_readq ( (_qib7322), (_ptr)->u.qwords, (_offset) )

Referenced by qib7322_ahb_read(), qib7322_ahb_wait(), qib7322_create_recv_wq(), qib7322_destroy_recv_wq(), qib7322_fini_send(), qib7322_i2c_read_bit(), qib7322_i2c_write_bit(), qib7322_init_ib_serdes(), qib7322_init_recv(), qib7322_init_send(), qib7322_link_speed_supported(), qib7322_link_state_changed(), and qib7322_probe().

◆ qib7322_readq_array8b

#define qib7322_readq_array8b ( _qib7322,
_ptr,
_offset,
_idx )
Value:
qib7322_readq ( (_qib7322), (_ptr), ( (_offset) + ( (_idx) * 8 ) ) )

Definition at line 156 of file qib7322.c.

156#define qib7322_readq_array8b( _qib7322, _ptr, _offset, _idx ) \
157 qib7322_readq ( (_qib7322), (_ptr), ( (_offset) + ( (_idx) * 8 ) ) )

◆ qib7322_readq_array64k

#define qib7322_readq_array64k ( _qib7322,
_ptr,
_offset,
_idx )
Value:
qib7322_readq ( (_qib7322), (_ptr), ( (_offset) + ( (_idx) * 65536 ) ) )

Definition at line 158 of file qib7322.c.

158#define qib7322_readq_array64k( _qib7322, _ptr, _offset, _idx ) \
159 qib7322_readq ( (_qib7322), (_ptr), ( (_offset) + ( (_idx) * 65536 ) ) )

◆ qib7322_readq_port

#define qib7322_readq_port ( _qib7322,
_ptr,
_offset,
_port )
Value:
qib7322_readq ( (_qib7322), (_ptr), ( (_offset) + ( (_port) * 4096 ) ) )

Definition at line 160 of file qib7322.c.

160#define qib7322_readq_port( _qib7322, _ptr, _offset, _port ) \
161 qib7322_readq ( (_qib7322), (_ptr), ( (_offset) + ( (_port) * 4096 ) ) )

Referenced by qib7322_close(), qib7322_create_recv_wq(), qib7322_destroy_recv_wq(), qib7322_link_state_changed(), qib7322_link_state_check(), qib7322_open(), qib7322_poll_eq(), and qib7322_set_port_info().

◆ qib7322_writeq

#define qib7322_writeq ( _qib7322,
_ptr,
_offset )
Value:
qib7322_writeq ( (_qib7322), (_ptr)->u.qwords, (_offset) )
#define qib7322_writeq(_qib7322, _ptr, _offset)
Definition qib7322.c:174

Definition at line 174 of file qib7322.c.

174#define qib7322_writeq( _qib7322, _ptr, _offset ) \
175 qib7322_writeq ( (_qib7322), (_ptr)->u.qwords, (_offset) )

Referenced by qib7322_ahb_read(), qib7322_ahb_release(), qib7322_ahb_request(), qib7322_ahb_write(), qib7322_create_recv_wq(), qib7322_destroy_recv_wq(), qib7322_fini_send(), qib7322_i2c_write_bit(), qib7322_init_ib_serdes(), qib7322_init_recv(), qib7322_init_send(), qib7322_link_state_changed(), qib7322_post_send(), and qib7322_reset().

◆ qib7322_writeq_array8b

#define qib7322_writeq_array8b ( _qib7322,
_ptr,
_offset,
_idx )
Value:
qib7322_writeq ( (_qib7322), (_ptr), ( (_offset) + ( (_idx) * 8 ) ) )

Definition at line 176 of file qib7322.c.

176#define qib7322_writeq_array8b( _qib7322, _ptr, _offset, _idx ) \
177 qib7322_writeq ( (_qib7322), (_ptr), ( (_offset) + ( (_idx) * 8 ) ) )

Referenced by qib7322_complete_recv(), qib7322_create_recv_wq(), qib7322_init_recv(), and qib7322_post_recv().

◆ qib7322_writeq_array64k

#define qib7322_writeq_array64k ( _qib7322,
_ptr,
_offset,
_idx )
Value:
qib7322_writeq ( (_qib7322), (_ptr), ( (_offset) + ( (_idx) * 65536 ) ))

Definition at line 178 of file qib7322.c.

178#define qib7322_writeq_array64k( _qib7322, _ptr, _offset, _idx ) \
179 qib7322_writeq ( (_qib7322), (_ptr), ( (_offset) + ( (_idx) * 65536 ) ))

Referenced by qib7322_create_recv_wq(), qib7322_poll_recv_wq(), and qib7322_post_recv().

◆ qib7322_writeq_port

#define qib7322_writeq_port ( _qib7322,
_ptr,
_offset,
_port )
Value:
qib7322_writeq ( (_qib7322), (_ptr), ( (_offset) + ( (_port) * 4096 ) ))

Definition at line 180 of file qib7322.c.

180#define qib7322_writeq_port( _qib7322, _ptr, _offset, _port ) \
181 qib7322_writeq ( (_qib7322), (_ptr), ( (_offset) + ( (_port) * 4096 ) ))

Referenced by qib7322_close(), qib7322_create_recv_wq(), qib7322_destroy_recv_wq(), qib7322_open(), qib7322_poll_eq(), and qib7322_set_port_info().

◆ QIB7322_SEND_BUF_TOGGLE

#define QIB7322_SEND_BUF_TOGGLE   0x8000

Send buffer toggle bit.

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

Definition at line 433 of file qib7322.c.

Referenced by qib7322_alloc_send_buf(), qib7322_send_buf_in_use(), and qib7322_send_buffer_offset().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ qib7322_readq()

void qib7322_readq ( struct qib7322 * qib7322,
uint64_t * qword,
unsigned long offset )
static

Read QIB7322 qword register.

Parameters
qib7322QIB7322 device
qwordRegister buffer to read into
offsetRegister offset

Definition at line 150 of file qib7322.c.

151 {
152 *qword = readq ( qib7322->regs + offset );
153}
uint16_t offset
Offset to command line.
Definition bzimage.h:3
#define readq(io_addr)
Definition io.h:234
A QIB7322 HCA.
Definition qib7322.c:101
void * regs
Registers.
Definition qib7322.c:103

References offset, readq, and qib7322::regs.

◆ qib7322_writeq()

void qib7322_writeq ( struct qib7322 * qib7322,
const uint64_t * qword,
unsigned long offset )
static

Write QIB7322 qword register.

Parameters
qib7322QIB7322 device
qwordRegister buffer to write
offsetRegister offset

Definition at line 170 of file qib7322.c.

171 {
172 writeq ( *qword, ( qib7322->regs + offset ) );
173}
#define writeq(data, io_addr)
Definition io.h:273

References offset, qib7322::regs, and writeq.

◆ qib7322_writel()

void qib7322_writel ( struct qib7322 * qib7322,
uint32_t dword,
unsigned long offset )
static

Write QIB7322 dword register.

Parameters
qib7322QIB7322 device
dwordValue to write
offsetRegister offset

Definition at line 190 of file qib7322.c.

191 {
192 writel ( dword, ( qib7322->regs + offset ) );
193}
unsigned long int dword
Definition smc9000.h:40
#define writel
Definition w89c840.c:160

References offset, qib7322::regs, and writel.

Referenced by qib7322_post_send().

◆ qib7322_link_state_text()

const char * qib7322_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 208 of file qib7322.c.

208 {
209 switch ( link_state ) {
210 case QIB7322_LINK_STATE_DOWN: return "DOWN";
211 case QIB7322_LINK_STATE_INIT: return "INIT";
212 case QIB7322_LINK_STATE_ARM: return "ARM";
213 case QIB7322_LINK_STATE_ACTIVE: return "ACTIVE";
214 case QIB7322_LINK_STATE_ACT_DEFER: return "ACT_DEFER";
215 default: return "UNKNOWN";
216 }
217}
@ QIB7322_LINK_STATE_ACT_DEFER
Definition qib7322.h:363
@ QIB7322_LINK_STATE_DOWN
Definition qib7322.h:359
@ QIB7322_LINK_STATE_INIT
Definition qib7322.h:360
@ QIB7322_LINK_STATE_ACTIVE
Definition qib7322.h:362
@ QIB7322_LINK_STATE_ARM
Definition qib7322.h:361

References QIB7322_LINK_STATE_ACT_DEFER, QIB7322_LINK_STATE_ACTIVE, QIB7322_LINK_STATE_ARM, QIB7322_LINK_STATE_DOWN, and QIB7322_LINK_STATE_INIT.

Referenced by qib7322_link_state_changed(), qib7322_link_state_check(), and qib7322_set_port_info().

◆ qib7322_link_state_changed()

void qib7322_link_state_changed ( struct ib_device * ibdev)
static

Handle link state change.

Parameters
qib7322QIB7322 device

Definition at line 224 of file qib7322.c.

224 {
225 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
226 struct QIB_7322_IBCStatusA_0 ibcstatusa;
227 struct QIB_7322_EXTCtrl extctrl;
228 unsigned int port = ( ibdev->port - QIB7322_PORT_BASE );
229 unsigned int link_training_state;
230 unsigned int link_state;
231 unsigned int link_width;
232 unsigned int link_speed;
233 unsigned int link_speed_qdr;
234 unsigned int green;
235 unsigned int yellow;
236
237 /* Read link state */
238 qib7322_readq_port ( qib7322, &ibcstatusa,
240 link_training_state = BIT_GET ( &ibcstatusa, LinkTrainingState );
241 link_state = BIT_GET ( &ibcstatusa, LinkState );
242 link_width = BIT_GET ( &ibcstatusa, LinkWidthActive );
243 link_speed = BIT_GET ( &ibcstatusa, LinkSpeedActive );
244 link_speed_qdr = BIT_GET ( &ibcstatusa, LinkSpeedQDR );
245 DBGC ( qib7322, "QIB7322 %p port %d training state %#x link state %s "
246 "(%s %s)\n", qib7322, port, link_training_state,
247 qib7322_link_state_text ( link_state ),
248 ( link_speed_qdr ? "QDR" : ( link_speed ? "DDR" : "SDR" ) ),
249 ( link_width ? "x4" : "x1" ) );
250
251 /* Set LEDs according to link state */
253 green = ( ( link_state >= QIB7322_LINK_STATE_INIT ) ? 1 : 0 );
254 yellow = ( ( link_state >= QIB7322_LINK_STATE_ACTIVE ) ? 1 : 0 );
255 if ( port == 0 ) {
256 BIT_SET ( &extctrl, LEDPort0GreenOn, green );
257 BIT_SET ( &extctrl, LEDPort0YellowOn, yellow );
258 } else {
259 BIT_SET ( &extctrl, LEDPort1GreenOn, green );
260 BIT_SET ( &extctrl, LEDPort1YellowOn, yellow );
261 }
263
264 /* Notify Infiniband core of link state change */
265 ibdev->port_state = ( link_state + 1 );
266 ibdev->link_width_active =
267 ( link_width ? IB_LINK_WIDTH_4X : IB_LINK_WIDTH_1X );
268 ibdev->link_speed_active =
269 ( link_speed ? IB_LINK_SPEED_DDR : IB_LINK_SPEED_SDR );
270 ib_link_state_changed ( ibdev );
271}
u8 port
Port number.
Definition CIB_PRM.h:3
#define DBGC(...)
Definition compiler.h:505
#define IB_LINK_SPEED_DDR
Definition ib_mad.h:146
#define IB_LINK_SPEED_SDR
Definition ib_mad.h:145
#define IB_LINK_WIDTH_1X
Definition ib_mad.h:140
#define IB_LINK_WIDTH_4X
Definition ib_mad.h:141
void ib_link_state_changed(struct ib_device *ibdev)
Notify of Infiniband link state change.
Definition infiniband.c:637
static __always_inline void * ib_get_drvdata(struct ib_device *ibdev)
Get Infiniband device driver-private data.
Definition infiniband.h:709
#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_SET(_ptr, _field, _value)
Definition pseudobit.h:238
static const char * qib7322_link_state_text(unsigned int link_state)
Textual representation of link state.
Definition qib7322.c:208
#define qib7322_readq_port(_qib7322, _ptr, _offset, _port)
Definition qib7322.c:160
#define QIB7322_PORT_BASE
QIB7322 base port number.
Definition qib7322.h:166
#define QIB_7322_IBCStatusA_0_offset
#define QIB_7322_EXTCtrl_offset
uint8_t link_speed_active
Link speed active.
Definition infiniband.h:438
uint8_t link_width_active
Link width active.
Definition infiniband.h:432
uint8_t port_state
Port state.
Definition infiniband.h:426
unsigned int port
Port number.
Definition infiniband.h:419
struct ib_device * ibdev[QIB7322_MAX_PORTS]
Infiniband devices.
Definition qib7322.c:129

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, qib7322::ibdev, ib_device::link_speed_active, ib_device::link_width_active, ib_device::port, port, ib_device::port_state, QIB7322_LINK_STATE_ACTIVE, QIB7322_LINK_STATE_INIT, qib7322_link_state_text(), QIB7322_PORT_BASE, qib7322_readq, qib7322_readq_port, qib7322_writeq, QIB_7322_EXTCtrl_offset, and QIB_7322_IBCStatusA_0_offset.

Referenced by qib7322_poll_eq(), and qib7322_set_port_info().

◆ qib7322_link_state_check()

int qib7322_link_state_check ( struct ib_device * ibdev,
unsigned int new_link_state )
static

Wait for link state change to take effect.

Parameters
ibdevInfiniband device
new_link_stateExpected link state
Return values
rcReturn status code

Definition at line 280 of file qib7322.c.

281 {
282 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
283 struct QIB_7322_IBCStatusA_0 ibcstatusa;
284 unsigned int port = ( ibdev->port - QIB7322_PORT_BASE );
285 unsigned int link_state;
286 unsigned int i;
287
288 for ( i = 0 ; i < QIB7322_LINK_STATE_MAX_WAIT_US ; i++ ) {
289 qib7322_readq_port ( qib7322, &ibcstatusa,
291 link_state = BIT_GET ( &ibcstatusa, LinkState );
292 if ( link_state == new_link_state )
293 return 0;
294 udelay ( 1 );
295 }
296
297 DBGC ( qib7322, "QIB7322 %p port %d timed out waiting for link state "
298 "%s\n", qib7322, port, qib7322_link_state_text ( link_state ) );
299 return -ETIMEDOUT;
300}
#define ETIMEDOUT
Connection timed out.
Definition errno.h:670
#define QIB7322_LINK_STATE_MAX_WAIT_US
Maximum time to wait for link state changes, in us.
Definition qib7322.h:367
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition timer.c:61

References BIT_GET, DBGC, ETIMEDOUT, ib_get_drvdata(), qib7322::ibdev, ib_device::port, port, QIB7322_LINK_STATE_MAX_WAIT_US, qib7322_link_state_text(), QIB7322_PORT_BASE, qib7322_readq_port, QIB_7322_IBCStatusA_0_offset, and udelay().

Referenced by qib7322_set_port_info().

◆ qib7322_set_port_info()

int qib7322_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 308 of file qib7322.c.

309 {
310 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
311 struct ib_port_info *port_info = &mad->smp.smp_data.port_info;
312 struct QIB_7322_IBCCtrlA_0 ibcctrla;
313 unsigned int port = ( ibdev->port - QIB7322_PORT_BASE );
314 unsigned int port_state;
315 unsigned int link_state;
316
317 /* Set new link state */
318 port_state = ( port_info->link_speed_supported__port_state & 0xf );
319 if ( port_state ) {
320 link_state = ( port_state - 1 );
321 DBGC ( qib7322, "QIB7322 %p set link state to %s (%x)\n",
322 qib7322, qib7322_link_state_text ( link_state ),
323 link_state );
324 qib7322_readq_port ( qib7322, &ibcctrla,
326 BIT_SET ( &ibcctrla, LinkCmd, link_state );
327 qib7322_writeq_port ( qib7322, &ibcctrla,
329
330 /* Wait for link state change to take effect. Ignore
331 * errors; the current link state will be returned via
332 * the GetResponse MAD.
333 */
334 qib7322_link_state_check ( ibdev, link_state );
335 }
336
337 /* Detect and report link state change */
339
340 return 0;
341}
u8 port_state
Definition CIB_PRM.h:10
union ib_mad mad
Definition arbel.h:1
struct ib_port_info port_info
Definition ib_mad.h:3
static int qib7322_link_state_check(struct ib_device *ibdev, unsigned int new_link_state)
Wait for link state change to take effect.
Definition qib7322.c:280
#define qib7322_writeq_port(_qib7322, _ptr, _offset, _port)
Definition qib7322.c:180
static void qib7322_link_state_changed(struct ib_device *ibdev)
Handle link state change.
Definition qib7322.c:224
#define QIB_7322_IBCCtrlA_0_offset
A Port Information attribute.
Definition ib_mad.h:105

References BIT_SET, DBGC, ib_get_drvdata(), qib7322::ibdev, mad, ib_device::port, port, port_info, port_state, qib7322_link_state_changed(), qib7322_link_state_check(), qib7322_link_state_text(), QIB7322_PORT_BASE, qib7322_readq_port, qib7322_writeq_port, and QIB_7322_IBCCtrlA_0_offset.

◆ qib7322_set_pkey_table()

int qib7322_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 349 of file qib7322.c.

350 {
351 /* Nothing to do */
352 return 0;
353}

References __unused, and mad.

◆ qib7322_alloc_ctx()

int qib7322_alloc_ctx ( struct ib_device * ibdev,
struct ib_queue_pair * qp )
static

Allocate a context and set queue pair number.

Parameters
ibdevInfiniband device
qpQueue pair
Return values
rcReturn status code

Definition at line 369 of file qib7322.c.

370 {
371 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
372 unsigned int port = ( ibdev->port - QIB7322_PORT_BASE );
373 unsigned int ctx;
374
375 for ( ctx = port ; ctx < QIB7322_NUM_CONTEXTS ; ctx += 2 ) {
376
377 if ( ! qib7322->used_ctx[ctx] ) {
378 qib7322->used_ctx[ctx] = 1;
379 qp->qpn = ( ctx & ~0x01 );
380 DBGC2 ( qib7322, "QIB7322 %p port %d QPN %ld is CTX "
381 "%d\n", qib7322, port, qp->qpn, ctx );
382 return 0;
383 }
384 }
385
386 DBGC ( qib7322, "QIB7322 %p port %d out of available contexts\n",
387 qib7322, port );
388 return -ENOENT;
389}
struct golan_eq_context ctx
Definition CIB_PRM.h:0
struct arbelprm_qp_db_record qp
Definition arbel.h:2
#define DBGC2(...)
Definition compiler.h:522
#define ENOENT
No such file or directory.
Definition errno.h:515
#define QIB7322_NUM_CONTEXTS
Number of contexts (including kernel context)
Definition qib7322.h:252
uint8_t used_ctx[QIB7322_NUM_CONTEXTS]
In-use contexts.
Definition qib7322.c:106

References ctx, DBGC, DBGC2, ENOENT, ib_get_drvdata(), qib7322::ibdev, ib_device::port, port, QIB7322_NUM_CONTEXTS, QIB7322_PORT_BASE, qp, and qib7322::used_ctx.

Referenced by qib7322_create_qp().

◆ qib7322_ctx()

unsigned int qib7322_ctx ( struct ib_device * ibdev,
struct ib_queue_pair * qp )
static

Get queue pair context number.

Parameters
ibdevInfiniband device
qpQueue pair
Return values
ctxContext index

Definition at line 398 of file qib7322.c.

399 {
400 return ( qp->qpn + ( ibdev->port - QIB7322_PORT_BASE ) );
401}

References qib7322::ibdev, ib_device::port, QIB7322_PORT_BASE, and qp.

Referenced by qib7322_create_qp(), qib7322_create_recv_wq(), qib7322_destroy_recv_wq(), qib7322_free_ctx(), qib7322_poll_recv_wq(), and qib7322_post_recv().

◆ qib7322_free_ctx()

void qib7322_free_ctx ( struct ib_device * ibdev,
struct ib_queue_pair * qp )
static

Free a context.

Parameters
qib7322QIB7322 device
ctxContext index

Definition at line 409 of file qib7322.c.

410 {
411 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
412 unsigned int port = ( ibdev->port - QIB7322_PORT_BASE );
413 unsigned int ctx = qib7322_ctx ( ibdev, qp );
414
415 qib7322->used_ctx[ctx] = 0;
416 DBGC2 ( qib7322, "QIB7322 %p port %d CTX %d freed\n",
417 qib7322, port, ctx );
418}
static unsigned int qib7322_ctx(struct ib_device *ibdev, struct ib_queue_pair *qp)
Get queue pair context number.
Definition qib7322.c:398

References ctx, DBGC2, ib_get_drvdata(), qib7322::ibdev, ib_device::port, port, qib7322_ctx(), QIB7322_PORT_BASE, qp, and qib7322::used_ctx.

Referenced by qib7322_create_qp(), and qib7322_destroy_qp().

◆ qib7322_create_send_bufs()

struct qib7322_send_buffers * qib7322_create_send_bufs ( struct qib7322 * qib7322,
unsigned long base,
unsigned int size,
unsigned int start,
unsigned int count )
static

Create send buffer set.

Parameters
qib7322QIB7322 device
baseSend buffer base offset
sizeSend buffer size
startIndex of first send buffer
countNumber of send buffers
Return values
send_bufsSend buffer set

Definition at line 446 of file qib7322.c.

448 {
449 struct qib7322_send_buffers *send_bufs;
450 unsigned int i;
451
452 /* Allocate send buffer set */
453 send_bufs = zalloc ( sizeof ( *send_bufs ) +
454 ( count * sizeof ( send_bufs->avail[0] ) ) );
455 if ( ! send_bufs )
456 return NULL;
457
458 /* Populate send buffer set */
459 send_bufs->base = base;
460 send_bufs->size = size;
461 send_bufs->start = start;
462 send_bufs->count = count;
463 for ( i = 0 ; i < count ; i++ )
464 send_bufs->avail[i] = ( start + i );
465
466 DBGC2 ( qib7322, "QIB7322 %p send buffer set %p [%d,%d] at %lx\n",
467 qib7322, send_bufs, start, ( start + count - 1 ),
468 send_bufs->base );
469
470 return send_bufs;
471}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
uint32_t start
Starting offset.
Definition netvsc.h:1
uint16_t size
Buffer size.
Definition dwmac.h:3
static unsigned int count
Number of entries.
Definition dwmac.h:220
uint32_t base
Base.
Definition librm.h:3
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662
A QIB7322 send buffer set.
Definition qib7322.c:50
uint16_t avail[0]
Send buffer availability.
Definition qib7322.c:67
unsigned int size
Send buffer size.
Definition qib7322.c:54
unsigned int count
Number of send buffers.
Definition qib7322.c:61
unsigned long base
Offset within register space of the first send buffer.
Definition qib7322.c:52
unsigned int start
Index of first send buffer.
Definition qib7322.c:56

References qib7322_send_buffers::avail, base, qib7322_send_buffers::base, count, qib7322_send_buffers::count, DBGC2, NULL, qib7322_send_buffers::size, size, qib7322_send_buffers::start, start, and zalloc().

Referenced by qib7322_init_send().

◆ qib7322_destroy_send_bufs()

void qib7322_destroy_send_bufs ( struct qib7322 *qib7322 __unused,
struct qib7322_send_buffers * send_bufs )
static

Destroy send buffer set.

Parameters
qib7322QIB7322 device
send_bufsSend buffer set

Definition at line 480 of file qib7322.c.

481 {
482 free ( send_bufs );
483}
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55

References __unused, and free.

Referenced by qib7322_fini_send(), and qib7322_init_send().

◆ qib7322_alloc_send_buf()

int qib7322_alloc_send_buf ( struct qib7322 * qib7322,
struct qib7322_send_buffers * send_bufs )
static

Allocate a send buffer.

Parameters
qib7322QIB7322 device
send_bufsSend buffer set
Return values
send_bufSend buffer, or negative error

Definition at line 492 of file qib7322.c.

493 {
494 unsigned int used;
495 unsigned int mask;
496 unsigned int send_buf;
497
498 used = ( send_bufs->cons - send_bufs->prod );
499 if ( used >= send_bufs->count ) {
500 DBGC ( qib7322, "QIB7322 %p send buffer set %p out of "
501 "buffers\n", qib7322, send_bufs );
502 return -ENOBUFS;
503 }
504
505 mask = ( send_bufs->count - 1 );
506 send_buf = send_bufs->avail[ send_bufs->cons++ & mask ];
507 send_buf ^= QIB7322_SEND_BUF_TOGGLE;
508 return send_buf;
509}
#define ENOBUFS
No buffer space available.
Definition errno.h:499
#define QIB7322_SEND_BUF_TOGGLE
Send buffer toggle bit.
Definition qib7322.c:433
unsigned int prod
Send buffer availability producer counter.
Definition qib7322.c:63
unsigned int cons
Send buffer availability consumer counter.
Definition qib7322.c:65

References qib7322_send_buffers::avail, qib7322_send_buffers::cons, qib7322_send_buffers::count, DBGC, ENOBUFS, qib7322_send_buffers::prod, and QIB7322_SEND_BUF_TOGGLE.

Referenced by qib7322_post_send().

◆ qib7322_free_send_buf()

void qib7322_free_send_buf ( struct qib7322 *qib7322 __unused,
struct qib7322_send_buffers * send_bufs,
unsigned int send_buf )
static

Free a send buffer.

Parameters
qib7322QIB7322 device
send_bufsSend buffer set
send_bufSend buffer

Definition at line 518 of file qib7322.c.

520 {
521 unsigned int mask;
522
523 mask = ( send_bufs->count - 1 );
524 send_bufs->avail[ send_bufs->prod++ & mask ] = send_buf;
525}

References __unused, qib7322_send_buffers::avail, qib7322_send_buffers::count, and qib7322_send_buffers::prod.

Referenced by qib7322_complete_send().

◆ qib7322_send_buf_in_use()

int qib7322_send_buf_in_use ( struct qib7322 * qib7322,
unsigned int send_buf )
static

Check to see if send buffer is in use.

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

Definition at line 534 of file qib7322.c.

535 {
536 unsigned int send_idx;
537 unsigned int send_check;
538 unsigned int inusecheck;
539 unsigned int inuse;
540 unsigned int check;
541
542 send_idx = ( send_buf & ~QIB7322_SEND_BUF_TOGGLE );
543 send_check = ( !! ( send_buf & QIB7322_SEND_BUF_TOGGLE ) );
544 inusecheck = BIT_GET ( qib7322->sendbufavail, InUseCheck[send_idx] );
545 inuse = ( !! ( inusecheck & 0x02 ) );
546 check = ( !! ( inusecheck & 0x01 ) );
547 return ( inuse || ( check != send_check ) );
548}
struct QIB_7322_SendBufAvail * sendbufavail
Send buffer availability (reported by hardware)
Definition qib7322.c:113

References BIT_GET, QIB7322_SEND_BUF_TOGGLE, and qib7322::sendbufavail.

Referenced by qib7322_poll_send_wq().

◆ qib7322_send_buffer_offset()

unsigned long qib7322_send_buffer_offset ( struct qib7322 *qib7322 __unused,
struct qib7322_send_buffers * send_bufs,
unsigned int send_buf )
static

Calculate starting offset for send buffer.

Parameters
qib7322QIB7322 device
send_bufSend buffer
Return values
offsetStarting offset

Definition at line 558 of file qib7322.c.

560 {
561 unsigned int index;
562
563 index = ( ( send_buf & ~QIB7322_SEND_BUF_TOGGLE ) - send_bufs->start );
564 return ( send_bufs->base + ( index * send_bufs->size ) );
565}
long index
Definition bigint.h:65

References __unused, qib7322_send_buffers::base, index, QIB7322_SEND_BUF_TOGGLE, qib7322_send_buffers::size, and qib7322_send_buffers::start.

Referenced by qib7322_post_send().

◆ qib7322_create_send_wq()

int qib7322_create_send_wq ( struct ib_device * ibdev,
struct ib_queue_pair * qp )
static

Create send work queue.

Parameters
ibdevInfiniband device
qpQueue pair

Definition at line 573 of file qib7322.c.

574 {
575 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
576 struct ib_work_queue *wq = &qp->send;
577 struct qib7322_send_work_queue *qib7322_wq = ib_wq_get_drvdata ( wq );
578 unsigned int port = ( ibdev->port - QIB7322_PORT_BASE );
579
580 /* Select send buffer set */
581 if ( qp->type == IB_QPT_SMI ) {
582 if ( port == 0 ) {
584 } else {
586 }
587 } else {
588 qib7322_wq->send_bufs = qib7322->send_bufs_small;
589 }
590
591 /* Allocate space for send buffer usage list */
592 qib7322_wq->used = zalloc ( qp->send.num_wqes *
593 sizeof ( qib7322_wq->used[0] ) );
594 if ( ! qib7322_wq->used )
595 return -ENOMEM;
596
597 /* Reset work queue */
598 qib7322_wq->prod = 0;
599 qib7322_wq->cons = 0;
600
601 return 0;
602}
#define ENOMEM
Not enough space.
Definition errno.h:535
@ IB_QPT_SMI
Definition infiniband.h:140
static __always_inline void * ib_wq_get_drvdata(struct ib_work_queue *wq)
Get Infiniband work queue driver-private data.
Definition infiniband.h:621
An Infiniband Work Queue.
Definition infiniband.h:101
A QIB7322 send work queue.
Definition qib7322.c:71
uint16_t * used
Send buffer usage.
Definition qib7322.c:75
unsigned int cons
Consumer index.
Definition qib7322.c:79
struct qib7322_send_buffers * send_bufs
Send buffer set.
Definition qib7322.c:73
unsigned int prod
Producer index.
Definition qib7322.c:77
struct qib7322_send_buffers * send_bufs_vl15_port0
VL15 port 0 send buffers.
Definition qib7322.c:117
struct qib7322_send_buffers * send_bufs_vl15_port1
VL15 port 1 send buffers.
Definition qib7322.c:119
struct qib7322_send_buffers * send_bufs_small
Small send buffers.
Definition qib7322.c:115

References qib7322_send_work_queue::cons, ENOMEM, ib_get_drvdata(), IB_QPT_SMI, ib_wq_get_drvdata(), qib7322::ibdev, ib_device::port, port, qib7322_send_work_queue::prod, QIB7322_PORT_BASE, qp, qib7322_send_work_queue::send_bufs, qib7322::send_bufs_small, qib7322::send_bufs_vl15_port0, qib7322::send_bufs_vl15_port1, qib7322_send_work_queue::used, and zalloc().

Referenced by qib7322_create_qp().

◆ qib7322_destroy_send_wq()

void qib7322_destroy_send_wq ( struct ib_device *ibdev __unused,
struct ib_queue_pair * qp )
static

Destroy send work queue.

Parameters
ibdevInfiniband device
qpQueue pair

Definition at line 610 of file qib7322.c.

611 {
612 struct ib_work_queue *wq = &qp->send;
613 struct qib7322_send_work_queue *qib7322_wq = ib_wq_get_drvdata ( wq );
614
615 free ( qib7322_wq->used );
616}

References __unused, free, ib_wq_get_drvdata(), qp, and qib7322_send_work_queue::used.

Referenced by qib7322_create_qp(), and qib7322_destroy_qp().

◆ qib7322_init_send()

int qib7322_init_send ( struct qib7322 * qib7322)
static

Initialise send datapath.

Parameters
qib7322QIB7322 device
Return values
rcReturn status code

Definition at line 624 of file qib7322.c.

624 {
625 struct QIB_7322_SendBufBase sendbufbase;
626 struct QIB_7322_SendBufAvailAddr sendbufavailaddr;
627 struct QIB_7322_SendCtrl sendctrl;
628 struct QIB_7322_SendCtrl_0 sendctrlp;
629 unsigned long baseaddr_smallpio;
630 unsigned long baseaddr_largepio;
631 unsigned long baseaddr_vl15_port0;
632 unsigned long baseaddr_vl15_port1;
633 int rc;
634
635 /* Create send buffer sets */
637 baseaddr_smallpio = BIT_GET ( &sendbufbase, BaseAddr_SmallPIO );
638 baseaddr_largepio = BIT_GET ( &sendbufbase, BaseAddr_LargePIO );
639 baseaddr_vl15_port0 = ( baseaddr_largepio +
642 baseaddr_vl15_port1 = ( baseaddr_vl15_port0 +
645 qib7322_create_send_bufs ( qib7322, baseaddr_smallpio,
649 if ( ! qib7322->send_bufs_small ) {
650 rc = -ENOMEM;
651 goto err_create_send_bufs_small;
652 }
654 qib7322_create_send_bufs ( qib7322, baseaddr_vl15_port0,
658 if ( ! qib7322->send_bufs_vl15_port0 ) {
659 rc = -ENOMEM;
660 goto err_create_send_bufs_vl15_port0;
661 }
663 qib7322_create_send_bufs ( qib7322, baseaddr_vl15_port1,
667 if ( ! qib7322->send_bufs_vl15_port1 ) {
668 rc = -ENOMEM;
669 goto err_create_send_bufs_vl15_port1;
670 }
671
672 /* Allocate space for the SendBufAvail array */
675 if ( ! qib7322->sendbufavail ) {
676 rc = -ENOMEM;
677 goto err_alloc_sendbufavail;
678 }
679 memset ( qib7322->sendbufavail, 0, sizeof ( *qib7322->sendbufavail ) );
680
681 /* Program SendBufAvailAddr into the hardware */
682 memset ( &sendbufavailaddr, 0, sizeof ( sendbufavailaddr ) );
683 BIT_FILL_1 ( &sendbufavailaddr, SendBufAvailAddr,
684 ( virt_to_bus ( qib7322->sendbufavail ) >> 6 ) );
685 qib7322_writeq ( qib7322, &sendbufavailaddr,
687
688 /* Enable sending */
689 memset ( &sendctrlp, 0, sizeof ( sendctrlp ) );
690 BIT_FILL_1 ( &sendctrlp, SendEnable, 1 );
693
694 /* Enable DMA of SendBufAvail */
695 memset ( &sendctrl, 0, sizeof ( sendctrl ) );
696 BIT_FILL_1 ( &sendctrl, SendBufAvailUpd, 1 );
698
699 return 0;
700
702 err_alloc_sendbufavail:
704 err_create_send_bufs_vl15_port1:
706 err_create_send_bufs_vl15_port0:
708 err_create_send_bufs_small:
709 return rc;
710}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition io.h:184
void * memset(void *dest, int character, size_t len) __nonnull
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition malloc.c:707
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition malloc.c:723
#define BIT_FILL_1(_ptr, _field1,...)
Definition pseudobit.h:185
static struct qib7322_send_buffers * qib7322_create_send_bufs(struct qib7322 *qib7322, unsigned long base, unsigned int size, unsigned int start, unsigned int count)
Create send buffer set.
Definition qib7322.c:446
static void qib7322_destroy_send_bufs(struct qib7322 *qib7322 __unused, struct qib7322_send_buffers *send_bufs)
Destroy send buffer set.
Definition qib7322.c:480
#define QIB7322_LARGE_SEND_BUF_COUNT
QIB7322 large send buffer count.
Definition qib7322.h:220
#define QIB7322_VL15_PORT1_SEND_BUF_SIZE
QIB7322 VL15 port 0 send buffer size.
Definition qib7322.h:238
#define QIB7322_SMALL_SEND_BUF_START
QIB7322 small send buffer starting index.
Definition qib7322.h:208
#define QIB7322_SMALL_SEND_BUF_SIZE
QIB7322 small send buffer size.
Definition qib7322.h:205
#define QIB7322_VL15_PORT1_SEND_BUF_COUNT
QIB7322 VL15 port 0 send buffer count.
Definition qib7322.h:235
#define QIB7322_LARGE_SEND_BUF_SIZE
QIB7322 large send buffer size.
Definition qib7322.h:214
#define QIB7322_VL15_PORT0_SEND_BUF_COUNT
QIB7322 VL15 port 0 send buffer count.
Definition qib7322.h:226
#define QIB7322_SENDBUFAVAIL_ALIGN
DMA alignment for send buffer availability.
Definition qib7322.h:97
#define QIB7322_SMALL_SEND_BUF_USED
Number of small send buffers used.
Definition qib7322.h:246
#define QIB7322_VL15_PORT0_SEND_BUF_SIZE
QIB7322 VL15 port 0 send buffer size.
Definition qib7322.h:229
#define QIB7322_VL15_PORT0_SEND_BUF_START
QIB7322 VL15 port 0 send buffer starting index.
Definition qib7322.h:223
#define QIB7322_VL15_PORT1_SEND_BUF_START
QIB7322 VL15 port 0 send buffer starting index.
Definition qib7322.h:232
#define QIB_7322_SendCtrl_0_offset
#define QIB_7322_SendCtrl_offset
#define QIB_7322_SendBufBase_offset
#define QIB_7322_SendCtrl_1_offset
#define QIB_7322_SendBufAvailAddr_offset

References BIT_FILL_1, BIT_GET, ENOMEM, free_phys(), malloc_phys(), memset(), qib7322_create_send_bufs(), qib7322_destroy_send_bufs(), QIB7322_LARGE_SEND_BUF_COUNT, QIB7322_LARGE_SEND_BUF_SIZE, qib7322_readq, QIB7322_SENDBUFAVAIL_ALIGN, QIB7322_SMALL_SEND_BUF_SIZE, QIB7322_SMALL_SEND_BUF_START, QIB7322_SMALL_SEND_BUF_USED, QIB7322_VL15_PORT0_SEND_BUF_COUNT, QIB7322_VL15_PORT0_SEND_BUF_SIZE, QIB7322_VL15_PORT0_SEND_BUF_START, QIB7322_VL15_PORT1_SEND_BUF_COUNT, QIB7322_VL15_PORT1_SEND_BUF_SIZE, QIB7322_VL15_PORT1_SEND_BUF_START, qib7322_writeq, QIB_7322_SendBufAvailAddr_offset, QIB_7322_SendBufBase_offset, QIB_7322_SendCtrl_0_offset, QIB_7322_SendCtrl_1_offset, QIB_7322_SendCtrl_offset, rc, qib7322::send_bufs_small, qib7322::send_bufs_vl15_port0, qib7322::send_bufs_vl15_port1, qib7322::sendbufavail, and virt_to_bus().

Referenced by qib7322_probe().

◆ qib7322_fini_send()

void qib7322_fini_send ( struct qib7322 * qib7322)
static

Shut down send datapath.

Parameters
qib7322QIB7322 device

Definition at line 717 of file qib7322.c.

717 {
718 struct QIB_7322_SendCtrl sendctrl;
719
720 /* Disable sending and DMA of SendBufAvail */
721 memset ( &sendctrl, 0, sizeof ( sendctrl ) );
723 mb();
724
725 /* Ensure hardware has seen this disable */
727
732}
void mb(void)
Memory barrier.

References free_phys(), mb(), memset(), qib7322_destroy_send_bufs(), qib7322_readq, qib7322_writeq, QIB_7322_SendCtrl_offset, qib7322::send_bufs_small, qib7322::send_bufs_vl15_port0, qib7322::send_bufs_vl15_port1, and qib7322::sendbufavail.

Referenced by qib7322_probe(), and qib7322_remove().

◆ qib7322_create_recv_wq()

int qib7322_create_recv_wq ( struct ib_device * ibdev,
struct ib_queue_pair * qp )
static

Create receive work queue.

Parameters
ibdevInfiniband device
qpQueue pair
Return values
rcReturn status code

Definition at line 748 of file qib7322.c.

749 {
750 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
751 struct ib_work_queue *wq = &qp->recv;
752 struct qib7322_recv_work_queue *qib7322_wq = ib_wq_get_drvdata ( wq );
753 struct QIB_7322_RcvHdrAddr0 rcvhdraddr;
754 struct QIB_7322_RcvHdrTailAddr0 rcvhdrtailaddr;
755 struct QIB_7322_RcvHdrHead0 rcvhdrhead;
756 struct QIB_7322_scalar rcvegrindexhead;
757 struct QIB_7322_RcvCtrl rcvctrl;
758 struct QIB_7322_RcvCtrl_P rcvctrlp;
759 unsigned int port = ( ibdev->port - QIB7322_PORT_BASE );
760 unsigned int ctx = qib7322_ctx ( ibdev, qp );
761 int rc;
762
763 /* Reset context information */
764 memset ( &qib7322_wq->header_prod, 0,
765 sizeof ( qib7322_wq->header_prod ) );
766 qib7322_wq->header_cons = 0;
767 qib7322_wq->eager_prod = 0;
768 qib7322_wq->eager_cons = 0;
769
770 /* Allocate receive header buffer */
773 if ( ! qib7322_wq->header ) {
774 rc = -ENOMEM;
775 goto err_alloc_header;
776 }
777
778 /* Enable context in hardware */
779 memset ( &rcvhdraddr, 0, sizeof ( rcvhdraddr ) );
780 BIT_FILL_1 ( &rcvhdraddr, RcvHdrAddr,
781 ( virt_to_bus ( qib7322_wq->header ) >> 2 ) );
782 qib7322_writeq_array8b ( qib7322, &rcvhdraddr,
784 memset ( &rcvhdrtailaddr, 0, sizeof ( rcvhdrtailaddr ) );
785 BIT_FILL_1 ( &rcvhdrtailaddr, RcvHdrTailAddr,
786 ( virt_to_bus ( &qib7322_wq->header_prod ) >> 2 ) );
787 qib7322_writeq_array8b ( qib7322, &rcvhdrtailaddr,
789 memset ( &rcvhdrhead, 0, sizeof ( rcvhdrhead ) );
790 BIT_FILL_1 ( &rcvhdrhead, counter, 1 );
791 qib7322_writeq_array64k ( qib7322, &rcvhdrhead,
793 memset ( &rcvegrindexhead, 0, sizeof ( rcvegrindexhead ) );
794 BIT_FILL_1 ( &rcvegrindexhead, Value, 1 );
795 qib7322_writeq_array64k ( qib7322, &rcvegrindexhead,
797 qib7322_readq_port ( qib7322, &rcvctrlp,
799 BIT_SET ( &rcvctrlp, ContextEnable[ctx], 1 );
800 qib7322_writeq_port ( qib7322, &rcvctrlp,
803 BIT_SET ( &rcvctrl, IntrAvail[ctx], 1 );
805
806 DBGC ( qib7322, "QIB7322 %p port %d QPN %ld CTX %d hdrs [%lx,%lx) prod "
807 "%lx\n", qib7322, port, qp->qpn, ctx,
808 virt_to_bus ( qib7322_wq->header ),
809 ( virt_to_bus ( qib7322_wq->header )
811 virt_to_bus ( &qib7322_wq->header_prod ) );
812 return 0;
813
815 err_alloc_header:
816 return rc;
817}
#define qib7322_writeq_array64k(_qib7322, _ptr, _offset, _idx)
Definition qib7322.c:178
#define qib7322_writeq_array8b(_qib7322, _ptr, _offset, _idx)
Definition qib7322.c:176
#define QIB7322_RECV_HEADERS_SIZE
Total size of an RX header ring.
Definition qib7322.h:296
#define QIB7322_RECV_HEADERS_ALIGN
RX header alignment.
Definition qib7322.h:300
#define QIB_7322_RcvCtrl_0_offset
#define QIB_7322_RcvCtrl_offset
#define QIB_7322_RcvHdrHead0_offset
#define QIB_7322_RcvHdrTailAddr0_offset
#define QIB_7322_RcvEgrIndexHead0_offset
#define QIB_7322_RcvHdrAddr0_offset
A QIB7322 receive work queue.
Definition qib7322.c:83
struct QIB_7322_scalar header_prod
Receive header producer offset (written by hardware)
Definition qib7322.c:87
unsigned int header_cons
Receive header consumer offset.
Definition qib7322.c:89
unsigned int eager_prod
Eager array producer index.
Definition qib7322.c:95
unsigned int eager_cons
Eager array consumer index.
Definition qib7322.c:97
void * header
Receive header ring.
Definition qib7322.c:85

References BIT_FILL_1, BIT_SET, ctx, DBGC, qib7322_recv_work_queue::eager_cons, qib7322_recv_work_queue::eager_prod, ENOMEM, free_phys(), qib7322_recv_work_queue::header, qib7322_recv_work_queue::header_cons, qib7322_recv_work_queue::header_prod, ib_get_drvdata(), ib_wq_get_drvdata(), qib7322::ibdev, malloc_phys(), memset(), ib_device::port, port, qib7322_ctx(), QIB7322_PORT_BASE, qib7322_readq, qib7322_readq_port, QIB7322_RECV_HEADERS_ALIGN, QIB7322_RECV_HEADERS_SIZE, qib7322_writeq, qib7322_writeq_array64k, qib7322_writeq_array8b, qib7322_writeq_port, QIB_7322_RcvCtrl_0_offset, QIB_7322_RcvCtrl_offset, QIB_7322_RcvEgrIndexHead0_offset, QIB_7322_RcvHdrAddr0_offset, QIB_7322_RcvHdrHead0_offset, QIB_7322_RcvHdrTailAddr0_offset, qp, rc, and virt_to_bus().

Referenced by qib7322_create_qp().

◆ qib7322_destroy_recv_wq()

void qib7322_destroy_recv_wq ( struct ib_device * ibdev,
struct ib_queue_pair * qp )
static

Destroy receive work queue.

Parameters
ibdevInfiniband device
qpQueue pair

Definition at line 825 of file qib7322.c.

826 {
827 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
828 struct ib_work_queue *wq = &qp->recv;
829 struct qib7322_recv_work_queue *qib7322_wq = ib_wq_get_drvdata ( wq );
830 struct QIB_7322_RcvCtrl rcvctrl;
831 struct QIB_7322_RcvCtrl_P rcvctrlp;
832 unsigned int port = ( ibdev->port - QIB7322_PORT_BASE );
833 unsigned int ctx = qib7322_ctx ( ibdev, qp );
834
835 /* Disable context in hardware */
836 qib7322_readq_port ( qib7322, &rcvctrlp,
838 BIT_SET ( &rcvctrlp, ContextEnable[ctx], 0 );
839 qib7322_writeq_port ( qib7322, &rcvctrlp,
842 BIT_SET ( &rcvctrl, IntrAvail[ctx], 0 );
844
845 /* Make sure the hardware has seen that the context is disabled */
847 mb();
848
849 /* Free headers ring */
851}

References BIT_SET, ctx, free_phys(), qib7322_recv_work_queue::header, ib_get_drvdata(), ib_wq_get_drvdata(), qib7322::ibdev, mb(), ib_device::port, port, qib7322_ctx(), QIB7322_PORT_BASE, qib7322_readq, qib7322_readq_port, QIB7322_RECV_HEADERS_SIZE, qib7322_writeq, qib7322_writeq_port, QIB_7322_RcvCtrl_0_offset, QIB_7322_RcvCtrl_offset, and qp.

Referenced by qib7322_create_qp(), and qib7322_destroy_qp().

◆ qib7322_init_recv()

int qib7322_init_recv ( struct qib7322 * qib7322)
static

Initialise receive datapath.

Parameters
qib7322QIB7322 device
Return values
rcReturn status code

Definition at line 859 of file qib7322.c.

859 {
860 struct QIB_7322_RcvCtrl rcvctrl;
861 struct QIB_7322_RcvCtrl_0 rcvctrlp;
862 struct QIB_7322_RcvQPMapTableA_0 rcvqpmaptablea0;
863 struct QIB_7322_RcvQPMapTableB_0 rcvqpmaptableb0;
864 struct QIB_7322_RcvQPMapTableA_1 rcvqpmaptablea1;
865 struct QIB_7322_RcvQPMapTableB_1 rcvqpmaptableb1;
866 struct QIB_7322_RcvQPMulticastContext_0 rcvqpmcastctx0;
867 struct QIB_7322_RcvQPMulticastContext_1 rcvqpmcastctx1;
868 struct QIB_7322_scalar rcvegrbase;
869 struct QIB_7322_scalar rcvhdrentsize;
870 struct QIB_7322_scalar rcvhdrcnt;
871 struct QIB_7322_RcvBTHQP_0 rcvbthqp;
872 struct QIB_7322_RxCreditVL0_0 rxcreditvl;
873 unsigned int contextcfg;
874 unsigned long egrbase;
875 unsigned int eager_array_size_kernel;
876 unsigned int eager_array_size_user;
877 unsigned int ctx;
878
879 /* Select configuration based on number of contexts */
880 switch ( QIB7322_NUM_CONTEXTS ) {
881 case 6:
882 contextcfg = QIB7322_CONTEXTCFG_6CTX;
883 eager_array_size_kernel = QIB7322_EAGER_ARRAY_SIZE_6CTX_KERNEL;
884 eager_array_size_user = QIB7322_EAGER_ARRAY_SIZE_6CTX_USER;
885 break;
886 case 10:
887 contextcfg = QIB7322_CONTEXTCFG_10CTX;
888 eager_array_size_kernel = QIB7322_EAGER_ARRAY_SIZE_10CTX_KERNEL;
889 eager_array_size_user = QIB7322_EAGER_ARRAY_SIZE_10CTX_USER;
890 break;
891 case 18:
892 contextcfg = QIB7322_CONTEXTCFG_18CTX;
893 eager_array_size_kernel = QIB7322_EAGER_ARRAY_SIZE_18CTX_KERNEL;
894 eager_array_size_user = QIB7322_EAGER_ARRAY_SIZE_18CTX_USER;
895 break;
896 default:
897 build_assert ( 0 );
898 return -EINVAL;
899 }
900
901 /* Configure number of contexts */
902 memset ( &rcvctrl, 0, sizeof ( rcvctrl ) );
903 BIT_FILL_2 ( &rcvctrl,
904 TailUpd, 1,
905 ContextCfg, contextcfg );
907
908 /* Map QPNs to contexts */
909 memset ( &rcvctrlp, 0, sizeof ( rcvctrlp ) );
910 BIT_FILL_3 ( &rcvctrlp,
911 RcvIBPortEnable, 1,
912 RcvQPMapEnable, 1,
913 RcvPartitionKeyDisable, 1 );
916 memset ( &rcvqpmaptablea0, 0, sizeof ( rcvqpmaptablea0 ) );
917 BIT_FILL_6 ( &rcvqpmaptablea0,
918 RcvQPMapContext0, 0,
919 RcvQPMapContext1, 2,
920 RcvQPMapContext2, 4,
921 RcvQPMapContext3, 6,
922 RcvQPMapContext4, 8,
923 RcvQPMapContext5, 10 );
924 qib7322_writeq ( qib7322, &rcvqpmaptablea0,
926 memset ( &rcvqpmaptableb0, 0, sizeof ( rcvqpmaptableb0 ) );
927 BIT_FILL_3 ( &rcvqpmaptableb0,
928 RcvQPMapContext6, 12,
929 RcvQPMapContext7, 14,
930 RcvQPMapContext8, 16 );
931 qib7322_writeq ( qib7322, &rcvqpmaptableb0,
933 memset ( &rcvqpmaptablea1, 0, sizeof ( rcvqpmaptablea1 ) );
934 BIT_FILL_6 ( &rcvqpmaptablea1,
935 RcvQPMapContext0, 1,
936 RcvQPMapContext1, 3,
937 RcvQPMapContext2, 5,
938 RcvQPMapContext3, 7,
939 RcvQPMapContext4, 9,
940 RcvQPMapContext5, 11 );
941 qib7322_writeq ( qib7322, &rcvqpmaptablea1,
943 memset ( &rcvqpmaptableb1, 0, sizeof ( rcvqpmaptableb1 ) );
944 BIT_FILL_3 ( &rcvqpmaptableb1,
945 RcvQPMapContext6, 13,
946 RcvQPMapContext7, 15,
947 RcvQPMapContext8, 17 );
948 qib7322_writeq ( qib7322, &rcvqpmaptableb1,
950
951 /* Map multicast QPNs to contexts */
952 memset ( &rcvqpmcastctx0, 0, sizeof ( rcvqpmcastctx0 ) );
953 BIT_FILL_1 ( &rcvqpmcastctx0, RcvQpMcContext, 0 );
954 qib7322_writeq ( qib7322, &rcvqpmcastctx0,
956 memset ( &rcvqpmcastctx1, 0, sizeof ( rcvqpmcastctx1 ) );
957 BIT_FILL_1 ( &rcvqpmcastctx1, RcvQpMcContext, 1 );
958 qib7322_writeq ( qib7322, &rcvqpmcastctx1,
960
961 /* Configure receive header buffer sizes */
962 memset ( &rcvhdrcnt, 0, sizeof ( rcvhdrcnt ) );
963 BIT_FILL_1 ( &rcvhdrcnt, Value, QIB7322_RECV_HEADER_COUNT );
965 memset ( &rcvhdrentsize, 0, sizeof ( rcvhdrentsize ) );
966 BIT_FILL_1 ( &rcvhdrentsize, Value, ( QIB7322_RECV_HEADER_SIZE >> 2 ) );
967 qib7322_writeq ( qib7322, &rcvhdrentsize,
969
970 /* Calculate eager array start addresses for each context */
972 egrbase = BIT_GET ( &rcvegrbase, Value );
973 for ( ctx = 0 ; ctx < QIB7322_MAX_PORTS ; ctx++ ) {
974 qib7322->recv_wq[ctx].eager_array = egrbase;
975 qib7322->recv_wq[ctx].eager_entries = eager_array_size_kernel;
976 egrbase += ( eager_array_size_kernel *
977 sizeof ( struct QIB_7322_RcvEgr ) );
978 }
979 for ( ; ctx < QIB7322_NUM_CONTEXTS ; ctx++ ) {
980 qib7322->recv_wq[ctx].eager_array = egrbase;
981 qib7322->recv_wq[ctx].eager_entries = eager_array_size_user;
982 egrbase += ( eager_array_size_user *
983 sizeof ( struct QIB_7322_RcvEgr ) );
984 }
985 for ( ctx = 0 ; ctx < QIB7322_NUM_CONTEXTS ; ctx++ ) {
986 DBGC ( qib7322, "QIB7322 %p CTX %d eager array at %lx (%d "
987 "entries)\n", qib7322, ctx,
990 }
991
992 /* Set the BTH QP for Infinipath packets to an unused value */
993 memset ( &rcvbthqp, 0, sizeof ( rcvbthqp ) );
994 BIT_FILL_1 ( &rcvbthqp, RcvBTHQP, QIB7322_QP_IDETH );
997
998 /* Assign initial credits */
999 memset ( &rxcreditvl, 0, sizeof ( rxcreditvl ) );
1000 BIT_FILL_1 ( &rxcreditvl, RxMaxCreditVL, QIB7322_MAX_CREDITS_VL0 );
1001 qib7322_writeq_array8b ( qib7322, &rxcreditvl,
1003 qib7322_writeq_array8b ( qib7322, &rxcreditvl,
1005 BIT_FILL_1 ( &rxcreditvl, RxMaxCreditVL, QIB7322_MAX_CREDITS_VL15 );
1006 qib7322_writeq_array8b ( qib7322, &rxcreditvl,
1008 qib7322_writeq_array8b ( qib7322, &rxcreditvl,
1010
1011 return 0;
1012}
#define build_assert(condition)
Assert a condition at build time (after dead code elimination)
Definition assert.h:77
#define EINVAL
Invalid argument.
Definition errno.h:429
#define BIT_FILL_3(_ptr, _field1,...)
Definition pseudobit.h:195
#define BIT_FILL_2(_ptr, _field1,...)
Definition pseudobit.h:190
#define BIT_FILL_6(_ptr, _field1,...)
Definition pseudobit.h:210
#define QIB7322_EAGER_ARRAY_SIZE_10CTX_KERNEL
Definition qib7322.h:264
#define QIB7322_QP_IDETH
QPN used for Infinipath Packets.
Definition qib7322.h:334
#define QIB7322_EAGER_ARRAY_SIZE_18CTX_KERNEL
Definition qib7322.h:266
#define QIB7322_EAGER_ARRAY_SIZE_10CTX_USER
Definition qib7322.h:265
#define QIB7322_MAX_PORTS
QIB7322 maximum number of ports.
Definition qib7322.h:169
#define QIB7322_EAGER_ARRAY_SIZE_18CTX_USER
Definition qib7322.h:267
#define QIB7322_RECV_HEADER_COUNT
Number of RX headers per context.
Definition qib7322.h:287
#define QIB7322_RECV_HEADER_SIZE
Maximum size of each RX header.
Definition qib7322.h:293
#define QIB7322_EAGER_ARRAY_SIZE_6CTX_KERNEL
ContextCfg values for different numbers of contexts.
Definition qib7322.h:262
#define QIB7322_EAGER_ARRAY_SIZE_6CTX_USER
Definition qib7322.h:263
#define QIB7322_MAX_CREDITS_VL15
Number of credits to advertise for VL15.
Definition qib7322.h:320
#define QIB7322_MAX_CREDITS_VL0
Number of credits to advertise for VL0.
Definition qib7322.h:326
@ QIB7322_CONTEXTCFG_18CTX
Definition qib7322.h:258
@ QIB7322_CONTEXTCFG_10CTX
Definition qib7322.h:257
@ QIB7322_CONTEXTCFG_6CTX
Definition qib7322.h:256
#define QIB_7322_RxCreditVL0_1_offset
#define QIB_7322_RcvEgrBase_offset
#define QIB_7322_RcvQPMapTableB_0_offset
#define QIB_7322_RcvQPMulticastContext_0_offset
#define QIB_7322_RcvHdrCnt_offset
#define QIB_7322_RcvQPMapTableB_1_offset
#define QIB_7322_RcvQPMapTableA_1_offset
#define QIB_7322_RcvBTHQP_0_offset
#define QIB_7322_RcvBTHQP_1_offset
#define QIB_7322_RcvQPMulticastContext_1_offset
#define QIB_7322_RcvQPMapTableA_0_offset
#define QIB_7322_RcvHdrEntSize_offset
#define QIB_7322_RxCreditVL0_0_offset
#define QIB_7322_RcvCtrl_1_offset
unsigned long eager_array
Offset within register space of the eager array.
Definition qib7322.c:91
unsigned int eager_entries
Number of entries in eager array.
Definition qib7322.c:93
struct qib7322_recv_work_queue recv_wq[QIB7322_NUM_CONTEXTS]
Receive work queues.
Definition qib7322.c:110

References BIT_FILL_1, BIT_FILL_2, BIT_FILL_3, BIT_FILL_6, BIT_GET, build_assert, ctx, DBGC, qib7322_recv_work_queue::eager_array, qib7322_recv_work_queue::eager_entries, EINVAL, memset(), QIB7322_CONTEXTCFG_10CTX, QIB7322_CONTEXTCFG_18CTX, QIB7322_CONTEXTCFG_6CTX, QIB7322_EAGER_ARRAY_SIZE_10CTX_KERNEL, QIB7322_EAGER_ARRAY_SIZE_10CTX_USER, QIB7322_EAGER_ARRAY_SIZE_18CTX_KERNEL, QIB7322_EAGER_ARRAY_SIZE_18CTX_USER, QIB7322_EAGER_ARRAY_SIZE_6CTX_KERNEL, QIB7322_EAGER_ARRAY_SIZE_6CTX_USER, QIB7322_MAX_CREDITS_VL0, QIB7322_MAX_CREDITS_VL15, QIB7322_MAX_PORTS, QIB7322_NUM_CONTEXTS, QIB7322_QP_IDETH, qib7322_readq, QIB7322_RECV_HEADER_COUNT, QIB7322_RECV_HEADER_SIZE, qib7322_writeq, qib7322_writeq_array8b, QIB_7322_RcvBTHQP_0_offset, QIB_7322_RcvBTHQP_1_offset, QIB_7322_RcvCtrl_0_offset, QIB_7322_RcvCtrl_1_offset, QIB_7322_RcvCtrl_offset, QIB_7322_RcvEgrBase_offset, QIB_7322_RcvHdrCnt_offset, QIB_7322_RcvHdrEntSize_offset, QIB_7322_RcvQPMapTableA_0_offset, QIB_7322_RcvQPMapTableA_1_offset, QIB_7322_RcvQPMapTableB_0_offset, QIB_7322_RcvQPMapTableB_1_offset, QIB_7322_RcvQPMulticastContext_0_offset, QIB_7322_RcvQPMulticastContext_1_offset, QIB_7322_RxCreditVL0_0_offset, QIB_7322_RxCreditVL0_1_offset, and qib7322::recv_wq.

Referenced by qib7322_probe().

◆ qib7322_fini_recv()

void qib7322_fini_recv ( struct qib7322 *qib7322 __unused)
static

Shut down receive datapath.

Parameters
qib7322QIB7322 device

Definition at line 1019 of file qib7322.c.

1019 {
1020 /* Nothing to do; all contexts were already disabled when the
1021 * queue pairs were destroyed
1022 */
1023}

References __unused.

Referenced by qib7322_probe(), and qib7322_remove().

◆ qib7322_create_cq()

int qib7322_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 1039 of file qib7322.c.

1040 {
1041 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
1042 static int cqn;
1043
1044 /* The hardware has no concept of completion queues. We
1045 * simply use the association between CQs and WQs (already
1046 * handled by the IB core) to decide which WQs to poll.
1047 *
1048 * We do set a CQN, just to avoid confusing debug messages
1049 * from the IB core.
1050 */
1051 cq->cqn = ++cqn;
1052 DBGC ( qib7322, "QIB7322 %p CQN %ld created\n", qib7322, cq->cqn );
1053
1054 return 0;
1055}
__be32 cqn
Definition CIB_PRM.h:1
unsigned long cqn
Completion queue number.
Definition infiniband.h:231

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

◆ qib7322_destroy_cq()

void qib7322_destroy_cq ( struct ib_device * ibdev,
struct ib_completion_queue * cq )
static

Destroy completion queue.

Parameters
ibdevInfiniband device
cqCompletion queue

Definition at line 1063 of file qib7322.c.

1064 {
1065 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
1066
1067 /* Nothing to do */
1068 DBGC ( qib7322, "QIB7322 %p CQN %ld destroyed\n", qib7322, cq->cqn );
1069}

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

◆ qib7322_create_qp()

int qib7322_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 1085 of file qib7322.c.

1086 {
1087 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
1088 unsigned int ctx;
1089 int rc;
1090
1091 /* Allocate a context and QPN */
1092 if ( ( rc = qib7322_alloc_ctx ( ibdev, qp ) ) != 0 )
1093 goto err_alloc_ctx;
1094 ctx = qib7322_ctx ( ibdev, qp );
1095
1096 /* Set work-queue private data pointers */
1097 ib_wq_set_drvdata ( &qp->send, &qib7322->send_wq[ctx] );
1098 ib_wq_set_drvdata ( &qp->recv, &qib7322->recv_wq[ctx] );
1099
1100 /* Create receive work queue */
1101 if ( ( rc = qib7322_create_recv_wq ( ibdev, qp ) ) != 0 )
1102 goto err_create_recv_wq;
1103
1104 /* Create send work queue */
1105 if ( ( rc = qib7322_create_send_wq ( ibdev, qp ) ) != 0 )
1106 goto err_create_send_wq;
1107
1108 return 0;
1109
1111 err_create_send_wq:
1113 err_create_recv_wq:
1115 err_alloc_ctx:
1116 return rc;
1117}
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:610
static void qib7322_destroy_recv_wq(struct ib_device *ibdev, struct ib_queue_pair *qp)
Destroy receive work queue.
Definition qib7322.c:825
static int qib7322_alloc_ctx(struct ib_device *ibdev, struct ib_queue_pair *qp)
Allocate a context and set queue pair number.
Definition qib7322.c:369
static int qib7322_create_send_wq(struct ib_device *ibdev, struct ib_queue_pair *qp)
Create send work queue.
Definition qib7322.c:573
static int qib7322_create_recv_wq(struct ib_device *ibdev, struct ib_queue_pair *qp)
Create receive work queue.
Definition qib7322.c:748
static void qib7322_destroy_send_wq(struct ib_device *ibdev __unused, struct ib_queue_pair *qp)
Destroy send work queue.
Definition qib7322.c:610
static void qib7322_free_ctx(struct ib_device *ibdev, struct ib_queue_pair *qp)
Free a context.
Definition qib7322.c:409
struct qib7322_send_work_queue send_wq[QIB7322_NUM_CONTEXTS]
Send work queues.
Definition qib7322.c:108

References ctx, ib_get_drvdata(), ib_wq_set_drvdata(), qib7322::ibdev, qib7322_alloc_ctx(), qib7322_create_recv_wq(), qib7322_create_send_wq(), qib7322_ctx(), qib7322_destroy_recv_wq(), qib7322_destroy_send_wq(), qib7322_free_ctx(), qp, rc, qib7322::recv_wq, and qib7322::send_wq.

◆ qib7322_modify_qp()

int qib7322_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 1126 of file qib7322.c.

1127 {
1128 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
1129
1130 /* Nothing to do; the hardware doesn't have a notion of queue
1131 * keys
1132 */
1133 DBGC2 ( qib7322, "QIB7322 %p QPN %ld modified\n", qib7322, qp->qpn );
1134 return 0;
1135}

References DBGC2, ib_get_drvdata(), qib7322::ibdev, and qp.

◆ qib7322_destroy_qp()

void qib7322_destroy_qp ( struct ib_device * ibdev,
struct ib_queue_pair * qp )
static

Destroy queue pair.

Parameters
ibdevInfiniband device
qpQueue pair

Definition at line 1143 of file qib7322.c.

1144 {
1145
1146 qib7322_destroy_send_wq ( ibdev, qp );
1147 qib7322_destroy_recv_wq ( ibdev, qp );
1148 qib7322_free_ctx ( ibdev, qp );
1149}

References qib7322::ibdev, qib7322_destroy_recv_wq(), qib7322_destroy_send_wq(), qib7322_free_ctx(), and qp.

◆ qib7322_post_send()

int qib7322_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 1167 of file qib7322.c.

1170 {
1171 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
1172 struct ib_work_queue *wq = &qp->send;
1173 struct qib7322_send_work_queue *qib7322_wq = ib_wq_get_drvdata ( wq );
1174 struct QIB_7322_SendPbc sendpbc;
1175 unsigned int port = ( ibdev->port - QIB7322_PORT_BASE );
1176 uint8_t header_buf[IB_MAX_HEADER_SIZE];
1177 struct io_buffer headers;
1178 int send_buf;
1179 unsigned long start_offset;
1180 unsigned long offset;
1181 size_t len;
1182 ssize_t frag_len;
1183 uint32_t *data;
1184
1185 /* Allocate send buffer and calculate offset */
1186 send_buf = qib7322_alloc_send_buf ( qib7322, qib7322_wq->send_bufs );
1187 if ( send_buf < 0 )
1188 return send_buf;
1189 start_offset = offset =
1191 send_buf );
1192
1193 /* Store I/O buffer and send buffer index */
1194 assert ( wq->iobufs[qib7322_wq->prod] == NULL );
1195 wq->iobufs[qib7322_wq->prod] = iobuf;
1196 qib7322_wq->used[qib7322_wq->prod] = send_buf;
1197
1198 /* Construct headers */
1199 iob_populate ( &headers, header_buf, 0, sizeof ( header_buf ) );
1200 iob_reserve ( &headers, sizeof ( header_buf ) );
1201 ib_push ( ibdev, &headers, qp, iob_len ( iobuf ), dest );
1202
1203 /* Calculate packet length */
1204 len = ( ( sizeof ( sendpbc ) + iob_len ( &headers ) +
1205 iob_len ( iobuf ) + 3 ) & ~3 );
1206
1207 /* Construct send per-buffer control word */
1208 memset ( &sendpbc, 0, sizeof ( sendpbc ) );
1209 BIT_FILL_3 ( &sendpbc,
1210 LengthP1_toibc, ( ( len >> 2 ) - 1 ),
1211 Port, port,
1212 VL15, ( ( qp->type == IB_QPT_SMI ) ? 1 : 0 ) );
1213
1214 /* Write SendPbc */
1216 qib7322_writeq ( qib7322, &sendpbc, offset );
1217 offset += sizeof ( sendpbc );
1218
1219 /* Write headers */
1220 for ( data = headers.data, frag_len = iob_len ( &headers ) ;
1221 frag_len > 0 ; data++, offset += 4, frag_len -= 4 ) {
1223 }
1224
1225 /* Write data */
1226 for ( data = iobuf->data, frag_len = iob_len ( iobuf ) ;
1227 frag_len > 0 ; data++, offset += 4, frag_len -= 4 ) {
1229 }
1231
1232 assert ( ( start_offset + len ) == offset );
1233 DBGC2 ( qib7322, "QIB7322 %p QPN %ld TX %04x(%04x) posted [%lx,%lx)\n",
1234 qib7322, qp->qpn, send_buf, qib7322_wq->prod,
1235 start_offset, offset );
1236
1237 /* Increment producer counter */
1238 qib7322_wq->prod = ( ( qib7322_wq->prod + 1 ) & ( wq->num_wqes - 1 ) );
1239
1240 return 0;
1241}
uint8_t headers[IB_MAX_HEADER_SIZE]
Definition arbel.h:3
unsigned int uint32_t
Definition stdint.h:12
unsigned char uint8_t
Definition stdint.h:10
signed long ssize_t
Definition stdint.h:7
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" retur dest)
Definition string.h:151
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
ring len
Length.
Definition dwmac.h:226
uint8_t data[48]
Additional event data.
Definition ena.h:11
#define DBGLVL_IO
Definition compiler.h:322
#define DBG_DISABLE(level)
Definition compiler.h:312
#define DBG_ENABLE(level)
Definition compiler.h:313
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:157
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:195
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition iobuf.h:160
#define iob_reserve(iobuf, len)
Definition iobuf.h:72
static unsigned long qib7322_send_buffer_offset(struct qib7322 *qib7322 __unused, struct qib7322_send_buffers *send_bufs, unsigned int send_buf)
Calculate starting offset for send buffer.
Definition qib7322.c:558
static void qib7322_writel(struct qib7322 *qib7322, uint32_t dword, unsigned long offset)
Write QIB7322 dword register.
Definition qib7322.c:190
static int qib7322_alloc_send_buf(struct qib7322 *qib7322, struct qib7322_send_buffers *send_bufs)
Allocate a send buffer.
Definition qib7322.c:492
struct io_buffer ** iobufs
I/O buffers assigned to work queue.
Definition infiniband.h:125
unsigned int num_wqes
Number of work queue entries.
Definition infiniband.h:113
A persistent I/O buffer.
Definition iobuf.h:38
void * data
Start of data.
Definition iobuf.h:53

References assert, BIT_FILL_3, data, io_buffer::data, DBG_DISABLE, DBG_ENABLE, DBGC2, DBGLVL_IO, dest, headers, ib_get_drvdata(), IB_MAX_HEADER_SIZE, ib_push(), IB_QPT_SMI, ib_wq_get_drvdata(), qib7322::ibdev, iob_len(), iob_populate(), iob_reserve, ib_work_queue::iobufs, len, memset(), NULL, ib_work_queue::num_wqes, offset, ib_device::port, port, qib7322_send_work_queue::prod, qib7322_alloc_send_buf(), QIB7322_PORT_BASE, qib7322_send_buffer_offset(), qib7322_writel(), qib7322_writeq, qp, qib7322_send_work_queue::send_bufs, and qib7322_send_work_queue::used.

◆ qib7322_complete_send()

void qib7322_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 1250 of file qib7322.c.

1252 {
1253 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
1254 struct ib_work_queue *wq = &qp->send;
1255 struct qib7322_send_work_queue *qib7322_wq = ib_wq_get_drvdata ( wq );
1256 struct io_buffer *iobuf;
1257 unsigned int send_buf;
1258
1259 /* Parse completion */
1260 send_buf = qib7322_wq->used[wqe_idx];
1261 DBGC2 ( qib7322, "QIB7322 %p QPN %ld TX %04x(%04x) complete\n",
1262 qib7322, qp->qpn, send_buf, wqe_idx );
1263
1264 /* Complete work queue entry */
1265 iobuf = wq->iobufs[wqe_idx];
1266 assert ( iobuf != NULL );
1267 ib_complete_send ( ibdev, qp, iobuf, 0 );
1268 wq->iobufs[wqe_idx] = NULL;
1269
1270 /* Free send buffer */
1271 qib7322_free_send_buf ( qib7322, qib7322_wq->send_bufs, send_buf );
1272}
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 qib7322_free_send_buf(struct qib7322 *qib7322 __unused, struct qib7322_send_buffers *send_bufs, unsigned int send_buf)
Free a send buffer.
Definition qib7322.c:518

References assert, DBGC2, ib_complete_send(), ib_get_drvdata(), ib_wq_get_drvdata(), qib7322::ibdev, ib_work_queue::iobufs, NULL, qib7322_free_send_buf(), qp, qib7322_send_work_queue::send_bufs, and qib7322_send_work_queue::used.

Referenced by qib7322_poll_send_wq().

◆ qib7322_poll_send_wq()

void qib7322_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 1280 of file qib7322.c.

1281 {
1282 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
1283 struct ib_work_queue *wq = &qp->send;
1284 struct qib7322_send_work_queue *qib7322_wq = ib_wq_get_drvdata ( wq );
1285 unsigned int send_buf;
1286
1287 /* Look for completions */
1288 while ( wq->fill ) {
1289
1290 /* Check to see if send buffer has completed */
1291 send_buf = qib7322_wq->used[qib7322_wq->cons];
1292 if ( qib7322_send_buf_in_use ( qib7322, send_buf ) )
1293 break;
1294
1295 /* Complete this buffer */
1296 qib7322_complete_send ( ibdev, qp, qib7322_wq->cons );
1297
1298 /* Increment consumer counter */
1299 qib7322_wq->cons = ( ( qib7322_wq->cons + 1 ) &
1300 ( wq->num_wqes - 1 ) );
1301 }
1302}
static int qib7322_send_buf_in_use(struct qib7322 *qib7322, unsigned int send_buf)
Check to see if send buffer is in use.
Definition qib7322.c:534
static void qib7322_complete_send(struct ib_device *ibdev, struct ib_queue_pair *qp, unsigned int wqe_idx)
Complete send work queue entry.
Definition qib7322.c:1250
unsigned int fill
Number of occupied work queue entries.
Definition infiniband.h:115

References qib7322_send_work_queue::cons, ib_work_queue::fill, ib_get_drvdata(), ib_wq_get_drvdata(), qib7322::ibdev, ib_work_queue::num_wqes, qib7322_complete_send(), qib7322_send_buf_in_use(), qp, and qib7322_send_work_queue::used.

Referenced by qib7322_poll_cq().

◆ qib7322_post_recv()

int qib7322_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 1312 of file qib7322.c.

1314 {
1315 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
1316 struct ib_work_queue *wq = &qp->recv;
1317 struct qib7322_recv_work_queue *qib7322_wq = ib_wq_get_drvdata ( wq );
1318 struct QIB_7322_RcvEgr rcvegr;
1319 struct QIB_7322_scalar rcvegrindexhead;
1320 unsigned int ctx = qib7322_ctx ( ibdev, qp );
1322 size_t len;
1323 unsigned int wqe_idx;
1324 unsigned int bufsize;
1325
1326 /* Sanity checks */
1327 addr = virt_to_bus ( iobuf->data );
1328 len = iob_tailroom ( iobuf );
1329 if ( addr & ( QIB7322_EAGER_BUFFER_ALIGN - 1 ) ) {
1330 DBGC ( qib7322, "QIB7322 %p QPN %ld misaligned RX buffer "
1331 "(%08lx)\n", qib7322, qp->qpn, addr );
1332 return -EINVAL;
1333 }
1334 if ( len != QIB7322_RECV_PAYLOAD_SIZE ) {
1335 DBGC ( qib7322, "QIB7322 %p QPN %ld wrong RX buffer size "
1336 "(%zd)\n", qib7322, qp->qpn, len );
1337 return -EINVAL;
1338 }
1339
1340 /* Calculate eager producer index and WQE index */
1341 wqe_idx = ( qib7322_wq->eager_prod & ( wq->num_wqes - 1 ) );
1342 assert ( wq->iobufs[wqe_idx] == NULL );
1343
1344 /* Store I/O buffer */
1345 wq->iobufs[wqe_idx] = iobuf;
1346
1347 /* Calculate buffer size */
1348 switch ( QIB7322_RECV_PAYLOAD_SIZE ) {
1349 case 2048: bufsize = QIB7322_EAGER_BUFFER_2K; break;
1350 case 4096: bufsize = QIB7322_EAGER_BUFFER_4K; break;
1351 case 8192: bufsize = QIB7322_EAGER_BUFFER_8K; break;
1352 case 16384: bufsize = QIB7322_EAGER_BUFFER_16K; break;
1353 case 32768: bufsize = QIB7322_EAGER_BUFFER_32K; break;
1354 case 65536: bufsize = QIB7322_EAGER_BUFFER_64K; break;
1355 default: build_assert ( 0 );
1357 }
1358
1359 /* Post eager buffer */
1360 memset ( &rcvegr, 0, sizeof ( rcvegr ) );
1361 BIT_FILL_2 ( &rcvegr,
1362 Addr, ( addr >> 11 ),
1363 BufSize, bufsize );
1364 qib7322_writeq_array8b ( qib7322, &rcvegr, qib7322_wq->eager_array,
1365 qib7322_wq->eager_prod );
1366 DBGC2 ( qib7322, "QIB7322 %p QPN %ld RX egr %04x(%04x) posted "
1367 "[%lx,%lx)\n", qib7322, qp->qpn, qib7322_wq->eager_prod,
1368 wqe_idx, addr, ( addr + len ) );
1369
1370 /* Increment producer index */
1371 qib7322_wq->eager_prod = ( ( qib7322_wq->eager_prod + 1 ) &
1372 ( qib7322_wq->eager_entries - 1 ) );
1373
1374 /* Update head index */
1375 memset ( &rcvegrindexhead, 0, sizeof ( rcvegrindexhead ) );
1376 BIT_FILL_1 ( &rcvegrindexhead,
1377 Value, ( ( qib7322_wq->eager_prod + 1 ) &
1378 ( qib7322_wq->eager_entries - 1 ) ) );
1379 qib7322_writeq_array64k ( qib7322, &rcvegrindexhead,
1381
1382 return 0;
1383}
unsigned long physaddr_t
Definition stdint.h:20
uint32_t addr
Buffer address.
Definition dwmac.h:9
uint8_t bufsize
Size of the packet, in bytes.
Definition int13.h:1
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
Definition iobuf.h:180
#define QIB7322_EAGER_BUFFER_ALIGN
Eager buffer required alignment.
Definition qib7322.h:270
@ QIB7322_EAGER_BUFFER_NONE
Definition qib7322.h:274
@ QIB7322_EAGER_BUFFER_16K
Definition qib7322.h:278
@ QIB7322_EAGER_BUFFER_8K
Definition qib7322.h:277
@ QIB7322_EAGER_BUFFER_32K
Definition qib7322.h:279
@ QIB7322_EAGER_BUFFER_2K
Definition qib7322.h:275
@ QIB7322_EAGER_BUFFER_64K
Definition qib7322.h:280
@ QIB7322_EAGER_BUFFER_4K
Definition qib7322.h:276
#define QIB7322_RECV_PAYLOAD_SIZE
RX payload size.
Definition qib7322.h:306

References addr, assert, BIT_FILL_1, BIT_FILL_2, bufsize, build_assert, ctx, io_buffer::data, DBGC, DBGC2, qib7322_recv_work_queue::eager_array, qib7322_recv_work_queue::eager_entries, qib7322_recv_work_queue::eager_prod, EINVAL, ib_get_drvdata(), ib_wq_get_drvdata(), qib7322::ibdev, iob_tailroom(), ib_work_queue::iobufs, len, memset(), NULL, ib_work_queue::num_wqes, qib7322_ctx(), QIB7322_EAGER_BUFFER_16K, QIB7322_EAGER_BUFFER_2K, QIB7322_EAGER_BUFFER_32K, QIB7322_EAGER_BUFFER_4K, QIB7322_EAGER_BUFFER_64K, QIB7322_EAGER_BUFFER_8K, QIB7322_EAGER_BUFFER_ALIGN, QIB7322_EAGER_BUFFER_NONE, QIB7322_RECV_PAYLOAD_SIZE, qib7322_writeq_array64k, qib7322_writeq_array8b, QIB_7322_RcvEgrIndexHead0_offset, qp, and virt_to_bus().

◆ qib7322_complete_recv()

void qib7322_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 1392 of file qib7322.c.

1394 {
1395 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
1396 struct ib_work_queue *wq = &qp->recv;
1397 struct qib7322_recv_work_queue *qib7322_wq = ib_wq_get_drvdata ( wq );
1398 struct QIB_7322_RcvHdrFlags *rcvhdrflags;
1399 struct QIB_7322_RcvEgr rcvegr;
1400 struct io_buffer headers;
1401 struct io_buffer *iobuf;
1402 struct ib_queue_pair *intended_qp;
1403 struct ib_address_vector dest;
1404 struct ib_address_vector source;
1405 unsigned int rcvtype;
1406 unsigned int pktlen;
1407 unsigned int egrindex;
1408 unsigned int useegrbfr;
1409 unsigned int iberr, mkerr, tiderr, khdrerr, mtuerr;
1410 unsigned int lenerr, parityerr, vcrcerr, icrcerr;
1411 unsigned int err;
1412 unsigned int hdrqoffset;
1413 unsigned int header_len;
1414 unsigned int padded_payload_len;
1415 unsigned int wqe_idx;
1416 size_t payload_len;
1417 int qp0;
1418 int rc;
1419
1420 /* RcvHdrFlags are at the end of the header entry */
1421 rcvhdrflags = ( qib7322_wq->header + header_offs +
1422 QIB7322_RECV_HEADER_SIZE - sizeof ( *rcvhdrflags ) );
1423 rcvtype = BIT_GET ( rcvhdrflags, RcvType );
1424 pktlen = ( BIT_GET ( rcvhdrflags, PktLen ) << 2 );
1425 egrindex = BIT_GET ( rcvhdrflags, EgrIndex );
1426 useegrbfr = BIT_GET ( rcvhdrflags, UseEgrBfr );
1427 hdrqoffset = ( BIT_GET ( rcvhdrflags, HdrqOffset ) << 2 );
1428 iberr = BIT_GET ( rcvhdrflags, IBErr );
1429 mkerr = BIT_GET ( rcvhdrflags, MKErr );
1430 tiderr = BIT_GET ( rcvhdrflags, TIDErr );
1431 khdrerr = BIT_GET ( rcvhdrflags, KHdrErr );
1432 mtuerr = BIT_GET ( rcvhdrflags, MTUErr );
1433 lenerr = BIT_GET ( rcvhdrflags, LenErr );
1434 parityerr = BIT_GET ( rcvhdrflags, ParityErr );
1435 vcrcerr = BIT_GET ( rcvhdrflags, VCRCErr );
1436 icrcerr = BIT_GET ( rcvhdrflags, ICRCErr );
1437 header_len = ( QIB7322_RECV_HEADER_SIZE - hdrqoffset -
1438 sizeof ( *rcvhdrflags ) );
1439 padded_payload_len = ( pktlen - header_len - 4 /* ICRC */ );
1440 err = ( iberr | mkerr | tiderr | khdrerr | mtuerr |
1441 lenerr | parityerr | vcrcerr | icrcerr );
1442 /* IB header is placed immediately before RcvHdrFlags */
1443 iob_populate ( &headers, ( ( ( void * ) rcvhdrflags ) - header_len ),
1444 header_len, header_len );
1445
1446 /* Dump diagnostic information */
1447 DBGC2 ( qib7322, "QIB7322 %p QPN %ld RX egr %04x%s hdr %d type %d len "
1448 "%d(%d+%d+4)%s%s%s%s%s%s%s%s%s%s%s\n", qib7322, qp->qpn,
1449 egrindex, ( useegrbfr ? "" : "(unused)" ),
1450 ( header_offs / QIB7322_RECV_HEADER_SIZE ),
1451 rcvtype, pktlen, header_len, padded_payload_len,
1452 ( err ? " [Err" : "" ), ( iberr ? " IB" : "" ),
1453 ( mkerr ? " MK" : "" ), ( tiderr ? " TID" : "" ),
1454 ( khdrerr ? " KHdr" : "" ), ( mtuerr ? " MTU" : "" ),
1455 ( lenerr ? " Len" : "" ), ( parityerr ? " Parity" : ""),
1456 ( vcrcerr ? " VCRC" : "" ), ( icrcerr ? " ICRC" : "" ),
1457 ( err ? "]" : "" ) );
1458 DBGCP_HDA ( qib7322, hdrqoffset, headers.data,
1459 ( header_len + sizeof ( *rcvhdrflags ) ) );
1460
1461 /* Parse header to generate address vector */
1462 qp0 = ( qp->qpn == 0 );
1463 intended_qp = NULL;
1464 if ( ( rc = ib_pull ( ibdev, &headers, ( qp0 ? &intended_qp : NULL ),
1465 &payload_len, &dest, &source ) ) != 0 ) {
1466 DBGC ( qib7322, "QIB7322 %p could not parse headers: %s\n",
1467 qib7322, strerror ( rc ) );
1468 err = 1;
1469 }
1470 if ( ! intended_qp )
1471 intended_qp = qp;
1472
1473 /* Complete this buffer and any skipped buffers. Note that
1474 * when the hardware runs out of buffers, it will repeatedly
1475 * report the same buffer (the tail) as a TID error, and that
1476 * it also has a habit of sometimes skipping over several
1477 * buffers at once.
1478 */
1479 while ( 1 ) {
1480
1481 /* If we have caught up to the producer counter, stop.
1482 * This will happen when the hardware first runs out
1483 * of buffers and starts reporting TID errors against
1484 * the eager buffer it wants to use next.
1485 */
1486 if ( qib7322_wq->eager_cons == qib7322_wq->eager_prod )
1487 break;
1488
1489 /* If we have caught up to where we should be after
1490 * completing this egrindex, stop. We phrase the test
1491 * this way to avoid completing the entire ring when
1492 * we receive the same egrindex twice in a row.
1493 */
1494 if ( ( qib7322_wq->eager_cons ==
1495 ( ( egrindex + 1 ) & ( qib7322_wq->eager_entries - 1 ))))
1496 break;
1497
1498 /* Identify work queue entry and corresponding I/O
1499 * buffer.
1500 */
1501 wqe_idx = ( qib7322_wq->eager_cons & ( wq->num_wqes - 1 ) );
1502 iobuf = wq->iobufs[wqe_idx];
1503 assert ( iobuf != NULL );
1504 wq->iobufs[wqe_idx] = NULL;
1505
1506 /* Complete the eager buffer */
1507 if ( qib7322_wq->eager_cons == egrindex ) {
1508 /* Completing the eager buffer described in
1509 * this header entry.
1510 */
1511 if ( payload_len <= iob_tailroom ( iobuf ) ) {
1512 iob_put ( iobuf, payload_len );
1513 rc = ( err ?
1514 -EIO : ( useegrbfr ? 0 : -ECANCELED ) );
1515 } else {
1516 DBGC ( qib7322, "QIB7322 %p bad payload len "
1517 "%zd\n", qib7322, payload_len );
1518 rc = -EPROTO;
1519 }
1520 /* Redirect to target QP if necessary */
1521 if ( qp != intended_qp ) {
1522 DBGC2 ( qib7322, "QIB7322 %p redirecting QPN "
1523 "%ld => %ld\n",
1524 qib7322, qp->qpn, intended_qp->qpn );
1525 /* Compensate for incorrect fill levels */
1526 qp->recv.fill--;
1527 intended_qp->recv.fill++;
1528 }
1529 ib_complete_recv ( ibdev, intended_qp, &dest, &source,
1530 iobuf, rc );
1531 } else {
1532 /* Completing on a skipped-over eager buffer */
1533 ib_complete_recv ( ibdev, qp, &dest, &source, iobuf,
1534 -ECANCELED );
1535 }
1536
1537 /* Clear eager buffer */
1538 memset ( &rcvegr, 0, sizeof ( rcvegr ) );
1540 qib7322_wq->eager_array,
1541 qib7322_wq->eager_cons );
1542
1543 /* Increment consumer index */
1544 qib7322_wq->eager_cons = ( ( qib7322_wq->eager_cons + 1 ) &
1545 ( qib7322_wq->eager_entries - 1 ) );
1546 }
1547}
#define DBGCP_HDA(...)
Definition compiler.h:540
#define EPROTO
Protocol error.
Definition errno.h:625
#define EIO
Input/output error.
Definition errno.h:434
#define ECANCELED
Operation canceled.
Definition errno.h:344
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
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
#define iob_put(iobuf, len)
Definition iobuf.h:125
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
An Infiniband Address Vector.
Definition infiniband.h:73
An Infiniband Queue Pair.
Definition infiniband.h:158
struct ib_work_queue recv
Receive queue.
Definition infiniband.h:181
unsigned long qpn
Queue pair number.
Definition infiniband.h:166

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

Referenced by qib7322_poll_recv_wq().

◆ qib7322_poll_recv_wq()

void qib7322_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 1555 of file qib7322.c.

1556 {
1557 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
1558 struct ib_work_queue *wq = &qp->recv;
1559 struct qib7322_recv_work_queue *qib7322_wq = ib_wq_get_drvdata ( wq );
1560 struct QIB_7322_RcvHdrHead0 rcvhdrhead;
1561 unsigned int ctx = qib7322_ctx ( ibdev, qp );
1562 unsigned int header_prod;
1563
1564 /* Check for received packets */
1565 header_prod = ( BIT_GET ( &qib7322_wq->header_prod, Value ) << 2 );
1566 if ( header_prod == qib7322_wq->header_cons )
1567 return;
1568
1569 /* Process all received packets */
1570 while ( qib7322_wq->header_cons != header_prod ) {
1571
1572 /* Complete the receive */
1573 qib7322_complete_recv ( ibdev, qp, qib7322_wq->header_cons );
1574
1575 /* Increment the consumer offset */
1578
1579 /* QIB7322 has only one send buffer per port for VL15,
1580 * which almost always leads to send buffer exhaustion
1581 * and dropped MADs. Mitigate this by refusing to
1582 * process more than one VL15 MAD per poll, which will
1583 * enforce interleaved TX/RX polls.
1584 */
1585 if ( qp->type == IB_QPT_SMI )
1586 break;
1587 }
1588
1589 /* Update consumer offset */
1590 memset ( &rcvhdrhead, 0, sizeof ( rcvhdrhead ) );
1591 BIT_FILL_2 ( &rcvhdrhead,
1592 RcvHeadPointer, ( qib7322_wq->header_cons >> 2 ),
1593 counter, 1 );
1594 qib7322_writeq_array64k ( qib7322, &rcvhdrhead,
1596}
static void qib7322_complete_recv(struct ib_device *ibdev, struct ib_queue_pair *qp, unsigned int header_offs)
Complete receive work queue entry.
Definition qib7322.c:1392

References BIT_FILL_2, BIT_GET, ctx, qib7322_recv_work_queue::header_cons, qib7322_recv_work_queue::header_prod, ib_get_drvdata(), IB_QPT_SMI, ib_wq_get_drvdata(), qib7322::ibdev, memset(), qib7322_complete_recv(), qib7322_ctx(), QIB7322_RECV_HEADER_SIZE, QIB7322_RECV_HEADERS_SIZE, qib7322_writeq_array64k, QIB_7322_RcvHdrHead0_offset, and qp.

Referenced by qib7322_poll_cq().

◆ qib7322_poll_cq()

void qib7322_poll_cq ( struct ib_device * ibdev,
struct ib_completion_queue * cq )
static

Poll completion queue.

Parameters
ibdevInfiniband device
cqCompletion queue

Definition at line 1604 of file qib7322.c.

1605 {
1606 struct ib_work_queue *wq;
1607
1608 /* Poll associated send and receive queues */
1610 if ( wq->is_send ) {
1611 qib7322_poll_send_wq ( ibdev, wq->qp );
1612 } else {
1613 qib7322_poll_recv_wq ( ibdev, wq->qp );
1614 }
1615 }
1616}
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition list.h:432
static void qib7322_poll_send_wq(struct ib_device *ibdev, struct ib_queue_pair *qp)
Poll send work queue.
Definition qib7322.c:1280
static void qib7322_poll_recv_wq(struct ib_device *ibdev, struct ib_queue_pair *qp)
Poll receive work queue.
Definition qib7322.c:1555
struct list_head work_queues
List of work queues completing to this queue.
Definition infiniband.h:243
struct ib_completion_queue * cq
Associated completion queue.
Definition infiniband.h:107
struct list_head list
List of work queues on this completion queue.
Definition infiniband.h:109
struct ib_queue_pair * qp
Containing queue pair.
Definition infiniband.h:103
int is_send
"Is a send queue" flag
Definition infiniband.h:105

References ib_work_queue::cq, ib_work_queue::is_send, ib_work_queue::list, list_for_each_entry, qib7322_poll_recv_wq(), qib7322_poll_send_wq(), ib_work_queue::qp, and ib_completion_queue::work_queues.

◆ qib7322_poll_eq()

void qib7322_poll_eq ( struct ib_device * ibdev)
static

Poll event queue.

Parameters
ibdevInfiniband device

Definition at line 1630 of file qib7322.c.

1630 {
1631 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
1632 struct QIB_7322_ErrStatus_0 errstatus;
1633 unsigned int port = ( ibdev->port - QIB7322_PORT_BASE );
1634
1635 /* Check for and clear status bits */
1637 qib7322_readq_port ( qib7322, &errstatus,
1639 if ( errstatus.u.qwords[0] ) {
1640 DBGC ( qib7322, "QIB7322 %p port %d status %08x%08x\n", qib7322,
1641 port, errstatus.u.dwords[1], errstatus.u.dwords[0] );
1642 qib7322_writeq_port ( qib7322, &errstatus,
1644 }
1646
1647 /* Check for link status changes */
1648 if ( BIT_GET ( &errstatus, IBStatusChanged ) )
1650}
#define QIB_7322_ErrStatus_0_offset
#define QIB_7322_ErrClear_0_offset

References BIT_GET, DBG_DISABLE, DBG_ENABLE, DBGC, DBGLVL_IO, ib_get_drvdata(), qib7322::ibdev, ib_device::port, port, qib7322_link_state_changed(), QIB7322_PORT_BASE, qib7322_readq_port, qib7322_writeq_port, QIB_7322_ErrClear_0_offset, and QIB_7322_ErrStatus_0_offset.

◆ qib7322_link_speed_supported()

unsigned int qib7322_link_speed_supported ( struct qib7322 * qib7322,
unsigned int port )
static

Determine supported link speeds.

Parameters
qib7322QIB7322 device
Return values
supportedSupported link speeds

Definition at line 1665 of file qib7322.c.

1666 {
1669 unsigned int supported;
1670 unsigned int boardid;
1671
1672 /* Read the active feature mask */
1675 switch ( port ) {
1676 case 0 :
1677 supported = BIT_GET ( &features, Port0_Link_Speed_Supported );
1678 break;
1679 case 1 :
1680 supported = BIT_GET ( &features, Port1_Link_Speed_Supported );
1681 break;
1682 default:
1683 DBGC ( qib7322, "QIB7322 %p port %d is invalid\n",
1684 qib7322, port );
1685 supported = 0;
1686 break;
1687 }
1688
1689 /* Apply hacks for specific board IDs */
1691 boardid = BIT_GET ( &revision, BoardID );
1692 switch ( boardid ) {
1694 DBGC2 ( qib7322, "QIB7322 %p is a QMH7342; forcing QDR-only\n",
1695 qib7322 );
1697 break;
1698 default:
1699 /* Do nothing */
1700 break;
1701 }
1702
1703 DBGC2 ( qib7322, "QIB7322 %p port %d %s%s%s%s\n", qib7322, port,
1704 ( supported ? "supports" : "disabled" ),
1705 ( ( supported & IB_LINK_SPEED_SDR ) ? " SDR" : "" ),
1706 ( ( supported & IB_LINK_SPEED_DDR ) ? " DDR" : "" ),
1707 ( ( supported & IB_LINK_SPEED_QDR ) ? " QDR" : "" ) );
1708 return supported;
1709}
uint32_t features
Supported features.
Definition ena.h:5
uint16_t supported
Bitmask of supported option values.
Definition ena.h:1
#define IB_LINK_SPEED_QDR
Definition ib_mad.h:147
uint32_t revision
Entry point revision.
Definition ib_mad.h:9
@ QIB7322_BOARD_QMH7342
Definition qib7322.h:182
#define QIB_7322_Revision_offset
#define QIB_7322_active_feature_mask_offset

References BIT_GET, DBGC, DBGC2, features, IB_LINK_SPEED_DDR, IB_LINK_SPEED_QDR, IB_LINK_SPEED_SDR, port, QIB7322_BOARD_QMH7342, qib7322_readq, QIB_7322_active_feature_mask_offset, QIB_7322_Revision_offset, revision, and supported.

Referenced by qib7322_probe().

◆ qib7322_open()

int qib7322_open ( struct ib_device * ibdev)
static

Initialise Infiniband link.

Parameters
ibdevInfiniband device
Return values
rcReturn status code

Definition at line 1717 of file qib7322.c.

1717 {
1718 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
1719 struct QIB_7322_IBCCtrlA_0 ibcctrla;
1720 unsigned int port = ( ibdev->port - QIB7322_PORT_BASE );
1721
1722 /* Enable link */
1723 qib7322_readq_port ( qib7322, &ibcctrla,
1725 BIT_SET ( &ibcctrla, IBLinkEn, 1 );
1726 qib7322_writeq_port ( qib7322, &ibcctrla,
1728
1729 return 0;
1730}

References BIT_SET, ib_get_drvdata(), qib7322::ibdev, ib_device::port, port, QIB7322_PORT_BASE, qib7322_readq_port, qib7322_writeq_port, and QIB_7322_IBCCtrlA_0_offset.

◆ qib7322_close()

void qib7322_close ( struct ib_device * ibdev)
static

Close Infiniband link.

Parameters
ibdevInfiniband device

Definition at line 1737 of file qib7322.c.

1737 {
1738 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
1739 struct QIB_7322_IBCCtrlA_0 ibcctrla;
1740 unsigned int port = ( ibdev->port - QIB7322_PORT_BASE );
1741
1742 /* Disable link */
1743 qib7322_readq_port ( qib7322, &ibcctrla,
1745 BIT_SET ( &ibcctrla, IBLinkEn, 0 );
1746 qib7322_writeq_port ( qib7322, &ibcctrla,
1748}

References BIT_SET, ib_get_drvdata(), qib7322::ibdev, ib_device::port, port, QIB7322_PORT_BASE, qib7322_readq_port, qib7322_writeq_port, and QIB_7322_IBCCtrlA_0_offset.

◆ qib7322_mcast_attach()

int qib7322_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 1765 of file qib7322.c.

1767 {
1768 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
1769
1770 ( void ) qib7322;
1771 ( void ) qp;
1772 ( void ) gid;
1773 return 0;
1774}
u8 gid[16]
Definition CIB_PRM.h:3

References gid, ib_get_drvdata(), qib7322::ibdev, and qp.

◆ qib7322_mcast_detach()

void qib7322_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 1783 of file qib7322.c.

1785 {
1786 struct qib7322 *qib7322 = ib_get_drvdata ( ibdev );
1787
1788 ( void ) qib7322;
1789 ( void ) qp;
1790 ( void ) gid;
1791 }

References gid, ib_get_drvdata(), qib7322::ibdev, and qp.

◆ qib7322_i2c_read_bit()

int qib7322_i2c_read_bit ( struct bit_basher * basher,
unsigned int bit_id )
static

Read QIB7322 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 1833 of file qib7322.c.

1834 {
1835 struct qib7322 *qib7322 =
1836 container_of ( basher, struct qib7322, i2c.basher );
1837 struct QIB_7322_EXTStatus extstatus;
1838 unsigned int status;
1839
1841
1843 status = ( BIT_GET ( &extstatus, GPIOIn ) & qib7322_i2c_bits[bit_id] );
1844
1846
1847 return status;
1848}
uint8_t status
Status.
Definition ena.h:5
static unsigned int qib7322_i2c_bits[]
QIB7322 I2C bit to GPIO mappings.
Definition qib7322.c:1820
#define QIB_7322_EXTStatus_offset
#define container_of(ptr, type, field)
Get containing structure.
Definition stddef.h:36
struct bit_basher basher
Bit-bashing interface.
Definition i2c.h:95
struct i2c_bit_basher i2c
I2C bit-bashing interface.
Definition qib7322.c:122

References i2c_bit_basher::basher, BIT_GET, container_of, DBG_DISABLE, DBG_ENABLE, DBGLVL_IO, qib7322::i2c, qib7322_i2c_bits, qib7322_readq, QIB_7322_EXTStatus_offset, and status.

◆ qib7322_i2c_write_bit()

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

Write QIB7322 I2C line status.

Parameters
basherBit-bashing interface
bit_idBit number
dataValue to write

Definition at line 1857 of file qib7322.c.

1858 {
1859 struct qib7322 *qib7322 =
1860 container_of ( basher, struct qib7322, i2c.basher );
1861 struct QIB_7322_EXTCtrl extctrl;
1862 struct QIB_7322_GPIO gpioout;
1863 unsigned int bit = qib7322_i2c_bits[bit_id];
1864 unsigned int outputs = 0;
1865 unsigned int output_enables = 0;
1866
1868
1869 /* Read current GPIO mask and outputs */
1872
1873 /* Update outputs and output enables. I2C lines are tied
1874 * high, so we always set the output to 0 and use the output
1875 * enable to control the line.
1876 */
1877 output_enables = BIT_GET ( &extctrl, GPIOOe );
1878 output_enables = ( ( output_enables & ~bit ) | ( ~data & bit ) );
1879 outputs = BIT_GET ( &gpioout, GPIO );
1880 outputs = ( outputs & ~bit );
1881 BIT_SET ( &extctrl, GPIOOe, output_enables );
1882 BIT_SET ( &gpioout, GPIO, outputs );
1883
1884 /* Write the output enable first; that way we avoid logic
1885 * hazards.
1886 */
1889 mb();
1890
1892}
static unsigned int unsigned int bit
Definition bigint.h:392
#define QIB_7322_GPIOOut_offset

References i2c_bit_basher::basher, bit, BIT_GET, BIT_SET, container_of, data, DBG_DISABLE, DBG_ENABLE, DBGLVL_IO, qib7322::i2c, mb(), qib7322_i2c_bits, qib7322_readq, qib7322_writeq, QIB_7322_EXTCtrl_offset, and QIB_7322_GPIOOut_offset.

◆ qib7322_init_i2c()

int qib7322_init_i2c ( struct qib7322 * qib7322)
static

Initialise QIB7322 I2C subsystem.

Parameters
qib7322QIB7322 device
Return values
rcReturn status code

Definition at line 1906 of file qib7322.c.

1906 {
1907 static int try_eeprom_address[] = { 0x51, 0x50 };
1908 unsigned int i;
1909 int rc;
1910
1911 /* Initialise bus */
1912 if ( ( rc = init_i2c_bit_basher ( &qib7322->i2c,
1913 &qib7322_i2c_basher_ops ) ) != 0 ) {
1914 DBGC ( qib7322, "QIB7322 %p could not initialise I2C bus: %s\n",
1915 qib7322, strerror ( rc ) );
1916 return rc;
1917 }
1918
1919 /* Probe for devices */
1920 for ( i = 0 ; i < ( sizeof ( try_eeprom_address ) /
1921 sizeof ( try_eeprom_address[0] ) ) ; i++ ) {
1922 init_i2c_eeprom ( &qib7322->eeprom, try_eeprom_address[i] );
1923 if ( ( rc = i2c_check_presence ( &qib7322->i2c.i2c,
1924 &qib7322->eeprom ) ) == 0 ) {
1925 DBGC2 ( qib7322, "QIB7322 %p found EEPROM at %02x\n",
1926 qib7322, try_eeprom_address[i] );
1927 return 0;
1928 }
1929 }
1930
1931 DBGC ( qib7322, "QIB7322 %p could not find EEPROM\n", qib7322 );
1932 return -ENODEV;
1933}
#define ENODEV
No such device.
Definition errno.h:510
static int i2c_check_presence(struct i2c_interface *i2c, struct i2c_device *i2cdev)
Check presence of I2C device.
Definition i2c.h:135
static __always_inline void init_i2c_eeprom(struct i2c_device *i2cdev, unsigned int dev_addr)
Initialise generic I2C EEPROM device.
Definition i2c.h:149
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
static struct bit_basher_operations qib7322_i2c_basher_ops
QIB7322 I2C bit-bashing interface operations.
Definition qib7322.c:1895
struct i2c_interface i2c
I2C interface.
Definition i2c.h:93
struct i2c_device eeprom
I2C serial EEPROM.
Definition qib7322.c:124

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

Referenced by qib7322_probe().

◆ qib7322_read_eeprom()

int qib7322_read_eeprom ( struct qib7322 * qib7322)
static

Read EEPROM parameters.

Parameters
qib7322QIB7322 device
Return values
rcReturn status code

Definition at line 1941 of file qib7322.c.

1941 {
1942 struct i2c_interface *i2c = &qib7322->i2c.i2c;
1943 union ib_guid *guid = &qib7322->guid;
1944 int rc;
1945
1946 /* Read GUID */
1947 if ( ( rc = i2c->read ( i2c, &qib7322->eeprom,
1949 sizeof ( *guid ) ) ) != 0 ) {
1950 DBGC ( qib7322, "QIB7322 %p could not read GUID: %s\n",
1951 qib7322, strerror ( rc ) );
1952 return rc;
1953 }
1954 DBGC2 ( qib7322, "QIB7322 %p has GUID " IB_GUID_FMT "\n",
1955 qib7322, IB_GUID_ARGS ( guid ) );
1956
1957 /* Read serial number (debug only) */
1958 if ( DBG_LOG ) {
1960
1961 serial[ sizeof ( serial ) - 1 ] = '\0';
1962 if ( ( rc = i2c->read ( i2c, &qib7322->eeprom,
1964 ( sizeof ( serial ) - 1 ) ) ) != 0 ) {
1965 DBGC ( qib7322, "QIB7322 %p could not read serial: "
1966 "%s\n", qib7322, strerror ( rc ) );
1967 return rc;
1968 }
1969 DBGC2 ( qib7322, "QIB7322 %p has serial number \"%s\"\n",
1970 qib7322, serial );
1971 }
1972
1973 return 0;
1974}
uint64_t serial
Serial number.
Definition edd.h:1
uint64_t guid
GUID.
Definition edd.h:1
#define DBG_LOG
Definition compiler.h:317
#define IB_GUID_FMT
Infiniband Globally Unique Identifier debug message format.
Definition ib_packet.h:27
#define IB_GUID_ARGS(guid)
Infiniband Globally Unique Identifier debug message arguments.
Definition ib_packet.h:30
#define QIB7322_EEPROM_SERIAL_SIZE
Board serial number size within EEPROM.
Definition qib7322.h:202
#define QIB7322_EEPROM_SERIAL_OFFSET
Board serial number offset within EEPROM.
Definition qib7322.h:199
#define QIB7322_EEPROM_GUID_OFFSET
GUID offset within EEPROM.
Definition qib7322.h:193
An I2C interface.
Definition i2c.h:57
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
union ib_guid guid
Base GUID.
Definition qib7322.c:127
An Infiniband Globally Unique Identifier.
Definition ib_packet.h:19

References DBG_LOG, DBGC, DBGC2, qib7322::eeprom, guid, qib7322::guid, i2c_bit_basher::i2c, qib7322::i2c, IB_GUID_ARGS, IB_GUID_FMT, QIB7322_EEPROM_GUID_OFFSET, QIB7322_EEPROM_SERIAL_OFFSET, QIB7322_EEPROM_SERIAL_SIZE, rc, i2c_interface::read, serial, and strerror().

Referenced by qib7322_probe().

◆ qib7322_ahb_wait()

int qib7322_ahb_wait ( struct qib7322 * qib7322)
static

Wait for AHB transaction to complete.

Parameters
qib7322QIB7322 device
Return values
rcReturn status code

Definition at line 1989 of file qib7322.c.

1989 {
1990 struct QIB_7322_ahb_transaction_reg transaction;
1991 unsigned int i;
1992
1993 /* Wait for Ready bit to be asserted */
1994 for ( i = 0 ; i < QIB7322_AHB_MAX_WAIT_US ; i++ ) {
1995 qib7322_readq ( qib7322, &transaction,
1997 if ( BIT_GET ( &transaction, ahb_rdy ) )
1998 return 0;
1999 udelay ( 1 );
2000 }
2001
2002 DBGC ( qib7322, "QIB7322 %p timed out waiting for AHB transaction\n",
2003 qib7322 );
2004 return -ETIMEDOUT;
2005}
#define QIB7322_AHB_MAX_WAIT_US
Maximum time for wait for AHB, in us.
Definition qib7322.h:337
#define QIB_7322_ahb_transaction_reg_offset

References BIT_GET, DBGC, ETIMEDOUT, QIB7322_AHB_MAX_WAIT_US, qib7322_readq, QIB_7322_ahb_transaction_reg_offset, and udelay().

Referenced by qib7322_ahb_read(), qib7322_ahb_request(), and qib7322_ahb_write().

◆ qib7322_ahb_request()

int qib7322_ahb_request ( struct qib7322 * qib7322,
unsigned int location )
static

Request ownership of the AHB.

Parameters
qib7322QIB7322 device
locationAHB location
Return values
rcReturn status code

Definition at line 2014 of file qib7322.c.

2015 {
2016 struct QIB_7322_ahb_access_ctrl access;
2017 int rc;
2018
2019 /* Request ownership */
2020 memset ( &access, 0, sizeof ( access ) );
2021 BIT_FILL_2 ( &access,
2022 sw_ahb_sel, 1,
2023 sw_sel_ahb_trgt, QIB7322_AHB_LOC_TARGET ( location ) );
2025
2026 /* Wait for ownership to be granted */
2027 if ( ( rc = qib7322_ahb_wait ( qib7322 ) ) != 0 ) {
2028 DBGC ( qib7322, "QIB7322 %p could not obtain AHB ownership: "
2029 "%s\n", qib7322, strerror ( rc ) );
2030 return rc;
2031 }
2032
2033 return 0;
2034}
static int qib7322_ahb_wait(struct qib7322 *qib7322)
Wait for AHB transaction to complete.
Definition qib7322.c:1989
#define QIB7322_AHB_LOC_TARGET(_location)
Definition qib7322.h:341
#define QIB_7322_ahb_access_ctrl_offset

References BIT_FILL_2, DBGC, memset(), QIB7322_AHB_LOC_TARGET, qib7322_ahb_wait(), qib7322_writeq, QIB_7322_ahb_access_ctrl_offset, rc, and strerror().

Referenced by qib7322_ahb_mod_reg().

◆ qib7322_ahb_release()

void qib7322_ahb_release ( struct qib7322 * qib7322)
static

Release ownership of the AHB.

Parameters
qib7322QIB7322 device

Definition at line 2041 of file qib7322.c.

2041 {
2042 struct QIB_7322_ahb_access_ctrl access;
2043
2044 memset ( &access, 0, sizeof ( access ) );
2046}

References memset(), qib7322_writeq, and QIB_7322_ahb_access_ctrl_offset.

Referenced by qib7322_ahb_mod_reg().

◆ qib7322_ahb_read()

int qib7322_ahb_read ( struct qib7322 * qib7322,
unsigned int location,
uint32_t * data )
static

Read data via AHB.

Parameters
qib7322QIB7322 device
locationAHB location
dataData to read
Return values
rcReturn status code

You must have already acquired ownership of the AHB.

Definition at line 2058 of file qib7322.c.

2059 {
2061 int rc;
2062
2063 /* Avoid returning uninitialised data on error */
2064 *data = 0;
2065
2066 /* Initiate transaction */
2067 memset ( &xact, 0, sizeof ( xact ) );
2068 BIT_FILL_2 ( &xact,
2069 ahb_address, QIB7322_AHB_LOC_ADDRESS ( location ),
2070 write_not_read, 0 );
2072
2073 /* Wait for transaction to complete */
2074 if ( ( rc = qib7322_ahb_wait ( qib7322 ) ) != 0 )
2075 return rc;
2076
2077 /* Read transaction data */
2079 *data = BIT_GET ( &xact, ahb_data );
2080 return 0;
2081}
uint32_t xact
Requester transaction ID.
Definition eth_slow.h:7
#define QIB7322_AHB_LOC_ADDRESS(_location)
QIB7322 AHB locations.
Definition qib7322.h:340

References BIT_FILL_2, BIT_GET, data, memset(), QIB7322_AHB_LOC_ADDRESS, qib7322_ahb_wait(), qib7322_readq, qib7322_writeq, QIB_7322_ahb_transaction_reg_offset, rc, and xact.

Referenced by qib7322_ahb_mod_reg().

◆ qib7322_ahb_write()

int qib7322_ahb_write ( struct qib7322 * qib7322,
unsigned int location,
uint32_t data )
static

Write data via AHB.

Parameters
qib7322QIB7322 device
locationAHB location
dataData to write
Return values
rcReturn status code

You must have already acquired ownership of the AHB.

Definition at line 2093 of file qib7322.c.

2094 {
2096 int rc;
2097
2098 /* Initiate transaction */
2099 memset ( &xact, 0, sizeof ( xact ) );
2100 BIT_FILL_3 ( &xact,
2101 ahb_address, QIB7322_AHB_LOC_ADDRESS ( location ),
2102 write_not_read, 1,
2103 ahb_data, data );
2105
2106 /* Wait for transaction to complete */
2107 if ( ( rc = qib7322_ahb_wait ( qib7322 ) ) != 0 )
2108 return rc;
2109
2110 return 0;
2111}

References BIT_FILL_3, data, memset(), QIB7322_AHB_LOC_ADDRESS, qib7322_ahb_wait(), qib7322_writeq, QIB_7322_ahb_transaction_reg_offset, rc, and xact.

Referenced by qib7322_ahb_mod_reg().

◆ qib7322_ahb_mod_reg()

int qib7322_ahb_mod_reg ( struct qib7322 * qib7322,
unsigned int location,
uint32_t value,
uint32_t mask )
static

Read/modify/write AHB register.

Parameters
qib7322QIB7322 device
locationAHB location
valueValue to set
maskMask to apply to old value
Return values
rcReturn status code

Definition at line 2122 of file qib7322.c.

2123 {
2124 uint32_t old_value;
2125 uint32_t new_value;
2126 int rc;
2127
2129
2130 /* Sanity check */
2131 assert ( ( value & mask ) == value );
2132
2133 /* Acquire bus ownership */
2134 if ( ( rc = qib7322_ahb_request ( qib7322, location ) ) != 0 )
2135 goto out;
2136
2137 /* Read existing value */
2138 if ( ( rc = qib7322_ahb_read ( qib7322, location, &old_value ) ) != 0 )
2139 goto out_release;
2140
2141 /* Update value */
2142 new_value = ( ( old_value & ~mask ) | value );
2143 DBGCP ( qib7322, "QIB7322 %p AHB %x %#08x => %#08x\n",
2144 qib7322, location, old_value, new_value );
2145 if ( ( rc = qib7322_ahb_write ( qib7322, location, new_value ) ) != 0 )
2146 goto out_release;
2147
2148 out_release:
2149 /* Release bus */
2151 out:
2153 return rc;
2154}
__be32 out[4]
Definition CIB_PRM.h:8
pseudo_bit_t value[0x00020]
Definition arbel.h:2
#define DBGCP(...)
Definition compiler.h:539
static int qib7322_ahb_write(struct qib7322 *qib7322, unsigned int location, uint32_t data)
Write data via AHB.
Definition qib7322.c:2093
static void qib7322_ahb_release(struct qib7322 *qib7322)
Release ownership of the AHB.
Definition qib7322.c:2041
static int qib7322_ahb_request(struct qib7322 *qib7322, unsigned int location)
Request ownership of the AHB.
Definition qib7322.c:2014
static int qib7322_ahb_read(struct qib7322 *qib7322, unsigned int location, uint32_t *data)
Read data via AHB.
Definition qib7322.c:2058

References assert, DBG_DISABLE, DBG_ENABLE, DBGCP, DBGLVL_IO, out, qib7322_ahb_read(), qib7322_ahb_release(), qib7322_ahb_request(), qib7322_ahb_write(), rc, and value.

Referenced by qib7322_ahb_mod_reg_all().

◆ qib7322_ahb_mod_reg_all()

int qib7322_ahb_mod_reg_all ( struct qib7322 * qib7322,
unsigned int reg,
uint32_t value,
uint32_t mask )
static

Read/modify/write AHB register across all ports and channels.

Parameters
qib7322QIB7322 device
regAHB register
valueValue to set
maskMask to apply to old value
Return values
rcReturn status code

Definition at line 2165 of file qib7322.c.

2166 {
2167 unsigned int port;
2168 unsigned int channel;
2169 unsigned int location;
2170 int rc;
2171
2172 for ( port = 0 ; port < QIB7322_MAX_PORTS ; port++ ) {
2173 for ( channel = 0 ; channel < QIB7322_MAX_WIDTH ; channel++ ) {
2174 location = QIB7322_AHB_LOCATION ( port, channel, reg );
2175 if ( ( rc = qib7322_ahb_mod_reg ( qib7322, location,
2176 value, mask ) ) != 0 )
2177 return rc;
2178 }
2179 }
2180 return 0;
2181}
static unsigned int unsigned int reg
Definition myson.h:162
uint32_t channel
RNDIS channel.
Definition netvsc.h:3
static int qib7322_ahb_mod_reg(struct qib7322 *qib7322, unsigned int location, uint32_t value, uint32_t mask)
Read/modify/write AHB register.
Definition qib7322.c:2122
#define QIB7322_AHB_LOCATION(_port, _channel, _register)
Definition qib7322.h:352
#define QIB7322_MAX_WIDTH
QIB7322 maximum width.
Definition qib7322.h:172

References channel, port, QIB7322_AHB_LOCATION, qib7322_ahb_mod_reg(), QIB7322_MAX_PORTS, QIB7322_MAX_WIDTH, rc, reg, and value.

Referenced by qib7322_init_ib_serdes().

◆ qib7322_init_ib_serdes()

int qib7322_init_ib_serdes ( struct qib7322 * qib7322)
static

Initialise the IB SerDes.

Parameters
qib7322QIB7322 device
Return values
rcReturn status code

Definition at line 2196 of file qib7322.c.

2196 {
2197 struct QIB_7322_IBCCtrlA_0 ibcctrla;
2198 struct QIB_7322_IBCCtrlB_0 ibcctrlb;
2199 struct QIB_7322_IBPCSConfig_0 ibpcsconfig;
2200
2201 /* Configure sensible defaults for IBC */
2202 memset ( &ibcctrla, 0, sizeof ( ibcctrla ) );
2203 BIT_FILL_5 ( &ibcctrla, /* Tuning values taken from Linux driver */
2204 FlowCtrlPeriod, 0x03,
2205 FlowCtrlWaterMark, 0x05,
2206 MaxPktLen, ( ( QIB7322_RECV_HEADER_SIZE +
2208 4 /* ICRC */ ) >> 2 ),
2209 PhyerrThreshold, 0xf,
2210 OverrunThreshold, 0xf );
2213
2214 /* Force SDR only to avoid needing all the DDR tuning,
2215 * Mellanox compatibility hacks etc. SDR is plenty for
2216 * boot-time operation.
2217 */
2219 BIT_SET ( &ibcctrlb, IB_ENHANCED_MODE, 0 );
2220 BIT_SET ( &ibcctrlb, SD_SPEED_SDR, 1 );
2221 BIT_SET ( &ibcctrlb, SD_SPEED_DDR, 0 );
2222 BIT_SET ( &ibcctrlb, SD_SPEED_QDR, 0 );
2223 BIT_SET ( &ibcctrlb, IB_NUM_CHANNELS, 1 ); /* 4X only */
2224 BIT_SET ( &ibcctrlb, IB_LANE_REV_SUPPORTED, 0 );
2225 BIT_SET ( &ibcctrlb, HRTBT_ENB, 0 );
2226 BIT_SET ( &ibcctrlb, HRTBT_AUTO, 0 );
2229
2230 /* Tune SerDes */
2231 qib7322_ahb_mod_reg_all ( qib7322, 2, 0, 0x00000e00UL );
2232
2233 /* Bring XGXS out of reset */
2234 memset ( &ibpcsconfig, 0, sizeof ( ibpcsconfig ) );
2237
2238 return 0;
2239}
#define BIT_FILL_5(_ptr, _field1,...)
Definition pseudobit.h:205
static int qib7322_ahb_mod_reg_all(struct qib7322 *qib7322, unsigned int reg, uint32_t value, uint32_t mask)
Read/modify/write AHB register across all ports and channels.
Definition qib7322.c:2165
#define QIB_7322_IBCCtrlB_1_offset
#define QIB_7322_IBPCSConfig_1_offset
#define QIB_7322_IBCCtrlB_0_offset
#define QIB_7322_IBPCSConfig_0_offset
#define QIB_7322_IBCCtrlA_1_offset

References BIT_FILL_5, BIT_SET, memset(), qib7322_ahb_mod_reg_all(), qib7322_readq, QIB7322_RECV_HEADER_SIZE, QIB7322_RECV_PAYLOAD_SIZE, qib7322_writeq, QIB_7322_IBCCtrlA_0_offset, QIB_7322_IBCCtrlA_1_offset, QIB_7322_IBCCtrlB_0_offset, QIB_7322_IBCCtrlB_1_offset, QIB_7322_IBPCSConfig_0_offset, and QIB_7322_IBPCSConfig_1_offset.

Referenced by qib7322_probe().

◆ qib7322_reset()

void qib7322_reset ( struct qib7322 * qib7322,
struct pci_device * pci )
static

Reset QIB7322.

Parameters
qib7322QIB7322 device
pciPCI device
Return values
rcReturn status code

Definition at line 2255 of file qib7322.c.

2255 {
2257 struct pci_config_backup backup;
2258
2259 /* Back up PCI configuration space */
2260 pci_backup ( pci, &backup, PCI_CONFIG_BACKUP_ALL, NULL );
2261
2262 /* Assert reset */
2263 memset ( &control, 0, sizeof ( control ) );
2264 BIT_FILL_1 ( &control, SyncReset, 1 );
2266
2267 /* Wait for reset to complete */
2268 mdelay ( 1000 );
2269
2270 /* Restore PCI configuration space */
2271 pci_restore ( pci, &backup, PCI_CONFIG_BACKUP_ALL, NULL );
2272}
uint32_t control
Control.
Definition myson.h:3
void pci_restore(struct pci_device *pci, struct pci_config_backup *backup, unsigned int limit, const uint8_t *exclude)
Restore PCI configuration space.
Definition pcibackup.c:88
void pci_backup(struct pci_device *pci, struct pci_config_backup *backup, unsigned int limit, const uint8_t *exclude)
Back up PCI configuration space.
Definition pcibackup.c:68
#define PCI_CONFIG_BACKUP_ALL
Limit of PCI configuration space.
Definition pcibackup.h:16
#define QIB_7322_Control_offset
A PCI configuration space backup.
Definition pcibackup.h:22
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition timer.c:79

References BIT_FILL_1, control, mdelay(), memset(), NULL, pci_backup(), PCI_CONFIG_BACKUP_ALL, pci_restore(), qib7322_writeq, and QIB_7322_Control_offset.

Referenced by qib7322_probe().

◆ qib7322_probe()

int qib7322_probe ( struct pci_device * pci)
static

Probe PCI device.

Parameters
pciPCI device
idPCI ID
Return values
rcReturn status code

Definition at line 2281 of file qib7322.c.

2281 {
2282 struct qib7322 *qib7322;
2284 struct ib_device *ibdev;
2285 unsigned int link_speed_supported;
2286 int i;
2287 int rc;
2288
2289 /* Allocate QIB7322 device */
2290 qib7322 = zalloc ( sizeof ( *qib7322 ) );
2291 if ( ! qib7322 ) {
2292 rc = -ENOMEM;
2293 goto err_alloc_qib7322;
2294 }
2295 pci_set_drvdata ( pci, qib7322 );
2296
2297 /* Fix up PCI device */
2298 adjust_pci_device ( pci );
2299
2300 /* Map PCI BARs */
2302 DBGC2 ( qib7322, "QIB7322 %p has BAR at %08lx\n",
2303 qib7322, pci->membase );
2304
2305 /* Reset device */
2306 qib7322_reset ( qib7322, pci );
2307
2308 /* Print some general data */
2310 DBGC2 ( qib7322, "QIB7322 %p board %02lx v%ld.%ld.%ld.%ld\n", qib7322,
2311 BIT_GET ( &revision, BoardID ),
2312 BIT_GET ( &revision, R_SW ),
2313 BIT_GET ( &revision, R_Arch ),
2314 BIT_GET ( &revision, R_ChipRevMajor ),
2315 BIT_GET ( &revision, R_ChipRevMinor ) );
2316
2317 /* Initialise I2C subsystem */
2318 if ( ( rc = qib7322_init_i2c ( qib7322 ) ) != 0 )
2319 goto err_init_i2c;
2320
2321 /* Read EEPROM parameters */
2322 if ( ( rc = qib7322_read_eeprom ( qib7322 ) ) != 0 )
2323 goto err_read_eeprom;
2324
2325 /* Initialise send datapath */
2326 if ( ( rc = qib7322_init_send ( qib7322 ) ) != 0 )
2327 goto err_init_send;
2328
2329 /* Initialise receive datapath */
2330 if ( ( rc = qib7322_init_recv ( qib7322 ) ) != 0 )
2331 goto err_init_recv;
2332
2333 /* Initialise the IB SerDes */
2334 if ( ( rc = qib7322_init_ib_serdes ( qib7322 ) ) != 0 )
2335 goto err_init_ib_serdes;
2336
2337 /* Allocate Infiniband devices */
2338 for ( i = 0 ; i < QIB7322_MAX_PORTS ; i++ ) {
2341 if ( ! link_speed_supported )
2342 continue;
2343 ibdev = alloc_ibdev ( 0 );
2344 if ( ! ibdev ) {
2345 rc = -ENOMEM;
2346 goto err_alloc_ibdev;
2347 }
2348 qib7322->ibdev[i] = ibdev;
2349 ibdev->dev = &pci->dev;
2350 ibdev->op = &qib7322_ib_operations;
2351 ibdev->port = ( QIB7322_PORT_BASE + i );
2352 ibdev->ports = QIB7322_MAX_PORTS;
2354 IB_LINK_WIDTH_4X; /* 1x does not work */
2356 IB_LINK_SPEED_SDR; /* to avoid need for link tuning */
2357 memcpy ( &ibdev->node_guid, &qib7322->guid,
2358 sizeof ( ibdev->node_guid ) );
2359 memcpy ( &ibdev->gid.s.guid, &qib7322->guid,
2360 sizeof ( ibdev->gid.s.guid ) );
2361 assert ( ( ibdev->gid.s.guid.bytes[7] & i ) == 0 );
2362 ibdev->gid.s.guid.bytes[7] |= i;
2363 ib_set_drvdata ( ibdev, qib7322 );
2364 }
2365
2366 /* Register Infiniband devices */
2367 for ( i = 0 ; i < QIB7322_MAX_PORTS ; i++ ) {
2368 if ( ! qib7322->ibdev[i] )
2369 continue;
2370 if ( ( rc = register_ibdev ( qib7322->ibdev[i] ) ) != 0 ) {
2371 DBGC ( qib7322, "QIB7322 %p port %d could not register "
2372 "IB device: %s\n", qib7322, i, strerror ( rc ) );
2373 goto err_register_ibdev;
2374 }
2375 }
2376
2377 return 0;
2378
2380 err_register_ibdev:
2381 for ( i-- ; i >= 0 ; i-- ) {
2382 if ( qib7322->ibdev[i] )
2384 }
2386 err_alloc_ibdev:
2387 for ( i-- ; i >= 0 ; i-- )
2388 ibdev_put ( qib7322->ibdev[i] );
2389 err_init_ib_serdes:
2391 err_init_send:
2393 err_init_recv:
2394 err_read_eeprom:
2395 err_init_i2c:
2396 iounmap ( qib7322->regs );
2397 free ( qib7322 );
2398 err_alloc_qib7322:
2399 return rc;
2400}
void iounmap(volatile const void *io_addr)
Unmap I/O address.
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
int register_ibdev(struct ib_device *ibdev)
Register Infiniband device.
Definition infiniband.c:944
void unregister_ibdev(struct ib_device *ibdev)
Unregister Infiniband device.
Definition infiniband.c:985
struct ib_device * alloc_ibdev(size_t priv_size)
Allocate Infiniband device.
Definition infiniband.c:917
static __always_inline void ib_set_drvdata(struct ib_device *ibdev, void *priv)
Set Infiniband device driver-private data.
Definition infiniband.h:698
static __always_inline void ibdev_put(struct ib_device *ibdev)
Drop reference to Infiniband device.
Definition infiniband.h:599
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition pci.c:241
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition pci.h:366
static int qib7322_read_eeprom(struct qib7322 *qib7322)
Read EEPROM parameters.
Definition qib7322.c:1941
static int qib7322_init_i2c(struct qib7322 *qib7322)
Initialise QIB7322 I2C subsystem.
Definition qib7322.c:1906
static int qib7322_init_ib_serdes(struct qib7322 *qib7322)
Initialise the IB SerDes.
Definition qib7322.c:2196
static int qib7322_init_recv(struct qib7322 *qib7322)
Initialise receive datapath.
Definition qib7322.c:859
static void qib7322_fini_send(struct qib7322 *qib7322)
Shut down send datapath.
Definition qib7322.c:717
static int qib7322_init_send(struct qib7322 *qib7322)
Initialise send datapath.
Definition qib7322.c:624
static unsigned int qib7322_link_speed_supported(struct qib7322 *qib7322, unsigned int port)
Determine supported link speeds.
Definition qib7322.c:1665
static void qib7322_reset(struct qib7322 *qib7322, struct pci_device *pci)
Reset QIB7322.
Definition qib7322.c:2255
static struct ib_device_operations qib7322_ib_operations
QIB7322 Infiniband operations.
Definition qib7322.c:1794
static void qib7322_fini_recv(struct qib7322 *qib7322 __unused)
Shut down receive datapath.
Definition qib7322.c:1019
#define QIB7322_BAR0_SIZE
QIB7322 memory BAR size.
Definition qib7322.h:163
An Infiniband device.
Definition infiniband.h:399
uint8_t link_width_enabled
Link width enabled.
Definition infiniband.h:430
unsigned int ports
Total ports on device.
Definition infiniband.h:421
uint8_t link_speed_supported
Link speed supported.
Definition infiniband.h:434
struct ib_device_operations * op
Infiniband operations.
Definition infiniband.h:417
union ib_guid node_guid
Node GUID.
Definition infiniband.h:440
struct device * dev
Underlying device.
Definition infiniband.h:411
uint8_t link_speed_enabled
Link speed enabled.
Definition infiniband.h:436
uint8_t link_width_supported
Link width supported.
Definition infiniband.h:428
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition infiniband.h:442
unsigned long membase
Memory base.
Definition pci.h:220
struct device dev
Generic device.
Definition pci.h:213
struct ib_gid::@251011351113275240012301235177256303262052134237 s
union ib_guid guid
Definition ib_packet.h:41
uint8_t bytes[8]
Definition ib_packet.h:20

References adjust_pci_device(), alloc_ibdev(), assert, BIT_GET, ib_guid::bytes, DBGC, DBGC2, ib_device::dev, pci_device::dev, ENOMEM, free, ib_device::gid, ib_gid::guid, qib7322::guid, IB_LINK_SPEED_SDR, IB_LINK_WIDTH_4X, ib_set_drvdata(), qib7322::ibdev, ibdev_put(), iounmap(), 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, QIB7322_BAR0_SIZE, qib7322_fini_recv(), qib7322_fini_send(), qib7322_ib_operations, qib7322_init_i2c(), qib7322_init_ib_serdes(), qib7322_init_recv(), qib7322_init_send(), qib7322_link_speed_supported(), QIB7322_MAX_PORTS, QIB7322_PORT_BASE, qib7322_read_eeprom(), qib7322_readq, qib7322_reset(), QIB_7322_Revision_offset, rc, register_ibdev(), qib7322::regs, revision, ib_gid::s, strerror(), unregister_ibdev(), and zalloc().

◆ qib7322_remove()

void qib7322_remove ( struct pci_device * pci)
static

Remove PCI device.

Parameters
pciPCI device

Definition at line 2407 of file qib7322.c.

2407 {
2408 struct qib7322 *qib7322 = pci_get_drvdata ( pci );
2409 int i;
2410
2411 for ( i = ( QIB7322_MAX_PORTS - 1 ) ; i >= 0 ; i-- ) {
2412 if ( qib7322->ibdev[i] )
2414 }
2415 for ( i = ( QIB7322_MAX_PORTS - 1 ) ; i >= 0 ; i-- )
2416 ibdev_put ( qib7322->ibdev[i] );
2419 iounmap ( qib7322->regs );
2420 free ( qib7322 );
2421}
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition pci.h:376

References free, qib7322::ibdev, ibdev_put(), iounmap(), pci_get_drvdata(), qib7322_fini_recv(), qib7322_fini_send(), QIB7322_MAX_PORTS, qib7322::regs, and unregister_ibdev().

Variable Documentation

◆ qib7322_ib_operations

struct ib_device_operations qib7322_ib_operations
static
Initial value:
= {
.create_cq = qib7322_create_cq,
.destroy_cq = qib7322_destroy_cq,
.create_qp = qib7322_create_qp,
.modify_qp = qib7322_modify_qp,
.destroy_qp = qib7322_destroy_qp,
.post_send = qib7322_post_send,
.post_recv = qib7322_post_recv,
.poll_cq = qib7322_poll_cq,
.poll_eq = qib7322_poll_eq,
.open = qib7322_open,
.close = qib7322_close,
.mcast_attach = qib7322_mcast_attach,
.mcast_detach = qib7322_mcast_detach,
.set_port_info = qib7322_set_port_info,
.set_pkey_table = qib7322_set_pkey_table,
}
static int qib7322_open(struct ib_device *ibdev)
Initialise Infiniband link.
Definition qib7322.c:1717
static int qib7322_modify_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Modify queue pair.
Definition qib7322.c:1126
static int qib7322_set_port_info(struct ib_device *ibdev, union ib_mad *mad)
Set port information.
Definition qib7322.c:308
static void qib7322_close(struct ib_device *ibdev)
Close Infiniband link.
Definition qib7322.c:1737
static void qib7322_poll_eq(struct ib_device *ibdev)
Poll event queue.
Definition qib7322.c:1630
static int qib7322_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 qib7322.c:1167
static int qib7322_create_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Create queue pair.
Definition qib7322.c:1085
static int qib7322_post_recv(struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf)
Post receive work queue entry.
Definition qib7322.c:1312
static void qib7322_mcast_detach(struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
Detach from multicast group.
Definition qib7322.c:1783
static int qib7322_set_pkey_table(struct ib_device *ibdev __unused, union ib_mad *mad __unused)
Set partition key table.
Definition qib7322.c:349
static int qib7322_create_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Create completion queue.
Definition qib7322.c:1039
static int qib7322_mcast_attach(struct ib_device *ibdev, struct ib_queue_pair *qp, union ib_gid *gid)
Attach to multicast group.
Definition qib7322.c:1765
static void qib7322_destroy_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Destroy completion queue.
Definition qib7322.c:1063
static void qib7322_destroy_qp(struct ib_device *ibdev, struct ib_queue_pair *qp)
Destroy queue pair.
Definition qib7322.c:1143
static void qib7322_poll_cq(struct ib_device *ibdev, struct ib_completion_queue *cq)
Poll completion queue.
Definition qib7322.c:1604

QIB7322 Infiniband operations.

Definition at line 1794 of file qib7322.c.

1794 {
1795 .create_cq = qib7322_create_cq,
1796 .destroy_cq = qib7322_destroy_cq,
1797 .create_qp = qib7322_create_qp,
1798 .modify_qp = qib7322_modify_qp,
1799 .destroy_qp = qib7322_destroy_qp,
1800 .post_send = qib7322_post_send,
1801 .post_recv = qib7322_post_recv,
1802 .poll_cq = qib7322_poll_cq,
1803 .poll_eq = qib7322_poll_eq,
1804 .open = qib7322_open,
1805 .close = qib7322_close,
1806 .mcast_attach = qib7322_mcast_attach,
1807 .mcast_detach = qib7322_mcast_detach,
1808 .set_port_info = qib7322_set_port_info,
1809 .set_pkey_table = qib7322_set_pkey_table,
1810};

Referenced by qib7322_probe().

◆ qib7322_i2c_bits

unsigned int qib7322_i2c_bits[]
static
Initial value:
= {
}
@ I2C_BIT_SDA
Serial data.
Definition i2c.h:116
@ I2C_BIT_SCL
Serial clock.
Definition i2c.h:114
#define QIB7322_GPIO_SCL
QIB7322 I2C SCL line GPIO number.
Definition qib7322.h:187
#define QIB7322_GPIO_SDA
QIB7322 I2C SDA line GPIO number.
Definition qib7322.h:190

QIB7322 I2C bit to GPIO mappings.

Definition at line 1820 of file qib7322.c.

1820 {
1821 [I2C_BIT_SCL] = ( 1 << QIB7322_GPIO_SCL ),
1822 [I2C_BIT_SDA] = ( 1 << QIB7322_GPIO_SDA ),
1823};

Referenced by qib7322_i2c_read_bit(), and qib7322_i2c_write_bit().

◆ qib7322_i2c_basher_ops

struct bit_basher_operations qib7322_i2c_basher_ops
static
Initial value:
= {
}
static void qib7322_i2c_write_bit(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
Write QIB7322 I2C line status.
Definition qib7322.c:1857
static int qib7322_i2c_read_bit(struct bit_basher *basher, unsigned int bit_id)
Read QIB7322 I2C line status.
Definition qib7322.c:1833

QIB7322 I2C bit-bashing interface operations.

Definition at line 1895 of file qib7322.c.

1895 {
1896 .read = qib7322_i2c_read_bit,
1897 .write = qib7322_i2c_write_bit,
1898};

Referenced by qib7322_init_i2c().

◆ qib7322_nics

struct pci_device_id qib7322_nics[]
static
Initial value:
= {
PCI_ROM ( 0x1077, 0x7322, "iba7322", "IBA7322 QDR InfiniBand HCA", 0 ),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition pci.h:308

Definition at line 2423 of file qib7322.c.

2423 {
2424 PCI_ROM ( 0x1077, 0x7322, "iba7322", "IBA7322 QDR InfiniBand HCA", 0 ),
2425};

◆ __pci_driver

struct pci_driver qib7322_driver __pci_driver
Initial value:
= {
.ids = qib7322_nics,
.id_count = ( sizeof ( qib7322_nics ) / sizeof ( qib7322_nics[0] ) ),
.probe = qib7322_probe,
}
static int qib7322_probe(struct pci_device *pci)
Probe PCI device.
Definition qib7322.c:2281
static void qib7322_remove(struct pci_device *pci)
Remove PCI device.
Definition qib7322.c:2407
static struct pci_device_id qib7322_nics[]
Definition qib7322.c:2423
static struct xen_remove_from_physmap * remove
Definition xenmem.h:40

Definition at line 2427 of file qib7322.c.

2427 {
2428 .ids = qib7322_nics,
2429 .id_count = ( sizeof ( qib7322_nics ) / sizeof ( qib7322_nics[0] ) ),
2430 .probe = qib7322_probe,
2432};