hermon.h

Go to the documentation of this file.
00001 #ifndef _HERMON_H
00002 #define _HERMON_H
00003 
00004 /** @file
00005  *
00006  * Mellanox Hermon Infiniband HCA driver
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  * Hardware constants
00020  *
00021  */
00022 
00023 /* Ports in existence */
00024 #define HERMON_MAX_PORTS                2
00025 #define HERMON_PORT_BASE                1
00026 
00027 /* PCI BARs */
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 /* Device reset */
00033 #define HERMON_RESET_OFFSET             0x0f0010
00034 #define HERMON_RESET_MAGIC              0x01000000UL
00035 #define HERMON_RESET_WAIT_TIME_MS       1000
00036 
00037 /* Work queue entry and completion queue entry opcodes */
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 /* HCA command register opcodes */
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 /* Service types */
00082 #define HERMON_ST_RC                    0x00
00083 #define HERMON_ST_UD                    0x03
00084 #define HERMON_ST_MLX                   0x07
00085 
00086 /* MTUs */
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  * Datatypes that seem to be missing from the autogenerated documentation
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 /** Hermon sense port */
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  * Wrapper structures for hardware datatypes
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  * Composite hardware datatypes
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  * gPXE-specific definitions
00277  *
00278  */
00279 
00280 /** Hermon device capabilitiess */
00281 struct hermon_dev_cap {
00282         /** CMPT entry size */
00283         size_t cmpt_entry_size;
00284         /** Number of reserved QPs */
00285         unsigned int reserved_qps;
00286         /** QP context entry size */
00287         size_t qpc_entry_size;
00288         /** Alternate path context entry size */
00289         size_t altc_entry_size;
00290         /** Auxiliary context entry size */
00291         size_t auxc_entry_size;
00292         /** Number of reserved SRQs */
00293         unsigned int reserved_srqs;
00294         /** SRQ context entry size */
00295         size_t srqc_entry_size;
00296         /** Number of reserved CQs */
00297         unsigned int reserved_cqs;
00298         /** CQ context entry size */
00299         size_t cqc_entry_size;
00300         /** Number of reserved EQs */
00301         unsigned int reserved_eqs;
00302         /** EQ context entry size */
00303         size_t eqc_entry_size;
00304         /** Number of reserved MTTs */
00305         unsigned int reserved_mtts;
00306         /** MTT entry size */
00307         size_t mtt_entry_size;
00308         /** Number of reserved MRWs */
00309         unsigned int reserved_mrws;
00310         /** DMPT entry size */
00311         size_t dmpt_entry_size;
00312         /** Number of reserved UARs */
00313         unsigned int reserved_uars;
00314         /** Number of ports */
00315         unsigned int num_ports;
00316         /** Dual-port different protocol */
00317         int dpdp;
00318 };
00319 
00320 /** Number of cMPT entries of each type */
00321 #define HERMON_CMPT_MAX_ENTRIES ( 1 << 24 )
00322 
00323 /** Hermon ICM memory map entry */
00324 struct hermon_icm_map {
00325         /** Offset (virtual address within ICM) */
00326         uint64_t offset;
00327         /** Length */
00328         size_t len;
00329 };
00330 
00331 /** Discontiguous regions within Hermon ICM */
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 /** UAR page for doorbell accesses
00342  *
00343  * Pages 0-127 are reserved for event queue doorbells only, so we use
00344  * page 128.
00345  */
00346 #define HERMON_UAR_NON_EQ_PAGE  128
00347 
00348 /** Maximum number of allocatable MTT entries
00349  *
00350  * This is a policy decision, not a device limit.
00351  */
00352 #define HERMON_MAX_MTTS         64
00353 
00354 /** A Hermon MTT descriptor */
00355 struct hermon_mtt {
00356         /** MTT offset */
00357         unsigned int mtt_offset;
00358         /** Number of pages */
00359         unsigned int num_pages;
00360         /** MTT base address */
00361         unsigned int mtt_base_addr;
00362         /** Offset within page */
00363         unsigned int page_offset;
00364 };
00365 
00366 /** Alignment of Hermon send work queue entries */
00367 #define HERMON_SEND_WQE_ALIGN 128
00368 
00369 /** A Hermon send work queue entry */
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 /** A Hermon send work queue */
00379 struct hermon_send_work_queue {
00380         /** Number of work queue entries, including headroom
00381          *
00382          * Hermon requires us to leave unused space within the send
00383          * WQ, so we create a send WQ with more entries than are
00384          * requested in the create_qp() call.
00385          */
00386         unsigned int num_wqes;
00387         /** Work queue entries */
00388         union hermon_send_wqe *wqe;
00389         /** Size of work queue */
00390         size_t wqe_size;
00391         /** Doorbell register */
00392         void *doorbell;
00393 };
00394 
00395 /** Alignment of Hermon receive work queue entries */
00396 #define HERMON_RECV_WQE_ALIGN 16
00397 
00398 /** A Hermon receive work queue entry */
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 /** A Hermon receive work queue */
00405 struct hermon_recv_work_queue {
00406         /** Work queue entries */
00407         union hermon_recv_wqe *wqe;
00408         /** Size of work queue */
00409         size_t wqe_size;
00410         /** Doorbell */
00411         struct hermonprm_qp_db_record doorbell __attribute__ (( aligned (4) ));
00412 };
00413 
00414 /** Number of special queue pairs */
00415 #define HERMON_NUM_SPECIAL_QPS 8
00416 
00417 /** Number of queue pairs reserved for the "special QP" block
00418  *
00419  * The special QPs must be within a contiguous block aligned on its
00420  * own size.
00421  */
00422 #define HERMON_RSVD_SPECIAL_QPS ( ( HERMON_NUM_SPECIAL_QPS << 1 ) - 1 )
00423 
00424 /** Maximum number of allocatable queue pairs
00425  *
00426  * This is a policy decision, not a device limit.
00427  */
00428 #define HERMON_MAX_QPS          8
00429 
00430 /** Queue pair number randomisation mask */
00431 #define HERMON_QPN_RANDOM_MASK 0xfff000
00432 
00433 /** Hermon queue pair state */
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 /** A Hermon queue pair */
00442 struct hermon_queue_pair {
00443         /** Work queue buffer */
00444         void *wqe;
00445         /** Size of work queue buffer */
00446         size_t wqe_size;
00447         /** MTT descriptor */
00448         struct hermon_mtt mtt;
00449         /** Send work queue */
00450         struct hermon_send_work_queue send;
00451         /** Receive work queue */
00452         struct hermon_recv_work_queue recv;
00453         /** Queue state */
00454         enum hermon_queue_pair_state state;
00455 };
00456 
00457 /** Maximum number of allocatable completion queues
00458  *
00459  * This is a policy decision, not a device limit.
00460  */
00461 #define HERMON_MAX_CQS          8
00462 
00463 /** A Hermon completion queue */
00464 struct hermon_completion_queue {
00465         /** Completion queue entries */
00466         union hermonprm_completion_entry *cqe;
00467         /** Size of completion queue */
00468         size_t cqe_size;
00469         /** MTT descriptor */
00470         struct hermon_mtt mtt;
00471         /** Doorbell */
00472         struct hermonprm_cq_db_record doorbell __attribute__ (( aligned (8) ));
00473 };
00474 
00475 /** Maximum number of allocatable event queues
00476  *
00477  * This is a policy decision, not a device limit.
00478  */
00479 #define HERMON_MAX_EQS          8
00480 
00481 /** A Hermon event queue */
00482 struct hermon_event_queue {
00483         /** Event queue entries */
00484         union hermonprm_event_entry *eqe;
00485         /** Size of event queue */
00486         size_t eqe_size;
00487         /** MTT descriptor */
00488         struct hermon_mtt mtt;
00489         /** Event queue number */
00490         unsigned long eqn;
00491         /** Next event queue entry index */
00492         unsigned long next_idx;
00493         /** Doorbell register */
00494         void *doorbell;
00495 };
00496 
00497 /** Number of event queue entries
00498  *
00499  * This is a policy decision.
00500  */
00501 #define HERMON_NUM_EQES         4
00502 
00503 /** A Hermon resource bitmask */
00504 typedef uint32_t hermon_bitmask_t;
00505 
00506 /** Size of a hermon resource bitmask */
00507 #define HERMON_BITMASK_SIZE(max_entries)                                     \
00508         ( ( (max_entries) + ( 8 * sizeof ( hermon_bitmask_t ) ) - 1 ) /      \
00509           ( 8 * sizeof ( hermon_bitmask_t ) ) )
00510 
00511 /** A Hermon device */
00512 struct hermon {
00513         /** PCI configuration registers */
00514         void *config;
00515         /** PCI user Access Region */
00516         void *uar;
00517 
00518         /** Command toggle */
00519         unsigned int toggle;
00520         /** Command input mailbox */
00521         void *mailbox_in;
00522         /** Command output mailbox */
00523         void *mailbox_out;
00524 
00525         /** Firmware area in external memory */
00526         userptr_t firmware_area;
00527         /** ICM map */
00528         struct hermon_icm_map icm_map[HERMON_ICM_NUM_REGIONS];
00529         /** ICM area */
00530         userptr_t icm;
00531 
00532         /** Event queue */
00533         struct hermon_event_queue eq;
00534         /** Unrestricted LKey
00535          *
00536          * Used to get unrestricted memory access.
00537          */
00538         unsigned long lkey;
00539 
00540         /** Completion queue in-use bitmask */
00541         hermon_bitmask_t cq_inuse[ HERMON_BITMASK_SIZE ( HERMON_MAX_CQS ) ];
00542         /** Queue pair in-use bitmask */
00543         hermon_bitmask_t qp_inuse[ HERMON_BITMASK_SIZE ( HERMON_MAX_QPS ) ];
00544         /** MTT entry in-use bitmask */
00545         hermon_bitmask_t mtt_inuse[ HERMON_BITMASK_SIZE ( HERMON_MAX_MTTS ) ];
00546 
00547         /** Device capabilities */
00548         struct hermon_dev_cap cap;
00549         /** Special QPN base */
00550         unsigned long special_qpn_base;
00551         /** QPN base */
00552         unsigned long qpn_base;
00553 
00554         /** Infiniband devices */
00555         struct ib_device *ibdev[HERMON_MAX_PORTS];
00556 };
00557 
00558 /** Global protection domain */
00559 #define HERMON_GLOBAL_PD                0x123456
00560 
00561 /** Memory key prefix */
00562 #define HERMON_MKEY_PREFIX              0x77000000UL
00563 
00564 /*
00565  * HCA commands
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 /* HCA command is split into
00576  *
00577  * bits  11:0   Opcode
00578  * bit     12   Input uses mailbox
00579  * bit     13   Output uses mailbox
00580  * bits 22:14   Input parameter length (in dwords)
00581  * bits 31:23   Output parameter length (in dwords)
00582  *
00583  * Encoding the information in this way allows us to cut out several
00584  * parameters to the hermon_command() call.
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 /** Build HCR command from component parts */
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 /* _HERMON_H */

Generated on Tue Apr 6 20:00:53 2010 for gPXE by  doxygen 1.5.7.1