#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <assert.h>
#include <gpxe/io.h>
#include <gpxe/pci.h>
#include <gpxe/infiniband.h>
#include <gpxe/i2c.h>
#include <gpxe/bitbash.h>
#include <gpxe/malloc.h>
#include <gpxe/iobuf.h>
#include "linda.h"
Go to the source code of this file.
Data Structures | |
| struct | linda_send_work_queue |
| A Linda send work queue. More... | |
| struct | linda_recv_work_queue |
| A Linda receive work queue. More... | |
| struct | linda |
| A Linda HCA. More... | |
| struct | linda_serdes_param |
| A Linda SerDes parameter. More... | |
Defines | |
| #define | linda_readq(_linda, _ptr, _offset) linda_readq ( (_linda), (_ptr)->u.dwords, (_offset) ) |
| #define | linda_readq_array8b(_linda, _ptr, _offset, _idx) linda_readq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 8 ) ) ) |
| #define | linda_readq_array64k(_linda, _ptr, _offset, _idx) linda_readq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 65536 ) ) ) |
| #define | linda_writeq(_linda, _ptr, _offset) linda_writeq ( (_linda), (_ptr)->u.dwords, (_offset) ) |
| #define | linda_writeq_array8b(_linda, _ptr, _offset, _idx) linda_writeq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 8 ) ) ) |
| #define | linda_writeq_array64k(_linda, _ptr, _offset, _idx) linda_writeq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 65536 ) ) ) |
| #define | LINDA_SEND_BUF_TOGGLE 0x80 |
| Send buffer toggle bit. | |
| #define | LINDA_EPB_ALL_CHANNELS 31 |
| Magic "all channels" channel number. | |
| #define | LINDA_SERDES_PARAM_END { 0, 0, 0 } |
| End of SerDes parameter list marker. | |
| #define | LINDA_DDS_VAL(amp_d, main_d, ipst_d, ipre_d,amp_s, main_s, ipst_s, ipre_s) |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| static void | linda_readq (struct linda *linda, uint32_t *dwords, unsigned long offset) |
| Read Linda qword register. | |
| static void | linda_writeq (struct linda *linda, const uint32_t *dwords, unsigned long offset) |
| Write Linda qword register. | |
| static void | linda_writel (struct linda *linda, uint32_t dword, unsigned long offset) |
| Write Linda dword register. | |
| static const char * | linda_link_state_text (unsigned int link_state) |
| Textual representation of link state. | |
| static void | linda_link_state_changed (struct ib_device *ibdev) |
| Handle link state change. | |
| static int | linda_link_state_check (struct linda *linda, unsigned int new_link_state) |
| Wait for link state change to take effect. | |
| static int | linda_set_port_info (struct ib_device *ibdev, union ib_mad *mad) |
| Set port information. | |
| static int | linda_set_pkey_table (struct ib_device *ibdev __unused, union ib_mad *mad __unused) |
| Set partition key table. | |
| static int | linda_ctx_to_qpn (unsigned int ctx) |
| Map context number to QPN. | |
| static int | linda_qpn_to_ctx (unsigned int qpn) |
| Map QPN to context number. | |
| static int | linda_alloc_ctx (struct linda *linda) |
| Allocate a context. | |
| static void | linda_free_ctx (struct linda *linda, unsigned int ctx) |
| Free a context. | |
| static unsigned int | linda_alloc_send_buf (struct linda *linda) |
| Allocate a send buffer. | |
| static void | linda_free_send_buf (struct linda *linda, unsigned int send_buf) |
| Free a send buffer. | |
| static int | linda_send_buf_in_use (struct linda *linda, unsigned int send_buf) |
| Check to see if send buffer is in use. | |
| static unsigned long | linda_send_buffer_offset (struct linda *linda, unsigned int send_buf) |
| Calculate starting offset for send buffer. | |
| static int | linda_create_send_wq (struct linda *linda, struct ib_queue_pair *qp) |
| Create send work queue. | |
| static void | linda_destroy_send_wq (struct linda *linda, struct ib_queue_pair *qp) |
| Destroy send work queue. | |
| static int | linda_init_send (struct linda *linda) |
| Initialise send datapath. | |
| static void | linda_fini_send (struct linda *linda) |
| Shut down send datapath. | |
| static int | linda_create_recv_wq (struct linda *linda, struct ib_queue_pair *qp) |
| Create receive work queue. | |
| static void | linda_destroy_recv_wq (struct linda *linda, struct ib_queue_pair *qp) |
| Destroy receive work queue. | |
| static int | linda_init_recv (struct linda *linda) |
| Initialise receive datapath. | |
| static void | linda_fini_recv (struct linda *linda __unused) |
| Shut down receive datapath. | |
| static int | linda_create_cq (struct ib_device *ibdev, struct ib_completion_queue *cq) |
| Create completion queue. | |
| static void | linda_destroy_cq (struct ib_device *ibdev, struct ib_completion_queue *cq) |
| Destroy completion queue. | |
| static int | linda_create_qp (struct ib_device *ibdev, struct ib_queue_pair *qp) |
| Create queue pair. | |
| static int | linda_modify_qp (struct ib_device *ibdev, struct ib_queue_pair *qp) |
| Modify queue pair. | |
| static void | linda_destroy_qp (struct ib_device *ibdev, struct ib_queue_pair *qp) |
| Destroy queue pair. | |
| static int | linda_post_send (struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_address_vector *av, struct io_buffer *iobuf) |
| Post send work queue entry. | |
| static void | linda_complete_send (struct ib_device *ibdev, struct ib_queue_pair *qp, unsigned int wqe_idx) |
| Complete send work queue entry. | |
| static void | linda_poll_send_wq (struct ib_device *ibdev, struct ib_queue_pair *qp) |
| Poll send work queue. | |
| static int | linda_post_recv (struct ib_device *ibdev, struct ib_queue_pair *qp, struct io_buffer *iobuf) |
| Post receive work queue entry. | |
| static void | linda_complete_recv (struct ib_device *ibdev, struct ib_queue_pair *qp, unsigned int header_offs) |
| Complete receive work queue entry. | |
| static void | linda_poll_recv_wq (struct ib_device *ibdev, struct ib_queue_pair *qp) |
| Poll receive work queue. | |
| static void | linda_poll_cq (struct ib_device *ibdev, struct ib_completion_queue *cq) |
| Poll completion queue. | |
| static void | linda_poll_eq (struct ib_device *ibdev) |
| Poll event queue. | |
| static int | linda_open (struct ib_device *ibdev) |
| Initialise Infiniband link. | |
| static void | linda_close (struct ib_device *ibdev) |
| Close Infiniband link. | |
| static int | linda_mcast_attach (struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_gid *gid) |
| Attach to multicast group. | |
| static void | linda_mcast_detach (struct ib_device *ibdev, struct ib_queue_pair *qp, struct ib_gid *gid) |
| Detach from multicast group. | |
| static int | linda_i2c_read_bit (struct bit_basher *basher, unsigned int bit_id) |
| Read Linda I2C line status. | |
| static void | linda_i2c_write_bit (struct bit_basher *basher, unsigned int bit_id, unsigned long data) |
| Write Linda I2C line status. | |
| static int | linda_init_i2c (struct linda *linda) |
| Initialise Linda I2C subsystem. | |
| static int | linda_read_eeprom (struct linda *linda, struct ib_gid_half *guid) |
| Read EEPROM parameters. | |
| static int | linda_ib_epb_request (struct linda *linda) |
| Request ownership of the IB external parallel bus. | |
| static int | linda_ib_epb_wait (struct linda *linda, struct QIB_7220_ibsd_epb_transaction_reg *xact) |
| Wait for IB external parallel bus transaction to complete. | |
| static void | linda_ib_epb_release (struct linda *linda) |
| Release ownership of the IB external parallel bus. | |
| static int | linda_ib_epb_read (struct linda *linda, unsigned int location) |
| Read data via IB external parallel bus. | |
| static int | linda_ib_epb_write (struct linda *linda, unsigned int location, unsigned int data) |
| Write data via IB external parallel bus. | |
| static int | linda_ib_epb_mod_reg (struct linda *linda, unsigned int cs, unsigned int channel, unsigned int element, unsigned int reg, unsigned int value, unsigned int mask) |
| Read/modify/write EPB register. | |
| static int | linda_ib_epb_ram_xfer (struct linda *linda, unsigned int address, const void *write, void *read, size_t len) |
| Transfer data to/from microcontroller RAM. | |
| static int | linda_set_serdes_param (struct linda *linda, struct linda_serdes_param *param) |
| Program IB SerDes register(s). | |
| static int | linda_set_serdes_params (struct linda *linda, struct linda_serdes_param *params) |
| Program IB SerDes registers. | |
| static int | linda_program_uc_ram (struct linda *linda) |
| Program the microcontroller RAM. | |
| static int | linda_verify_uc_ram (struct linda *linda) |
| Verify the microcontroller RAM. | |
| static int | linda_trim_ib (struct linda *linda) |
| Use the microcontroller to trim the IB link. | |
| static int | linda_init_ib_serdes (struct linda *linda) |
| Initialise the IB SerDes. | |
| static int | linda_probe (struct pci_device *pci, const struct pci_device_id *id __unused) |
| Probe PCI device. | |
| static void | linda_remove (struct pci_device *pci) |
| Remove PCI device. | |
Variables | |
| static struct ib_device_operations | linda_ib_operations |
| Linda Infiniband operations. | |
| static unsigned int | linda_i2c_bits [] |
| Linda I2C bit to GPIO mappings. | |
| static struct bit_basher_operations | linda_i2c_basher_ops |
| Linda I2C bit-bashing interface operations. | |
| struct linda_serdes_param | __packed |
| A Linda SerDes parameter. | |
| static struct linda_serdes_param | linda_serdes_defaults1 [] |
| Linda SerDes default parameters. | |
| static struct linda_serdes_param | linda_serdes_defaults2 [] |
| static struct linda_serdes_param | linda_serdes_defaults3 [] |
| static struct pci_device_id | linda_nics [] |
| struct pci_driver linda_driver | __pci_driver |
Definition in file linda.c.
| #define linda_readq | ( | _linda, | |||
| _ptr, | |||||
| _offset | ) | linda_readq ( (_linda), (_ptr)->u.dwords, (_offset) ) |
Definition at line 134 of file linda.c.
Referenced by linda_close(), linda_create_recv_wq(), linda_destroy_recv_wq(), linda_fini_send(), linda_i2c_read_bit(), linda_i2c_write_bit(), linda_ib_epb_request(), linda_ib_epb_wait(), linda_init_ib_serdes(), linda_init_recv(), linda_init_send(), linda_link_state_changed(), linda_link_state_check(), linda_open(), linda_poll_eq(), linda_probe(), linda_set_port_info(), and linda_trim_ib().
| #define linda_readq_array8b | ( | _linda, | |||
| _ptr, | |||||
| _offset, | |||||
| _idx | ) | linda_readq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 8 ) ) ) |
| #define linda_readq_array64k | ( | _linda, | |||
| _ptr, | |||||
| _offset, | |||||
| _idx | ) | linda_readq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 65536 ) ) ) |
| #define linda_writeq | ( | _linda, | |||
| _ptr, | |||||
| _offset | ) | linda_writeq ( (_linda), (_ptr)->u.dwords, (_offset) ) |
Definition at line 159 of file linda.c.
Referenced by linda_close(), linda_create_recv_wq(), linda_destroy_recv_wq(), linda_fini_send(), linda_i2c_write_bit(), linda_ib_epb_read(), linda_ib_epb_release(), linda_ib_epb_request(), linda_ib_epb_write(), linda_init_ib_serdes(), linda_init_recv(), linda_init_send(), linda_link_state_changed(), linda_open(), linda_poll_eq(), linda_post_send(), linda_set_port_info(), and linda_trim_ib().
| #define linda_writeq_array8b | ( | _linda, | |||
| _ptr, | |||||
| _offset, | |||||
| _idx | ) | linda_writeq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 8 ) ) ) |
Definition at line 161 of file linda.c.
Referenced by linda_complete_recv(), linda_create_recv_wq(), and linda_post_recv().
| #define linda_writeq_array64k | ( | _linda, | |||
| _ptr, | |||||
| _offset, | |||||
| _idx | ) | linda_writeq ( (_linda), (_ptr), ( (_offset) + ( (_idx) * 65536 ) ) ) |
Definition at line 163 of file linda.c.
Referenced by linda_create_recv_wq(), linda_poll_recv_wq(), and linda_post_recv().
| #define LINDA_SEND_BUF_TOGGLE 0x80 |
Send buffer toggle bit.
We encode send buffers as 7 bits of send buffer index plus a single bit which should match the "check" bit in the SendBufAvail array.
Definition at line 391 of file linda.c.
Referenced by linda_alloc_send_buf(), linda_send_buf_in_use(), and linda_send_buffer_offset().
| #define LINDA_EPB_ALL_CHANNELS 31 |
Magic "all channels" channel number.
Definition at line 1991 of file linda.c.
Referenced by linda_set_serdes_param().
| #define LINDA_SERDES_PARAM_END { 0, 0, 0 } |
| #define LINDA_DDS_VAL | ( | amp_d, | |||
| main_d, | |||||
| ipst_d, | |||||
| ipre_d, | |||||
| amp_s, | |||||
| main_s, | |||||
| ipst_s, | |||||
| ipre_s | ) |
Value:
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 9, 0x00 ), \
( ( ( amp_d & 0x1f ) << 1 ) | 1 ), 0xff }, \
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 9, 0x01 ), \
( ( ( amp_s & 0x1f ) << 1 ) | 1 ), 0xff }, \
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 9, 0x09 ), \
( ( main_d << 3 ) | 4 | ( ipre_d >> 2 ) ), 0xff }, \
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 9, 0x0a ), \
( ( main_s << 3 ) | 4 | ( ipre_s >> 2 ) ), 0xff }, \
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 9, 0x06 ), \
( ( ( ipst_d & 0xf ) << 1 ) | \
( ( ipre_d & 3 ) << 6 ) | 0x21 ), 0xff }, \
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 9, 0x07 ), \
( ( ( ipst_s & 0xf ) << 1 ) | \
( ( ipre_s & 3 ) << 6) | 0x21 ), 0xff }
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
Read Linda qword register.
Definition at line 123 of file linda.c.
References __asm__(), DBGIO, linda::regs, and virt_to_phys().
00124 { 00125 void *addr = ( linda->regs + offset ); 00126 00127 __asm__ __volatile__ ( "movq (%1), %%mm0\n\t" 00128 "movq %%mm0, (%0)\n\t" 00129 : : "r" ( dwords ), "r" ( addr ) : "memory" ); 00130 00131 DBGIO ( "[%08lx] => %08x%08x\n", 00132 virt_to_phys ( addr ), dwords[1], dwords[0] ); 00133 }
| static void linda_writeq | ( | struct linda * | linda, | |
| const uint32_t * | dwords, | |||
| unsigned long | offset | |||
| ) | [static] |
Write Linda qword register.
Definition at line 148 of file linda.c.
References __asm__(), DBGIO, linda::regs, and virt_to_phys().
00149 { 00150 void *addr = ( linda->regs + offset ); 00151 00152 DBGIO ( "[%08lx] <= %08x%08x\n", 00153 virt_to_phys ( addr ), dwords[1], dwords[0] ); 00154 00155 __asm__ __volatile__ ( "movq (%0), %%mm0\n\t" 00156 "movq %%mm0, (%1)\n\t" 00157 : : "r" ( dwords ), "r" ( addr ) : "memory" ); 00158 }
| static const char* linda_link_state_text | ( | unsigned int | link_state | ) | [static] |
Textual representation of link state.
| link_state | Link state |
| link_text | Link state text |
Definition at line 191 of file linda.c.
References LINDA_LINK_STATE_ACT_DEFER, LINDA_LINK_STATE_ACTIVE, LINDA_LINK_STATE_ARM, LINDA_LINK_STATE_DOWN, and LINDA_LINK_STATE_INIT.
Referenced by linda_link_state_changed(), linda_link_state_check(), and linda_set_port_info().
00191 { 00192 switch ( link_state ) { 00193 case LINDA_LINK_STATE_DOWN: return "DOWN"; 00194 case LINDA_LINK_STATE_INIT: return "INIT"; 00195 case LINDA_LINK_STATE_ARM: return "ARM"; 00196 case LINDA_LINK_STATE_ACTIVE: return "ACTIVE"; 00197 case LINDA_LINK_STATE_ACT_DEFER:return "ACT_DEFER"; 00198 default: return "UNKNOWN"; 00199 } 00200 }
| static void linda_link_state_changed | ( | struct ib_device * | ibdev | ) | [static] |
Handle link state change.
Definition at line 207 of file linda.c.
References BIT_GET, BIT_SET, DBGC, ib_get_drvdata(), IB_LINK_SPEED_DDR, IB_LINK_SPEED_SDR, ib_link_state_changed(), IB_LINK_WIDTH_1X, IB_LINK_WIDTH_4X, LINDA_LINK_STATE_ACTIVE, LINDA_LINK_STATE_INIT, linda_link_state_text(), linda_readq, linda_writeq, ib_device::link_speed_active, ib_device::link_width_active, ib_device::port_state, QIB_7220_EXTCtrl_offset, and QIB_7220_IBCStatus_offset.
Referenced by linda_poll_eq(), and linda_set_port_info().
00207 { 00208 struct linda *linda = ib_get_drvdata ( ibdev ); 00209 struct QIB_7220_IBCStatus ibcstatus; 00210 struct QIB_7220_EXTCtrl extctrl; 00211 unsigned int link_state; 00212 unsigned int link_width; 00213 unsigned int link_speed; 00214 00215 /* Read link state */ 00216 linda_readq ( linda, &ibcstatus, QIB_7220_IBCStatus_offset ); 00217 link_state = BIT_GET ( &ibcstatus, LinkState ); 00218 link_width = BIT_GET ( &ibcstatus, LinkWidthActive ); 00219 link_speed = BIT_GET ( &ibcstatus, LinkSpeedActive ); 00220 DBGC ( linda, "Linda %p link state %s (%s %s)\n", linda, 00221 linda_link_state_text ( link_state ), 00222 ( link_speed ? "DDR" : "SDR" ), ( link_width ? "x4" : "x1" ) ); 00223 00224 /* Set LEDs according to link state */ 00225 linda_readq ( linda, &extctrl, QIB_7220_EXTCtrl_offset ); 00226 BIT_SET ( &extctrl, LEDPriPortGreenOn, 00227 ( ( link_state >= LINDA_LINK_STATE_INIT ) ? 1 : 0 ) ); 00228 BIT_SET ( &extctrl, LEDPriPortYellowOn, 00229 ( ( link_state >= LINDA_LINK_STATE_ACTIVE ) ? 1 : 0 ) ); 00230 linda_writeq ( linda, &extctrl, QIB_7220_EXTCtrl_offset ); 00231 00232 /* Notify Infiniband core of link state change */ 00233 ibdev->port_state = ( link_state + 1 ); 00234 ibdev->link_width_active = 00235 ( link_width ? IB_LINK_WIDTH_4X : IB_LINK_WIDTH_1X ); 00236 ibdev->link_speed_active = 00237 ( link_speed ? IB_LINK_SPEED_DDR : IB_LINK_SPEED_SDR ); 00238 ib_link_state_changed ( ibdev ); 00239 }
| static int linda_link_state_check | ( | struct linda * | linda, | |
| unsigned int | new_link_state | |||
| ) | [static] |
Wait for link state change to take effect.
| rc | Return status code |
Definition at line 248 of file linda.c.
References BIT_GET, DBGC, ETIMEDOUT, LINDA_LINK_STATE_MAX_WAIT_US, linda_link_state_text(), linda_readq, QIB_7220_IBCStatus_offset, and udelay().
Referenced by linda_set_port_info().
00249 { 00250 struct QIB_7220_IBCStatus ibcstatus; 00251 unsigned int link_state; 00252 unsigned int i; 00253 00254 for ( i = 0 ; i < LINDA_LINK_STATE_MAX_WAIT_US ; i++ ) { 00255 linda_readq ( linda, &ibcstatus, QIB_7220_IBCStatus_offset ); 00256 link_state = BIT_GET ( &ibcstatus, LinkState ); 00257 if ( link_state == new_link_state ) 00258 return 0; 00259 udelay ( 1 ); 00260 } 00261 00262 DBGC ( linda, "Linda %p timed out waiting for link state %s\n", 00263 linda, linda_link_state_text ( link_state ) ); 00264 return -ETIMEDOUT; 00265 }
Set port information.
| ibdev | Infiniband device | |
| mad | Set port information MAD |
Definition at line 273 of file linda.c.
References BIT_SET, DBGC, ib_get_drvdata(), linda_link_state_changed(), linda_link_state_check(), linda_link_state_text(), linda_readq, linda_writeq, ib_port_info::link_speed_supported__port_state, ib_smp_data::port_info, QIB_7220_IBCCtrl_offset, ib_mad::smp, and ib_mad_smp::smp_data.
00273 { 00274 struct linda *linda = ib_get_drvdata ( ibdev ); 00275 struct ib_port_info *port_info = &mad->smp.smp_data.port_info; 00276 struct QIB_7220_IBCCtrl ibcctrl; 00277 unsigned int port_state; 00278 unsigned int link_state; 00279 00280 /* Set new link state */ 00281 port_state = ( port_info->link_speed_supported__port_state & 0xf ); 00282 if ( port_state ) { 00283 link_state = ( port_state - 1 ); 00284 DBGC ( linda, "Linda %p set link state to %s (%x)\n", linda, 00285 linda_link_state_text ( link_state ), link_state ); 00286 linda_readq ( linda, &ibcctrl, QIB_7220_IBCCtrl_offset ); 00287 BIT_SET ( &ibcctrl, LinkCmd, link_state ); 00288 linda_writeq ( linda, &ibcctrl, QIB_7220_IBCCtrl_offset ); 00289 00290 /* Wait for link state change to take effect. Ignore 00291 * errors; the current link state will be returned via 00292 * the GetResponse MAD. 00293 */ 00294 linda_link_state_check ( linda, link_state ); 00295 } 00296 00297 /* Detect and report link state change */ 00298 linda_link_state_changed ( ibdev ); 00299 00300 return 0; 00301 }
| static int linda_ctx_to_qpn | ( | unsigned int | ctx | ) | [static] |
Map context number to QPN.
| ctx | Context index |
| qpn | Queue pair number |
Definition at line 328 of file linda.c.
Referenced by linda_create_qp().
| static int linda_qpn_to_ctx | ( | unsigned int | qpn | ) | [static] |
Map QPN to context number.
| qpn | Queue pair number |
| ctx | Context index |
Definition at line 339 of file linda.c.
Referenced by linda_create_recv_wq(), linda_destroy_recv_wq(), linda_poll_recv_wq(), and linda_post_recv().
| static int linda_alloc_ctx | ( | struct linda * | linda | ) | [static] |
Allocate a context.
| ctx | Context index, or negative error |
Definition at line 350 of file linda.c.
References DBGC, DBGC2, ENOENT, LINDA_NUM_CONTEXTS, and linda::used_ctx.
Referenced by linda_create_qp().
00350 { 00351 unsigned int ctx; 00352 00353 for ( ctx = 0 ; ctx < LINDA_NUM_CONTEXTS ; ctx++ ) { 00354 00355 if ( ! linda->used_ctx[ctx] ) { 00356 linda->used_ctx[ctx ] = 1; 00357 DBGC2 ( linda, "Linda %p CTX %d allocated\n", 00358 linda, ctx ); 00359 return ctx; 00360 } 00361 } 00362 00363 DBGC ( linda, "Linda %p out of available contexts\n", linda ); 00364 return -ENOENT; 00365 }
| static void linda_free_ctx | ( | struct linda * | linda, | |
| unsigned int | ctx | |||
| ) | [static] |
Free a context.
Definition at line 373 of file linda.c.
References DBGC2, and linda::used_ctx.
Referenced by linda_create_qp(), and linda_destroy_recv_wq().
00373 { 00374 00375 linda->used_ctx[ctx] = 0; 00376 DBGC2 ( linda, "Linda %p CTX %d freed\n", linda, ctx ); 00377 }
| static unsigned int linda_alloc_send_buf | ( | struct linda * | linda | ) | [static] |
Allocate a send buffer.
| send_buf | Send buffer |
Definition at line 403 of file linda.c.
References LINDA_MAX_SEND_BUFS, LINDA_SEND_BUF_TOGGLE, linda::send_buf, and linda::send_buf_cons.
Referenced by linda_post_send().
00403 { 00404 unsigned int send_buf; 00405 00406 send_buf = linda->send_buf[linda->send_buf_cons]; 00407 send_buf ^= LINDA_SEND_BUF_TOGGLE; 00408 linda->send_buf_cons = ( ( linda->send_buf_cons + 1 ) % 00409 LINDA_MAX_SEND_BUFS ); 00410 return send_buf; 00411 }
| static void linda_free_send_buf | ( | struct linda * | linda, | |
| unsigned int | send_buf | |||
| ) | [static] |
Free a send buffer.
Definition at line 419 of file linda.c.
References LINDA_MAX_SEND_BUFS, linda::send_buf, and linda::send_buf_prod.
Referenced by linda_complete_send().
00420 { 00421 linda->send_buf[linda->send_buf_prod] = send_buf; 00422 linda->send_buf_prod = ( ( linda->send_buf_prod + 1 ) % 00423 LINDA_MAX_SEND_BUFS ); 00424 }
| static int linda_send_buf_in_use | ( | struct linda * | linda, | |
| unsigned int | send_buf | |||
| ) | [static] |
Check to see if send buffer is in use.
| in_use | Send buffer is in use |
Definition at line 433 of file linda.c.
References BIT_GET, check, LINDA_SEND_BUF_TOGGLE, and linda::sendbufavail.
Referenced by linda_poll_send_wq().
00434 { 00435 unsigned int send_idx; 00436 unsigned int send_check; 00437 unsigned int inusecheck; 00438 unsigned int inuse; 00439 unsigned int check; 00440 00441 send_idx = ( send_buf & ~LINDA_SEND_BUF_TOGGLE ); 00442 send_check = ( !! ( send_buf & LINDA_SEND_BUF_TOGGLE ) ); 00443 inusecheck = BIT_GET ( linda->sendbufavail, InUseCheck[send_idx] ); 00444 inuse = ( !! ( inusecheck & 0x02 ) ); 00445 check = ( !! ( inusecheck & 0x01 ) ); 00446 return ( inuse || ( check != send_check ) ); 00447 }
| static unsigned long linda_send_buffer_offset | ( | struct linda * | linda, | |
| unsigned int | send_buf | |||
| ) | [static] |
Calculate starting offset for send buffer.
| offset | Starting offset |
Definition at line 456 of file linda.c.
References LINDA_SEND_BUF_SIZE, LINDA_SEND_BUF_TOGGLE, and linda::send_buffer_base.
Referenced by linda_post_send().
00457 { 00458 return ( linda->send_buffer_base + 00459 ( ( send_buf & ~LINDA_SEND_BUF_TOGGLE ) * 00460 LINDA_SEND_BUF_SIZE ) ); 00461 }
| static int linda_create_send_wq | ( | struct linda * | linda, | |
| struct ib_queue_pair * | qp | |||
| ) | [static] |
Create send work queue.
Definition at line 469 of file linda.c.
References linda_send_work_queue::cons, DBGC, ENOBUFS, free(), ib_wq_get_drvdata(), LINDA_MAX_SEND_BUFS, ib_work_queue::num_wqes, linda_send_work_queue::prod, linda::reserved_send_bufs, ib_queue_pair::send, linda_send_work_queue::send_buf, and zalloc().
Referenced by linda_create_qp().
00470 { 00471 struct ib_work_queue *wq = &qp->send; 00472 struct linda_send_work_queue *linda_wq = ib_wq_get_drvdata ( wq ); 00473 int rc; 00474 00475 /* Reserve send buffers */ 00476 if ( ( linda->reserved_send_bufs + qp->send.num_wqes ) > 00477 LINDA_MAX_SEND_BUFS ) { 00478 DBGC ( linda, "Linda %p out of send buffers (have %d, used " 00479 "%d, need %d)\n", linda, LINDA_MAX_SEND_BUFS, 00480 linda->reserved_send_bufs, qp->send.num_wqes ); 00481 rc = -ENOBUFS; 00482 goto err_reserve_bufs; 00483 } 00484 linda->reserved_send_bufs += qp->send.num_wqes; 00485 00486 /* Reset work queue */ 00487 linda_wq->prod = 0; 00488 linda_wq->cons = 0; 00489 00490 /* Allocate space for send buffer uasge list */ 00491 linda_wq->send_buf = zalloc ( qp->send.num_wqes * 00492 sizeof ( linda_wq->send_buf[0] ) ); 00493 if ( ! linda_wq->send_buf ) { 00494 rc = -ENOBUFS; 00495 goto err_alloc_send_buf; 00496 } 00497 00498 return 0; 00499 00500 free ( linda_wq->send_buf ); 00501 err_alloc_send_buf: 00502 linda->reserved_send_bufs -= qp->send.num_wqes; 00503 err_reserve_bufs: 00504 return rc; 00505 }
| static void linda_destroy_send_wq | ( | struct linda * | linda, | |
| struct ib_queue_pair * | qp | |||
| ) | [static] |
Destroy send work queue.
Definition at line 513 of file linda.c.
References free(), ib_wq_get_drvdata(), ib_work_queue::num_wqes, linda::reserved_send_bufs, ib_queue_pair::send, and linda_send_work_queue::send_buf.
Referenced by linda_create_qp(), and linda_destroy_qp().
00514 { 00515 struct ib_work_queue *wq = &qp->send; 00516 struct linda_send_work_queue *linda_wq = ib_wq_get_drvdata ( wq ); 00517 00518 free ( linda_wq->send_buf ); 00519 linda->reserved_send_bufs -= qp->send.num_wqes; 00520 }
| static int linda_init_send | ( | struct linda * | linda | ) | [static] |
Initialise send datapath.
| rc | Return status code |
Definition at line 528 of file linda.c.
References BIT_FILL_1, BIT_FILL_2, BIT_GET, DBGC, ENOMEM, free_dma(), LINDA_MAX_SEND_BUFS, linda_readq, LINDA_SENDBUFAVAIL_ALIGN, linda_writeq, malloc_dma(), memset(), QIB_7220_SendBufAvailAddr_offset, QIB_7220_SendBufBase_offset, QIB_7220_SendCtrl_offset, linda::send_buf, linda::send_buffer_base, linda::sendbufavail, and virt_to_bus().
Referenced by linda_probe().
00528 { 00529 struct QIB_7220_SendBufBase sendbufbase; 00530 struct QIB_7220_SendBufAvailAddr sendbufavailaddr; 00531 struct QIB_7220_SendCtrl sendctrl; 00532 unsigned int i; 00533 int rc; 00534 00535 /* Retrieve SendBufBase */ 00536 linda_readq ( linda, &sendbufbase, QIB_7220_SendBufBase_offset ); 00537 linda->send_buffer_base = BIT_GET ( &sendbufbase, 00538 BaseAddr_SmallPIO ); 00539 DBGC ( linda, "Linda %p send buffers at %lx\n", 00540 linda, linda->send_buffer_base ); 00541 00542 /* Initialise the send_buf[] array */ 00543 for ( i = 0 ; i < LINDA_MAX_SEND_BUFS ; i++ ) 00544 linda->send_buf[i] = i; 00545 00546 /* Allocate space for the SendBufAvail array */ 00547 linda->sendbufavail = malloc_dma ( sizeof ( *linda->sendbufavail ), 00548 LINDA_SENDBUFAVAIL_ALIGN ); 00549 if ( ! linda->sendbufavail ) { 00550 rc = -ENOMEM; 00551 goto err_alloc_sendbufavail; 00552 } 00553 memset ( linda->sendbufavail, 0, sizeof ( linda->sendbufavail ) ); 00554 00555 /* Program SendBufAvailAddr into the hardware */ 00556 memset ( &sendbufavailaddr, 0, sizeof ( sendbufavailaddr ) ); 00557 BIT_FILL_1 ( &sendbufavailaddr, SendBufAvailAddr, 00558 ( virt_to_bus ( linda->sendbufavail ) >> 6 ) ); 00559 linda_writeq ( linda, &sendbufavailaddr, 00560 QIB_7220_SendBufAvailAddr_offset ); 00561 00562 /* Enable sending and DMA of SendBufAvail */ 00563 memset ( &sendctrl, 0, sizeof ( sendctrl ) ); 00564 BIT_FILL_2 ( &sendctrl, 00565 SendBufAvailUpd, 1, 00566 SPioEnable, 1 ); 00567 linda_writeq ( linda, &sendctrl, QIB_7220_SendCtrl_offset ); 00568 00569 return 0; 00570 00571 free_dma ( linda->sendbufavail, sizeof ( *linda->sendbufavail ) ); 00572 err_alloc_sendbufavail: 00573 return rc; 00574 }
| static void linda_fini_send | ( | struct linda * | linda | ) | [static] |
Shut down send datapath.
Definition at line 581 of file linda.c.
References free_dma(), linda_readq, linda_writeq, mb(), memset(), QIB_7220_SendCtrl_offset, and linda::sendbufavail.
Referenced by linda_probe(), and linda_remove().
00581 { 00582 struct QIB_7220_SendCtrl sendctrl; 00583 00584 /* Disable sending and DMA of SendBufAvail */ 00585 memset ( &sendctrl, 0, sizeof ( sendctrl ) ); 00586 linda_writeq ( linda, &sendctrl, QIB_7220_SendCtrl_offset ); 00587 mb(); 00588 00589 /* Ensure hardware has seen this disable */ 00590 linda_readq ( linda, &sendctrl, QIB_7220_SendCtrl_offset ); 00591 00592 free_dma ( linda->sendbufavail, sizeof ( *linda->sendbufavail ) ); 00593 }
| static int linda_create_recv_wq | ( | struct linda * | linda, | |
| struct ib_queue_pair * | qp | |||
| ) | [static] |
Create receive work queue.
| rc | Return status code |
Definition at line 609 of file linda.c.
References BIT_FILL_1, BIT_SET, DBGC, linda_recv_work_queue::eager_cons, linda_recv_work_queue::eager_prod, ENOMEM, free_dma(), linda_recv_work_queue::header, linda_recv_work_queue::header_cons, linda_recv_work_queue::header_prod, ib_wq_get_drvdata(), linda_qpn_to_ctx(), linda_readq, LINDA_RECV_HEADERS_ALIGN, LINDA_RECV_HEADERS_SIZE, linda_writeq, linda_writeq_array64k, linda_writeq_array8b, malloc_dma(), memset(), QIB_7220_RcvCtrl_offset, QIB_7220_RcvEgrIndexHead0_offset, QIB_7220_RcvHdrAddr0_offset, QIB_7220_RcvHdrHead0_offset, QIB_7220_RcvHdrTailAddr0_offset, ib_queue_pair::qpn, ib_queue_pair::recv, and virt_to_bus().
Referenced by linda_create_qp().
00610 { 00611 struct ib_work_queue *wq = &qp->recv; 00612 struct linda_recv_work_queue *linda_wq = ib_wq_get_drvdata ( wq ); 00613 struct QIB_7220_RcvHdrAddr0 rcvhdraddr; 00614 struct QIB_7220_RcvHdrTailAddr0 rcvhdrtailaddr; 00615 struct QIB_7220_RcvHdrHead0 rcvhdrhead; 00616 struct QIB_7220_scalar rcvegrindexhead; 00617 struct QIB_7220_RcvCtrl rcvctrl; 00618 unsigned int ctx = linda_qpn_to_ctx ( qp->qpn ); 00619 int rc; 00620 00621 /* Reset context information */ 00622 memset ( &linda_wq->header_prod, 0, 00623 sizeof ( linda_wq->header_prod ) ); 00624 linda_wq->header_cons = 0; 00625 linda_wq->eager_prod = 0; 00626 linda_wq->eager_cons = 0; 00627 00628 /* Allocate receive header buffer */ 00629 linda_wq->header = malloc_dma ( LINDA_RECV_HEADERS_SIZE, 00630 LINDA_RECV_HEADERS_ALIGN ); 00631 if ( ! linda_wq->header ) { 00632 rc = -ENOMEM; 00633 goto err_alloc_header; 00634 } 00635 00636 /* Enable context in hardware */ 00637 memset ( &rcvhdraddr, 0, sizeof ( rcvhdraddr ) ); 00638 BIT_FILL_1 ( &rcvhdraddr, RcvHdrAddr0, 00639 ( virt_to_bus ( linda_wq->header ) >> 2 ) ); 00640 linda_writeq_array8b ( linda, &rcvhdraddr, 00641 QIB_7220_RcvHdrAddr0_offset, ctx ); 00642 memset ( &rcvhdrtailaddr, 0, sizeof ( rcvhdrtailaddr ) ); 00643 BIT_FILL_1 ( &rcvhdrtailaddr, RcvHdrTailAddr0, 00644 ( virt_to_bus ( &linda_wq->header_prod ) >> 2 ) ); 00645 linda_writeq_array8b ( linda, &rcvhdrtailaddr, 00646 QIB_7220_RcvHdrTailAddr0_offset, ctx ); 00647 memset ( &rcvhdrhead, 0, sizeof ( rcvhdrhead ) ); 00648 BIT_FILL_1 ( &rcvhdrhead, counter, 1 ); 00649 linda_writeq_array64k ( linda, &rcvhdrhead, 00650 QIB_7220_RcvHdrHead0_offset, ctx ); 00651 memset ( &rcvegrindexhead, 0, sizeof ( rcvegrindexhead ) ); 00652 BIT_FILL_1 ( &rcvegrindexhead, Value, 1 ); 00653 linda_writeq_array64k ( linda, &rcvegrindexhead, 00654 QIB_7220_RcvEgrIndexHead0_offset, ctx ); 00655 linda_readq ( linda, &rcvctrl, QIB_7220_RcvCtrl_offset ); 00656 BIT_SET ( &rcvctrl, PortEnable[ctx], 1 ); 00657 BIT_SET ( &rcvctrl, IntrAvail[ctx], 1 ); 00658 linda_writeq ( linda, &rcvctrl, QIB_7220_RcvCtrl_offset ); 00659 00660 DBGC ( linda, "Linda %p QPN %ld CTX %d hdrs [%lx,%lx) prod %lx\n", 00661 linda, qp->qpn, ctx, virt_to_bus ( linda_wq->header ), 00662 ( virt_to_bus ( linda_wq->header ) + LINDA_RECV_HEADERS_SIZE ), 00663 virt_to_bus ( &linda_wq->header_prod ) ); 00664 return 0; 00665 00666 free_dma ( linda_wq->header, LINDA_RECV_HEADERS_SIZE ); 00667 err_alloc_header: 00668 return rc; 00669 }
| static void linda_destroy_recv_wq | ( | struct linda * | linda, | |
| struct ib_queue_pair * | qp | |||
| ) | [static] |
Destroy receive work queue.
Definition at line 677 of file linda.c.
References BIT_SET, free_dma(), linda_recv_work_queue::header, ib_wq_get_drvdata(), linda_free_ctx(), linda_qpn_to_ctx(), linda_readq, LINDA_RECV_HEADERS_SIZE, linda_writeq, mb(), QIB_7220_RcvCtrl_offset, ib_queue_pair::qpn, and ib_queue_pair::recv.
Referenced by linda_create_qp(), and linda_destroy_qp().
00678 { 00679 struct ib_work_queue *wq = &qp->recv; 00680 struct linda_recv_work_queue *linda_wq = ib_wq_get_drvdata ( wq ); 00681 struct QIB_7220_RcvCtrl rcvctrl; 00682 unsigned int ctx = linda_qpn_to_ctx ( qp->qpn ); 00683 00684 /* Disable context in hardware */ 00685 linda_readq ( linda, &rcvctrl, QIB_7220_RcvCtrl_offset ); 00686 BIT_SET ( &rcvctrl, PortEnable[ctx], 0 ); 00687 BIT_SET ( &rcvctrl, IntrAvail[ctx], 0 ); 00688 linda_writeq ( linda, &rcvctrl, QIB_7220_RcvCtrl_offset ); 00689 00690 /* Make sure the hardware has seen that the context is disabled */ 00691 linda_readq ( linda, &rcvctrl, QIB_7220_RcvCtrl_offset ); 00692 mb(); 00693 00694 /* Free headers ring */ 00695 free_dma ( linda_wq->header, LINDA_RECV_HEADERS_SIZE ); 00696 00697 /* Free context */ 00698 linda_free_ctx ( linda, ctx ); 00699 }
| static int linda_init_recv | ( | struct linda * | linda | ) | [static] |
Initialise receive datapath.
| rc | Return status code |
Definition at line 707 of file linda.c.
References BIT_FILL_1, BIT_FILL_3, BIT_GET, DBGC, linda_recv_work_queue::eager_array, linda_recv_work_queue::eager_entries, EINVAL, LINDA_EAGER_ARRAY_SIZE_17CTX_0, LINDA_EAGER_ARRAY_SIZE_17CTX_OTHER, LINDA_EAGER_ARRAY_SIZE_5CTX_0, LINDA_EAGER_ARRAY_SIZE_5CTX_OTHER, LINDA_EAGER_ARRAY_SIZE_9CTX_0, LINDA_EAGER_ARRAY_SIZE_9CTX_OTHER, LINDA_NUM_CONTEXTS, LINDA_PORTCFG_17CTX, LINDA_PORTCFG_5CTX, LINDA_PORTCFG_9CTX, LINDA_QP_IDETH, linda_readq, LINDA_RECV_HEADER_COUNT, LINDA_RECV_HEADER_SIZE, linda_writeq, linker_assert, memset(), QIB_7220_RcvBTHQP_offset, QIB_7220_RcvCtrl_offset, QIB_7220_RcvEgrBase_offset, QIB_7220_RcvHdrCnt_offset, QIB_7220_RcvHdrEntSize_offset, and linda::recv_wq.
Referenced by linda_probe().
00707 { 00708 struct QIB_7220_RcvCtrl rcvctrl; 00709 struct QIB_7220_scalar rcvegrbase; 00710 struct QIB_7220_scalar rcvhdrentsize; 00711 struct QIB_7220_scalar rcvhdrcnt; 00712 struct QIB_7220_RcvBTHQP rcvbthqp; 00713 unsigned int portcfg; 00714 unsigned long egrbase; 00715 unsigned int eager_array_size_0; 00716 unsigned int eager_array_size_other; 00717 unsigned int ctx; 00718 00719 /* Select configuration based on number of contexts */ 00720 switch ( LINDA_NUM_CONTEXTS ) { 00721 case 5: 00722 portcfg = LINDA_PORTCFG_5CTX; 00723 eager_array_size_0 = LINDA_EAGER_ARRAY_SIZE_5CTX_0; 00724 eager_array_size_other = LINDA_EAGER_ARRAY_SIZE_5CTX_OTHER; 00725 break; 00726 case 9: 00727 portcfg = LINDA_PORTCFG_9CTX; 00728 eager_array_size_0 = LINDA_EAGER_ARRAY_SIZE_9CTX_0; 00729 eager_array_size_other = LINDA_EAGER_ARRAY_SIZE_9CTX_OTHER; 00730 break; 00731 case 17: 00732 portcfg = LINDA_PORTCFG_17CTX; 00733 eager_array_size_0 = LINDA_EAGER_ARRAY_SIZE_17CTX_0; 00734 eager_array_size_other = LINDA_EAGER_ARRAY_SIZE_17CTX_OTHER; 00735 break; 00736 default: 00737 linker_assert ( 0, invalid_LINDA_NUM_CONTEXTS ); 00738 return -EINVAL; 00739 } 00740 00741 /* Configure number of contexts */ 00742 memset ( &rcvctrl, 0, sizeof ( rcvctrl ) ); 00743 BIT_FILL_3 ( &rcvctrl, 00744 TailUpd, 1, 00745 PortCfg, portcfg, 00746 RcvQPMapEnable, 1 ); 00747 linda_writeq ( linda, &rcvctrl, QIB_7220_RcvCtrl_offset ); 00748 00749 /* Configure receive header buffer sizes */ 00750 memset ( &rcvhdrcnt, 0, sizeof ( rcvhdrcnt ) ); 00751 BIT_FILL_1 ( &rcvhdrcnt, Value, LINDA_RECV_HEADER_COUNT ); 00752 linda_writeq ( linda, &rcvhdrcnt, QIB_7220_RcvHdrCnt_offset ); 00753 memset ( &rcvhdrentsize, 0, sizeof ( rcvhdrentsize ) ); 00754 BIT_FILL_1 ( &rcvhdrentsize, Value, ( LINDA_RECV_HEADER_SIZE >> 2 ) ); 00755 linda_writeq ( linda, &rcvhdrentsize, QIB_7220_RcvHdrEntSize_offset ); 00756 00757 /* Calculate eager array start addresses for each context */ 00758 linda_readq ( linda, &rcvegrbase, QIB_7220_RcvEgrBase_offset ); 00759 egrbase = BIT_GET ( &rcvegrbase, Value ); 00760 linda->recv_wq[0].eager_array = egrbase; 00761 linda->recv_wq[0].eager_entries = eager_array_size_0; 00762 egrbase += ( eager_array_size_0 * sizeof ( struct QIB_7220_RcvEgr ) ); 00763 for ( ctx = 1 ; ctx < LINDA_NUM_CONTEXTS ; ctx++ ) { 00764 linda->recv_wq[ctx].eager_array = egrbase; 00765 linda->recv_wq[ctx].eager_entries = eager_array_size_other; 00766 egrbase += ( eager_array_size_other * 00767 sizeof ( struct QIB_7220_RcvEgr ) ); 00768 } 00769 for ( ctx = 0 ; ctx < LINDA_NUM_CONTEXTS ; ctx++ ) { 00770 DBGC ( linda, "Linda %p CTX %d eager array at %lx (%d " 00771 "entries)\n", linda, ctx, 00772 linda->recv_wq[ctx].eager_array, 00773 linda->recv_wq[ctx].eager_entries ); 00774 } 00775 00776 /* Set the BTH QP for Infinipath packets to an unused value */ 00777 memset ( &rcvbthqp, 0, sizeof ( rcvbthqp ) ); 00778 BIT_FILL_1 ( &rcvbthqp, RcvBTHQP, LINDA_QP_IDETH ); 00779 linda_writeq ( linda, &rcvbthqp, QIB_7220_RcvBTHQP_offset ); 00780 00781 return 0; 00782 }
Shut down receive datapath.
Definition at line 789 of file linda.c.
Referenced by linda_probe(), and linda_remove().
00789 { 00790 /* Nothing to do; all contexts were already disabled when the 00791 * queue pairs were destroyed 00792 */ 00793 }
| static int linda_create_cq | ( | struct ib_device * | ibdev, | |
| struct ib_completion_queue * | cq | |||
| ) | [static] |
Create completion queue.
| ibdev | Infiniband device | |
| cq | Completion queue |
| rc | Return status code |
Definition at line 809 of file linda.c.
References ib_completion_queue::cqn, DBGC, and ib_get_drvdata().
00810 { 00811 struct linda *linda = ib_get_drvdata ( ibdev ); 00812 static int cqn; 00813 00814 /* The hardware has no concept of completion queues. We 00815 * simply use the association between CQs and WQs (already 00816 * handled by the IB core) to decide which WQs to poll. 00817 * 00818 * We do set a CQN, just to avoid confusing debug messages 00819 * from the IB core. 00820 */ 00821 cq->cqn = ++cqn; 00822 DBGC ( linda, "Linda %p CQN %ld created\n", linda, cq->cqn ); 00823 00824 return 0; 00825 }
| static void linda_destroy_cq | ( | struct ib_device * | ibdev, | |
| struct ib_completion_queue * | cq | |||
| ) | [static] |
Destroy completion queue.
| ibdev | Infiniband device | |
| cq | Completion queue |
Definition at line 833 of file linda.c.
References ib_completion_queue::cqn, DBGC, and ib_get_drvdata().
00834 { 00835 struct linda *linda = ib_get_drvdata ( ibdev ); 00836 00837 /* Nothing to do */ 00838 DBGC ( linda, "Linda %p CQN %ld destroyed\n", linda, cq->cqn ); 00839 }
| static int linda_create_qp | ( | struct ib_device * | ibdev, | |
| struct ib_queue_pair * | qp | |||
| ) | [static] |
Create queue pair.
| ibdev | Infiniband device | |
| qp | Queue pair |
| rc | Return status code |
Definition at line 855 of file linda.c.
References ib_get_drvdata(), ib_wq_set_drvdata(), linda_alloc_ctx(), linda_create_recv_wq(), linda_create_send_wq(), linda_ctx_to_qpn(), linda_destroy_recv_wq(), linda_destroy_send_wq(), linda_free_ctx(), ib_queue_pair::qpn, ib_queue_pair::recv, linda::recv_wq, ib_queue_pair::send, and linda::send_wq.
00856 { 00857 struct linda *linda = ib_get_drvdata ( ibdev ); 00858 int ctx; 00859 int rc; 00860 00861 /* Locate an available context */ 00862 ctx = linda_alloc_ctx ( linda ); 00863 if ( ctx < 0 ) { 00864 rc = ctx; 00865 goto err_alloc_ctx; 00866 } 00867 00868 /* Set queue pair number based on context index */ 00869 qp->qpn = linda_ctx_to_qpn ( ctx ); 00870 00871 /* Set work-queue private data pointers */ 00872 ib_wq_set_drvdata ( &qp->send, &linda->send_wq[ctx] ); 00873 ib_wq_set_drvdata ( &qp->recv, &linda->recv_wq[ctx] ); 00874 00875 /* Create receive work queue */ 00876 if ( ( rc = linda_create_recv_wq ( linda, qp ) ) != 0 ) 00877 goto err_create_recv_wq; 00878 00879 /* Create send work queue */ 00880 if ( ( rc = linda_create_send_wq ( linda, qp ) ) != 0 ) 00881 goto err_create_send_wq; 00882 00883 return 0; 00884 00885 linda_destroy_send_wq ( linda, qp ); 00886 err_create_send_wq: 00887 linda_destroy_recv_wq ( linda, qp ); 00888 err_create_recv_wq: 00889 linda_free_ctx ( linda, ctx ); 00890 err_alloc_ctx: 00891 return rc; 00892 }
| static int linda_modify_qp | ( | struct ib_device * | ibdev, | |
| struct ib_queue_pair * | qp | |||
| ) | [static] |
Modify queue pair.
| ibdev | Infiniband device | |
| qp | Queue pair |
| rc | Return status code |
Definition at line 901 of file linda.c.
References DBGC, ib_get_drvdata(), and ib_queue_pair::qpn.
00902 { 00903 struct linda *linda = ib_get_drvdata ( ibdev ); 00904 00905 /* Nothing to do; the hardware doesn't have a notion of queue 00906 * keys 00907 */ 00908 DBGC ( linda, "Linda %p QPN %ld modified\n", linda, qp->qpn ); 00909 return 0; 00910 }
| static void linda_destroy_qp | ( | struct ib_device * | ibdev, | |
| struct ib_queue_pair * | qp | |||
| ) | [static] |
Destroy queue pair.
| ibdev | Infiniband device | |
| qp | Queue pair |
Definition at line 918 of file linda.c.
References ib_get_drvdata(), linda_destroy_recv_wq(), and linda_destroy_send_wq().
00919 { 00920 struct linda *linda = ib_get_drvdata ( ibdev ); 00921 00922 linda_destroy_send_wq ( linda, qp ); 00923 linda_destroy_recv_wq ( linda, qp ); 00924 }
| static int linda_post_send | ( | struct ib_device * | ibdev, | |
| struct ib_queue_pair * | qp, | |||
| struct ib_address_vector * | av, | |||
| struct io_buffer * | iobuf | |||
| ) | [static] |
Post send work queue entry.
| ibdev | Infiniband device | |
| qp | Queue pair | |
| av | Address vector | |
| iobuf | I/O buffer |
| rc | Return status code |
Definition at line 942 of file linda.c.
References assert, BIT_FILL_2, io_buffer::data, DBG_DISABLE, DBG_ENABLE, DBGC2, DBGLVL_IO, ib_get_drvdata(), IB_MAX_HEADER_SIZE, ib_push(), ib_wq_get_drvdata(), iob_len(), iob_populate(), iob_reserve, ib_work_queue::iobufs, linda_alloc_send_buf(), linda_send_buffer_offset(), linda_writel(), linda_writeq, memset(), NULL, ib_work_queue::num_wqes, offset, linda_send_work_queue::prod, ib_queue_pair::qpn, ib_queue_pair::send, and linda_send_work_queue::send_buf.
00945 { 00946 struct linda *linda = ib_get_drvdata ( ibdev ); 00947 struct ib_work_queue *wq = &qp->send; 00948 struct linda_send_work_queue *linda_wq = ib_wq_get_drvdata ( wq ); 00949 struct QIB_7220_SendPbc sendpbc; 00950 uint8_t header_buf[IB_MAX_HEADER_SIZE]; 00951 struct io_buffer headers; 00952 unsigned int send_buf; 00953 unsigned long start_offset; 00954 unsigned long offset; 00955 size_t len; 00956 ssize_t frag_len; 00957 uint32_t *data; 00958 00959 /* Allocate send buffer and calculate offset */ 00960 send_buf = linda_alloc_send_buf ( linda ); 00961 start_offset = offset = linda_send_buffer_offset ( linda, send_buf ); 00962 00963 /* Store I/O buffer and send buffer index */ 00964 assert ( wq->iobufs[linda_wq->prod] == NULL ); 00965 wq->iobufs[linda_wq->prod] = iobuf; 00966 linda_wq->send_buf[linda_wq->prod] = send_buf; 00967 00968 /* Construct headers */ 00969 iob_populate ( &headers, header_buf, 0, sizeof ( header_buf ) ); 00970 iob_reserve ( &headers, sizeof ( header_buf ) ); 00971 ib_push ( ibdev, &headers, qp, iob_len ( iobuf ), av ); 00972 00973 /* Calculate packet length */ 00974 len = ( ( sizeof ( sendpbc ) + iob_len ( &headers ) + 00975 iob_len ( iobuf ) + 3 ) & ~3 ); 00976 00977 /* Construct send per-buffer control word */ 00978 memset ( &sendpbc, 0, sizeof ( sendpbc ) ); 00979 BIT_FILL_2 ( &sendpbc, 00980 LengthP1_toibc, ( ( len >> 2 ) - 1 ), 00981 VL15, 1 ); 00982 00983 /* Write SendPbc */ 00984 DBG_DISABLE ( DBGLVL_IO ); 00985 linda_writeq ( linda, &sendpbc, offset ); 00986 offset += sizeof ( sendpbc ); 00987 00988 /* Write headers */ 00989 for ( data = headers.data, frag_len = iob_len ( &headers ) ; 00990 frag_len > 0 ; data++, offset += 4, frag_len -= 4 ) { 00991 linda_writel ( linda, *data, offset ); 00992 } 00993 00994 /* Write data */ 00995 for ( data = iobuf->data, frag_len = iob_len ( iobuf ) ; 00996 frag_len > 0 ; data++, offset += 4, frag_len -= 4 ) { 00997 linda_writel ( linda, *data, offset ); 00998 } 00999 DBG_ENABLE ( DBGLVL_IO ); 01000 01001 assert ( ( start_offset + len ) == offset ); 01002 DBGC2 ( linda, "Linda %p QPN %ld TX %d(%d) posted [%lx,%lx)\n", 01003 linda, qp->qpn, send_buf, linda_wq->prod, 01004 start_offset, offset ); 01005 01006 /* Increment producer counter */ 01007 linda_wq->prod = ( ( linda_wq->prod + 1 ) & ( wq->num_wqes - 1 ) ); 01008 01009 return 0; 01010 }
| static void linda_complete_send | ( | struct ib_device * | ibdev, | |
| struct ib_queue_pair * | qp, | |||
| unsigned int | wqe_idx | |||
| ) | [static] |
Complete send work queue entry.
| ibdev | Infiniband device | |
| qp | Queue pair | |
| wqe_idx | Work queue entry index |
Definition at line 1019 of file linda.c.
References assert, DBGC2, ib_complete_send(), ib_get_drvdata(), ib_wq_get_drvdata(), ib_work_queue::iobufs, linda_free_send_buf(), NULL, ib_queue_pair::qpn, ib_queue_pair::send, and linda_send_work_queue::send_buf.
Referenced by linda_poll_send_wq().
01021 { 01022 struct linda *linda = ib_get_drvdata ( ibdev ); 01023 struct ib_work_queue *wq = &qp->send; 01024 struct linda_send_work_queue *linda_wq = ib_wq_get_drvdata ( wq ); 01025 struct io_buffer *iobuf; 01026 unsigned int send_buf; 01027 01028 /* Parse completion */ 01029 send_buf = linda_wq->send_buf[wqe_idx]; 01030 DBGC2 ( linda, "Linda %p QPN %ld TX %d(%d) complete\n", 01031 linda, qp->qpn, send_buf, wqe_idx ); 01032 01033 /* Complete work queue entry */ 01034 iobuf = wq->iobufs[wqe_idx]; 01035 assert ( iobuf != NULL ); 01036 ib_complete_send ( ibdev, qp, iobuf, 0 ); 01037 wq->iobufs[wqe_idx] = NULL; 01038 01039 /* Free send buffer */ 01040 linda_free_send_buf ( linda, send_buf ); 01041 }
| static void linda_poll_send_wq | ( | struct ib_device * | ibdev, | |
| struct ib_queue_pair * | qp | |||
| ) | [static] |
Poll send work queue.
| ibdev | Infiniband device | |
| qp | Queue pair |
Definition at line 1049 of file linda.c.
References linda_send_work_queue::cons, ib_work_queue::fill, ib_get_drvdata(), ib_wq_get_drvdata(), linda_complete_send(), linda_send_buf_in_use(), ib_work_queue::num_wqes, ib_queue_pair::send, and linda_send_work_queue::send_buf.
Referenced by linda_poll_cq().
01050 { 01051 struct linda *linda = ib_get_drvdata ( ibdev ); 01052 struct ib_work_queue *wq = &qp->send; 01053 struct linda_send_work_queue *linda_wq = ib_wq_get_drvdata ( wq ); 01054 unsigned int send_buf; 01055 01056 /* Look for completions */ 01057 while ( wq->fill ) { 01058 01059 /* Check to see if send buffer has completed */ 01060 send_buf = linda_wq->send_buf[linda_wq->cons]; 01061 if ( linda_send_buf_in_use ( linda, send_buf ) ) 01062 break; 01063 01064 /* Complete this buffer */ 01065 linda_complete_send ( ibdev, qp, linda_wq->cons ); 01066 01067 /* Increment consumer counter */ 01068 linda_wq->cons = ( ( linda_wq->cons + 1 ) & 01069 ( wq->num_wqes - 1 ) ); 01070 } 01071 }
| static int linda_post_recv | ( | struct ib_device * | ibdev, | |
| struct ib_queue_pair * | qp, | |||
| struct io_buffer * | iobuf | |||
| ) | [static] |
Post receive work queue entry.
| ibdev | Infiniband device | |
| qp | Queue pair | |
| iobuf | I/O buffer |
| rc | Return status code |
Definition at line 1081 of file linda.c.
References assert, BIT_FILL_1, BIT_FILL_2, io_buffer::data, DBGC, DBGC2, linda_recv_work_queue::eager_array, linda_recv_work_queue::eager_entries, linda_recv_work_queue::eager_prod, EINVAL, ib_get_drvdata(), ib_wq_get_drvdata(), iob_tailroom(), ib_work_queue::iobufs, LINDA_EAGER_BUFFER_16K, LINDA_EAGER_BUFFER_2K, LINDA_EAGER_BUFFER_32K, LINDA_EAGER_BUFFER_4K, LINDA_EAGER_BUFFER_64K, LINDA_EAGER_BUFFER_8K, LINDA_EAGER_BUFFER_ALIGN, LINDA_EAGER_BUFFER_NONE, linda_qpn_to_ctx(), LINDA_RECV_PAYLOAD_SIZE, linda_writeq_array64k, linda_writeq_array8b, linker_assert, memset(), NULL, ib_work_queue::num_wqes, QIB_7220_RcvEgrIndexHead0_offset, ib_queue_pair::qpn, ib_queue_pair::recv, and virt_to_bus().
01083 { 01084 struct linda *linda = ib_get_drvdata ( ibdev ); 01085 struct ib_work_queue *wq = &qp->recv; 01086 struct linda_recv_work_queue *linda_wq = ib_wq_get_drvdata ( wq ); 01087 struct QIB_7220_RcvEgr rcvegr; 01088 struct QIB_7220_scalar rcvegrindexhead; 01089 unsigned int ctx = linda_qpn_to_ctx ( qp->qpn ); 01090 physaddr_t addr; 01091 size_t len; 01092 unsigned int wqe_idx; 01093 unsigned int bufsize; 01094 01095 /* Sanity checks */ 01096 addr = virt_to_bus ( iobuf->data ); 01097 len = iob_tailroom ( iobuf ); 01098 if ( addr & ( LINDA_EAGER_BUFFER_ALIGN - 1 ) ) { 01099 DBGC ( linda, "Linda %p QPN %ld misaligned RX buffer " 01100 "(%08lx)\n", linda, qp->qpn, addr ); 01101 return -EINVAL; 01102 } 01103 if ( len != LINDA_RECV_PAYLOAD_SIZE ) { 01104 DBGC ( linda, "Linda %p QPN %ld wrong RX buffer size (%zd)\n", 01105 linda, qp->qpn, len ); 01106 return -EINVAL; 01107 } 01108 01109 /* Calculate eager producer index and WQE index */ 01110 wqe_idx = ( linda_wq->eager_prod & ( wq->num_wqes - 1 ) ); 01111 assert ( wq->iobufs[wqe_idx] == NULL ); 01112 01113 /* Store I/O buffer */ 01114 wq->iobufs[wqe_idx] = iobuf; 01115 01116 /* Calculate buffer size */ 01117 switch ( LINDA_RECV_PAYLOAD_SIZE ) { 01118 case 2048: bufsize = LINDA_EAGER_BUFFER_2K; break; 01119 case 4096: bufsize = LINDA_EAGER_BUFFER_4K; break; 01120 case 8192: bufsize = LINDA_EAGER_BUFFER_8K; break; 01121 case 16384: bufsize = LINDA_EAGER_BUFFER_16K; break; 01122 case 32768: bufsize = LINDA_EAGER_BUFFER_32K; break; 01123 case 65536: bufsize = LINDA_EAGER_BUFFER_64K; break; 01124 default: linker_assert ( 0, invalid_rx_payload_size ); 01125 bufsize = LINDA_EAGER_BUFFER_NONE; 01126 } 01127 01128 /* Post eager buffer */ 01129 memset ( &rcvegr, 0, sizeof ( rcvegr ) ); 01130 BIT_FILL_2 ( &rcvegr, 01131 Addr, ( addr >> 11 ), 01132 BufSize, bufsize ); 01133 linda_writeq_array8b ( linda, &rcvegr, 01134 linda_wq->eager_array, linda_wq->eager_prod ); 01135 DBGC2 ( linda, "Linda %p QPN %ld RX egr %d(%d) posted [%lx,%lx)\n", 01136 linda, qp->qpn, linda_wq->eager_prod, wqe_idx, 01137 addr, ( addr + len ) ); 01138 01139 /* Increment producer index */ 01140 linda_wq->eager_prod = ( ( linda_wq->eager_prod + 1 ) & 01141 ( linda_wq->eager_entries - 1 ) ); 01142 01143 /* Update head index */ 01144 memset ( &rcvegrindexhead, 0, sizeof ( rcvegrindexhead ) ); 01145 BIT_FILL_1 ( &rcvegrindexhead, 01146 Value, ( ( linda_wq->eager_prod + 1 ) & 01147 ( linda_wq->eager_entries - 1 ) ) ); 01148 linda_writeq_array64k ( linda, &rcvegrindexhead, 01149 QIB_7220_RcvEgrIndexHead0_offset, ctx ); 01150 01151 return 0; 01152 }
| static void linda_complete_recv | ( | struct ib_device * | ibdev, | |
| struct ib_queue_pair * | qp, | |||
| unsigned int | header_offs | |||
| ) | [static] |
Complete receive work queue entry.
| ibdev | Infiniband device | |
| qp | Queue pair | |
| header_offs | Header offset |
Definition at line 1161 of file linda.c.
References assert, BIT_GET, io_buffer::data, DBGC, DBGC2, DBGCP_HDA, linda_recv_work_queue::eager_array, linda_recv_work_queue::eager_cons, linda_recv_work_queue::eager_entries, linda_recv_work_queue::eager_prod, ECANCELED, EIO, ib_work_queue::fill, linda_recv_work_queue::header, ib_complete_recv(), ib_get_drvdata(), ib_pull(), ib_wq_get_drvdata(), iob_populate(), iob_put, ib_work_queue::iobufs, LINDA_RECV_HEADER_SIZE, linda_writeq_array8b, memset(), NULL, ib_work_queue::num_wqes, ParityErr, ib_queue_pair::qpn, ib_queue_pair::recv, and strerror().
Referenced by linda_poll_recv_wq().
01163 { 01164 struct linda *linda = ib_get_drvdata ( ibdev ); 01165 struct ib_work_queue *wq = &qp->recv; 01166 struct linda_recv_work_queue *linda_wq = ib_wq_get_drvdata ( wq ); 01167 struct QIB_7220_RcvHdrFlags *rcvhdrflags; 01168 struct QIB_7220_RcvEgr rcvegr; 01169 struct io_buffer headers; 01170 struct io_buffer *iobuf; 01171 struct ib_queue_pair *intended_qp; 01172 struct ib_address_vector av; 01173 unsigned int rcvtype; 01174 unsigned int pktlen; 01175 unsigned int egrindex; 01176 unsigned int useegrbfr; 01177 unsigned int iberr, mkerr, tiderr, khdrerr, mtuerr; 01178 unsigned int lenerr, parityerr, vcrcerr, icrcerr; 01179 unsigned int err; 01180 unsigned int hdrqoffset; 01181 unsigned int header_len; 01182 unsigned int padded_payload_len; 01183 unsigned int wqe_idx; 01184 size_t payload_len; 01185 int qp0; 01186 int rc; 01187 01188 /* RcvHdrFlags are at the end of the header entry */ 01189 rcvhdrflags = ( linda_wq->header + header_offs + 01190 LINDA_RECV_HEADER_SIZE - sizeof ( *rcvhdrflags ) ); 01191 rcvtype = BIT_GET ( rcvhdrflags, RcvType ); 01192 pktlen = ( BIT_GET ( rcvhdrflags, PktLen ) << 2 ); 01193 egrindex = BIT_GET ( rcvhdrflags, EgrIndex ); 01194 useegrbfr = BIT_GET ( rcvhdrflags, UseEgrBfr ); 01195 hdrqoffset = ( BIT_GET ( rcvhdrflags, HdrqOffset ) << 2 ); 01196 iberr = BIT_GET ( rcvhdrflags, IBErr ); 01197 mkerr = BIT_GET ( rcvhdrflags, MKErr ); 01198 tiderr = BIT_GET ( rcvhdrflags, TIDErr ); 01199 khdrerr = BIT_GET ( rcvhdrflags, KHdrErr ); 01200 mtuerr = BIT_GET ( rcvhdrflags, MTUErr ); 01201 lenerr = BIT_GET ( rcvhdrflags, LenErr ); 01202 parityerr = BIT_GET ( rcvhdrflags, ParityErr ); 01203 vcrcerr = BIT_GET ( rcvhdrflags, VCRCErr ); 01204 icrcerr = BIT_GET ( rcvhdrflags, ICRCErr ); 01205 header_len = ( LINDA_RECV_HEADER_SIZE - hdrqoffset - 01206 sizeof ( *rcvhdrflags ) ); 01207 padded_payload_len = ( pktlen - header_len - 4 /* ICRC */ ); 01208 err = ( iberr | mkerr | tiderr | khdrerr | mtuerr | 01209 lenerr | parityerr | vcrcerr | icrcerr ); 01210 /* IB header is placed immediately before RcvHdrFlags */ 01211 iob_populate ( &headers, ( ( ( void * ) rcvhdrflags ) - header_len ), 01212 header_len, header_len ); 01213 01214 /* Dump diagnostic information */ 01215 if ( err || ( ! useegrbfr ) ) { 01216 DBGC ( linda, "Linda %p QPN %ld RX egr %d%s hdr %d type %d " 01217 "len %d(%d+%d+4)%s%s%s%s%s%s%s%s%s%s%s\n", linda, 01218 qp->qpn, egrindex, ( useegrbfr ? "" : "(unused)" ), 01219 ( header_offs / LINDA_RECV_HEADER_SIZE ), rcvtype, 01220 pktlen, header_len, padded_payload_len, 01221 ( err ? " [Err" : "" ), ( iberr ? " IB" : "" ), 01222 ( mkerr ? " MK" : "" ), ( tiderr ? " TID" : "" ), 01223 ( khdrerr ? " KHdr" : "" ), ( mtuerr ? " MTU" : "" ), 01224 ( lenerr ? " Len" : "" ), ( parityerr ? " Parity" : ""), 01225 ( vcrcerr ? " VCRC" : "" ), ( icrcerr ? " ICRC" : "" ), 01226 ( err ? "]" : "" ) ); 01227 } else { 01228 DBGC2 ( linda, "Linda %p QPN %ld RX egr %d hdr %d type %d " 01229 "len %d(%d+%d+4)\n", linda, qp->qpn, egrindex, 01230 ( header_offs / LINDA_RECV_HEADER_SIZE ), rcvtype, 01231 pktlen, header_len, padded_payload_len ); 01232 } 01233 DBGCP_HDA ( linda, hdrqoffset, headers.data, 01234 ( header_len + sizeof ( *rcvhdrflags ) ) ); 01235 01236 /* Parse header to generate address vector */ 01237 qp0 = ( qp->qpn == 0 ); 01238 intended_qp = NULL; 01239 if ( ( rc = ib_pull ( ibdev, &headers, ( qp0 ? &intended_qp : NULL ), 01240 &payload_len, &av ) ) != 0 ) { 01241 DBGC ( linda, "Linda %p could not parse headers: %s\n", 01242 linda, strerror ( rc ) ); 01243 err = 1; 01244 } 01245 if ( ! intended_qp ) 01246 intended_qp = qp; 01247 01248 /* Complete this buffer and any skipped buffers. Note that 01249 * when the hardware runs out of buffers, it will repeatedly 01250 * report the same buffer (the tail) as a TID error, and that 01251 * it also has a habit of sometimes skipping over several 01252 * buffers at once. 01253 */ 01254 while ( 1 ) { 01255 01256 /* If we have caught up to the producer counter, stop. 01257 * This will happen when the hardware first runs out 01258 * of buffers and starts reporting TID errors against 01259 * the eager buffer it wants to use next. 01260 */ 01261 if ( linda_wq->eager_cons == linda_wq->eager_prod ) 01262 break; 01263 01264 /* If we have caught up to where we should be after 01265 * completing this egrindex, stop. We phrase the test 01266 * this way to avoid completing the entire ring when 01267 * we receive the same egrindex twice in a row. 01268 */ 01269 if ( ( linda_wq->eager_cons == 01270 ( ( egrindex + 1 ) & ( linda_wq->eager_entries - 1 ) ))) 01271 break; 01272 01273 /* Identify work queue entry and corresponding I/O 01274 * buffer. 01275 */ 01276 wqe_idx = ( linda_wq->eager_cons & ( wq->num_wqes - 1 ) ); 01277 iobuf = wq->iobufs[wqe_idx]; 01278 assert ( iobuf != NULL ); 01279 wq->iobufs[wqe_idx] = NULL; 01280 01281 /* Complete the eager buffer */ 01282 if ( linda_wq->eager_cons == egrindex ) { 01283 /* Completing the eager buffer described in 01284 * this header entry. 01285 */ 01286 iob_put ( iobuf, payload_len ); 01287 rc = ( err ? -EIO : ( useegrbfr ? 0 : -ECANCELED ) ); 01288 /* Redirect to target QP if necessary */ 01289 if ( qp != intended_qp ) { 01290 DBGC ( linda, "Linda %p redirecting QPN %ld " 01291 "=> %ld\n", 01292 linda, qp->qpn, intended_qp->qpn ); 01293 /* Compensate for incorrect fill levels */ 01294 qp->recv.fill--; 01295 intended_qp->recv.fill++; 01296 } 01297 ib_complete_recv ( ibdev, intended_qp, &av, iobuf, rc); 01298 } else { 01299 /* Completing on a skipped-over eager buffer */ 01300 ib_complete_recv ( ibdev, qp, &av, iobuf, -ECANCELED ); 01301 } 01302 01303 /* Clear eager buffer */ 01304 memset ( &rcvegr, 0, sizeof ( rcvegr ) ); 01305 linda_writeq_array8b ( linda, &rcvegr, linda_wq->eager_array, 01306 linda_wq->eager_cons ); 01307 01308 /* Increment consumer index */ 01309 linda_wq->eager_cons = ( ( linda_wq->eager_cons + 1 ) & 01310 ( linda_wq->eager_entries - 1 ) ); 01311 } 01312 }
| static void linda_poll_recv_wq | ( | struct ib_device * | ibdev, | |
| struct ib_queue_pair * | qp | |||
| ) | [static] |
Poll receive work queue.
| ibdev | Infiniband device | |
| qp | Queue pair |
Definition at line 1320 of file linda.c.
References BIT_FILL_2, BIT_GET, linda_recv_work_queue::header_cons, linda_recv_work_queue::header_prod, ib_get_drvdata(), ib_wq_get_drvdata(), linda_complete_recv(), linda_qpn_to_ctx(), LINDA_RECV_HEADER_SIZE, LINDA_RECV_HEADERS_SIZE, linda_writeq_array64k, memset(), QIB_7220_RcvHdrHead0_offset, ib_queue_pair::qpn, and ib_queue_pair::recv.
Referenced by linda_poll_cq().
01321 { 01322 struct linda *linda = ib_get_drvdata ( ibdev ); 01323 struct ib_work_queue *wq = &qp->recv; 01324 struct linda_recv_work_queue *linda_wq = ib_wq_get_drvdata ( wq ); 01325 struct QIB_7220_RcvHdrHead0 rcvhdrhead; 01326 unsigned int ctx = linda_qpn_to_ctx ( qp->qpn ); 01327 unsigned int header_prod; 01328 01329 /* Check for received packets */ 01330 header_prod = ( BIT_GET ( &linda_wq->header_prod, Value ) << 2 ); 01331 if ( header_prod == linda_wq->header_cons ) 01332 return; 01333 01334 /* Process all received packets */ 01335 while ( linda_wq->header_cons != header_prod ) { 01336 01337 /* Complete the receive */ 01338 linda_complete_recv ( ibdev, qp, linda_wq->header_cons ); 01339 01340 /* Increment the consumer offset */ 01341 linda_wq->header_cons += LINDA_RECV_HEADER_SIZE; 01342 linda_wq->header_cons %= LINDA_RECV_HEADERS_SIZE; 01343 } 01344 01345 /* Update consumer offset */ 01346 memset ( &rcvhdrhead, 0, sizeof ( rcvhdrhead ) ); 01347 BIT_FILL_2 ( &rcvhdrhead, 01348 RcvHeadPointer, ( linda_wq->header_cons >> 2 ), 01349 counter, 1 ); 01350 linda_writeq_array64k ( linda, &rcvhdrhead, 01351 QIB_7220_RcvHdrHead0_offset, ctx ); 01352 }
| static void linda_poll_cq | ( | struct ib_device * | ibdev, | |
| struct ib_completion_queue * | cq | |||
| ) | [static] |
Poll completion queue.
| ibdev | Infiniband device | |
| cq | Completion queue |
Definition at line 1360 of file linda.c.
References ib_work_queue::is_send, linda_poll_recv_wq(), linda_poll_send_wq(), ib_work_queue::list, list_for_each_entry, ib_work_queue::qp, and ib_completion_queue::work_queues.
01361 { 01362 struct ib_work_queue *wq; 01363 01364 /* Poll associated send and receive queues */ 01365 list_for_each_entry ( wq, &cq->work_queues, list ) { 01366 if ( wq->is_send ) { 01367 linda_poll_send_wq ( ibdev, wq->qp ); 01368 } else { 01369 linda_poll_recv_wq ( ibdev, wq->qp ); 01370 } 01371 } 01372 }
| static void linda_poll_eq | ( | struct ib_device * | ibdev | ) | [static] |
Poll event queue.
| ibdev | Infiniband device |
Definition at line 1386 of file linda.c.
References BIT_FILL_1, BIT_GET, DBG_DISABLE, DBG_ENABLE, DBGLVL_IO, ib_get_drvdata(), linda_link_state_changed(), linda_readq, linda_writeq, memset(), QIB_7220_ErrClear_offset, and QIB_7220_ErrStatus_offset.
01386 { 01387 struct linda *linda = ib_get_drvdata ( ibdev ); 01388 struct QIB_7220_ErrStatus errstatus; 01389 struct QIB_7220_ErrClear errclear; 01390 01391 /* Check for link status changes */ 01392 DBG_DISABLE ( DBGLVL_IO ); 01393 linda_readq ( linda, &errstatus, QIB_7220_ErrStatus_offset ); 01394 DBG_ENABLE ( DBGLVL_IO ); 01395 if ( BIT_GET ( &errstatus, IBStatusChanged ) ) { 01396 linda_link_state_changed ( ibdev ); 01397 memset ( &errclear, 0, sizeof ( errclear ) ); 01398 BIT_FILL_1 ( &errclear, IBStatusChangedClear, 1 ); 01399 linda_writeq ( linda, &errclear, QIB_7220_ErrClear_offset ); 01400 } 01401 }
| static int linda_open | ( | struct ib_device * | ibdev | ) | [static] |
Initialise Infiniband link.
| ibdev | Infiniband device |
| rc | Return status code |
Definition at line 1416 of file linda.c.
References BIT_SET, ib_get_drvdata(), linda_readq, linda_writeq, and QIB_7220_Control_offset.
01416 { 01417 struct linda *linda = ib_get_drvdata ( ibdev ); 01418 struct QIB_7220_Control control; 01419 01420 /* Disable link */ 01421 linda_readq ( linda, &control, QIB_7220_Control_offset ); 01422 BIT_SET ( &control, LinkEn, 1 ); 01423 linda_writeq ( linda, &control, QIB_7220_Control_offset ); 01424 return 0; 01425 }
| static void linda_close | ( | struct ib_device * | ibdev | ) | [static] |
Close Infiniband link.
| ibdev | Infiniband device |
Definition at line 1432 of file linda.c.
References BIT_SET, ib_get_drvdata(), linda_readq, linda_writeq, and QIB_7220_Control_offset.
01432 { 01433 struct linda *linda = ib_get_drvdata ( ibdev ); 01434 struct QIB_7220_Control control; 01435 01436 /* Disable link */ 01437 linda_readq ( linda, &control, QIB_7220_Control_offset ); 01438 BIT_SET ( &control, LinkEn, 0 ); 01439 linda_writeq ( linda, &control, QIB_7220_Control_offset ); 01440 }
| static int linda_mcast_attach | ( | struct ib_device * | ibdev, | |
| struct ib_queue_pair * | qp, | |||
| struct ib_gid * | gid | |||
| ) | [static] |
Attach to multicast group.
| ibdev | Infiniband device | |
| qp | Queue pair | |
| gid | Multicast GID |
| rc | Return status code |
Definition at line 1457 of file linda.c.
References ib_get_drvdata().
01459 { 01460 struct linda *linda = ib_get_drvdata ( ibdev ); 01461 01462 ( void ) linda; 01463 ( void ) qp; 01464 ( void ) gid; 01465 return 0; 01466 }
| static void linda_mcast_detach | ( | struct ib_device * | ibdev, | |
| struct ib_queue_pair * | qp, | |||
| struct ib_gid * | gid | |||
| ) | [static] |
Detach from multicast group.
| ibdev | Infiniband device | |
| qp | Queue pair | |
| gid | Multicast GID |
Definition at line 1475 of file linda.c.
References ib_get_drvdata().
01477 { 01478 struct linda *linda = ib_get_drvdata ( ibdev ); 01479 01480 ( void ) linda; 01481 ( void ) qp; 01482 ( void ) gid; 01483 }
| static int linda_i2c_read_bit | ( | struct bit_basher * | basher, | |
| unsigned int | bit_id | |||
| ) | [static] |
Read Linda I2C line status.
| basher | Bit-bashing interface | |
| bit_id | Bit number |
| zero | Input is a logic 0 | |
| non-zero | Input is a logic 1 |
Definition at line 1525 of file linda.c.
References i2c_bit_basher::basher, BIT_GET, container_of, DBG_DISABLE, DBG_ENABLE, DBGLVL_IO, linda::i2c, linda_i2c_bits, linda_readq, and QIB_7220_EXTStatus_offset.
01526 { 01527 struct linda *linda = 01528 container_of ( basher, struct linda, i2c.basher ); 01529 struct QIB_7220_EXTStatus extstatus; 01530 unsigned int status; 01531 01532 DBG_DISABLE ( DBGLVL_IO ); 01533 01534 linda_readq ( linda, &extstatus, QIB_7220_EXTStatus_offset ); 01535 status = ( BIT_GET ( &extstatus, GPIOIn ) & linda_i2c_bits[bit_id] ); 01536 01537 DBG_ENABLE ( DBGLVL_IO ); 01538 01539 return status; 01540 }
| static void linda_i2c_write_bit | ( | struct bit_basher * | basher, | |
| unsigned int | bit_id, | |||
| unsigned long | data | |||
| ) | [static] |
Write Linda I2C line status.
| basher | Bit-bashing interface | |
| bit_id | Bit number | |
| data | Value to write |
Definition at line 1549 of file linda.c.
References i2c_bit_basher::basher, BIT_GET, BIT_SET, container_of, DBG_DISABLE, DBG_ENABLE, DBGLVL_IO, linda::i2c, linda_i2c_bits, linda_readq, linda_writeq, mb(), QIB_7220_EXTCtrl_offset, and QIB_7220_GPIOOut_offset.
01550 { 01551 struct linda *linda = 01552 container_of ( basher, struct linda, i2c.basher ); 01553 struct QIB_7220_EXTCtrl extctrl; 01554 struct QIB_7220_GPIO gpioout; 01555 unsigned int bit = linda_i2c_bits[bit_id]; 01556 unsigned int outputs = 0; 01557 unsigned int output_enables = 0; 01558 01559 DBG_DISABLE ( DBGLVL_IO ); 01560 01561 /* Read current GPIO mask and outputs */ 01562 linda_readq ( linda, &extctrl, QIB_7220_EXTCtrl_offset ); 01563 linda_readq ( linda, &gpioout, QIB_7220_GPIOOut_offset ); 01564 01565 /* Update outputs and output enables. I2C lines are tied 01566 * high, so we always set the output to 0 and use the output 01567 * enable to control the line. 01568 */ 01569 output_enables = BIT_GET ( &extctrl, GPIOOe ); 01570 output_enables = ( ( output_enables & ~bit ) | ( ~data & bit ) ); 01571 outputs = BIT_GET ( &gpioout, GPIO ); 01572 outputs = ( outputs & ~bit ); 01573 BIT_SET ( &extctrl, GPIOOe, output_enables ); 01574 BIT_SET ( &gpioout, GPIO, outputs ); 01575 01576 /* Write the output enable first; that way we avoid logic 01577 * hazards. 01578 */ 01579 linda_writeq ( linda, &extctrl, QIB_7220_EXTCtrl_offset ); 01580 linda_writeq ( linda, &gpioout, QIB_7220_GPIOOut_offset ); 01581 mb(); 01582 01583 DBG_ENABLE ( DBGLVL_IO ); 01584 }
| static int linda_init_i2c | ( | struct linda * | linda | ) | [static] |
Initialise Linda I2C subsystem.
| rc | Return status code |
Definition at line 1598 of file linda.c.
References DBGC, DBGC2, linda::eeprom, ENODEV, i2c_bit_basher::i2c, linda::i2c, i2c_check_presence(), init_i2c_bit_basher(), init_i2c_eeprom(), and strerror().
Referenced by linda_probe().
01598 { 01599 static int try_eeprom_address[] = { 0x51, 0x50 }; 01600 unsigned int i; 01601 int rc; 01602 01603 /* Initialise bus */ 01604 if ( ( rc = init_i2c_bit_basher ( &linda->i2c, 01605 &linda_i2c_basher_ops ) ) != 0 ) { 01606 DBGC ( linda, "Linda %p could not initialise I2C bus: %s\n", 01607 linda, strerror ( rc ) ); 01608 return rc; 01609 } 01610 01611 /* Probe for devices */ 01612 for ( i = 0 ; i < ( sizeof ( try_eeprom_address ) / 01613 sizeof ( try_eeprom_address[0] ) ) ; i++ ) { 01614 init_i2c_eeprom ( &linda->eeprom, try_eeprom_address[i] ); 01615 if ( ( rc = i2c_check_presence ( &linda->i2c.i2c, 01616 &linda->eeprom ) ) == 0 ) { 01617 DBGC2 ( linda, "Linda %p found EEPROM at %02x\n", 01618 linda, try_eeprom_address[i] ); 01619 return 0; 01620 } 01621 } 01622 01623 DBGC ( linda, "Linda %p could not find EEPROM\n", linda ); 01624 return -ENODEV; 01625 }
| static int linda_read_eeprom | ( | struct linda * | linda, | |
| struct ib_gid_half * | guid | |||
| ) | [static] |
Read EEPROM parameters.
| rc | Return status code |
Definition at line 1634 of file linda.c.
References ib_gid_half::bytes, DBG_LOG, DBGC, DBGC2, linda::eeprom, i2c_bit_basher::i2c, linda::i2c, LINDA_EEPROM_GUID_OFFSET, LINDA_EEPROM_SERIAL_OFFSET, LINDA_EEPROM_SERIAL_SIZE, i2c_interface::read, strerror(), and ib_gid_half::u.
Referenced by linda_probe().
01635 { 01636 struct i2c_interface *i2c = &linda->i2c.i2c; 01637 int rc; 01638 01639 /* Read GUID */ 01640 if ( ( rc = i2c->read ( i2c, &linda->eeprom, LINDA_EEPROM_GUID_OFFSET, 01641 guid->u.bytes, sizeof ( *guid ) ) ) != 0 ) { 01642 DBGC ( linda, "Linda %p could not read GUID: %s\n", 01643 linda, strerror ( rc ) ); 01644 return rc; 01645 } 01646 DBGC2 ( linda, "Linda %p has GUID %02x:%02x:%02x:%02x:%02x:%02x:" 01647 "%02x:%02x\n", linda, guid->u.bytes[0], guid->u.bytes[1], 01648 guid->u.bytes[2], guid->u.bytes[3], guid->u.bytes[4], 01649 guid->u.bytes[5], guid->u.bytes[6], guid->u.bytes[7] ); 01650 01651 /* Read serial number (debug only) */ 01652 if ( DBG_LOG ) { 01653 uint8_t serial[LINDA_EEPROM_SERIAL_SIZE + 1]; 01654 01655 serial[ sizeof ( serial ) - 1 ] = '\0'; 01656 if ( ( rc = i2c->read ( i2c, &linda->eeprom, 01657 LINDA_EEPROM_SERIAL_OFFSET, serial, 01658 ( sizeof ( serial ) - 1 ) ) ) != 0 ) { 01659 DBGC ( linda, "Linda %p could not read serial: %s\n", 01660 linda, strerror ( rc ) ); 01661 return rc; 01662 } 01663 DBGC2 ( linda, "Linda %p has serial number \"%s\"\n", 01664 linda, serial ); 01665 } 01666 01667 return 0; 01668 }
| static int linda_ib_epb_request | ( | struct linda * | linda | ) | [static] |
Request ownership of the IB external parallel bus.
| rc | Return status code |
Definition at line 1683 of file linda.c.
References BIT_FILL_1, BIT_GET, DBGC, ETIMEDOUT, LINDA_EPB_REQUEST_MAX_WAIT_US, linda_readq, linda_writeq, memset(), QIB_7220_ibsd_epb_access_ctrl_offset, and udelay().
Referenced by linda_ib_epb_mod_reg(), and linda_ib_epb_ram_xfer().
01683 { 01684 struct QIB_7220_ibsd_epb_access_ctrl access; 01685 unsigned int i; 01686 01687 /* Request ownership */ 01688 memset ( &access, 0, sizeof ( access ) ); 01689 BIT_FILL_1 ( &access, sw_ib_epb_req, 1 ); 01690 linda_writeq ( linda, &access, QIB_7220_ibsd_epb_access_ctrl_offset ); 01691 01692 /* Wait for ownership to be granted */ 01693 for ( i = 0 ; i < LINDA_EPB_REQUEST_MAX_WAIT_US ; i++ ) { 01694 linda_readq ( linda, &access, 01695 QIB_7220_ibsd_epb_access_ctrl_offset ); 01696 if ( BIT_GET ( &access, sw_ib_epb_req_granted ) ) 01697 return 0; 01698 udelay ( 1 ); 01699 } 01700 01701 DBGC ( linda, "Linda %p timed out waiting for IB EPB request\n", 01702 linda ); 01703 return -ETIMEDOUT; 01704 }
| static int linda_ib_epb_wait | ( | struct linda * | linda, | |
| struct QIB_7220_ibsd_epb_transaction_reg * | xact | |||
| ) | [static] |
Wait for IB external parallel bus transaction to complete.
| rc | Return status code |
Definition at line 1713 of file linda.c.
References BIT_GET, DBGC, EIO, ETIMEDOUT, LINDA_EPB_XACT_MAX_WAIT_US, linda_readq, QIB_7220_ibsd_epb_transaction_reg_offset, and udelay().
Referenced by linda_ib_epb_read(), and linda_ib_epb_write().
01714 { 01715 unsigned int i; 01716 01717 /* Discard first read to allow for signals crossing clock domains */ 01718 linda_readq ( linda, xact, QIB_7220_ibsd_epb_transaction_reg_offset ); 01719 01720 for ( i = 0 ; i < LINDA_EPB_XACT_MAX_WAIT_US ; i++ ) { 01721 linda_readq ( linda, xact, 01722 QIB_7220_ibsd_epb_transaction_reg_offset ); 01723 if ( BIT_GET ( xact, ib_epb_rdy ) ) { 01724 if ( BIT_GET ( xact, ib_epb_req_error ) ) { 01725 DBGC ( linda, "Linda %p EPB transaction " 01726 "failed\n", linda ); 01727 return -EIO; 01728 } else { 01729 return 0; 01730 } 01731 } 01732 udelay ( 1 ); 01733 } 01734 01735 DBGC ( linda, "Linda %p timed out waiting for IB EPB transaction\n", 01736 linda ); 01737 return -ETIMEDOUT; 01738 }
| static void linda_ib_epb_release | ( | struct linda * | linda | ) | [static] |
Release ownership of the IB external parallel bus.
Definition at line 1745 of file linda.c.
References BIT_FILL_1, linda_writeq, memset(), and QIB_7220_ibsd_epb_access_ctrl_offset.
Referenced by linda_ib_epb_mod_reg(), and linda_ib_epb_ram_xfer().
01745 { 01746 struct QIB_7220_ibsd_epb_access_ctrl access; 01747 01748 memset ( &access, 0, sizeof ( access ) ); 01749 BIT_FILL_1 ( &access, sw_ib_epb_req, 0 ); 01750 linda_writeq ( linda, &access, QIB_7220_ibsd_epb_access_ctrl_offset ); 01751 }
| static int linda_ib_epb_read | ( | struct linda * | linda, | |
| unsigned int | location | |||
| ) | [static] |
Read data via IB external parallel bus.
| data | Data read, or negative error |
Definition at line 1763 of file linda.c.
References BIT_FILL_3, BIT_GET, LINDA_EPB_LOC_ADDRESS, LINDA_EPB_LOC_CS, LINDA_EPB_READ, linda_ib_epb_wait(), linda_writeq, memset(), and QIB_7220_ibsd_epb_transaction_reg_offset.
Referenced by linda_ib_epb_mod_reg(), and linda_ib_epb_ram_xfer().
01763 { 01764 struct QIB_7220_ibsd_epb_transaction_reg xact; 01765 unsigned int data; 01766 int rc; 01767 01768 /* Ensure no transaction is currently in progress */ 01769 if ( ( rc = linda_ib_epb_wait ( linda, &xact ) ) != 0 ) 01770 return rc; 01771 01772 /* Process data */ 01773 memset ( &xact, 0, sizeof ( xact ) ); 01774 BIT_FILL_3 ( &xact, 01775 ib_epb_address, LINDA_EPB_LOC_ADDRESS ( location ), 01776 ib_epb_read_write, LINDA_EPB_READ, 01777 ib_epb_cs, LINDA_EPB_LOC_CS ( location ) ); 01778 linda_writeq ( linda, &xact, 01779 QIB_7220_ibsd_epb_transaction_reg_offset ); 01780 01781 /* Wait for transaction to complete */ 01782 if ( ( rc = linda_ib_epb_wait ( linda, &xact ) ) != 0 ) 01783 return rc; 01784 01785 data = BIT_GET ( &xact, ib_epb_data ); 01786 return data; 01787 }
| static int linda_ib_epb_write | ( | struct linda * | linda, | |
| unsigned int | location, | |||
| unsigned int | data | |||
| ) | [static] |
Write data via IB external parallel bus.
| rc | Return status code |
Definition at line 1800 of file linda.c.
References BIT_FILL_4, LINDA_EPB_LOC_ADDRESS, LINDA_EPB_LOC_CS, LINDA_EPB_WRITE, linda_ib_epb_wait(), linda_writeq, memset(), and QIB_7220_ibsd_epb_transaction_reg_offset.
Referenced by linda_ib_epb_mod_reg(), and linda_ib_epb_ram_xfer().
01801 { 01802 struct QIB_7220_ibsd_epb_transaction_reg xact; 01803 int rc; 01804 01805 /* Ensure no transaction is currently in progress */ 01806 if ( ( rc = linda_ib_epb_wait ( linda, &xact ) ) != 0 ) 01807 return rc; 01808 01809 /* Process data */ 01810 memset ( &xact, 0, sizeof ( xact ) ); 01811 BIT_FILL_4 ( &xact, 01812 ib_epb_data, data, 01813 ib_epb_address, LINDA_EPB_LOC_ADDRESS ( location ), 01814 ib_epb_read_write, LINDA_EPB_WRITE, 01815 ib_epb_cs, LINDA_EPB_LOC_CS ( location ) ); 01816 linda_writeq ( linda, &xact, 01817 QIB_7220_ibsd_epb_transaction_reg_offset ); 01818 01819 /* Wait for transaction to complete */ 01820 if ( ( rc = linda_ib_epb_wait ( linda, &xact ) ) != 0 ) 01821 return rc; 01822 01823 return 0; 01824 }
| static int linda_ib_epb_mod_reg | ( | struct linda * | linda, | |
| unsigned int | cs, | |||
| unsigned int | channel, | |||
| unsigned int | element, | |||
| unsigned int | reg, | |||
| unsigned int | value, | |||
| unsigned int | mask | |||
| ) | [static] |
Read/modify/write EPB register.
| linda | Linda device | |
| cs | Chip select | |
| channel | Channel | |
| element | Element | |
| reg | Register | |
| value | Value to set | |
| mask | Mask to apply to old value |
| rc | Return status code |
Definition at line 1838 of file linda.c.
References assert, DBG_DISABLE, DBG_ENABLE, DBGCP, DBGLVL_IO, LINDA_EPB_LOC, linda_ib_epb_read(), linda_ib_epb_release(), linda_ib_epb_request(), and linda_ib_epb_write().
Referenced by linda_set_serdes_param().
01841 { 01842 unsigned int location; 01843 int old_value; 01844 int rc; 01845 01846 DBG_DISABLE ( DBGLVL_IO ); 01847 01848 /* Sanity check */ 01849 assert ( ( value & mask ) == value ); 01850 01851 /* Acquire bus ownership */ 01852 if ( ( rc = linda_ib_epb_request ( linda ) ) != 0 ) 01853 goto out; 01854 01855 /* Read existing value, if necessary */ 01856 location = LINDA_EPB_LOC ( cs, channel, element, reg ); 01857 if ( (~mask) & 0xff ) { 01858 old_value = linda_ib_epb_read ( linda, location ); 01859 if ( old_value < 0 ) { 01860 rc = old_value; 01861 goto out_release; 01862 } 01863 } else { 01864 old_value = 0; 01865 } 01866 01867 /* Update value */ 01868 value = ( ( old_value & ~mask ) | value ); 01869 DBGCP ( linda, "Linda %p CS %d EPB(%d,%d,%#02x) %#02x => %#02x\n", 01870 linda, cs, channel, element, reg, old_value, value ); 01871 if ( ( rc = linda_ib_epb_write ( linda, location, value ) ) != 0 ) 01872 goto out_release; 01873 01874 out_release: 01875 /* Release bus */ 01876 linda_ib_epb_release ( linda ); 01877 out: 01878 DBG_ENABLE ( DBGLVL_IO ); 01879 return rc; 01880 }
| static int linda_ib_epb_ram_xfer | ( | struct linda * | linda, | |
| unsigned int | address, | |||
| const void * | write, | |||
| void * | read, | |||
| size_t | len | |||
| ) | [static] |
Transfer data to/from microcontroller RAM.
| linda | Linda device | |
| address | Starting address | |
| write | Data to write, or NULL | |
| read | Data to read, or NULL | |
| len | Length of data |
| rc | Return status code |
Definition at line 1892 of file linda.c.
References assert, DBG_DISABLE, DBG_ENABLE, DBGLVL_IO, LINDA_EPB_UC_ADDR_HI, LINDA_EPB_UC_ADDR_LO, LINDA_EPB_UC_CHUNK_SIZE, LINDA_EPB_UC_CTL, LINDA_EPB_UC_CTL_READ, LINDA_EPB_UC_CTL_WRITE, LINDA_EPB_UC_DATA, linda_ib_epb_read(), linda_ib_epb_release(), linda_ib_epb_request(), and linda_ib_epb_write().
Referenced by linda_program_uc_ram(), and linda_verify_uc_ram().
01894 { 01895 unsigned int control; 01896 unsigned int address_hi; 01897 unsigned int address_lo; 01898 int data; 01899 int rc; 01900 01901 DBG_DISABLE ( DBGLVL_IO ); 01902 01903 assert ( ! ( write && read ) ); 01904 assert ( ( address % LINDA_EPB_UC_CHUNK_SIZE ) == 0 ); 01905 assert ( ( len % LINDA_EPB_UC_CHUNK_SIZE ) == 0 ); 01906 01907 /* Acquire bus ownership */ 01908 if ( ( rc = linda_ib_epb_request ( linda ) ) != 0 ) 01909 goto out; 01910 01911 /* Process data */ 01912 while ( len ) { 01913 01914 /* Reset the address for each new chunk */ 01915 if ( ( address % LINDA_EPB_UC_CHUNK_SIZE ) == 0 ) { 01916 01917 /* Write the control register */ 01918 control = ( read ? LINDA_EPB_UC_CTL_READ : 01919 LINDA_EPB_UC_CTL_WRITE ); 01920 if ( ( rc = linda_ib_epb_write ( linda, 01921 LINDA_EPB_UC_CTL, 01922 control ) ) != 0 ) 01923 break; 01924 01925 /* Write the address registers */ 01926 address_hi = ( address >> 8 ); 01927 if ( ( rc = linda_ib_epb_write ( linda, 01928 LINDA_EPB_UC_ADDR_HI, 01929 address_hi ) ) != 0 ) 01930 break; 01931 address_lo = ( address & 0xff ); 01932 if ( ( rc = linda_ib_epb_write ( linda, 01933 LINDA_EPB_UC_ADDR_LO, 01934 address_lo ) ) != 0 ) 01935 break; 01936 } 01937 01938 /* Read or write the data */ 01939 if ( read ) { 01940 data = linda_ib_epb_read ( linda, LINDA_EPB_UC_DATA ); 01941 if ( data < 0 ) { 01942 rc = data; 01943 break; 01944 } 01945 *( ( uint8_t * ) read++ ) = data; 01946 } else { 01947 data = *( ( uint8_t * ) write++ ); 01948 if ( ( rc = linda_ib_epb_write ( linda, 01949 LINDA_EPB_UC_DATA, 01950 data ) ) != 0 ) 01951 break; 01952 } 01953 address++; 01954 len--; 01955 01956 /* Reset the control byte after each chunk */ 01957 if ( ( address % LINDA_EPB_UC_CHUNK_SIZE ) == 0 ) { 01958 if ( ( rc = linda_ib_epb_write ( linda, 01959 LINDA_EPB_UC_CTL, 01960 0 ) ) != 0 ) 01961 break; 01962 } 01963 } 01964 01965 /* Release bus */ 01966 linda_ib_epb_release ( linda ); 01967 01968 out: 01969 DBG_ENABLE ( DBGLVL_IO ); 01970 return rc; 01971 }
| static int linda_set_serdes_param | ( | struct linda * | linda, | |
| struct linda_serdes_param * | param | |||
| ) | [static] |
Program IB SerDes register(s).
| rc | Return status code |
Definition at line 2003 of file linda.c.
References linda_serdes_param::address, LINDA_EPB_ADDRESS_CHANNEL, LINDA_EPB_ADDRESS_ELEMENT, LINDA_EPB_ADDRESS_REG, LINDA_EPB_ALL_CHANNELS, LINDA_EPB_CS_SERDES, linda_ib_epb_mod_reg(), linda_serdes_param::mask, and linda_serdes_param::value.
Referenced by linda_set_serdes_params().
02004 { 02005 unsigned int channel; 02006 unsigned int channel_start; 02007 unsigned int channel_end; 02008 unsigned int element; 02009 unsigned int reg; 02010 int rc; 02011 02012 /* Break down the EPB address and determine channels */ 02013 channel = LINDA_EPB_ADDRESS_CHANNEL ( param->address ); 02014 element = LINDA_EPB_ADDRESS_ELEMENT ( param->address ); 02015 reg = LINDA_EPB_ADDRESS_REG ( param->address ); 02016 if ( channel == LINDA_EPB_ALL_CHANNELS ) { 02017 channel_start = 0; 02018 channel_end = 3; 02019 } else { 02020 channel_start = channel_end = channel; 02021 } 02022 02023 /* Modify register for each specified channel */ 02024 for ( channel = channel_start ; channel <= channel_end ; channel++ ) { 02025 if ( ( rc = linda_ib_epb_mod_reg ( linda, LINDA_EPB_CS_SERDES, 02026 channel, element, reg, 02027 param->value, 02028 param->mask ) ) != 0 ) 02029 return rc; 02030 } 02031 02032 return 0; 02033 }
| static int linda_set_serdes_params | ( | struct linda * | linda, | |
| struct linda_serdes_param * | params | |||
| ) | [static] |
Program IB SerDes registers.
| rc | Return status code |
Definition at line 2043 of file linda.c.
References linda_set_serdes_param(), and linda_serdes_param::mask.
Referenced by linda_init_ib_serdes().
02044 { 02045 int rc; 02046 02047 for ( ; params->mask != 0 ; params++ ){ 02048 if ( ( rc = linda_set_serdes_param ( linda, 02049 params ) ) != 0 ) 02050 return rc; 02051 } 02052 02053 return 0; 02054 }
| static int linda_program_uc_ram | ( | struct linda * | linda | ) | [static] |
Program the microcontroller RAM.
| rc | Return status code |
Definition at line 2142 of file linda.c.
References DBGC, linda_ib_epb_ram_xfer(), linda_ib_fw, NULL, and strerror().
Referenced by linda_init_ib_serdes().
02142 { 02143 int rc; 02144 02145 if ( ( rc = linda_ib_epb_ram_xfer ( linda, 0, linda_ib_fw, NULL, 02146 sizeof ( linda_ib_fw ) ) ) != 0 ){ 02147 DBGC ( linda, "Linda %p could not load IB firmware: %s\n", 02148 linda, strerror ( rc ) ); 02149 return rc; 02150 } 02151 02152 return 0; 02153 }
| static int linda_verify_uc_ram | ( | struct linda * | linda | ) | [static] |
Verify the microcontroller RAM.
| rc | Return status code |
Definition at line 2161 of file linda.c.
References DBGC, DBGC2, DBGC_HDA, EIO, LINDA_EPB_UC_CHUNK_SIZE, linda_ib_epb_ram_xfer(), linda_ib_fw, memcmp(), NULL, offset, and strerror().
Referenced by linda_init_ib_serdes().
02161 { 02162 uint8_t verify[LINDA_EPB_UC_CHUNK_SIZE]; 02163 unsigned int offset; 02164 int rc; 02165 02166 for ( offset = 0 ; offset < sizeof ( linda_ib_fw ); 02167 offset += sizeof ( verify ) ) { 02168 if ( ( rc = linda_ib_epb_ram_xfer ( linda, offset, 02169 NULL, verify, 02170 sizeof (verify) )) != 0 ){ 02171 DBGC ( linda, "Linda %p could not read back IB " 02172 "firmware: %s\n", linda, strerror ( rc ) ); 02173 return rc; 02174 } 02175 if ( memcmp ( ( linda_ib_fw + offset ), verify, 02176 sizeof ( verify ) ) != 0 ) { 02177 DBGC ( linda, "Linda %p firmware verification failed " 02178 "at offset %#x\n", linda, offset ); 02179 DBGC_HDA ( linda, offset, ( linda_ib_fw + offset ), 02180 sizeof ( verify ) ); 02181 DBGC_HDA ( linda, offset, verify, sizeof ( verify ) ); 02182 return -EIO; 02183 } 02184 } 02185 02186 DBGC2 ( linda, "Linda %p firmware verified ok\n", linda ); 02187 return 0; 02188 }
| static int linda_trim_ib | ( | struct linda * | linda | ) | [static] |
Use the microcontroller to trim the IB link.
| rc | Return status code |
Definition at line 2196 of file linda.c.
References BIT_GET, BIT_SET, DBGC, ETIMEDOUT, linda_readq, LINDA_TRIM_DONE_MAX_WAIT_MS, linda_writeq, mdelay(), QIB_7220_IBSerDesCtrl_offset, and QIB_7220_IntStatus_offset.
Referenced by linda_init_ib_serdes().
02196 { 02197 struct QIB_7220_IBSerDesCtrl ctrl; 02198 struct QIB_7220_IntStatus intstatus; 02199 unsigned int i; 02200 int rc; 02201 02202 /* Bring the microcontroller out of reset */ 02203 linda_readq ( linda, &ctrl, QIB_7220_IBSerDesCtrl_offset ); 02204 BIT_SET ( &ctrl, ResetIB_uC_Core, 0 ); 02205 linda_writeq ( linda, &ctrl, QIB_7220_IBSerDesCtrl_offset ); 02206 02207 /* Wait for the "trim done" signal */ 02208 for ( i = 0 ; i < LINDA_TRIM_DONE_MAX_WAIT_MS ; i++ ) { 02209 linda_readq ( linda, &intstatus, QIB_7220_IntStatus_offset ); 02210 if ( BIT_GET ( &intstatus, IBSerdesTrimDone ) ) { 02211 rc = 0; 02212 goto out_reset; 02213 } 02214 mdelay ( 1 ); 02215 } 02216 02217 DBGC ( linda, "Linda %p timed out waiting for trim done\n", linda ); 02218 rc = -ETIMEDOUT; 02219 out_reset: 02220 /* Put the microcontroller back into reset */ 02221 BIT_SET ( &ctrl, ResetIB_uC_Core, 1 ); 02222 linda_writeq ( linda, &ctrl, QIB_7220_IBSerDesCtrl_offset ); 02223 02224 return rc; 02225 }
| static int linda_init_ib_serdes | ( | struct linda * | linda | ) | [static] |
Initialise the IB SerDes.
| rc | Return status code |
Definition at line 2233 of file linda.c.
References BIT_FILL_6, BIT_SET, DBGLVL_LOG, linda_program_uc_ram(), linda_readq, LINDA_RECV_HEADER_SIZE, LINDA_RECV_PAYLOAD_SIZE, linda_set_serdes_params(), linda_trim_ib(), linda_verify_uc_ram(), linda_writeq, memset(), QIB_7220_Control_offset, QIB_7220_IBCCtrl_offset, QIB_7220_IBCDDRCtrl_offset, QIB_7220_XGXSCfg_offset, and udelay().
Referenced by linda_probe().
02233 { 02234 struct QIB_7220_Control control; 02235 struct QIB_7220_IBCCtrl ibcctrl; 02236 struct QIB_7220_IBCDDRCtrl ibcddrctrl; 02237 struct QIB_7220_XGXSCfg xgxscfg; 02238 int rc; 02239 02240 /* Disable link */ 02241 linda_readq ( linda, &control, QIB_7220_Control_offset ); 02242 BIT_SET ( &control, LinkEn, 0 ); 02243 linda_writeq ( linda, &control, QIB_7220_Control_offset ); 02244 02245 /* Configure sensible defaults for IBC */ 02246 memset ( &ibcctrl, 0, sizeof ( ibcctrl ) ); 02247 BIT_FILL_6 ( &ibcctrl, /* Tuning values taken from Linux driver */ 02248 FlowCtrlPeriod, 0x03, 02249 FlowCtrlWaterMark, 0x05, 02250 MaxPktLen, ( ( LINDA_RECV_HEADER_SIZE + 02251 LINDA_RECV_PAYLOAD_SIZE + 02252 4 /* ICRC */ ) >> 2 ), 02253 PhyerrThreshold, 0xf, 02254 OverrunThreshold, 0xf, 02255 CreditScale, 0x4 ); 02256 linda_writeq ( linda, &ibcctrl, QIB_7220_IBCCtrl_offset ); 02257 02258 /* Force SDR only to avoid needing all the DDR tuning, 02259 * Mellanox compatibility hacks etc. SDR is plenty for 02260 * boot-time operation. 02261 */ 02262 linda_readq ( linda, &ibcddrctrl, QIB_7220_IBCDDRCtrl_offset ); 02263 BIT_SET ( &ibcddrctrl, IB_ENHANCED_MODE, 0 ); 02264 BIT_SET ( &ibcddrctrl, SD_SPEED_SDR, 1 ); 02265 BIT_SET ( &ibcddrctrl, SD_SPEED_DDR, 0 ); 02266 BIT_SET ( &ibcddrctrl, SD_SPEED_QDR, 0 ); 02267 BIT_SET ( &ibcddrctrl, HRTBT_ENB, 0 ); 02268 BIT_SET ( &ibcddrctrl, HRTBT_AUTO, 0 ); 02269 linda_writeq ( linda, &ibcddrctrl, QIB_7220_IBCDDRCtrl_offset ); 02270 02271 /* Set default SerDes parameters */ 02272 if ( ( rc = linda_set_serdes_params ( linda, 02273 linda_serdes_defaults1 ) ) != 0 ) 02274 return rc; 02275 udelay ( 415 ); /* Magic delay while SerDes sorts itself out */ 02276 if ( ( rc = linda_set_serdes_params ( linda, 02277 linda_serdes_defaults2 ) ) != 0 ) 02278 return rc; 02279 02280 /* Program the microcontroller RAM */ 02281 if ( ( rc = linda_program_uc_ram ( linda ) ) != 0 ) 02282 return rc; 02283 02284 /* Verify the microcontroller RAM contents */ 02285 if ( DBGLVL_LOG ) { 02286 if ( ( rc = linda_verify_uc_ram ( linda ) ) != 0 ) 02287 return rc; 02288 } 02289 02290 /* More SerDes tuning */ 02291 if ( ( rc = linda_set_serdes_params ( linda, 02292 linda_serdes_defaults3 ) ) != 0 ) 02293 return rc; 02294 02295 /* Use the microcontroller to trim the IB link */ 02296 if ( ( rc = linda_trim_ib ( linda ) ) != 0 ) 02297 return rc; 02298 02299 /* Bring XGXS out of reset */ 02300 linda_readq ( linda, &xgxscfg, QIB_7220_XGXSCfg_offset ); 02301 BIT_SET ( &xgxscfg, tx_rx_reset, 0 ); 02302 BIT_SET ( &xgxscfg, xcv_reset, 0 ); 02303 linda_writeq ( linda, &xgxscfg, QIB_7220_XGXSCfg_offset ); 02304 02305 return rc; 02306 }
| static int linda_probe | ( | struct pci_device * | pci, | |
| const struct pci_device_id *id | __unused | |||
| ) | [static] |
Probe PCI device.
| pci | PCI device | |
| id | PCI ID |
| rc | Return status code |
Definition at line 2322 of file linda.c.
References adjust_pci_device(), alloc_ibdev(), BIT_GET, DBGC, DBGC2, pci_device::dev, ib_device::dev, ENOMEM, ib_device::gid, ib_gid::half, ib_get_drvdata(), IB_LINK_SPEED_SDR, IB_LINK_WIDTH_1X, IB_LINK_WIDTH_4X, ibdev_put(), ioremap(), LINDA_BAR0_SIZE, linda_fini_recv(), linda_fini_send(), linda_init_i2c(), linda_init_ib_serdes(), linda_init_recv(), linda_init_send(), linda_read_eeprom(), linda_readq, ib_device::link_speed_enabled, ib_device::link_speed_supported, ib_device::link_width_enabled, ib_device::link_width_supported, pci_device::membase, ib_device::op, pci_set_drvdata(), ib_device::port, QIB_7220_Revision_offset, register_ibdev(), linda::regs, strerror(), ib_gid::u, and unregister_ibdev().
02323 { 02324 struct ib_device *ibdev; 02325 struct linda *linda; 02326 struct QIB_7220_Revision revision; 02327 int rc; 02328 02329 /* Allocate Infiniband device */ 02330 ibdev = alloc_ibdev ( sizeof ( *linda ) ); 02331 if ( ! ibdev ) { 02332 rc = -ENOMEM; 02333 goto err_alloc_ibdev; 02334 } 02335 pci_set_drvdata ( pci, ibdev ); 02336 linda = ib_get_drvdata ( ibdev ); 02337 ibdev->op = &linda_ib_operations; 02338 ibdev->dev = &pci->dev; 02339 ibdev->port = 1; 02340 02341 /* Fix up PCI device */ 02342 adjust_pci_device ( pci ); 02343 02344 /* Get PCI BARs */ 02345 linda->regs = ioremap ( pci->membase, LINDA_BAR0_SIZE ); 02346 DBGC2 ( linda, "Linda %p has BAR at %08lx\n", linda, pci->membase ); 02347 02348 /* Print some general data */ 02349 linda_readq ( linda, &revision, QIB_7220_Revision_offset ); 02350 DBGC2 ( linda, "Linda %p board %02lx v%ld.%ld.%ld.%ld\n", linda, 02351 BIT_GET ( &revision, BoardID ), 02352 BIT_GET ( &revision, R_SW ), 02353 BIT_GET ( &revision, R_Arch ), 02354 BIT_GET ( &revision, R_ChipRevMajor ), 02355 BIT_GET ( &revision, R_ChipRevMinor ) ); 02356 02357 /* Record link capabilities. Note that we force SDR only to 02358 * avoid having to carry extra code for DDR tuning etc. 02359 */ 02360 ibdev->link_width_enabled = ibdev->link_width_supported = 02361 ( IB_LINK_WIDTH_4X | IB_LINK_WIDTH_1X ); 02362 ibdev->link_speed_enabled = ibdev->link_speed_supported = 02363 IB_LINK_SPEED_SDR; 02364 02365 /* Initialise I2C subsystem */ 02366 if ( ( rc = linda_init_i2c ( linda ) ) != 0 ) 02367 goto err_init_i2c; 02368 02369 /* Read EEPROM parameters */ 02370 if ( ( rc = linda_read_eeprom ( linda, &ibdev->gid.u.half[1] ) ) != 0 ) 02371 goto err_read_eeprom; 02372 02373 /* Initialise send datapath */ 02374 if ( ( rc = linda_init_send ( linda ) ) != 0 ) 02375 goto err_init_send; 02376 02377 /* Initialise receive datapath */ 02378 if ( ( rc = linda_init_recv ( linda ) ) != 0 ) 02379 goto err_init_recv; 02380 02381 /* Initialise the IB SerDes */ 02382 if ( ( rc = linda_init_ib_serdes ( linda ) ) != 0 ) 02383 goto err_init_ib_serdes; 02384 02385 /* Register Infiniband device */ 02386 if ( ( rc = register_ibdev ( ibdev ) ) != 0 ) { 02387 DBGC ( linda, "Linda %p could not register IB " 02388 "device: %s\n", linda, strerror ( rc ) ); 02389 goto err_register_ibdev; 02390 } 02391 02392 return 0; 02393 02394 unregister_ibdev ( ibdev ); 02395 err_register_ibdev: 02396 linda_fini_recv ( linda ); 02397 err_init_recv: 02398 linda_fini_send ( linda ); 02399 err_init_send: 02400 err_init_ib_serdes: 02401 err_read_eeprom: 02402 err_init_i2c: 02403 ibdev_put ( ibdev ); 02404 err_alloc_ibdev: 02405 return rc; 02406 }
| static void linda_remove | ( | struct pci_device * | pci | ) | [static] |
Remove PCI device.
| pci | PCI device |
Definition at line 2413 of file linda.c.
References ib_get_drvdata(), ibdev_put(), linda_fini_recv(), linda_fini_send(), pci_get_drvdata(), and unregister_ibdev().
02413 { 02414 struct ib_device *ibdev = pci_get_drvdata ( pci ); 02415 struct linda *linda = ib_get_drvdata ( ibdev ); 02416 02417 unregister_ibdev ( ibdev ); 02418 linda_fini_recv ( linda ); 02419 linda_fini_send ( linda ); 02420 ibdev_put ( ibdev ); 02421 }
struct ib_device_operations linda_ib_operations [static] |
Initial value:
{
.create_cq = linda_create_cq,
.destroy_cq = linda_destroy_cq,
.create_qp = linda_create_qp,
.modify_qp = linda_modify_qp,
.destroy_qp = linda_destroy_qp,
.post_send = linda_post_send,
.post_recv = linda_post_recv,
.poll_cq = linda_poll_cq,
.poll_eq = linda_poll_eq,
.open = linda_open,
.close = linda_close,
.mcast_attach = linda_mcast_attach,
.mcast_detach = linda_mcast_detach,
.set_port_info = linda_set_port_info,
.set_pkey_table = linda_set_pkey_table,
}
unsigned int linda_i2c_bits[] [static] |
Initial value:
{
[I2C_BIT_SCL] = ( 1 << LINDA_GPIO_SCL ),
[I2C_BIT_SDA] = ( 1 << LINDA_GPIO_SDA ),
}
Definition at line 1512 of file linda.c.
Referenced by linda_i2c_read_bit(), and linda_i2c_write_bit().
struct bit_basher_operations linda_i2c_basher_ops [static] |
Initial value:
{
.read = linda_i2c_read_bit,
.write = linda_i2c_write_bit,
}
| struct linda_serdes_param __packed |
A Linda SerDes parameter.
struct linda_serdes_param linda_serdes_defaults1[] [static] |
Initial value:
{
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 6, 0x00 ), 0xd4, 0xff },
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 6, 0x05 ), 0x2d, 0xff },
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 6, 0x08 ), 0x03, 0x0f },
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 7, 0x27 ), 0x10, 0xff },
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 7, 0x28 ), 0x30, 0xff },
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 6, 0x0e ), 0x40, 0xff },
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 7, 0x06 ), 0x04, 0xff },
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 6, 0x0f ), 0x04, 0xff },
LINDA_SERDES_PARAM_END
}
These magic start-of-day values are taken from the Linux driver.
struct linda_serdes_param linda_serdes_defaults2[] [static] |
struct linda_serdes_param linda_serdes_defaults3[] [static] |
Initial value:
{
{ LINDA_EPB_ADDRESS ( LINDA_EPB_ALL_CHANNELS, 7, 0x27 ), 0x00, 0x38 },
LINDA_SERDES_PARAM_END
}
struct pci_device_id linda_nics[] [static] |
| struct pci_driver linda_driver __pci_driver |
Initial value:
{
.ids = linda_nics,
.id_count = ( sizeof ( linda_nics ) / sizeof ( linda_nics[0] ) ),
.probe = linda_probe,
.remove = linda_remove,
}
1.5.7.1