arbel.h
Go to the documentation of this file.00001 #ifndef _ARBEL_H
00002 #define _ARBEL_H
00003
00004
00005
00006
00007
00008
00009
00010 FILE_LICENCE ( GPL2_OR_LATER );
00011
00012 #include <stdint.h>
00013 #include <gpxe/uaccess.h>
00014 #include "mlx_bitops.h"
00015 #include "MT25218_PRM.h"
00016
00017
00018
00019
00020
00021
00022
00023 #define ARBEL_NUM_PORTS 2
00024 #define ARBEL_PORT_BASE 1
00025
00026
00027 #define ARBEL_PCI_CONFIG_BAR PCI_BASE_ADDRESS_0
00028 #define ARBEL_PCI_CONFIG_BAR_SIZE 0x100000
00029 #define ARBEL_PCI_UAR_BAR PCI_BASE_ADDRESS_2
00030 #define ARBEL_PCI_UAR_IDX 1
00031 #define ARBEL_PCI_UAR_SIZE 0x1000
00032
00033
00034 #define ARBEL_UAR_RES_NONE 0x00
00035 #define ARBEL_UAR_RES_CQ_CI 0x01
00036 #define ARBEL_UAR_RES_CQ_ARM 0x02
00037 #define ARBEL_UAR_RES_SQ 0x03
00038 #define ARBEL_UAR_RES_RQ 0x04
00039 #define ARBEL_UAR_RES_GROUP_SEP 0x07
00040
00041
00042 #define ARBEL_OPCODE_SEND 0x0a
00043 #define ARBEL_OPCODE_RECV_ERROR 0xfe
00044 #define ARBEL_OPCODE_SEND_ERROR 0xff
00045
00046
00047 #define ARBEL_HCR_QUERY_DEV_LIM 0x0003
00048 #define ARBEL_HCR_QUERY_FW 0x0004
00049 #define ARBEL_HCR_INIT_HCA 0x0007
00050 #define ARBEL_HCR_CLOSE_HCA 0x0008
00051 #define ARBEL_HCR_INIT_IB 0x0009
00052 #define ARBEL_HCR_CLOSE_IB 0x000a
00053 #define ARBEL_HCR_SW2HW_MPT 0x000d
00054 #define ARBEL_HCR_MAP_EQ 0x0012
00055 #define ARBEL_HCR_SW2HW_EQ 0x0013
00056 #define ARBEL_HCR_HW2SW_EQ 0x0014
00057 #define ARBEL_HCR_SW2HW_CQ 0x0016
00058 #define ARBEL_HCR_HW2SW_CQ 0x0017
00059 #define ARBEL_HCR_RST2INIT_QPEE 0x0019
00060 #define ARBEL_HCR_INIT2RTR_QPEE 0x001a
00061 #define ARBEL_HCR_RTR2RTS_QPEE 0x001b
00062 #define ARBEL_HCR_RTS2RTS_QPEE 0x001c
00063 #define ARBEL_HCR_2RST_QPEE 0x0021
00064 #define ARBEL_HCR_MAD_IFC 0x0024
00065 #define ARBEL_HCR_READ_MGM 0x0025
00066 #define ARBEL_HCR_WRITE_MGM 0x0026
00067 #define ARBEL_HCR_MGID_HASH 0x0027
00068 #define ARBEL_HCR_RUN_FW 0x0ff6
00069 #define ARBEL_HCR_DISABLE_LAM 0x0ff7
00070 #define ARBEL_HCR_ENABLE_LAM 0x0ff8
00071 #define ARBEL_HCR_UNMAP_ICM 0x0ff9
00072 #define ARBEL_HCR_MAP_ICM 0x0ffa
00073 #define ARBEL_HCR_UNMAP_ICM_AUX 0x0ffb
00074 #define ARBEL_HCR_MAP_ICM_AUX 0x0ffc
00075 #define ARBEL_HCR_SET_ICM_SIZE 0x0ffd
00076 #define ARBEL_HCR_UNMAP_FA 0x0ffe
00077 #define ARBEL_HCR_MAP_FA 0x0fff
00078
00079
00080 #define ARBEL_ST_UD 0x03
00081
00082
00083 #define ARBEL_MTU_2048 0x04
00084
00085 #define ARBEL_NO_EQ 64
00086
00087 #define ARBEL_INVALID_LKEY 0x00000100UL
00088
00089 #define ARBEL_PAGE_SIZE 4096
00090
00091 #define ARBEL_DB_POST_SND_OFFSET 0x10
00092 #define ARBEL_DB_EQ_OFFSET(_eqn) ( 0x08 * (_eqn) )
00093
00094 #define ARBEL_QPEE_OPT_PARAM_QKEY 0x00000020UL
00095
00096 #define ARBEL_MAP_EQ ( 0UL << 31 )
00097 #define ARBEL_UNMAP_EQ ( 1UL << 31 )
00098
00099 #define ARBEL_EV_PORT_STATE_CHANGE 0x09
00100
00101
00102
00103
00104
00105 struct arbelprm_mgm_hash_st {
00106 pseudo_bit_t reserved0[0x00020];
00107
00108 pseudo_bit_t hash[0x00010];
00109 pseudo_bit_t reserved1[0x00010];
00110 } __attribute__ (( packed ));
00111
00112 struct arbelprm_scalar_parameter_st {
00113 pseudo_bit_t reserved0[0x00020];
00114
00115 pseudo_bit_t value[0x00020];
00116 } __attribute__ (( packed ));
00117
00118 struct arbelprm_event_mask_st {
00119 pseudo_bit_t reserved0[0x00020];
00120
00121 pseudo_bit_t completion[0x00001];
00122 pseudo_bit_t reserved1[0x0008];
00123 pseudo_bit_t port_state_change[0x00001];
00124 pseudo_bit_t reserved2[0x00016];
00125 } __attribute__ (( packed ));
00126
00127 struct arbelprm_eq_set_ci_st {
00128 pseudo_bit_t ci[0x00020];
00129 } __attribute__ (( packed ));
00130
00131 struct arbelprm_port_state_change_event_st {
00132 pseudo_bit_t reserved[0x00020];
00133 struct arbelprm_port_state_change_st data;
00134 } __attribute__ (( packed ));
00135
00136
00137
00138
00139
00140
00141 struct MLX_DECLARE_STRUCT ( arbelprm_access_lam );
00142 struct MLX_DECLARE_STRUCT ( arbelprm_completion_queue_context );
00143 struct MLX_DECLARE_STRUCT ( arbelprm_completion_queue_entry );
00144 struct MLX_DECLARE_STRUCT ( arbelprm_completion_with_error );
00145 struct MLX_DECLARE_STRUCT ( arbelprm_cq_arm_db_record );
00146 struct MLX_DECLARE_STRUCT ( arbelprm_cq_ci_db_record );
00147 struct MLX_DECLARE_STRUCT ( arbelprm_event_mask );
00148 struct MLX_DECLARE_STRUCT ( arbelprm_event_queue_entry );
00149 struct MLX_DECLARE_STRUCT ( arbelprm_eq_set_ci );
00150 struct MLX_DECLARE_STRUCT ( arbelprm_eqc );
00151 struct MLX_DECLARE_STRUCT ( arbelprm_hca_command_register );
00152 struct MLX_DECLARE_STRUCT ( arbelprm_init_hca );
00153 struct MLX_DECLARE_STRUCT ( arbelprm_init_ib );
00154 struct MLX_DECLARE_STRUCT ( arbelprm_mad_ifc );
00155 struct MLX_DECLARE_STRUCT ( arbelprm_mgm_entry );
00156 struct MLX_DECLARE_STRUCT ( arbelprm_mgm_hash );
00157 struct MLX_DECLARE_STRUCT ( arbelprm_mpt );
00158 struct MLX_DECLARE_STRUCT ( arbelprm_port_state_change_event );
00159 struct MLX_DECLARE_STRUCT ( arbelprm_qp_db_record );
00160 struct MLX_DECLARE_STRUCT ( arbelprm_qp_ee_state_transitions );
00161 struct MLX_DECLARE_STRUCT ( arbelprm_query_dev_lim );
00162 struct MLX_DECLARE_STRUCT ( arbelprm_query_fw );
00163 struct MLX_DECLARE_STRUCT ( arbelprm_queue_pair_ee_context_entry );
00164 struct MLX_DECLARE_STRUCT ( arbelprm_recv_wqe_segment_next );
00165 struct MLX_DECLARE_STRUCT ( arbelprm_scalar_parameter );
00166 struct MLX_DECLARE_STRUCT ( arbelprm_send_doorbell );
00167 struct MLX_DECLARE_STRUCT ( arbelprm_ud_address_vector );
00168 struct MLX_DECLARE_STRUCT ( arbelprm_virtual_physical_mapping );
00169 struct MLX_DECLARE_STRUCT ( arbelprm_wqe_segment_ctrl_send );
00170 struct MLX_DECLARE_STRUCT ( arbelprm_wqe_segment_data_ptr );
00171 struct MLX_DECLARE_STRUCT ( arbelprm_wqe_segment_next );
00172 struct MLX_DECLARE_STRUCT ( arbelprm_wqe_segment_ud );
00173
00174
00175
00176
00177
00178
00179 #define ARBEL_MAX_GATHER 1
00180
00181 struct arbelprm_ud_send_wqe {
00182 struct arbelprm_wqe_segment_next next;
00183 struct arbelprm_wqe_segment_ctrl_send ctrl;
00184 struct arbelprm_wqe_segment_ud ud;
00185 struct arbelprm_wqe_segment_data_ptr data[ARBEL_MAX_GATHER];
00186 } __attribute__ (( packed ));
00187
00188 #define ARBEL_MAX_SCATTER 1
00189
00190 struct arbelprm_recv_wqe {
00191
00192
00193
00194
00195
00196
00197
00198 struct arbelprm_recv_wqe_segment_next next;
00199 uint32_t ctrl[2];
00200 struct arbelprm_wqe_segment_data_ptr data[ARBEL_MAX_SCATTER];
00201 } __attribute__ (( packed ));
00202
00203 union arbelprm_completion_entry {
00204 struct arbelprm_completion_queue_entry normal;
00205 struct arbelprm_completion_with_error error;
00206 } __attribute__ (( packed ));
00207
00208 union arbelprm_event_entry {
00209 struct arbelprm_event_queue_entry generic;
00210 struct arbelprm_port_state_change_event port_state_change;
00211 } __attribute__ (( packed ));
00212
00213 union arbelprm_doorbell_record {
00214 struct arbelprm_cq_arm_db_record cq_arm;
00215 struct arbelprm_cq_ci_db_record cq_ci;
00216 struct arbelprm_qp_db_record qp;
00217 } __attribute__ (( packed ));
00218
00219 union arbelprm_doorbell_register {
00220 struct arbelprm_send_doorbell send;
00221 uint32_t dword[2];
00222 } __attribute__ (( packed ));
00223
00224 union arbelprm_eq_doorbell_register {
00225 struct arbelprm_eq_set_ci ci;
00226 uint32_t dword[1];
00227 } __attribute__ (( packed ));
00228
00229 union arbelprm_mad {
00230 struct arbelprm_mad_ifc ifc;
00231 union ib_mad mad;
00232 } __attribute__ (( packed ));
00233
00234
00235
00236
00237
00238
00239
00240 struct arbel_dev_limits {
00241
00242 unsigned int reserved_qps;
00243
00244 size_t qpc_entry_size;
00245
00246 size_t eqpc_entry_size;
00247
00248 unsigned int reserved_srqs;
00249
00250 size_t srqc_entry_size;
00251
00252 unsigned int reserved_ees;
00253
00254 size_t eec_entry_size;
00255
00256 size_t eeec_entry_size;
00257
00258 unsigned int reserved_cqs;
00259
00260 size_t cqc_entry_size;
00261
00262 unsigned int reserved_eqs;
00263
00264 unsigned int reserved_mtts;
00265
00266 size_t mtt_entry_size;
00267
00268 unsigned int reserved_mrws;
00269
00270 size_t mpt_entry_size;
00271
00272 unsigned int reserved_rdbs;
00273
00274 size_t eqc_entry_size;
00275
00276 unsigned int reserved_uars;
00277 };
00278
00279
00280 #define ARBEL_SEND_WQE_ALIGN 128
00281
00282
00283 union arbel_send_wqe {
00284 struct arbelprm_ud_send_wqe ud;
00285 uint8_t force_align[ARBEL_SEND_WQE_ALIGN];
00286 } __attribute__ (( packed ));
00287
00288
00289 struct arbel_send_work_queue {
00290
00291 unsigned int doorbell_idx;
00292
00293 union arbel_send_wqe *wqe;
00294
00295 size_t wqe_size;
00296 };
00297
00298
00299 #define ARBEL_RECV_WQE_ALIGN 64
00300
00301
00302 union arbel_recv_wqe {
00303 struct arbelprm_recv_wqe recv;
00304 uint8_t force_align[ARBEL_RECV_WQE_ALIGN];
00305 } __attribute__ (( packed ));
00306
00307
00308 struct arbel_recv_work_queue {
00309
00310 unsigned int doorbell_idx;
00311
00312 union arbel_recv_wqe *wqe;
00313
00314 size_t wqe_size;
00315 };
00316
00317
00318
00319
00320
00321 #define ARBEL_MAX_QPS 8
00322
00323
00324 #define ARBEL_QPN_BASE 0x550000
00325
00326
00327 struct arbel_queue_pair {
00328
00329 struct arbel_send_work_queue send;
00330
00331 struct arbel_recv_work_queue recv;
00332 };
00333
00334
00335
00336
00337
00338 #define ARBEL_MAX_CQS 8
00339
00340
00341 struct arbel_completion_queue {
00342
00343 unsigned int ci_doorbell_idx;
00344
00345 unsigned int arm_doorbell_idx;
00346
00347 union arbelprm_completion_entry *cqe;
00348
00349 size_t cqe_size;
00350 };
00351
00352
00353
00354
00355
00356 #define ARBEL_MAX_EQS 64
00357
00358
00359 struct arbel_event_queue {
00360
00361 union arbelprm_event_entry *eqe;
00362
00363 size_t eqe_size;
00364
00365 unsigned long eqn;
00366
00367 unsigned long next_idx;
00368
00369 void *doorbell;
00370 };
00371
00372
00373
00374
00375
00376 #define ARBEL_NUM_EQES 4
00377
00378
00379
00380 typedef uint32_t arbel_bitmask_t;
00381
00382
00383 #define ARBEL_BITMASK_SIZE(max_entries) \
00384 ( ( (max_entries) + ( 8 * sizeof ( arbel_bitmask_t ) ) - 1 ) / \
00385 ( 8 * sizeof ( arbel_bitmask_t ) ) )
00386
00387
00388 struct arbel {
00389
00390 void *config;
00391
00392 void *uar;
00393
00394 void *eq_ci_doorbells;
00395
00396
00397 void *mailbox_in;
00398
00399 void *mailbox_out;
00400
00401
00402 userptr_t firmware_area;
00403
00404 size_t icm_len;
00405
00406 size_t icm_aux_len;
00407
00408 userptr_t icm;
00409
00410
00411 struct arbel_event_queue eq;
00412
00413 union arbelprm_doorbell_record *db_rec;
00414
00415
00416
00417
00418 unsigned long reserved_lkey;
00419
00420
00421 arbel_bitmask_t cq_inuse[ ARBEL_BITMASK_SIZE ( ARBEL_MAX_CQS ) ];
00422
00423 arbel_bitmask_t qp_inuse[ ARBEL_BITMASK_SIZE ( ARBEL_MAX_QPS ) ];
00424
00425
00426 struct arbel_dev_limits limits;
00427
00428
00429 struct ib_device *ibdev[ARBEL_NUM_PORTS];
00430 };
00431
00432
00433 #define ARBEL_GLOBAL_PD 0x123456
00434
00435
00436 #define ARBEL_MKEY_PREFIX 0x77000000UL
00437
00438
00439
00440
00441
00442
00443 #define ARBEL_HCR_BASE 0x80680
00444 #define ARBEL_HCR_REG(x) ( ARBEL_HCR_BASE + 4 * (x) )
00445 #define ARBEL_HCR_MAX_WAIT_MS 2000
00446 #define ARBEL_MBOX_ALIGN 4096
00447 #define ARBEL_MBOX_SIZE 512
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460 #define ARBEL_HCR_IN_MBOX 0x00001000UL
00461 #define ARBEL_HCR_OUT_MBOX 0x00002000UL
00462 #define ARBEL_HCR_OPCODE( _command ) ( (_command) & 0xfff )
00463 #define ARBEL_HCR_IN_LEN( _command ) ( ( (_command) >> 12 ) & 0x7fc )
00464 #define ARBEL_HCR_OUT_LEN( _command ) ( ( (_command) >> 21 ) & 0x7fc )
00465
00466
00467 #define ARBEL_HCR_INOUT_CMD( _opcode, _in_mbox, _in_len, \
00468 _out_mbox, _out_len ) \
00469 ( (_opcode) | \
00470 ( (_in_mbox) ? ARBEL_HCR_IN_MBOX : 0 ) | \
00471 ( ( (_in_len) / 4 ) << 14 ) | \
00472 ( (_out_mbox) ? ARBEL_HCR_OUT_MBOX : 0 ) | \
00473 ( ( (_out_len) / 4 ) << 23 ) )
00474
00475 #define ARBEL_HCR_IN_CMD( _opcode, _in_mbox, _in_len ) \
00476 ARBEL_HCR_INOUT_CMD ( _opcode, _in_mbox, _in_len, 0, 0 )
00477
00478 #define ARBEL_HCR_OUT_CMD( _opcode, _out_mbox, _out_len ) \
00479 ARBEL_HCR_INOUT_CMD ( _opcode, 0, 0, _out_mbox, _out_len )
00480
00481 #define ARBEL_HCR_VOID_CMD( _opcode ) \
00482 ARBEL_HCR_INOUT_CMD ( _opcode, 0, 0, 0, 0 )
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497 #define ARBEL_MAX_DOORBELL_RECORDS 512
00498 #define ARBEL_GROUP_SEPARATOR_DOORBELL ( ARBEL_MAX_CQS + ARBEL_MAX_QPS )
00499
00500
00501
00502
00503
00504
00505
00506 static inline unsigned int
00507 arbel_cq_arm_doorbell_idx ( unsigned int cqn_offset ) {
00508 return cqn_offset;
00509 }
00510
00511
00512
00513
00514
00515
00516
00517 static inline unsigned int
00518 arbel_send_doorbell_idx ( unsigned int qpn_offset ) {
00519 return ( ARBEL_MAX_CQS + qpn_offset );
00520 }
00521
00522
00523
00524
00525
00526
00527
00528 static inline unsigned int
00529 arbel_recv_doorbell_idx ( unsigned int qpn_offset ) {
00530 return ( ARBEL_MAX_DOORBELL_RECORDS - ARBEL_MAX_CQS - qpn_offset - 1 );
00531 }
00532
00533
00534
00535
00536
00537
00538
00539 static inline unsigned int
00540 arbel_cq_ci_doorbell_idx ( unsigned int cqn_offset ) {
00541 return ( ARBEL_MAX_DOORBELL_RECORDS - cqn_offset - 1 );
00542 }
00543
00544 #endif