hermon.h
Go to the documentation of this file.00001 #ifndef _HERMON_H
00002 #define _HERMON_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 <gpxe/ib_packet.h>
00015 #include "mlx_bitops.h"
00016 #include "MT25408_PRM.h"
00017
00018
00019
00020
00021
00022
00023
00024 #define HERMON_MAX_PORTS 2
00025 #define HERMON_PORT_BASE 1
00026
00027
00028 #define HERMON_PCI_CONFIG_BAR PCI_BASE_ADDRESS_0
00029 #define HERMON_PCI_CONFIG_BAR_SIZE 0x100000
00030 #define HERMON_PCI_UAR_BAR PCI_BASE_ADDRESS_2
00031
00032
00033 #define HERMON_RESET_OFFSET 0x0f0010
00034 #define HERMON_RESET_MAGIC 0x01000000UL
00035 #define HERMON_RESET_WAIT_TIME_MS 1000
00036
00037
00038 #define HERMON_OPCODE_NOP 0x00
00039 #define HERMON_OPCODE_SEND 0x0a
00040 #define HERMON_OPCODE_RECV_ERROR 0xfe
00041 #define HERMON_OPCODE_SEND_ERROR 0xff
00042
00043
00044 #define HERMON_HCR_QUERY_DEV_CAP 0x0003
00045 #define HERMON_HCR_QUERY_FW 0x0004
00046 #define HERMON_HCR_INIT_HCA 0x0007
00047 #define HERMON_HCR_CLOSE_HCA 0x0008
00048 #define HERMON_HCR_INIT_PORT 0x0009
00049 #define HERMON_HCR_CLOSE_PORT 0x000a
00050 #define HERMON_HCR_SW2HW_MPT 0x000d
00051 #define HERMON_HCR_WRITE_MTT 0x0011
00052 #define HERMON_HCR_MAP_EQ 0x0012
00053 #define HERMON_HCR_SW2HW_EQ 0x0013
00054 #define HERMON_HCR_HW2SW_EQ 0x0014
00055 #define HERMON_HCR_QUERY_EQ 0x0015
00056 #define HERMON_HCR_SW2HW_CQ 0x0016
00057 #define HERMON_HCR_HW2SW_CQ 0x0017
00058 #define HERMON_HCR_RST2INIT_QP 0x0019
00059 #define HERMON_HCR_INIT2RTR_QP 0x001a
00060 #define HERMON_HCR_RTR2RTS_QP 0x001b
00061 #define HERMON_HCR_RTS2RTS_QP 0x001c
00062 #define HERMON_HCR_2RST_QP 0x0021
00063 #define HERMON_HCR_QUERY_QP 0x0022
00064 #define HERMON_HCR_CONF_SPECIAL_QP 0x0023
00065 #define HERMON_HCR_MAD_IFC 0x0024
00066 #define HERMON_HCR_READ_MCG 0x0025
00067 #define HERMON_HCR_WRITE_MCG 0x0026
00068 #define HERMON_HCR_MGID_HASH 0x0027
00069 #define HERMON_HCR_SENSE_PORT 0x004d
00070 #define HERMON_HCR_RUN_FW 0x0ff6
00071 #define HERMON_HCR_DISABLE_LAM 0x0ff7
00072 #define HERMON_HCR_ENABLE_LAM 0x0ff8
00073 #define HERMON_HCR_UNMAP_ICM 0x0ff9
00074 #define HERMON_HCR_MAP_ICM 0x0ffa
00075 #define HERMON_HCR_UNMAP_ICM_AUX 0x0ffb
00076 #define HERMON_HCR_MAP_ICM_AUX 0x0ffc
00077 #define HERMON_HCR_SET_ICM_SIZE 0x0ffd
00078 #define HERMON_HCR_UNMAP_FA 0x0ffe
00079 #define HERMON_HCR_MAP_FA 0x0fff
00080
00081
00082 #define HERMON_ST_RC 0x00
00083 #define HERMON_ST_UD 0x03
00084 #define HERMON_ST_MLX 0x07
00085
00086
00087 #define HERMON_MTU_2048 0x04
00088
00089 #define HERMON_INVALID_LKEY 0x00000100UL
00090
00091 #define HERMON_PAGE_SIZE 4096
00092
00093 #define HERMON_DB_POST_SND_OFFSET 0x14
00094 #define HERMON_DB_EQ_OFFSET(_eqn) \
00095 ( 0x800 + HERMON_PAGE_SIZE * ( (_eqn) / 4 ) + 0x08 * ( (_eqn) % 4 ) )
00096
00097 #define HERMON_QP_OPT_PARAM_PM_STATE 0x00000400UL
00098 #define HERMON_QP_OPT_PARAM_QKEY 0x00000020UL
00099 #define HERMON_QP_OPT_PARAM_ALT_PATH 0x00000001UL
00100
00101 #define HERMON_MAP_EQ ( 0UL << 31 )
00102 #define HERMON_UNMAP_EQ ( 1UL << 31 )
00103
00104 #define HERMON_EV_PORT_STATE_CHANGE 0x09
00105
00106 #define HERMON_SCHED_QP0 0x3f
00107 #define HERMON_SCHED_DEFAULT 0x83
00108
00109 #define HERMON_PM_STATE_ARMED 0x00
00110 #define HERMON_PM_STATE_REARM 0x01
00111 #define HERMON_PM_STATE_MIGRATED 0x03
00112
00113 #define HERMON_RETRY_MAX 0x07
00114
00115
00116
00117
00118
00119 struct hermonprm_mgm_hash_st {
00120 pseudo_bit_t reserved0[0x00020];
00121
00122 pseudo_bit_t hash[0x00010];
00123 pseudo_bit_t reserved1[0x00010];
00124 } __attribute__ (( packed ));
00125
00126 struct hermonprm_mcg_entry_st {
00127 struct hermonprm_mcg_hdr_st hdr;
00128 struct hermonprm_mcg_qp_dw_st qp[8];
00129 } __attribute__ (( packed ));
00130
00131 struct hermonprm_cq_db_record_st {
00132 pseudo_bit_t update_ci[0x00018];
00133 pseudo_bit_t reserved0[0x00008];
00134
00135 pseudo_bit_t arm_ci[0x00018];
00136 pseudo_bit_t cmd[0x00003];
00137 pseudo_bit_t reserved1[0x00001];
00138 pseudo_bit_t cmd_sn[0x00002];
00139 pseudo_bit_t reserved2[0x00002];
00140 } __attribute__ (( packed ));
00141
00142 struct hermonprm_send_db_register_st {
00143 pseudo_bit_t reserved[0x00008];
00144 pseudo_bit_t qn[0x00018];
00145 } __attribute__ (( packed ));
00146
00147 struct hermonprm_event_db_register_st {
00148 pseudo_bit_t ci[0x00018];
00149 pseudo_bit_t reserver[0x00007];
00150 pseudo_bit_t a[0x00001];
00151 } __attribute__ (( packed ));
00152
00153 struct hermonprm_scalar_parameter_st {
00154 pseudo_bit_t value_hi[0x00020];
00155
00156 pseudo_bit_t value[0x00020];
00157 } __attribute__ (( packed ));
00158
00159 struct hermonprm_event_mask_st {
00160 pseudo_bit_t reserved0[0x00020];
00161
00162 pseudo_bit_t completion[0x00001];
00163 pseudo_bit_t reserved1[0x0008];
00164 pseudo_bit_t port_state_change[0x00001];
00165 pseudo_bit_t reserved2[0x00016];
00166 } __attribute__ (( packed ));
00167
00168 struct hermonprm_port_state_change_event_st {
00169 pseudo_bit_t reserved[0x00020];
00170 struct hermonprm_port_state_change_st data;
00171 } __attribute__ (( packed ));
00172
00173
00174 struct hermonprm_sense_port_st {
00175 pseudo_bit_t port_type[0x00020];
00176
00177 pseudo_bit_t reserved[0x00020];
00178 };
00179 #define HERMON_PORT_TYPE_IB 1
00180
00181
00182
00183
00184
00185
00186 struct MLX_DECLARE_STRUCT ( hermonprm_completion_queue_context );
00187 struct MLX_DECLARE_STRUCT ( hermonprm_completion_queue_entry );
00188 struct MLX_DECLARE_STRUCT ( hermonprm_completion_with_error );
00189 struct MLX_DECLARE_STRUCT ( hermonprm_cq_db_record );
00190 struct MLX_DECLARE_STRUCT ( hermonprm_eqc );
00191 struct MLX_DECLARE_STRUCT ( hermonprm_event_db_register );
00192 struct MLX_DECLARE_STRUCT ( hermonprm_event_mask );
00193 struct MLX_DECLARE_STRUCT ( hermonprm_event_queue_entry );
00194 struct MLX_DECLARE_STRUCT ( hermonprm_hca_command_register );
00195 struct MLX_DECLARE_STRUCT ( hermonprm_init_hca );
00196 struct MLX_DECLARE_STRUCT ( hermonprm_init_port );
00197 struct MLX_DECLARE_STRUCT ( hermonprm_mad_ifc );
00198 struct MLX_DECLARE_STRUCT ( hermonprm_mcg_entry );
00199 struct MLX_DECLARE_STRUCT ( hermonprm_mgm_hash );
00200 struct MLX_DECLARE_STRUCT ( hermonprm_mpt );
00201 struct MLX_DECLARE_STRUCT ( hermonprm_mtt );
00202 struct MLX_DECLARE_STRUCT ( hermonprm_port_state_change_event );
00203 struct MLX_DECLARE_STRUCT ( hermonprm_qp_db_record );
00204 struct MLX_DECLARE_STRUCT ( hermonprm_qp_ee_state_transitions );
00205 struct MLX_DECLARE_STRUCT ( hermonprm_query_dev_cap );
00206 struct MLX_DECLARE_STRUCT ( hermonprm_query_fw );
00207 struct MLX_DECLARE_STRUCT ( hermonprm_queue_pair_ee_context_entry );
00208 struct MLX_DECLARE_STRUCT ( hermonprm_scalar_parameter );
00209 struct MLX_DECLARE_STRUCT ( hermonprm_sense_port );
00210 struct MLX_DECLARE_STRUCT ( hermonprm_send_db_register );
00211 struct MLX_DECLARE_STRUCT ( hermonprm_ud_address_vector );
00212 struct MLX_DECLARE_STRUCT ( hermonprm_virtual_physical_mapping );
00213 struct MLX_DECLARE_STRUCT ( hermonprm_wqe_segment_ctrl_mlx );
00214 struct MLX_DECLARE_STRUCT ( hermonprm_wqe_segment_ctrl_send );
00215 struct MLX_DECLARE_STRUCT ( hermonprm_wqe_segment_data_ptr );
00216 struct MLX_DECLARE_STRUCT ( hermonprm_wqe_segment_ud );
00217
00218
00219
00220
00221
00222
00223 struct hermonprm_write_mtt {
00224 struct hermonprm_scalar_parameter mtt_base_addr;
00225 struct hermonprm_scalar_parameter reserved;
00226 struct hermonprm_mtt mtt;
00227 } __attribute__ (( packed ));
00228
00229 #define HERMON_MAX_GATHER 2
00230
00231 struct hermonprm_ud_send_wqe {
00232 struct hermonprm_wqe_segment_ctrl_send ctrl;
00233 struct hermonprm_wqe_segment_ud ud;
00234 struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_GATHER];
00235 } __attribute__ (( packed ));
00236
00237 struct hermonprm_mlx_send_wqe {
00238 struct hermonprm_wqe_segment_ctrl_mlx ctrl;
00239 struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_GATHER];
00240 uint8_t headers[IB_MAX_HEADER_SIZE];
00241 } __attribute__ (( packed ));
00242
00243 struct hermonprm_rc_send_wqe {
00244 struct hermonprm_wqe_segment_ctrl_send ctrl;
00245 struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_GATHER];
00246 } __attribute__ (( packed ));
00247
00248 #define HERMON_MAX_SCATTER 1
00249
00250 struct hermonprm_recv_wqe {
00251 struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_SCATTER];
00252 } __attribute__ (( packed ));
00253
00254 union hermonprm_completion_entry {
00255 struct hermonprm_completion_queue_entry normal;
00256 struct hermonprm_completion_with_error error;
00257 } __attribute__ (( packed ));
00258
00259 union hermonprm_event_entry {
00260 struct hermonprm_event_queue_entry generic;
00261 struct hermonprm_port_state_change_event port_state_change;
00262 } __attribute__ (( packed ));
00263
00264 union hermonprm_doorbell_register {
00265 struct hermonprm_send_db_register send;
00266 struct hermonprm_event_db_register event;
00267 uint32_t dword[1];
00268 } __attribute__ (( packed ));
00269
00270 union hermonprm_mad {
00271 struct hermonprm_mad_ifc ifc;
00272 union ib_mad mad;
00273 } __attribute__ (( packed ));
00274
00275
00276
00277
00278
00279
00280
00281 struct hermon_dev_cap {
00282
00283 size_t cmpt_entry_size;
00284
00285 unsigned int reserved_qps;
00286
00287 size_t qpc_entry_size;
00288
00289 size_t altc_entry_size;
00290
00291 size_t auxc_entry_size;
00292
00293 unsigned int reserved_srqs;
00294
00295 size_t srqc_entry_size;
00296
00297 unsigned int reserved_cqs;
00298
00299 size_t cqc_entry_size;
00300
00301 unsigned int reserved_eqs;
00302
00303 size_t eqc_entry_size;
00304
00305 unsigned int reserved_mtts;
00306
00307 size_t mtt_entry_size;
00308
00309 unsigned int reserved_mrws;
00310
00311 size_t dmpt_entry_size;
00312
00313 unsigned int reserved_uars;
00314
00315 unsigned int num_ports;
00316
00317 int dpdp;
00318 };
00319
00320
00321 #define HERMON_CMPT_MAX_ENTRIES ( 1 << 24 )
00322
00323
00324 struct hermon_icm_map {
00325
00326 uint64_t offset;
00327
00328 size_t len;
00329 };
00330
00331
00332 enum hermon_icm_map_regions {
00333 HERMON_ICM_QP_CMPT = 0,
00334 HERMON_ICM_SRQ_CMPT,
00335 HERMON_ICM_CQ_CMPT,
00336 HERMON_ICM_EQ_CMPT,
00337 HERMON_ICM_OTHER,
00338 HERMON_ICM_NUM_REGIONS
00339 };
00340
00341
00342
00343
00344
00345
00346 #define HERMON_UAR_NON_EQ_PAGE 128
00347
00348
00349
00350
00351
00352 #define HERMON_MAX_MTTS 64
00353
00354
00355 struct hermon_mtt {
00356
00357 unsigned int mtt_offset;
00358
00359 unsigned int num_pages;
00360
00361 unsigned int mtt_base_addr;
00362
00363 unsigned int page_offset;
00364 };
00365
00366
00367 #define HERMON_SEND_WQE_ALIGN 128
00368
00369
00370 union hermon_send_wqe {
00371 struct hermonprm_wqe_segment_ctrl_send ctrl;
00372 struct hermonprm_ud_send_wqe ud;
00373 struct hermonprm_mlx_send_wqe mlx;
00374 struct hermonprm_rc_send_wqe rc;
00375 uint8_t force_align[HERMON_SEND_WQE_ALIGN];
00376 } __attribute__ (( packed ));
00377
00378
00379 struct hermon_send_work_queue {
00380
00381
00382
00383
00384
00385
00386 unsigned int num_wqes;
00387
00388 union hermon_send_wqe *wqe;
00389
00390 size_t wqe_size;
00391
00392 void *doorbell;
00393 };
00394
00395
00396 #define HERMON_RECV_WQE_ALIGN 16
00397
00398
00399 union hermon_recv_wqe {
00400 struct hermonprm_recv_wqe recv;
00401 uint8_t force_align[HERMON_RECV_WQE_ALIGN];
00402 } __attribute__ (( packed ));
00403
00404
00405 struct hermon_recv_work_queue {
00406
00407 union hermon_recv_wqe *wqe;
00408
00409 size_t wqe_size;
00410
00411 struct hermonprm_qp_db_record doorbell __attribute__ (( aligned (4) ));
00412 };
00413
00414
00415 #define HERMON_NUM_SPECIAL_QPS 8
00416
00417
00418
00419
00420
00421
00422 #define HERMON_RSVD_SPECIAL_QPS ( ( HERMON_NUM_SPECIAL_QPS << 1 ) - 1 )
00423
00424
00425
00426
00427
00428 #define HERMON_MAX_QPS 8
00429
00430
00431 #define HERMON_QPN_RANDOM_MASK 0xfff000
00432
00433
00434 enum hermon_queue_pair_state {
00435 HERMON_QP_ST_RST = 0,
00436 HERMON_QP_ST_INIT,
00437 HERMON_QP_ST_RTR,
00438 HERMON_QP_ST_RTS,
00439 };
00440
00441
00442 struct hermon_queue_pair {
00443
00444 void *wqe;
00445
00446 size_t wqe_size;
00447
00448 struct hermon_mtt mtt;
00449
00450 struct hermon_send_work_queue send;
00451
00452 struct hermon_recv_work_queue recv;
00453
00454 enum hermon_queue_pair_state state;
00455 };
00456
00457
00458
00459
00460
00461 #define HERMON_MAX_CQS 8
00462
00463
00464 struct hermon_completion_queue {
00465
00466 union hermonprm_completion_entry *cqe;
00467
00468 size_t cqe_size;
00469
00470 struct hermon_mtt mtt;
00471
00472 struct hermonprm_cq_db_record doorbell __attribute__ (( aligned (8) ));
00473 };
00474
00475
00476
00477
00478
00479 #define HERMON_MAX_EQS 8
00480
00481
00482 struct hermon_event_queue {
00483
00484 union hermonprm_event_entry *eqe;
00485
00486 size_t eqe_size;
00487
00488 struct hermon_mtt mtt;
00489
00490 unsigned long eqn;
00491
00492 unsigned long next_idx;
00493
00494 void *doorbell;
00495 };
00496
00497
00498
00499
00500
00501 #define HERMON_NUM_EQES 4
00502
00503
00504 typedef uint32_t hermon_bitmask_t;
00505
00506
00507 #define HERMON_BITMASK_SIZE(max_entries) \
00508 ( ( (max_entries) + ( 8 * sizeof ( hermon_bitmask_t ) ) - 1 ) / \
00509 ( 8 * sizeof ( hermon_bitmask_t ) ) )
00510
00511
00512 struct hermon {
00513
00514 void *config;
00515
00516 void *uar;
00517
00518
00519 unsigned int toggle;
00520
00521 void *mailbox_in;
00522
00523 void *mailbox_out;
00524
00525
00526 userptr_t firmware_area;
00527
00528 struct hermon_icm_map icm_map[HERMON_ICM_NUM_REGIONS];
00529
00530 userptr_t icm;
00531
00532
00533 struct hermon_event_queue eq;
00534
00535
00536
00537
00538 unsigned long lkey;
00539
00540
00541 hermon_bitmask_t cq_inuse[ HERMON_BITMASK_SIZE ( HERMON_MAX_CQS ) ];
00542
00543 hermon_bitmask_t qp_inuse[ HERMON_BITMASK_SIZE ( HERMON_MAX_QPS ) ];
00544
00545 hermon_bitmask_t mtt_inuse[ HERMON_BITMASK_SIZE ( HERMON_MAX_MTTS ) ];
00546
00547
00548 struct hermon_dev_cap cap;
00549
00550 unsigned long special_qpn_base;
00551
00552 unsigned long qpn_base;
00553
00554
00555 struct ib_device *ibdev[HERMON_MAX_PORTS];
00556 };
00557
00558
00559 #define HERMON_GLOBAL_PD 0x123456
00560
00561
00562 #define HERMON_MKEY_PREFIX 0x77000000UL
00563
00564
00565
00566
00567
00568
00569 #define HERMON_HCR_BASE 0x80680
00570 #define HERMON_HCR_REG(x) ( HERMON_HCR_BASE + 4 * (x) )
00571 #define HERMON_HCR_MAX_WAIT_MS 2000
00572 #define HERMON_MBOX_ALIGN 4096
00573 #define HERMON_MBOX_SIZE 512
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586 #define HERMON_HCR_IN_MBOX 0x00001000UL
00587 #define HERMON_HCR_OUT_MBOX 0x00002000UL
00588 #define HERMON_HCR_OPCODE( _command ) ( (_command) & 0xfff )
00589 #define HERMON_HCR_IN_LEN( _command ) ( ( (_command) >> 12 ) & 0x7fc )
00590 #define HERMON_HCR_OUT_LEN( _command ) ( ( (_command) >> 21 ) & 0x7fc )
00591
00592
00593 #define HERMON_HCR_INOUT_CMD( _opcode, _in_mbox, _in_len, \
00594 _out_mbox, _out_len ) \
00595 ( (_opcode) | \
00596 ( (_in_mbox) ? HERMON_HCR_IN_MBOX : 0 ) | \
00597 ( ( (_in_len) / 4 ) << 14 ) | \
00598 ( (_out_mbox) ? HERMON_HCR_OUT_MBOX : 0 ) | \
00599 ( ( (_out_len) / 4 ) << 23 ) )
00600
00601 #define HERMON_HCR_IN_CMD( _opcode, _in_mbox, _in_len ) \
00602 HERMON_HCR_INOUT_CMD ( _opcode, _in_mbox, _in_len, 0, 0 )
00603
00604 #define HERMON_HCR_OUT_CMD( _opcode, _out_mbox, _out_len ) \
00605 HERMON_HCR_INOUT_CMD ( _opcode, 0, 0, _out_mbox, _out_len )
00606
00607 #define HERMON_HCR_VOID_CMD( _opcode ) \
00608 HERMON_HCR_INOUT_CMD ( _opcode, 0, 0, 0, 0 )
00609
00610 #endif