summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2007-09-18 08:07:04 +0200
committerMichael Brown2007-09-18 08:07:04 +0200
commit0f60150c44f3e6d70baa88050f2779ae25e403c5 (patch)
tree153cca57735c8e35d14d98fe660aa40931db1b2a
parentMerge branch 'master' into 3leaf-rewrite (diff)
downloadipxe-0f60150c44f3e6d70baa88050f2779ae25e403c5.tar.gz
ipxe-0f60150c44f3e6d70baa88050f2779ae25e403c5.tar.xz
ipxe-0f60150c44f3e6d70baa88050f2779ae25e403c5.zip
Reverted driver/net/mlx_ipoib to clean master state
-rw-r--r--src/drivers/net/mlx_ipoib/arbel.h455
-rw-r--r--src/drivers/net/mlx_ipoib/bit_ops.h191
-rw-r--r--src/drivers/net/mlx_ipoib/cmdif_comm.c30
-rw-r--r--src/drivers/net/mlx_ipoib/cmdif_mt25218.c51
-rw-r--r--src/drivers/net/mlx_ipoib/doc/README.boot_over_ib20
-rw-r--r--src/drivers/net/mlx_ipoib/ib_driver.c32
-rw-r--r--src/drivers/net/mlx_ipoib/ib_driver.h12
-rw-r--r--src/drivers/net/mlx_ipoib/ib_mad.c7
-rw-r--r--src/drivers/net/mlx_ipoib/ib_mad.h2
-rw-r--r--src/drivers/net/mlx_ipoib/ib_mt23108.c64
-rw-r--r--src/drivers/net/mlx_ipoib/ib_mt25218.c125
-rw-r--r--src/drivers/net/mlx_ipoib/ipoib.c68
-rw-r--r--src/drivers/net/mlx_ipoib/mt23108.c37
-rw-r--r--src/drivers/net/mlx_ipoib/mt23108_imp.c6
-rw-r--r--src/drivers/net/mlx_ipoib/mt25218.c2267
-rw-r--r--src/drivers/net/mlx_ipoib/mt25218.h50
-rw-r--r--src/drivers/net/mlx_ipoib/mt25218_imp.c8
-rw-r--r--src/drivers/net/mlx_ipoib/mt_version.c2
-rw-r--r--src/drivers/net/mlx_ipoib/patches/dhcpd.patch18
19 files changed, 361 insertions, 3084 deletions
diff --git a/src/drivers/net/mlx_ipoib/arbel.h b/src/drivers/net/mlx_ipoib/arbel.h
deleted file mode 100644
index dcca5107..00000000
--- a/src/drivers/net/mlx_ipoib/arbel.h
+++ /dev/null
@@ -1,455 +0,0 @@
-#ifndef _ARBEL_H
-#define _ARBEL_H
-
-/** @file
- *
- * Mellanox Arbel Infiniband HCA driver
- *
- */
-
-#include <stdint.h>
-#include <gpxe/uaccess.h>
-
-/*
- * Hardware constants
- *
- */
-
-/* PCI BARs */
-#define ARBEL_PCI_CONFIG_BAR PCI_BASE_ADDRESS_0
-#define ARBEL_PCI_CONFIG_BAR_SIZE 0x100000
-#define ARBEL_PCI_UAR_BAR PCI_BASE_ADDRESS_2
-#define ARBEL_PCI_UAR_IDX 1
-#define ARBEL_PCI_UAR_SIZE 0x1000
-
-/* UAR context table (UCE) resource types */
-#define ARBEL_UAR_RES_NONE 0x00
-#define ARBEL_UAR_RES_CQ_CI 0x01
-#define ARBEL_UAR_RES_CQ_ARM 0x02
-#define ARBEL_UAR_RES_SQ 0x03
-#define ARBEL_UAR_RES_RQ 0x04
-#define ARBEL_UAR_RES_GROUP_SEP 0x07
-
-/* Work queue entry and completion queue entry opcodes */
-#define ARBEL_OPCODE_SEND 0x0a
-#define ARBEL_OPCODE_RECV_ERROR 0xfe
-#define ARBEL_OPCODE_SEND_ERROR 0xff
-
-/* HCA command register opcodes */
-#define ARBEL_HCR_QUERY_DEV_LIM 0x0003
-#define ARBEL_HCR_QUERY_FW 0x0004
-#define ARBEL_HCR_INIT_HCA 0x0007
-#define ARBEL_HCR_CLOSE_HCA 0x0008
-#define ARBEL_HCR_INIT_IB 0x0009
-#define ARBEL_HCR_CLOSE_IB 0x000a
-#define ARBEL_HCR_SW2HW_MPT 0x000d
-#define ARBEL_HCR_MAP_EQ 0x0012
-#define ARBEL_HCR_SW2HW_EQ 0x0013
-#define ARBEL_HCR_HW2SW_EQ 0x0014
-#define ARBEL_HCR_SW2HW_CQ 0x0016
-#define ARBEL_HCR_HW2SW_CQ 0x0017
-#define ARBEL_HCR_RST2INIT_QPEE 0x0019
-#define ARBEL_HCR_INIT2RTR_QPEE 0x001a
-#define ARBEL_HCR_RTR2RTS_QPEE 0x001b
-#define ARBEL_HCR_2RST_QPEE 0x0021
-#define ARBEL_HCR_MAD_IFC 0x0024
-#define ARBEL_HCR_READ_MGM 0x0025
-#define ARBEL_HCR_WRITE_MGM 0x0026
-#define ARBEL_HCR_MGID_HASH 0x0027
-#define ARBEL_HCR_RUN_FW 0x0ff6
-#define ARBEL_HCR_DISABLE_LAM 0x0ff7
-#define ARBEL_HCR_ENABLE_LAM 0x0ff8
-#define ARBEL_HCR_UNMAP_ICM 0x0ff9
-#define ARBEL_HCR_MAP_ICM 0x0ffa
-#define ARBEL_HCR_UNMAP_ICM_AUX 0x0ffb
-#define ARBEL_HCR_MAP_ICM_AUX 0x0ffc
-#define ARBEL_HCR_SET_ICM_SIZE 0x0ffd
-#define ARBEL_HCR_UNMAP_FA 0x0ffe
-#define ARBEL_HCR_MAP_FA 0x0fff
-
-/* Service types */
-#define ARBEL_ST_UD 0x03
-
-/* MTUs */
-#define ARBEL_MTU_2048 0x04
-
-#define ARBEL_NO_EQ 64
-
-#define ARBEL_INVALID_LKEY 0x00000100UL
-
-/*
- * Datatypes that seem to be missing from the autogenerated documentation
- *
- */
-struct arbelprm_mgm_hash_st {
- pseudo_bit_t reserved0[0x00020];
-/* -------------- */
- pseudo_bit_t hash[0x00010];
- pseudo_bit_t reserved1[0x00010];
-} __attribute__ (( packed ));
-
-struct arbelprm_scalar_parameter_st {
- pseudo_bit_t reserved0[0x00020];
-/* -------------- */
- pseudo_bit_t value[0x00020];
-} __attribute__ (( packed ));
-
-/*
- * Wrapper structures for hardware datatypes
- *
- */
-
-struct MLX_DECLARE_STRUCT ( arbelprm_access_lam );
-struct MLX_DECLARE_STRUCT ( arbelprm_completion_queue_context );
-struct MLX_DECLARE_STRUCT ( arbelprm_completion_queue_entry );
-struct MLX_DECLARE_STRUCT ( arbelprm_completion_with_error );
-struct MLX_DECLARE_STRUCT ( arbelprm_cq_arm_db_record );
-struct MLX_DECLARE_STRUCT ( arbelprm_cq_ci_db_record );
-struct MLX_DECLARE_STRUCT ( arbelprm_eqc );
-struct MLX_DECLARE_STRUCT ( arbelprm_hca_command_register );
-struct MLX_DECLARE_STRUCT ( arbelprm_init_hca );
-struct MLX_DECLARE_STRUCT ( arbelprm_init_ib );
-struct MLX_DECLARE_STRUCT ( arbelprm_mad_ifc );
-struct MLX_DECLARE_STRUCT ( arbelprm_mgm_entry );
-struct MLX_DECLARE_STRUCT ( arbelprm_mgm_hash );
-struct MLX_DECLARE_STRUCT ( arbelprm_mpt );
-struct MLX_DECLARE_STRUCT ( arbelprm_qp_db_record );
-struct MLX_DECLARE_STRUCT ( arbelprm_qp_ee_state_transitions );
-struct MLX_DECLARE_STRUCT ( arbelprm_query_dev_lim );
-struct MLX_DECLARE_STRUCT ( arbelprm_query_fw );
-struct MLX_DECLARE_STRUCT ( arbelprm_queue_pair_ee_context_entry );
-struct MLX_DECLARE_STRUCT ( arbelprm_recv_wqe_segment_next );
-struct MLX_DECLARE_STRUCT ( arbelprm_scalar_parameter );
-struct MLX_DECLARE_STRUCT ( arbelprm_send_doorbell );
-struct MLX_DECLARE_STRUCT ( arbelprm_ud_address_vector );
-struct MLX_DECLARE_STRUCT ( arbelprm_virtual_physical_mapping );
-struct MLX_DECLARE_STRUCT ( arbelprm_wqe_segment_ctrl_send );
-struct MLX_DECLARE_STRUCT ( arbelprm_wqe_segment_data_ptr );
-struct MLX_DECLARE_STRUCT ( arbelprm_wqe_segment_next );
-struct MLX_DECLARE_STRUCT ( arbelprm_wqe_segment_ud );
-
-/*
- * Composite hardware datatypes
- *
- */
-
-#define ARBEL_MAX_GATHER 1
-
-struct arbelprm_ud_send_wqe {
- struct arbelprm_wqe_segment_next next;
- struct arbelprm_wqe_segment_ctrl_send ctrl;
- struct arbelprm_wqe_segment_ud ud;
- struct arbelprm_wqe_segment_data_ptr data[ARBEL_MAX_GATHER];
-} __attribute__ (( packed ));
-
-#define ARBEL_MAX_SCATTER 1
-
-struct arbelprm_recv_wqe {
- /* The autogenerated header is inconsistent between send and
- * receive WQEs. The "ctrl" structure for receive WQEs is
- * defined to include the "next" structure. Since the "ctrl"
- * part of the "ctrl" structure contains only "reserved, must
- * be zero" bits, we ignore its definition and provide
- * something more usable.
- */
- struct arbelprm_recv_wqe_segment_next next;
- uint32_t ctrl[2]; /* All "reserved, must be zero" */
- struct arbelprm_wqe_segment_data_ptr data[ARBEL_MAX_SCATTER];
-} __attribute__ (( packed ));
-
-union arbelprm_completion_entry {
- struct arbelprm_completion_queue_entry normal;
- struct arbelprm_completion_with_error error;
-} __attribute__ (( packed ));
-
-union arbelprm_doorbell_record {
- struct arbelprm_cq_arm_db_record cq_arm;
- struct arbelprm_cq_ci_db_record cq_ci;
- struct arbelprm_qp_db_record qp;
-} __attribute__ (( packed ));
-
-union arbelprm_doorbell_register {
- struct arbelprm_send_doorbell send;
- uint32_t dword[2];
-} __attribute__ (( packed ));
-
-union arbelprm_mad {
- struct arbelprm_mad_ifc ifc;
- union ib_mad mad;
-} __attribute__ (( packed ));
-
-/*
- * gPXE-specific definitions
- *
- */
-
-/** Arbel device limits */
-struct arbel_dev_limits {
- /** Number of reserved QPs */
- unsigned int reserved_qps;
- /** QP context entry size */
- size_t qpc_entry_size;
- /** Extended QP context entry size */
- size_t eqpc_entry_size;
- /** Number of reserved SRQs */
- unsigned int reserved_srqs;
- /** SRQ context entry size */
- size_t srqc_entry_size;
- /** Number of reserved EEs */
- unsigned int reserved_ees;
- /** EE context entry size */
- size_t eec_entry_size;
- /** Extended EE context entry size */
- size_t eeec_entry_size;
- /** Number of reserved CQs */
- unsigned int reserved_cqs;
- /** CQ context entry size */
- size_t cqc_entry_size;
- /** Number of reserved MTTs */
- unsigned int reserved_mtts;
- /** MTT entry size */
- size_t mtt_entry_size;
- /** Number of reserved MRWs */
- unsigned int reserved_mrws;
- /** MPT entry size */
- size_t mpt_entry_size;
- /** Number of reserved RDBs */
- unsigned int reserved_rdbs;
- /** EQ context entry size */
- size_t eqc_entry_size;
- /** Number of reserved UARs */
- unsigned int reserved_uars;
-};
-
-/** Alignment of Arbel send work queue entries */
-#define ARBEL_SEND_WQE_ALIGN 128
-
-/** An Arbel send work queue entry */
-union arbel_send_wqe {
- struct arbelprm_ud_send_wqe ud;
- uint8_t force_align[ARBEL_SEND_WQE_ALIGN];
-} __attribute__ (( packed ));
-
-/** An Arbel send work queue */
-struct arbel_send_work_queue {
- /** Doorbell record number */
- unsigned int doorbell_idx;
- /** Work queue entries */
- union arbel_send_wqe *wqe;
- /** Size of work queue */
- size_t wqe_size;
-};
-
-/** Alignment of Arbel receive work queue entries */
-#define ARBEL_RECV_WQE_ALIGN 64
-
-/** An Arbel receive work queue entry */
-union arbel_recv_wqe {
- struct arbelprm_recv_wqe recv;
- uint8_t force_align[ARBEL_RECV_WQE_ALIGN];
-} __attribute__ (( packed ));
-
-/** An Arbel receive work queue */
-struct arbel_recv_work_queue {
- /** Doorbell record number */
- unsigned int doorbell_idx;
- /** Work queue entries */
- union arbel_recv_wqe *wqe;
- /** Size of work queue */
- size_t wqe_size;
-};
-
-/** Maximum number of allocatable queue pairs
- *
- * This is a policy decision, not a device limit.
- */
-#define ARBEL_MAX_QPS 8
-
-/** Base queue pair number */
-#define ARBEL_QPN_BASE 0x550000
-
-/** An Arbel queue pair */
-struct arbel_queue_pair {
- /** Send work queue */
- struct arbel_send_work_queue send;
- /** Receive work queue */
- struct arbel_recv_work_queue recv;
-};
-
-/** Maximum number of allocatable completion queues
- *
- * This is a policy decision, not a device limit.
- */
-#define ARBEL_MAX_CQS 8
-
-/** An Arbel completion queue */
-struct arbel_completion_queue {
- /** Consumer counter doorbell record number */
- unsigned int ci_doorbell_idx;
- /** Arm queue doorbell record number */
- unsigned int arm_doorbell_idx;
- /** Completion queue entries */
- union arbelprm_completion_entry *cqe;
- /** Size of completion queue */
- size_t cqe_size;
-};
-
-/** An Arbel resource bitmask */
-typedef uint32_t arbel_bitmask_t;
-
-/** Size of an Arbel resource bitmask */
-#define ARBEL_BITMASK_SIZE(max_entries) \
- ( ( (max_entries) + ( 8 * sizeof ( arbel_bitmask_t ) ) - 1 ) / \
- ( 8 * sizeof ( arbel_bitmask_t ) ) )
-
-/** An Arbel device */
-struct arbel {
- /** PCI configuration registers */
- void *config;
- /** PCI user Access Region */
- void *uar;
-
- /** Command input mailbox */
- void *mailbox_in;
- /** Command output mailbox */
- void *mailbox_out;
-
- /** Firmware area in external memory */
- userptr_t firmware_area;
- /** ICM size */
- size_t icm_len;
- /** ICM AUX size */
- size_t icm_aux_len;
- /** ICM area */
- userptr_t icm;
-
- /** Doorbell records */
- union arbelprm_doorbell_record *db_rec;
- /** Reserved LKey
- *
- * Used to get unrestricted memory access.
- */
- unsigned long reserved_lkey;
-
- /** Completion queue in-use bitmask */
- arbel_bitmask_t cq_inuse[ ARBEL_BITMASK_SIZE ( ARBEL_MAX_CQS ) ];
- /** Queue pair in-use bitmask */
- arbel_bitmask_t qp_inuse[ ARBEL_BITMASK_SIZE ( ARBEL_MAX_QPS ) ];
-
- /** Device limits */
- struct arbel_dev_limits limits;
-};
-
-/** Global protection domain */
-#define ARBEL_GLOBAL_PD 0x123456
-
-/** Memory key prefix */
-#define ARBEL_MKEY_PREFIX 0x77000000UL
-
-/*
- * HCA commands
- *
- */
-
-#define ARBEL_HCR_BASE 0x80680
-#define ARBEL_HCR_REG(x) ( ARBEL_HCR_BASE + 4 * (x) )
-#define ARBEL_HCR_MAX_WAIT_MS 2000
-#define ARBEL_MBOX_ALIGN 4096
-#define ARBEL_MBOX_SIZE 512
-
-/* HCA command is split into
- *
- * bits 11:0 Opcode
- * bit 12 Input uses mailbox
- * bit 13 Output uses mailbox
- * bits 22:14 Input parameter length (in dwords)
- * bits 31:23 Output parameter length (in dwords)
- *
- * Encoding the information in this way allows us to cut out several
- * parameters to the arbel_command() call.
- */
-#define ARBEL_HCR_IN_MBOX 0x00001000UL
-#define ARBEL_HCR_OUT_MBOX 0x00002000UL
-#define ARBEL_HCR_OPCODE( _command ) ( (_command) & 0xfff )
-#define ARBEL_HCR_IN_LEN( _command ) ( ( (_command) >> 12 ) & 0x7fc )
-#define ARBEL_HCR_OUT_LEN( _command ) ( ( (_command) >> 21 ) & 0x7fc )
-
-/** Build HCR command from component parts */
-#define ARBEL_HCR_INOUT_CMD( _opcode, _in_mbox, _in_len, \
- _out_mbox, _out_len ) \
- ( (_opcode) | \
- ( (_in_mbox) ? ARBEL_HCR_IN_MBOX : 0 ) | \
- ( ( (_in_len) / 4 ) << 14 ) | \
- ( (_out_mbox) ? ARBEL_HCR_OUT_MBOX : 0 ) | \
- ( ( (_out_len) / 4 ) << 23 ) )
-
-#define ARBEL_HCR_IN_CMD( _opcode, _in_mbox, _in_len ) \
- ARBEL_HCR_INOUT_CMD ( _opcode, _in_mbox, _in_len, 0, 0 )
-
-#define ARBEL_HCR_OUT_CMD( _opcode, _out_mbox, _out_len ) \
- ARBEL_HCR_INOUT_CMD ( _opcode, 0, 0, _out_mbox, _out_len )
-
-#define ARBEL_HCR_VOID_CMD( _opcode ) \
- ARBEL_HCR_INOUT_CMD ( _opcode, 0, 0, 0, 0 )
-
-/*
- * Doorbell record allocation
- *
- * The doorbell record map looks like:
- *
- * ARBEL_MAX_CQS * Arm completion queue doorbell
- * ARBEL_MAX_QPS * Send work request doorbell
- * Group separator
- * ...(empty space)...
- * ARBEL_MAX_QPS * Receive work request doorbell
- * ARBEL_MAX_CQS * Completion queue consumer counter update doorbell
- */
-
-#define ARBEL_MAX_DOORBELL_RECORDS 512
-#define ARBEL_GROUP_SEPARATOR_DOORBELL ( ARBEL_MAX_CQS + ARBEL_MAX_QPS )
-
-/**
- * Get arm completion queue doorbell index
- *
- * @v cqn_offset Completion queue number offset
- * @ret doorbell_idx Doorbell index
- */
-static inline unsigned int
-arbel_cq_arm_doorbell_idx ( unsigned int cqn_offset ) {
- return cqn_offset;
-}
-
-/**
- * Get send work request doorbell index
- *
- * @v qpn_offset Queue pair number offset
- * @ret doorbell_idx Doorbell index
- */
-static inline unsigned int
-arbel_send_doorbell_idx ( unsigned int qpn_offset ) {
- return ( ARBEL_MAX_CQS + qpn_offset );
-}
-
-/**
- * Get receive work request doorbell index
- *
- * @v qpn_offset Queue pair number offset
- * @ret doorbell_idx Doorbell index
- */
-static inline unsigned int
-arbel_recv_doorbell_idx ( unsigned int qpn_offset ) {
- return ( ARBEL_MAX_DOORBELL_RECORDS - ARBEL_MAX_CQS - qpn_offset - 1 );
-}
-
-/**
- * Get completion queue consumer counter doorbell index
- *
- * @v cqn_offset Completion queue number offset
- * @ret doorbell_idx Doorbell index
- */
-static inline unsigned int
-arbel_cq_ci_doorbell_idx ( unsigned int cqn_offset ) {
- return ( ARBEL_MAX_DOORBELL_RECORDS - cqn_offset - 1 );
-}
-
-#endif /* _ARBEL_H */
diff --git a/src/drivers/net/mlx_ipoib/bit_ops.h b/src/drivers/net/mlx_ipoib/bit_ops.h
index 8b81bfcc..e3fb4331 100644
--- a/src/drivers/net/mlx_ipoib/bit_ops.h
+++ b/src/drivers/net/mlx_ipoib/bit_ops.h
@@ -81,14 +81,6 @@ struct addr_64_st {
#define MT_EXTRACT_ARRAY32(A,O,S) MT_EXTRACT32(((__u32*)A)[O >> 5],(O & MASK32(5)),S)
/*
- * MT_EXTRACT_ARRAY32_BE macro is similar to EXTRACT but works on an array of (__u32),
- * thus offset may be larger than 32 (but not size).
- *
- * (added by mcb30)
- */
-#define MT_EXTRACT_ARRAY32_BE(A,O,S) MT_EXTRACT32(be32_to_cpu(((__u32*)A)[O >> 5]),(O & MASK32(5)),S)
-
-/*
* MT_INSERT_ARRAY32 macro is similar to INSERT but works on an array of (__u32),
* thus offset may be larger than 32 (but not size).
*/
@@ -98,8 +90,6 @@ struct addr_64_st {
#define EX_FLD(a, st, fld) MT_EXTRACT_ARRAY32(a, MT_BIT_OFFSET(st, fld), MT_BIT_SIZE(st, fld))
-#define EX_FLD_BE(a, st, fld) MT_EXTRACT_ARRAY32_BE(a, MT_BIT_OFFSET(st, fld), MT_BIT_SIZE(st, fld))
-
/* return the address of the dword holding the field
buf = pointer to buffer where to place the value
@@ -133,185 +123,4 @@ struct addr_64_st {
field; \
})
-
-
-/* Remaining code Copyright Fen Systems Ltd. 2007 */
-
-/**
- * Wrapper structure for pseudo_bit_t structures
- *
- * This structure provides a wrapper around the autogenerated
- * pseudo_bit_t structures. It has the correct size, and also
- * encapsulates type information about the underlying pseudo_bit_t
- * structure, which allows the MLX_FILL etc. macros to work without
- * requiring explicit type information.
- */
-#define MLX_DECLARE_STRUCT( _structure ) \
- _structure { \
- union { \
- uint8_t bytes[ sizeof ( struct _structure ## _st ) / 8 ]; \
- uint32_t dwords[ sizeof ( struct _structure ## _st ) / 32 ]; \
- struct _structure ## _st *dummy[0]; \
- } u; \
- }
-
-/** Get pseudo_bit_t structure type from wrapper structure pointer */
-#define MLX_PSEUDO_STRUCT( _ptr ) \
- typeof ( *((_ptr)->u.dummy[0]) )
-
-/** Bit offset of a field within a pseudo_bit_t structure */
-#define MLX_BIT_OFFSET( _structure_st, _field ) \
- offsetof ( _structure_st, _field )
-
-/** Dword offset of a field within a pseudo_bit_t structure */
-#define MLX_DWORD_OFFSET( _structure_st, _field ) \
- ( MLX_BIT_OFFSET ( _structure_st, _field ) / 32 )
-
-/** Dword bit offset of a field within a pseudo_bit_t structure
- *
- * Yes, using mod-32 would work, but would lose the check for the
- * error of specifying a mismatched field name and dword index.
- */
-#define MLX_DWORD_BIT_OFFSET( _structure_st, _index, _field ) \
- ( MLX_BIT_OFFSET ( _structure_st, _field ) - ( 32 * (_index) ) )
-
-/** Bit width of a field within a pseudo_bit_t structure */
-#define MLX_BIT_WIDTH( _structure_st, _field ) \
- sizeof ( ( ( _structure_st * ) NULL )->_field )
-
-/** Bit mask for a field within a pseudo_bit_t structure */
-#define MLX_BIT_MASK( _structure_st, _field ) \
- ( ( ~( ( uint32_t ) 0 ) ) >> \
- ( 32 - MLX_BIT_WIDTH ( _structure_st, _field ) ) )
-
-/*
- * Assemble native-endian dword from named fields and values
- *
- */
-
-#define MLX_ASSEMBLE_1( _structure_st, _index, _field, _value ) \
- ( (_value) << MLX_DWORD_BIT_OFFSET ( _structure_st, _index, _field ) )
-
-#define MLX_ASSEMBLE_2( _structure_st, _index, _field, _value, ... ) \
- ( MLX_ASSEMBLE_1 ( _structure_st, _index, _field, _value ) | \
- MLX_ASSEMBLE_1 ( _structure_st, _index, __VA_ARGS__ ) )
-
-#define MLX_ASSEMBLE_3( _structure_st, _index, _field, _value, ... ) \
- ( MLX_ASSEMBLE_1 ( _structure_st, _index, _field, _value ) | \
- MLX_ASSEMBLE_2 ( _structure_st, _index, __VA_ARGS__ ) )
-
-#define MLX_ASSEMBLE_4( _structure_st, _index, _field, _value, ... ) \
- ( MLX_ASSEMBLE_1 ( _structure_st, _index, _field, _value ) | \
- MLX_ASSEMBLE_3 ( _structure_st, _index, __VA_ARGS__ ) )
-
-#define MLX_ASSEMBLE_5( _structure_st, _index, _field, _value, ... ) \
- ( MLX_ASSEMBLE_1 ( _structure_st, _index, _field, _value ) | \
- MLX_ASSEMBLE_4 ( _structure_st, _index, __VA_ARGS__ ) )
-
-#define MLX_ASSEMBLE_6( _structure_st, _index, _field, _value, ... ) \
- ( MLX_ASSEMBLE_1 ( _structure_st, _index, _field, _value ) | \
- MLX_ASSEMBLE_5 ( _structure_st, _index, __VA_ARGS__ ) )
-
-/*
- * Build native-endian (positive) dword bitmasks from named fields
- *
- */
-
-#define MLX_MASK_1( _structure_st, _index, _field ) \
- ( MLX_BIT_MASK ( _structure_st, _field ) << \
- MLX_DWORD_BIT_OFFSET ( _structure_st, _index, _field ) )
-
-#define MLX_MASK_2( _structure_st, _index, _field, ... ) \
- ( MLX_MASK_1 ( _structure_st, _index, _field ) | \
- MLX_MASK_1 ( _structure_st, _index, __VA_ARGS__ ) )
-
-#define MLX_MASK_3( _structure_st, _index, _field, ... ) \
- ( MLX_MASK_1 ( _structure_st, _index, _field ) | \
- MLX_MASK_2 ( _structure_st, _index, __VA_ARGS__ ) )
-
-#define MLX_MASK_4( _structure_st, _index, _field, ... ) \
- ( MLX_MASK_1 ( _structure_st, _index, _field ) | \
- MLX_MASK_3 ( _structure_st, _index, __VA_ARGS__ ) )
-
-#define MLX_MASK_5( _structure_st, _index, _field, ... ) \
- ( MLX_MASK_1 ( _structure_st, _index, _field ) | \
- MLX_MASK_4 ( _structure_st, _index, __VA_ARGS__ ) )
-
-#define MLX_MASK_6( _structure_st, _index, _field, ... ) \
- ( MLX_MASK_1 ( _structure_st, _index, _field ) | \
- MLX_MASK_5 ( _structure_st, _index, __VA_ARGS__ ) )
-
-/*
- * Populate big-endian dwords from named fields and values
- *
- */
-
-#define MLX_FILL( _ptr, _index, _assembled ) \
- do { \
- uint32_t *__ptr = &(_ptr)->u.dwords[(_index)]; \
- uint32_t __assembled = (_assembled); \
- *__ptr = cpu_to_be32 ( __assembled ); \
- } while ( 0 )
-
-#define MLX_FILL_1( _ptr, _index, ... ) \
- MLX_FILL ( _ptr, _index, MLX_ASSEMBLE_1 ( MLX_PSEUDO_STRUCT ( _ptr ),\
- _index, __VA_ARGS__ ) )
-
-#define MLX_FILL_2( _ptr, _index, ... ) \
- MLX_FILL ( _ptr, _index, MLX_ASSEMBLE_2 ( MLX_PSEUDO_STRUCT ( _ptr ),\
- _index, __VA_ARGS__ ) )
-
-#define MLX_FILL_3( _ptr, _index, ... ) \
- MLX_FILL ( _ptr, _index, MLX_ASSEMBLE_3 ( MLX_PSEUDO_STRUCT ( _ptr ),\
- _index, __VA_ARGS__ ) )
-
-#define MLX_FILL_4( _ptr, _index, ... ) \
- MLX_FILL ( _ptr, _index, MLX_ASSEMBLE_4 ( MLX_PSEUDO_STRUCT ( _ptr ),\
- _index, __VA_ARGS__ ) )
-
-#define MLX_FILL_5( _ptr, _index, ... ) \
- MLX_FILL ( _ptr, _index, MLX_ASSEMBLE_5 ( MLX_PSEUDO_STRUCT ( _ptr ),\
- _index, __VA_ARGS__ ) )
-
-#define MLX_FILL_6( _ptr, _index, ... ) \
- MLX_FILL ( _ptr, _index, MLX_ASSEMBLE_6 ( MLX_PSEUDO_STRUCT ( _ptr ),\
- _index, __VA_ARGS__ ) )
-
-/*
- * Modify big-endian dword using named field and value
- *
- */
-
-#define MLX_SET( _ptr, _field, _value ) \
- do { \
- unsigned int __index = \
- MLX_DWORD_OFFSET ( MLX_PSEUDO_STRUCT ( _ptr ), _field ); \
- uint32_t *__ptr = &(_ptr)->u.dwords[__index]; \
- uint32_t __value = be32_to_cpu ( *__ptr ); \
- __value &= ~( MLX_MASK_1 ( MLX_PSEUDO_STRUCT ( _ptr ), \
- __index, _field ) ); \
- __value |= MLX_ASSEMBLE_1 ( MLX_PSEUDO_STRUCT ( _ptr ), \
- __index, _field, _value ); \
- *__ptr = cpu_to_be32 ( __value ); \
- } while ( 0 )
-
-/*
- * Extract value of named field
- *
- */
-
-#define MLX_GET( _ptr, _field ) \
- ( { \
- unsigned int __index = \
- MLX_DWORD_OFFSET ( MLX_PSEUDO_STRUCT ( _ptr ), _field ); \
- uint32_t *__ptr = &(_ptr)->u.dwords[__index]; \
- uint32_t __value = be32_to_cpu ( *__ptr ); \
- __value >>= \
- MLX_DWORD_BIT_OFFSET ( MLX_PSEUDO_STRUCT ( _ptr ), \
- __index, _field ); \
- __value &= \
- MLX_BIT_MASK ( MLX_PSEUDO_STRUCT ( _ptr ), _field ); \
- __value; \
- } )
-
#endif /* __bit_ops_h__ */
diff --git a/src/drivers/net/mlx_ipoib/cmdif_comm.c b/src/drivers/net/mlx_ipoib/cmdif_comm.c
index 363e4209..d43a1068 100644
--- a/src/drivers/net/mlx_ipoib/cmdif_comm.c
+++ b/src/drivers/net/mlx_ipoib/cmdif_comm.c
@@ -112,8 +112,6 @@ static XHH_cmd_status_t cmd_invoke(command_fields_t * cmd_prms)
__u32 hcr[7], data;
__u8 status;
- DBG ( "Executing command:\n" );
-
/* check if go bit is free */
ret = cmdif_is_free(&is_free);
if (ret) {
@@ -131,15 +129,6 @@ static XHH_cmd_status_t cmd_invoke(command_fields_t * cmd_prms)
edit_hcr(cmd_prms, hcr);
__asm__ __volatile__("":::"memory");
- DBG_HD ( &hcr[0], sizeof ( hcr ) );
- if ( cmd_prms->in_trans == TRANS_MAILBOX ) {
- size_t size = ( 4 * cmd_prms->in_param_size );
- if ( size > 512 )
- size = 512;
- DBG2 ( "Input mailbox:\n" );
- DBG2_HD ( &cmd_prms->in_param[0], size );
- }
-
for (i = 0; i < 7; ++i) {
ret = gw_write_cr(HCR_BASE + i * 4, hcr[i]);
if (ret) {
@@ -170,14 +159,6 @@ static XHH_cmd_status_t cmd_invoke(command_fields_t * cmd_prms)
return status;
}
- if ( cmd_prms->out_trans == TRANS_MAILBOX ) {
- size_t size = ( 4 * cmd_prms->out_param_size );
- if ( size > 512 )
- size = 512;
- DBG2 ( "Output mailbox:\n" );
- DBG2_HD ( &cmd_prms->out_param[0], size );
- }
-
if (cmd_prms->out_trans == TRANS_MAILBOX)
be_to_cpu_buf(cmd_prms->out_param, cmd_prms->out_param_size);
else if (cmd_prms->out_trans == TRANS_IMMEDIATE) {
@@ -187,8 +168,6 @@ static XHH_cmd_status_t cmd_invoke(command_fields_t * cmd_prms)
return -1;
}
- DBG ( "Command executed successfully\n" );
-
return 0;
}
@@ -563,10 +542,7 @@ static int cmd_mgid_hash(__u8 * gid, __u16 * mgid_hash_p)
{
int rc;
command_fields_t cmd_desc;
- union {
- __u32 u32;
- __u16 u16[2];
- } result;
+ __u16 result[2];
memset(&cmd_desc, 0, sizeof cmd_desc);
@@ -578,9 +554,9 @@ static int cmd_mgid_hash(__u8 * gid, __u16 * mgid_hash_p)
rc = cmd_invoke(&cmd_desc);
if (!rc) {
- rc = gw_read_cr(HCR_BASE + 16, &result.u32);
+ rc = gw_read_cr(HCR_BASE + 16, (__u32 *) result);
if (!rc) {
- *mgid_hash_p = result.u16[0];
+ *mgid_hash_p = result[0];
}
}
diff --git a/src/drivers/net/mlx_ipoib/cmdif_mt25218.c b/src/drivers/net/mlx_ipoib/cmdif_mt25218.c
index 704fb1fc..fb95edbe 100644
--- a/src/drivers/net/mlx_ipoib/cmdif_mt25218.c
+++ b/src/drivers/net/mlx_ipoib/cmdif_mt25218.c
@@ -23,6 +23,14 @@
#include "mt25218.h"
/*
+ * cmd_sys_dis
+ */
+static int cmd_sys_dis(void)
+{
+ return 0;
+}
+
+/*
* cmd_write_mgm
*/
static int cmd_write_mgm(void *mg, __u16 index)
@@ -317,24 +325,6 @@ static int cmd_map_icm_aux(struct map_icm_st *map_icm_aux_p)
return rc;
}
-
-/*
- * cmd_unmap_icm_aux
- */
-static int cmd_unmap_icm_aux(void)
-{
- int rc;
- command_fields_t cmd_desc;
-
- memset(&cmd_desc, 0, sizeof cmd_desc);
-
- cmd_desc.opcode = MEMFREE_CMD_UNMAP_ICM_AUX;
-
- rc = cmd_invoke(&cmd_desc);
-
- return rc;
-}
-
/*
* cmd_map_icm
*/
@@ -381,31 +371,6 @@ static int cmd_map_icm(struct map_icm_st *map_icm_p)
return rc;
}
-
-
-/*
- * cmd_unmap_icm
- */
-static int cmd_unmap_icm(struct map_icm_st *map_icm_p)
-{
- int rc;
- command_fields_t cmd_desc;
- __u32 iprm[2];
-
- memset(&cmd_desc, 0, sizeof cmd_desc);
-
- cmd_desc.opcode = MEMFREE_CMD_UNMAP_ICM;
- iprm[0] = map_icm_p->vpm_arr[0].va_h;
- iprm[1] = map_icm_p->vpm_arr[0].va_l;
- cmd_desc.in_param = iprm;
- cmd_desc.in_trans = TRANS_IMMEDIATE;
- cmd_desc.input_modifier = 1 << map_icm_p->vpm_arr[0].log2_size;
-
- rc = cmd_invoke(&cmd_desc);
-
- return rc;
-}
-
/*
* cmd_query_dev_lim
*/
diff --git a/src/drivers/net/mlx_ipoib/doc/README.boot_over_ib b/src/drivers/net/mlx_ipoib/doc/README.boot_over_ib
index 062abd3f..07738628 100644
--- a/src/drivers/net/mlx_ipoib/doc/README.boot_over_ib
+++ b/src/drivers/net/mlx_ipoib/doc/README.boot_over_ib
@@ -92,11 +92,13 @@ files with .mlx extension also available from Mellanox's web site.
6. Preparing the DHCP Server
-----------------------------
-The DHCP server may need to be modified in order to work on IPOIB. Some
-distributuions alreay support this (Some SUSE distributuions) while others
-do not. If the pre-installed server does not support IPOIB, the user can download
-the sources from ISC http://www.isc.org/ and apply the appropriate patch in
-the patches directory.
+DHCP messages over IP Over IB are transmitted as broadcasts. In order to
+distinguish between messages belonging to a certain DHCP session, the messages
+must carry the client identifier option (see ietf documentation referred to
+above). As of November 2005, ISC DHCP servers do not support this feature.
+They are expected to support this at the end of 2005. In order to work this
+out, the appropriate patch must be applied (see patches directory). It has
+been tested on version isc-dhcpd-V3.0.4b2.
The DHCP server must run on a machine which supports IP Over IB. The Mellanox
IBGD package (gen1 or gen2) can be used to provide this.
@@ -169,14 +171,6 @@ PXE_IB_PORT.
14. Installing a package from Mellanox
--------------------------------------
-The package comes as a compressed file with extension .bz2 or .gz. Follow
-these steps:
-1. Create a directory
-2. cd to this directory
-3. tar jxf <package file name> for .bz2 files or
- tar zxf <package file name> for .gz files
-
-The binaries can be found under src/bin
When using a package obtained from Mellanox Technologies' web site, the
directory src/bin will contain the driver binary files. The files have a .bin
extension and are equivalent to the same files with .zrom extension.
diff --git a/src/drivers/net/mlx_ipoib/ib_driver.c b/src/drivers/net/mlx_ipoib/ib_driver.c
index 34d4cbaa..a46db7fc 100644
--- a/src/drivers/net/mlx_ipoib/ib_driver.c
+++ b/src/drivers/net/mlx_ipoib/ib_driver.c
@@ -62,9 +62,6 @@ static int wait_logic_link_up(__u8 port)
return 0;
}
-unsigned long ipoib_qkey;
-unsigned long hack_ipoib_qkey;
-
static int ib_driver_init(struct pci_device *pci, udqp_t * ipoib_qph_p)
{
int rc;
@@ -150,9 +147,6 @@ static int ib_driver_init(struct pci_device *pci, udqp_t * ipoib_qph_p)
qkey, mlid);
}
- hack_ipoib_qkey = ipoib_qkey = qkey;
-
-#if 0
rc = create_ipoib_qp(&ib_data.ipoib_qp,
&ib_data.ipoib_snd_cq,
&ib_data.ipoib_rcv_cq, qkey);
@@ -172,7 +166,6 @@ static int ib_driver_init(struct pci_device *pci, udqp_t * ipoib_qph_p)
} else {
tprintf("add_qp_to_mcast_group() success");
}
-#endif
/* create a broadcast group ud AV */
av = alloc_ud_av();
@@ -185,19 +178,6 @@ static int ib_driver_init(struct pci_device *pci, udqp_t * ipoib_qph_p)
tprintf("modify_av_params() success");
ib_data.bcast_av = av;
-#if ! CREATE_OWN
- rc = create_ipoib_qp(&ib_data.ipoib_qp,
- &ib_data.ipoib_snd_cq,
- &ib_data.ipoib_rcv_cq, qkey);
- if (rc) {
- eprintf("");
- return rc;
- }
-
- tprintf("create_ipoib_qp() success");
- *ipoib_qph_p = ib_data.ipoib_qp;
-#endif
-
do {
rc = poll_eq(&ib_eqe, &num_eqe);
if (rc) {
@@ -268,10 +248,12 @@ static int ib_driver_close(int fw_fatal)
ret = 1;
}
- rc = unset_hca();
- if (rc) {
- eprintf("");
- ret = 1;
+ if (!fw_fatal) {
+ rc = cmd_sys_dis();
+ if (rc) {
+ eprintf("");
+ ret = 1;
+ }
}
return ret;
@@ -286,7 +268,7 @@ static int poll_cqe_tout(cq_t cqh, __u16 tout, void **wqe, int *good_p)
end = currticks() + tout;
do {
- rc = ib_poll_cqx(cqh, &ib_cqe, &num_cqes);
+ rc = ib_poll_cq(cqh, &ib_cqe, &num_cqes);
if (rc)
return rc;
diff --git a/src/drivers/net/mlx_ipoib/ib_driver.h b/src/drivers/net/mlx_ipoib/ib_driver.h
index 7fc57364..305bb5d4 100644
--- a/src/drivers/net/mlx_ipoib/ib_driver.h
+++ b/src/drivers/net/mlx_ipoib/ib_driver.h
@@ -49,17 +49,17 @@
#define QPN_BASE 0x550000
enum {
+ MADS_QPN_SN,
IPOIB_QPN_SN,
- MADS_QPN_SN = 4,
- MAX_APP_QPS = 8
+ MAX_APP_QPS
};
enum {
+ MADS_SND_CQN_SN,
+ MADS_RCV_CQN_SN,
IPOIB_SND_CQN_SN,
IPOIB_RCV_CQN_SN,
- MADS_SND_CQN_SN = 4,
- MADS_RCV_CQN_SN,
- MAX_APP_CQS = 8
+ MAX_APP_CQS
};
enum {
@@ -153,7 +153,7 @@ static int gw_read_cr(__u32 addr, __u32 * result);
static int gw_write_cr(__u32 addr, __u32 data);
static ud_av_t alloc_ud_av(void);
static void free_ud_av(ud_av_t av);
-static int ib_poll_cqx(cq_t cq, struct ib_cqe_st *ib_cqe_p, __u8 * num_cqes);
+static int ib_poll_cq(cq_t cq, struct ib_cqe_st *ib_cqe_p, __u8 * num_cqes);
static int add_qp_to_mcast_group(union ib_gid_u mcast_gid, __u8 add);
static int clear_interrupt(void);
static int poll_cqe_tout(cq_t cqh, __u16 tout, void **wqe, int *good_p);
diff --git a/src/drivers/net/mlx_ipoib/ib_mad.c b/src/drivers/net/mlx_ipoib/ib_mad.c
index 4da4677b..3e263a5b 100644
--- a/src/drivers/net/mlx_ipoib/ib_mad.c
+++ b/src/drivers/net/mlx_ipoib/ib_mad.c
@@ -158,7 +158,7 @@ static int join_mc_group(__u32 * qkey_p, __u16 * mlid_p, __u8 join)
eprintf("");
return -1;
}
- tprintf("allocated snd_wqe=%p", snd_wqe);
+ tprintf("allocated snd_wqe=0x%lx", snd_wqe);
mad = get_send_wqe_buf(snd_wqe, 0);
memset(mad, 0, 256);
@@ -264,7 +264,7 @@ static int join_mc_group(__u32 * qkey_p, __u16 * mlid_p, __u8 join)
return is_good ? 0 : -1;
}
-int get_path_record(union ib_gid_u *dgid, __u16 * dlid_p, u8 * sl_p,
+static int get_path_record(union ib_gid_u *dgid, __u16 * dlid_p, u8 * sl_p,
u8 * rate_p)
{
struct path_record_mad_st *mad, *rcv_mad;
@@ -321,9 +321,6 @@ int get_path_record(union ib_gid_u *dgid, __u16 * dlid_p, u8 * sl_p,
cpu_to_be_buf(mad, sizeof *mad);
memcpy(mad->path_record.sgid.raw, ib_data.port_gid.raw, 16);
- DBG ( "data:\n" );
- DBG_HD ( mad, sizeof ( *mad ) );
-
rc = post_send_req(qp, snd_wqe, 1);
if (rc) {
eprintf("");
diff --git a/src/drivers/net/mlx_ipoib/ib_mad.h b/src/drivers/net/mlx_ipoib/ib_mad.h
index 51b90d21..5ffb5404 100644
--- a/src/drivers/net/mlx_ipoib/ib_mad.h
+++ b/src/drivers/net/mlx_ipoib/ib_mad.h
@@ -104,7 +104,7 @@ union mad_u {
struct ib_mad_st mad;
} __attribute__ ((packed));
-int get_path_record(union ib_gid_u *dgid, __u16 * dlid_p, __u8 * sl_p,
+static int get_path_record(union ib_gid_u *dgid, __u16 * dlid_p, __u8 * sl_p,
__u8 * rate_p);
#endif /* __ib_mad_h__ */
diff --git a/src/drivers/net/mlx_ipoib/ib_mt23108.c b/src/drivers/net/mlx_ipoib/ib_mt23108.c
index d9261b9c..ca3abb10 100644
--- a/src/drivers/net/mlx_ipoib/ib_mt23108.c
+++ b/src/drivers/net/mlx_ipoib/ib_mt23108.c
@@ -92,12 +92,7 @@ static int find_mlx_bridge(__u8 hca_bus, __u8 * br_bus_p, __u8 * br_devfn_p)
for (bus = 0; bus < 256; ++bus) {
for (dev = 0; dev < 32; ++dev) {
devfn = (dev << 3);
-
- struct pci_device tmp;
- tmp.bus = bus;
- tmp.devfn = devfn;
-
- rc = pcibios_read_config_word(&tmp, PCI_VENDOR_ID,
+ rc = pcibios_read_config_word(bus, devfn, PCI_VENDOR_ID,
&vendor);
if (rc)
return rc;
@@ -105,7 +100,7 @@ static int find_mlx_bridge(__u8 hca_bus, __u8 * br_bus_p, __u8 * br_devfn_p)
if (vendor != MELLANOX_VENDOR_ID)
continue;
- rc = pcibios_read_config_word(&tmp, PCI_DEVICE_ID,
+ rc = pcibios_read_config_word(bus, devfn, PCI_DEVICE_ID,
&dev_id);
if (rc)
return rc;
@@ -113,7 +108,7 @@ static int find_mlx_bridge(__u8 hca_bus, __u8 * br_bus_p, __u8 * br_devfn_p)
if (dev_id != TAVOR_BRIDGE_DEVICE_ID)
continue;
- rc = pcibios_read_config_byte(&tmp,
+ rc = pcibios_read_config_byte(bus, devfn,
PCI_SECONDARY_BUS,
&sec_bus);
if (rc)
@@ -166,7 +161,7 @@ static int ib_device_init(struct pci_device *dev)
tavor_pci_dev.dev.dev = dev;
tprintf("");
- if (dev->device == TAVOR_DEVICE_ID) {
+ if (dev->dev_id == TAVOR_DEVICE_ID) {
rc = find_mlx_bridge(dev->bus, &br_bus, &br_devfn);
if (rc) {
@@ -180,12 +175,7 @@ static int ib_device_init(struct pci_device *dev)
tprintf("bus=%d devfn=0x%x", br_bus, br_devfn);
/* save config space */
for (i = 0; i < 64; ++i) {
-
- struct pci_device tmp;
- tmp.bus = br_bus;
- tmp.devfn = br_devfn;
-
- rc = pcibios_read_config_dword(&tmp, i << 2,
+ rc = pcibios_read_config_dword(br_bus, br_devfn, i << 2,
&tavor_pci_dev.br.
dev_config_space[i]);
if (rc) {
@@ -213,7 +203,7 @@ static int ib_device_init(struct pci_device *dev)
eprintf("");
return -1;
}
- tprintf("uar_base (pa:va) = 0x%lx %p",
+ tprintf("uar_base (pa:va) = 0x%lx 0x%lx",
tavor_pci_dev.dev.bar[2] + UAR_IDX * 0x1000, tavor_pci_dev.uar);
tprintf("");
@@ -235,7 +225,7 @@ static int init_dev_data(void)
dev_buffers_p = bus_to_virt(tmp);
memreg_size = (__u32) (&memreg_size) - (__u32) dev_buffers_p;
- tprintf("src_buf=%p, dev_buffers_p=%p, memreg_size=0x%lx", src_buf,
+ tprintf("src_buf=0x%lx, dev_buffers_p=0x%lx, memreg_size=0x%x", src_buf,
dev_buffers_p, memreg_size);
return 0;
@@ -246,14 +236,10 @@ static int restore_config(void)
int i;
int rc;
- if (tavor_pci_dev.dev.dev->device == TAVOR_DEVICE_ID) {
+ if (tavor_pci_dev.dev.dev->dev_id == TAVOR_DEVICE_ID) {
for (i = 0; i < 64; ++i) {
-
- struct pci_device tmp;
- tmp.bus = tavor_pci_dev.br.bus;
- tmp.devfn = tavor_pci_dev.br.devfn;
-
- rc = pcibios_write_config_dword(&tmp,
+ rc = pcibios_write_config_dword(tavor_pci_dev.br.bus,
+ tavor_pci_dev.br.devfn,
i << 2,
tavor_pci_dev.br.
dev_config_space[i]);
@@ -565,9 +551,9 @@ static int setup_hca(__u8 port, void **eq_p)
tprintf("fw_rev_major=%d", qfw.fw_rev_major);
tprintf("fw_rev_minor=%d", qfw.fw_rev_minor);
tprintf("fw_rev_subminor=%d", qfw.fw_rev_subminor);
- tprintf("error_buf_start_h=0x%lx", qfw.error_buf_start_h);
- tprintf("error_buf_start_l=0x%lx", qfw.error_buf_start_l);
- tprintf("error_buf_size=%ld", qfw.error_buf_size);
+ tprintf("error_buf_start_h=0x%x", qfw.error_buf_start_h);
+ tprintf("error_buf_start_l=0x%x", qfw.error_buf_start_l);
+ tprintf("error_buf_size=%d", qfw.error_buf_size);
}
if (qfw.error_buf_start_h) {
@@ -813,20 +799,6 @@ static int setup_hca(__u8 port, void **eq_p)
return ret;
}
-
-static int unset_hca(void)
-{
- int rc = 0;
-
- if (!fw_fatal) {
- rc = cmd_sys_dis();
- if (rc)
- eprintf("");
- }
-
- return rc;
-}
-
static void *get_inprm_buf(void)
{
return dev_buffers_p->inprm_buf;
@@ -958,7 +930,7 @@ static int post_send_req(void *qph, void *wqeh, __u8 num_gather)
__u32 *psrc, *pdst;
__u32 nds;
- tprintf("snd_wqe=%p, virt_to_bus(snd_wqe)=0x%lx", snd_wqe,
+ tprintf("snd_wqe=0x%lx, virt_to_bus(snd_wqe)=0x%lx", snd_wqe,
virt_to_bus(snd_wqe));
memset(&dbell, 0, sizeof dbell);
@@ -1082,7 +1054,7 @@ static int create_ipoib_qp(void **qp_pp,
/* update data */
qp->rcv_wq[i].wqe_cont.qp = qp;
qp->rcv_bufs[i] = ib_buffers.ipoib_rcv_buf[i];
- tprintf("rcv_buf=%p", qp->rcv_bufs[i]);
+ tprintf("rcv_buf=%lx", qp->rcv_bufs[i]);
}
/* init send queue WQEs list */
@@ -1415,7 +1387,7 @@ static int ib_poll_cq(void *cqh, struct ib_cqe_st *ib_cqe_p, u8 * num_cqes)
eprintf("syndrome=0x%lx",
EX_FLD(cqe.error_cqe, tavorprm_completion_with_error_st,
syndrome));
- eprintf("wqe_addr=%p", wqe_p);
+ eprintf("wqe_addr=0x%lx", wqe_p);
eprintf("wqe_size=0x%lx",
EX_FLD(cqe.error_cqe, tavorprm_completion_with_error_st,
wqe_size));
@@ -1544,7 +1516,7 @@ static struct recv_wqe_st *alloc_rcv_wqe(struct udqp_st *qp)
wqe->mpointer[1].lkey = dev_ib_data.mkey;
wqe->mpointer[1].byte_count = qp->rcv_buf_sz;
- tprintf("rcv_buf=%p\n", qp->rcv_bufs[new_entry]);
+ tprintf("rcv_buf=%lx\n", qp->rcv_bufs[new_entry]);
/* we do it only on the data segment since the control
segment is always owned by HW */
@@ -1671,7 +1643,7 @@ static int poll_eq(struct ib_eqe_st *ib_eqe_p, __u8 * num_eqes)
struct eq_st *eq = &dev_ib_data.eq;
ptr = (__u32 *) (&(eq->eq_buf[eq->cons_idx]));
- tprintf("cons)idx=%ld, addr(eqe)=%lx, val=0x%lx", eq->cons_idx, virt_to_bus(ptr), ptr[7]);
+ tprintf("cons)idx=%d, addr(eqe)=%x, val=0x%x", eq->cons_idx, virt_to_bus(ptr), ptr[7]);
owner = (ptr[7] & 0x80000000) ? OWNER_HW : OWNER_SW;
if (owner == OWNER_SW) {
tprintf("got eqe");
diff --git a/src/drivers/net/mlx_ipoib/ib_mt25218.c b/src/drivers/net/mlx_ipoib/ib_mt25218.c
index 174a2309..f16577f1 100644
--- a/src/drivers/net/mlx_ipoib/ib_mt25218.c
+++ b/src/drivers/net/mlx_ipoib/ib_mt25218.c
@@ -89,10 +89,6 @@ static struct dev_pci_struct memfree_pci_dev;
static struct device_buffers_st *dev_buffers_p;
static struct device_ib_data_st dev_ib_data;
-
-
-struct map_icm_st icm_map_obj;
-
static int gw_write_cr(__u32 addr, __u32 data)
{
writel(htonl(data), memfree_pci_dev.cr_space + addr);
@@ -159,7 +155,7 @@ static int ib_device_init(struct pci_device *dev)
eprintf("");
return -1;
}
- tprintf("uar_base (pa:va) = 0x%lx %p",
+ tprintf("uar_base (pa:va) = 0x%lx 0x%lx",
memfree_pci_dev.dev.bar[2] + UAR_IDX * 0x1000,
memfree_pci_dev.uar);
@@ -174,8 +170,6 @@ static inline unsigned long lalign(unsigned long buf, unsigned long align)
(~(((unsigned long)align) - 1)));
}
-#include <gpxe/umalloc.h>
-
static int init_dev_data(void)
{
unsigned long tmp;
@@ -185,21 +179,17 @@ static int init_dev_data(void)
dev_buffers_p = bus_to_virt(tmp);
memreg_size = (__u32) (&memreg_size) - (__u32) dev_buffers_p;
- tprintf("src_buf=%p, dev_buffers_p=%p, memreg_size=0x%lx", src_buf,
+ tprintf("src_buf=0x%lx, dev_buffers_p=0x%lx, memreg_size=0x%x", src_buf,
dev_buffers_p, memreg_size);
- tprintf("inprm: va=%p, pa=0x%lx", dev_buffers_p->inprm_buf,
+ tprintf("inprm: va=0x%lx, pa=0x%lx", dev_buffers_p->inprm_buf,
virt_to_bus(dev_buffers_p->inprm_buf));
- tprintf("outprm: va=%p, pa=0x%lx", dev_buffers_p->outprm_buf,
+ tprintf("outprm: va=0x%lx, pa=0x%lx", dev_buffers_p->outprm_buf,
virt_to_bus(dev_buffers_p->outprm_buf));
- userptr_t lotsofmem = umalloc ( reserve_size * 2 );
- if ( ! lotsofmem ) {
- printf ( "Could not allocate large memblock\n" );
- return -1;
- }
- phys_mem.base = ( ( user_to_phys ( lotsofmem, 0 ) + reserve_size ) &
- ~( reserve_size - 1 ) );
+ phys_mem.base =
+ (virt_to_phys(_text) - reserve_size) & (~(reserve_size - 1));
+
phys_mem.offset = 0;
return 0;
@@ -333,13 +323,9 @@ static void prep_sw2hw_mpt_buf(void *buf, __u32 mkey)
INS_FLD(1, buf, arbelprm_mpt_st, r_w);
INS_FLD(mkey, buf, arbelprm_mpt_st, mem_key);
INS_FLD(GLOBAL_PD, buf, arbelprm_mpt_st, pd);
- // INS_FLD(virt_to_bus(dev_buffers_p), buf, arbelprm_mpt_st,
- // start_address_l);
- // INS_FLD(memreg_size, buf, arbelprm_mpt_st, reg_wnd_len_l);
- INS_FLD(0, buf, arbelprm_mpt_st, start_address_l);
- INS_FLD(0, buf, arbelprm_mpt_st, start_address_h);
- INS_FLD(0xffffffffUL, buf, arbelprm_mpt_st, reg_wnd_len_l);
- INS_FLD(0xffffffffUL, buf, arbelprm_mpt_st, reg_wnd_len_h);
+ INS_FLD(virt_to_bus(dev_buffers_p), buf, arbelprm_mpt_st,
+ start_address_l);
+ INS_FLD(memreg_size, buf, arbelprm_mpt_st, reg_wnd_len_l);
}
static void prep_sw2hw_eq_buf(void *buf, struct eqe_t *eq_buf)
@@ -675,9 +661,9 @@ static int setup_hca(__u8 port, void **eq_p)
tprintf("fw_rev_major=%d", qfw.fw_rev_major);
tprintf("fw_rev_minor=%d", qfw.fw_rev_minor);
tprintf("fw_rev_subminor=%d", qfw.fw_rev_subminor);
- tprintf("error_buf_start_h=0x%lx", qfw.error_buf_start_h);
- tprintf("error_buf_start_l=0x%lx", qfw.error_buf_start_l);
- tprintf("error_buf_size=%ld", qfw.error_buf_size);
+ tprintf("error_buf_start_h=0x%x", qfw.error_buf_start_h);
+ tprintf("error_buf_start_l=0x%x", qfw.error_buf_start_l);
+ tprintf("error_buf_size=%d", qfw.error_buf_size);
}
@@ -758,20 +744,17 @@ static int setup_hca(__u8 port, void **eq_p)
tmp = get_req_icm_pages(dev_lim.log2_rsvd_qps,
MAX_APP_QPS,
dev_lim.qpc_entry_sz, &log2_entries);
- DBG ( "qpc_base_addr_l = %lx\n", icm_start );
init_hca.qpc_base_addr_l = icm_start;
init_hca.log_num_of_qp = log2_entries;
icm_start += (tmp << 12);
icm_size += (tmp << 12);
- DBG ( "eqpc_base_addr_l = %lx\n", icm_start );
init_hca.eqpc_base_addr_l = icm_start;
icm_start += (tmp << 12);
icm_size += (tmp << 12);
tmp = get_req_icm_pages(dev_lim.log2_rsvd_srqs,
0, dev_lim.srq_entry_sz, &log2_entries);
- DBG ( "srqc_base_addr_l = %lx\n", icm_start );
init_hca.srqc_base_addr_l = icm_start;
init_hca.log_num_of_srq = log2_entries;
icm_start += (tmp << 12);
@@ -779,18 +762,15 @@ static int setup_hca(__u8 port, void **eq_p)
tmp = get_req_icm_pages(dev_lim.log2_rsvd_ees,
0, dev_lim.eec_entry_sz, &log2_entries);
- DBG ( "eec_base_addr_l = %lx\n", icm_start );
init_hca.eec_base_addr_l = icm_start;
init_hca.log_num_of_ee = log2_entries;
icm_start += (tmp << 12);
icm_size += (tmp << 12);
- DBG ( "eeec_base_addr_l = %lx\n", icm_start );
init_hca.eeec_base_addr_l = icm_start;
icm_start += (tmp << 12);
icm_size += (tmp << 12);
- DBG ( "cqc_base_addr_l = %lx\n", icm_start );
tmp = get_req_icm_pages(dev_lim.log2_rsvd_cqs,
MAX_APP_CQS,
dev_lim.cqc_entry_sz, &log2_entries);
@@ -801,35 +781,29 @@ static int setup_hca(__u8 port, void **eq_p)
tmp = get_req_icm_pages(dev_lim.log2_rsvd_mtts,
0, dev_lim.mtt_entry_sz, &log2_entries);
- DBG ( "mtt_base_addr_l = %lx\n", icm_start );
init_hca.mtt_base_addr_l = icm_start;
icm_start += (tmp << 12);
icm_size += (tmp << 12);
tmp = get_req_icm_pages(dev_lim.log2_rsvd_mrws,
1, dev_lim.mpt_entry_sz, &log2_entries);
- DBG ( "mpt_base_addr_l = %lx\n", icm_start );
init_hca.mpt_base_addr_l = icm_start;
init_hca.log_mpt_sz = log2_entries;
- DBG ( "log2_entries for mpt = %ld\n", log2_entries );
icm_start += (tmp << 12);
icm_size += (tmp << 12);
tmp = get_req_icm_pages(dev_lim.log2_rsvd_rdbs, 1, 32, /* size of rdb entry */
&log2_entries);
- DBG ( "rdb_base_addr_l = %lx\n", icm_start );
init_hca.rdb_base_addr_l = icm_start;
icm_start += (tmp << 12);
icm_size += (tmp << 12);
- DBG ( "eqc_base_addr_l = %lx\n", icm_start );
init_hca.eqc_base_addr_l = icm_start;
init_hca.log_num_of_eq = LOG2_EQS;
tmp = dev_lim.eqc_entry_sz * (1 << LOG2_EQS);
icm_start += tmp;
icm_size += tmp;
- DBG ( "mc_base_addr_l = %lx\n", icm_start );
init_hca.mc_base_addr_l = icm_start;
init_hca.log_mc_table_entry_sz =
my_log2(MT_STRUCT_SIZE(arbelprm_mgm_entry_st));
@@ -840,8 +814,6 @@ static int setup_hca(__u8 port, void **eq_p)
icm_start +=
(MT_STRUCT_SIZE(arbelprm_mgm_entry_st) * init_hca.mc_table_hash_sz);
- DBG ( "icm_size = %lx\n", icm_size );
-
rc = cmd_set_icm_size(icm_size, &aux_pages);
if (rc) {
ret = -1;
@@ -864,7 +836,7 @@ static int setup_hca(__u8 port, void **eq_p)
uar_context_pa = phys_mem.base + phys_mem.offset +
dev_ib_data.uar_idx * 4096;
uar_context_va = phys_to_virt(uar_context_pa);
- tprintf("uar_context: va=%p, pa=0x%lx", uar_context_va,
+ tprintf("uar_context: va=0x%lx, pa=0x%lx", uar_context_va,
uar_context_pa);
dev_ib_data.uar_context_base = uar_context_va;
@@ -878,12 +850,10 @@ static int setup_hca(__u8 port, void **eq_p)
eprintf("");
goto undo_map_fa;
}
- icm_map_obj = map_obj;
-
phys_mem.offset += (1 << (map_obj.vpm_arr[0].log2_size + 12));
init_hca.log_max_uars = log_max_uars;
- tprintf("inprm: va=%p, pa=0x%lx", inprm, virt_to_bus(inprm));
+ tprintf("inprm: va=0x%lx, pa=0x%lx", inprm, virt_to_bus(inprm));
prep_init_hca_buf(&init_hca, inprm);
rc = cmd_init_hca(inprm, MT_STRUCT_SIZE(arbelprm_init_hca_st));
if (rc) {
@@ -1008,30 +978,6 @@ static int setup_hca(__u8 port, void **eq_p)
return ret;
}
-
-static int unset_hca(void)
-{
- int rc, ret = 0;
-
- rc = cmd_unmap_icm(&icm_map_obj);
- if (rc)
- eprintf("");
- ret |= rc;
-
-
- rc = cmd_unmap_icm_aux();
- if (rc)
- eprintf("");
- ret |= rc;
-
- rc = cmd_unmap_fa();
- if (rc)
- eprintf("");
- ret |= rc;
-
- return ret;
-}
-
static void *get_inprm_buf(void)
{
return dev_buffers_p->inprm_buf;
@@ -1140,14 +1086,9 @@ static int post_send_req(void *qph, void *wqeh, __u8 num_gather)
struct send_doorbell_st dbell;
__u32 nds;
- DBG ( "Work queue entry:\n" );
- DBG_HD ( snd_wqe, sizeof ( *snd_wqe ) );
-
qp->post_send_counter++;
WRITE_WORD_VOL(qp->send_uar_context, 2, htons(qp->post_send_counter));
- DBG ( "Doorbell record:\n" );
- DBG_HD ( qp->send_uar_context, 8 );
memset(&dbell, 0, sizeof dbell);
INS_FLD(XDEV_NOPCODE_SEND, &dbell, arbelprm_send_doorbell_st, nopcode);
@@ -1171,10 +1112,6 @@ static int post_send_req(void *qph, void *wqeh, __u8 num_gather)
INS_FLD_TO_BE(XDEV_NOPCODE_SEND,
&qp->last_posted_snd_wqe->next.next,
arbelprm_wqe_segment_next_st, nopcode);
-
- DBG ( "Previous work queue entry's next field:\n" );
- DBG_HD ( &qp->last_posted_snd_wqe->next.next,
- sizeof ( qp->last_posted_snd_wqe->next.next ) );
}
rc = cmd_post_doorbell(&dbell, POST_SND_OFFSET);
@@ -1195,8 +1132,6 @@ static int create_mads_qp(void **qp_pp, void **snd_cq_pp, void **rcv_cq_pp)
__u8 nds;
void *ptr;
- DBG ( "*** Creating MADS queue pair ***\n" );
-
qp = &dev_ib_data.mads_qp;
/* set the pointer to the receive WQEs buffer */
@@ -1307,8 +1242,6 @@ static int create_mads_qp(void **qp_pp, void **snd_cq_pp, void **rcv_cq_pp)
*rcv_cq_pp = &qp->rcv_cq;
}
- DBG ( "*** Created MADS queue pair ***\n" );
-
return rc;
}
@@ -1322,8 +1255,6 @@ static int create_ipoib_qp(void **qp_pp,
__u8 nds;
void *ptr;
- DBG ( "*** Creating IPoIB queue pair ***\n" );
-
qp = &dev_ib_data.ipoib_qp;
/* set the pointer to the receive WQEs buffer */
@@ -1333,7 +1264,7 @@ static int create_ipoib_qp(void **qp_pp,
qp->rcv_buf_sz = IPOIB_RCV_BUF_SZ;
qp->max_recv_wqes = NUM_IPOIB_RCV_WQES;
- qp->recv_wqe_cur_free = 0; //NUM_IPOIB_RCV_WQES;
+ qp->recv_wqe_cur_free = NUM_IPOIB_RCV_WQES;
qp->rcv_uar_context =
dev_ib_data.uar_context_base + 8 * IPOIB_RCV_QP_DB_IDX;
@@ -1429,8 +1360,6 @@ static int create_ipoib_qp(void **qp_pp,
*rcv_cq_pp = &qp->rcv_cq;
}
- DBG ( "*** Created IPoIB queue pair ***\n" );
-
return rc;
}
@@ -1451,8 +1380,6 @@ static int create_udqp(struct udqp_st *qp)
qp->snd_cq.ci_db_ctx_pointer =
dev_ib_data.uar_context_base + 8 * qp->snd_cq.ci_db_ctx_idx;
- DBG ( "* Creating send CQ *\n" );
-
/* create send CQ */
init_cq_buf(qp->snd_cq.cq_buf, qp->snd_cq.num_cqes);
qp->snd_cq.cons_counter = 0;
@@ -1469,8 +1396,6 @@ static int create_udqp(struct udqp_st *qp)
goto exit;
}
- DBG ( "* Creating receive CQ *\n" );
-
/* create receive CQ */
init_cq_buf(qp->rcv_cq.cq_buf, qp->rcv_cq.num_cqes);
qp->rcv_cq.cons_counter = 0;
@@ -1488,8 +1413,6 @@ static int create_udqp(struct udqp_st *qp)
goto undo_snd_cq;
}
- DBG ( "* Creating QP *\n" );
-
prep_rst2init_qpee_buf(inprm,
qp->snd_cq.cqn,
qp->rcv_cq.cqn,
@@ -1627,15 +1550,6 @@ static void prep_send_wqe_buf(void *qph,
len += offset;
}
snd_wqe->mpointer[0].byte_count = cpu_to_be32(len);
-
-#if 0
- DBG ( "prep_send_wqe_buf()\n" );
- DBG ( "snd_wqe:\n" );
- DBG_HD ( snd_wqe, sizeof ( *snd_wqe ) );
- DBG ( "packet:\n" );
- DBG_HD ( bus_to_virt(be32_to_cpu(snd_wqe->mpointer[0].local_addr_l)),
- len );
-#endif
}
static void *alloc_ud_av(void)
@@ -1744,7 +1658,7 @@ static void dev2ib_cqe(struct ib_cqe_st *ib_cqe_p, union cqe_st *cqe_p)
byte_cnt);
}
-static int ib_poll_cqx(void *cqh, struct ib_cqe_st *ib_cqe_p, u8 * num_cqes)
+static int ib_poll_cq(void *cqh, struct ib_cqe_st *ib_cqe_p, u8 * num_cqes)
{
int rc;
union cqe_st cqe;
@@ -1776,7 +1690,7 @@ static int ib_poll_cqx(void *cqh, struct ib_cqe_st *ib_cqe_p, u8 * num_cqes)
eprintf("vendor_syndrome=0x%lx",
EX_FLD(cqe.error_cqe, arbelprm_completion_with_error_st,
vendor_code));
- eprintf("wqe_addr=%p", wqe_p);
+ eprintf("wqe_addr=0x%lx", wqe_p);
eprintf("myqpn=0x%lx",
EX_FLD(cqe.error_cqe, arbelprm_completion_with_error_st,
myqpn));
@@ -2006,9 +1920,6 @@ static void dev_post_dbell(void *dbell, __u32 offset)
address = (unsigned long)(memfree_pci_dev.uar) + offset;
tprintf("va=0x%lx pa=0x%lx", address,
virt_to_bus((const void *)address));
- DBG ( "dev_post_dbell %08lx:%08lx to %lx\n",
- htonl ( ptr[0] ), htonl ( ptr[1] ),
- virt_to_phys ( memfree_pci_dev.uar + offset ) );
writel(htonl(ptr[0]), memfree_pci_dev.uar + offset);
barrier();
address += 4;
diff --git a/src/drivers/net/mlx_ipoib/ipoib.c b/src/drivers/net/mlx_ipoib/ipoib.c
index d8dd6bf6..85eaac7a 100644
--- a/src/drivers/net/mlx_ipoib/ipoib.c
+++ b/src/drivers/net/mlx_ipoib/ipoib.c
@@ -357,12 +357,52 @@ static void modify_dhcp_resp(void *buf, __u16 size)
modify_udp_csum(buf, size);
}
+static void get_my_client_id(__u8 * my_client_id)
+{
+
+ my_client_id[0] = 0;
+ qpn2buf(ipoib_data.ipoib_qpn, my_client_id + 1);
+ memcpy(my_client_id + 4, ipoib_data.port_gid_raw, 16);
+}
+
+static const __u8 *get_client_id(const void *buf, int len)
+{
+ const __u8 *ptr;
+ int delta;
+
+ if (len < 268)
+ return NULL;
+
+ /* pointer to just after magic cookie */
+ ptr = (const __u8 *)buf + 268;
+
+ /* find last client identifier option */
+ do {
+ if (ptr[0] == 255) {
+ /* found end of options list */
+ return NULL;
+ }
+
+ if (ptr[0] == 0x3d) {
+ /* client identifer option */
+ return ptr + 3;
+ }
+
+ delta = ptr[1] + 2;
+ ptr += delta;
+ len -= delta;
+ } while (len > 0);
+
+ return NULL;
+}
+
static int handle_ipv4_packet(void *buf, void **out_buf_p,
unsigned int *new_size_p, int *is_bcast_p)
{
void *new_buf;
__u16 new_size;
__u8 msg_type;
+ __u8 my_client_id[20];
new_buf = (void *)(((__u8 *) buf) + 4);
new_size = (*new_size_p) - 4;
@@ -371,6 +411,7 @@ static int handle_ipv4_packet(void *buf, void **out_buf_p,
if (get_ip_protocl(new_buf) == IP_PROT_UDP) {
__u16 udp_dst_port;
+ const __u8 *client_id;
udp_dst_port = get_udp_dst_port(new_buf);
@@ -379,6 +420,22 @@ static int handle_ipv4_packet(void *buf, void **out_buf_p,
*out_buf_p = 0;
return 0;
}
+
+ if (udp_dst_port == 68) {
+ get_my_client_id(my_client_id);
+
+ /* packet client id */
+ client_id = get_client_id(new_buf, new_size);
+ if (!client_id) {
+ *out_buf_p = 0;
+ return 0;
+ }
+
+ if (memcmp(client_id, my_client_id, 20)) {
+ *out_buf_p = 0;
+ return 0;
+ }
+ }
}
msg_type = get_dhcp_msg_type(new_buf);
@@ -458,9 +515,8 @@ static int ipoib_handle_rcv(void *buf, void **out_buf_p,
rc = handle_ipv4_packet(buf, out_buf_p, new_size_p, is_bcast_p);
return rc;
}
- tprintf("prot=0x%x", prot_type);
- *out_buf_p = NULL;
- return 0;
+ eprintf("prot=0x%x", prot_type);
+ return -1;
}
static int is_null_mac(const __u8 * mac)
@@ -879,7 +935,7 @@ static int ipoib_read_packet(__u16 * prot_p, void *data, unsigned int *size_p,
void *buf, *out_buf;
__u16 prot_type;
- rc = ib_poll_cqx(ipoib_data.rcv_cqh, &ib_cqe, &num_cqes);
+ rc = ib_poll_cq(ipoib_data.rcv_cqh, &ib_cqe, &num_cqes);
if (rc) {
return rc;
}
@@ -897,7 +953,7 @@ static int ipoib_read_packet(__u16 * prot_p, void *data, unsigned int *size_p,
new_size = ib_cqe.count - GRH_SIZE;
buf = get_rcv_wqe_buf(ib_cqe.wqe, 1);
- tprintf("buf=%p", buf);
+ tprintf("buf=%lx", buf);
rc = ipoib_handle_rcv(buf, &out_buf, &new_size, is_bcast_p);
if (rc) {
eprintf("");
@@ -944,7 +1000,7 @@ static int ipoib_init(struct pci_device *pci)
ipoib_data.ipoib_qpn = ib_get_qpn(qph);
if(print_info)
- printf("local ipoib qpn=0x%lx\n", ipoib_data.ipoib_qpn);
+ printf("local ipoib qpn=0x%x\n", ipoib_data.ipoib_qpn);
ipoib_data.bcast_av = ib_data.bcast_av;
ipoib_data.port_gid_raw = ib_data.port_gid.raw;
diff --git a/src/drivers/net/mlx_ipoib/mt23108.c b/src/drivers/net/mlx_ipoib/mt23108.c
index 37947a8c..492bc901 100644
--- a/src/drivers/net/mlx_ipoib/mt23108.c
+++ b/src/drivers/net/mlx_ipoib/mt23108.c
@@ -14,6 +14,10 @@ Skeleton NIC driver for Etherboot
#include "etherboot.h"
/* to get the interface to the body of the program */
#include "nic.h"
+/* to get the PCI support functions, if this is a PCI NIC */
+#include <gpxe/pci.h>
+/* to get the ISA support functions, if this is an ISA NIC */
+#include <gpxe/isa.h>
#include "mt_version.c"
#include "mt23108_imp.c"
@@ -148,7 +152,7 @@ static void tavor_transmit(struct nic *nic, const char *dest, /* Destination */
/**************************************************************************
DISABLE - Turn off ethernet interface
***************************************************************************/
-static void tavor_disable(struct nic *nic)
+static void tavor_disable(struct dev *dev)
{
/* put the card in its initial state */
/* This function serves 3 purposes.
@@ -160,24 +164,18 @@ static void tavor_disable(struct nic *nic)
* This allows etherboot to reinitialize the interface
* if something is something goes wrong.
*/
- if (nic || 1) { // ????
+ if (dev || 1) { // ????
disable_imp();
}
}
-static struct nic_operations tavor_operations = {
- .connect = dummy_connect,
- .poll = tavor_poll,
- .transmit = tavor_transmit,
- .irq = tavor_irq,
-};
-
/**************************************************************************
PROBE - Look for an adapter, this routine's visible to the outside
***************************************************************************/
-static int tavor_probe(struct nic *nic, struct pci_device *pci)
+static int tavor_probe(struct dev *dev, struct pci_device *pci)
{
+ struct nic *nic = (struct nic *)dev;
int rc;
unsigned char user_request;
@@ -221,7 +219,10 @@ static int tavor_probe(struct nic *nic, struct pci_device *pci)
nic->ioaddr = pci->ioaddr & ~3;
nic->irqno = pci->irq;
/* point to NIC specific routines */
- nic->nic_op = &tavor_operations;
+ dev->disable = tavor_disable;
+ nic->poll = tavor_poll;
+ nic->transmit = tavor_transmit;
+ nic->irq = tavor_irq;
return 1;
}
@@ -229,12 +230,16 @@ static int tavor_probe(struct nic *nic, struct pci_device *pci)
return 0;
}
-static struct pci_device_id tavor_nics[] = {
+static struct pci_id tavor_nics[] = {
PCI_ROM(0x15b3, 0x5a44, "MT23108", "MT23108 HCA driver"),
PCI_ROM(0x15b3, 0x6278, "MT25208", "MT25208 HCA driver"),
};
-PCI_DRIVER ( tavor_driver, tavor_nics, PCI_NO_CLASS );
-
-DRIVER ( "MT23108/MT25208", nic_driver, pci_driver, tavor_driver,
- tavor_probe, tavor_disable );
+struct pci_driver tavor_driver __pci_driver = {
+ .type = NIC_DRIVER,
+ .name = "MT23108/MT25208",
+ .probe = tavor_probe,
+ .ids = tavor_nics,
+ .id_count = sizeof(tavor_nics) / sizeof(tavor_nics[0]),
+ .class = 0,
+};
diff --git a/src/drivers/net/mlx_ipoib/mt23108_imp.c b/src/drivers/net/mlx_ipoib/mt23108_imp.c
index d2bdf46b..4e601668 100644
--- a/src/drivers/net/mlx_ipoib/mt23108_imp.c
+++ b/src/drivers/net/mlx_ipoib/mt23108_imp.c
@@ -91,12 +91,10 @@ static int transmit_imp(const char *dest, /* Destination */
rc = ipoib_send_packet(dest, type, packet, size);
if (rc) {
printf("*** ERROR IN SEND FLOW ***\n");
-#if 0
printf("restarting Etherboot\n");
sleep(1);
longjmp(restart_etherboot, -1);
/* we should not be here ... */
-#endif
return -1;
}
@@ -108,7 +106,7 @@ static void hd(void *where, int n)
int i;
while (n > 0) {
- printf("%p ", where);
+ printf("%X ", where);
for (i = 0; i < ((n > 16) ? 16 : n); i++)
printf(" %hhX", ((char *)where)[i]);
printf("\n");
@@ -224,11 +222,9 @@ static int poll_imp(struct nic *nic, int retrieve, unsigned int *size_p)
fatal_handling:
printf("restarting Etherboot\n");
-#if 0
sleep(1);
longjmp(restart_etherboot, -1);
/* we should not be here ... */
-#endif
return -1;
}
diff --git a/src/drivers/net/mlx_ipoib/mt25218.c b/src/drivers/net/mlx_ipoib/mt25218.c
index 338a7db1..a603cdeb 100644
--- a/src/drivers/net/mlx_ipoib/mt25218.c
+++ b/src/drivers/net/mlx_ipoib/mt25218.c
@@ -10,2151 +10,236 @@ Skeleton NIC driver for Etherboot
* your option) any later version.
*/
-#include <errno.h>
-#include <gpxe/pci.h>
-#include <gpxe/malloc.h>
-#include <gpxe/iobuf.h>
-#include <gpxe/netdevice.h>
-#include <gpxe/infiniband.h>
-#include <gpxe/ipoib.h>
-
/* to get some global routines like printf */
#include "etherboot.h"
/* to get the interface to the body of the program */
#include "nic.h"
+/* to get the PCI support functions, if this is a PCI NIC */
+#include <gpxe/pci.h>
+/* to get the ISA support functions, if this is an ISA NIC */
+#include <gpxe/isa.h>
-#define CREATE_OWN 1
-
+#include "mt_version.c"
#include "mt25218_imp.c"
-#include "arbel.h"
-
-
-/* Port to use */
-#define PXE_IB_PORT 1
-
-/***************************************************************************
- *
- * Queue number allocation
- *
- ***************************************************************************
- */
-
-/**
- * Allocate queue number
- *
- * @v q_inuse Queue usage bitmask
- * @v max_inuse Maximum number of in-use queues
- * @ret qn_offset Free queue number offset, or negative error
- */
-static int arbel_alloc_qn_offset ( arbel_bitmask_t *q_inuse,
- unsigned int max_inuse ) {
- unsigned int qn_offset = 0;
- arbel_bitmask_t mask = 1;
-
- while ( qn_offset < max_inuse ) {
- if ( ( mask & *q_inuse ) == 0 ) {
- *q_inuse |= mask;
- return qn_offset;
- }
- qn_offset++;
- mask <<= 1;
- if ( ! mask ) {
- mask = 1;
- q_inuse++;
- }
- }
- return -ENFILE;
-}
-
-/**
- * Free queue number
- *
- * @v q_inuse Queue usage bitmask
- * @v qn_offset Queue number offset
- */
-static void arbel_free_qn_offset ( arbel_bitmask_t *q_inuse, int qn_offset ) {
- arbel_bitmask_t mask;
-
- mask = ( 1 << ( qn_offset % ( 8 * sizeof ( mask ) ) ) );
- q_inuse += ( qn_offset / ( 8 * sizeof ( mask ) ) );
- *q_inuse &= ~mask;
-}
-
-/***************************************************************************
- *
- * HCA commands
- *
- ***************************************************************************
- */
-
-/**
- * Wait for Arbel command completion
- *
- * @v arbel Arbel device
- * @ret rc Return status code
- */
-static int arbel_cmd_wait ( struct arbel *arbel,
- struct arbelprm_hca_command_register *hcr ) {
- unsigned int wait;
-
- for ( wait = ARBEL_HCR_MAX_WAIT_MS ; wait ; wait-- ) {
- hcr->u.dwords[6] =
- readl ( arbel->config + ARBEL_HCR_REG ( 6 ) );
- if ( MLX_GET ( hcr, go ) == 0 )
- return 0;
- mdelay ( 1 );
- }
- return -EBUSY;
-}
-
-/**
- * Issue HCA command
- *
- * @v arbel Arbel device
- * @v command Command opcode, flags and input/output lengths
- * @v op_mod Opcode modifier (0 if no modifier applicable)
- * @v in Input parameters
- * @v in_mod Input modifier (0 if no modifier applicable)
- * @v out Output parameters
- * @ret rc Return status code
- */
-static int arbel_cmd ( struct arbel *arbel, unsigned long command,
- unsigned int op_mod, const void *in,
- unsigned int in_mod, void *out ) {
- struct arbelprm_hca_command_register hcr;
- unsigned int opcode = ARBEL_HCR_OPCODE ( command );
- size_t in_len = ARBEL_HCR_IN_LEN ( command );
- size_t out_len = ARBEL_HCR_OUT_LEN ( command );
- void *in_buffer;
- void *out_buffer;
- unsigned int status;
- unsigned int i;
- int rc;
-
- assert ( in_len <= ARBEL_MBOX_SIZE );
- assert ( out_len <= ARBEL_MBOX_SIZE );
-
- DBGC2 ( arbel, "Arbel %p command %02x in %zx%s out %zx%s\n",
- arbel, opcode, in_len,
- ( ( command & ARBEL_HCR_IN_MBOX ) ? "(mbox)" : "" ), out_len,
- ( ( command & ARBEL_HCR_OUT_MBOX ) ? "(mbox)" : "" ) );
-
- /* Check that HCR is free */
- if ( ( rc = arbel_cmd_wait ( arbel, &hcr ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p command interface locked\n", arbel );
- return rc;
- }
-
- /* Prepare HCR */
- memset ( &hcr, 0, sizeof ( hcr ) );
- in_buffer = &hcr.u.dwords[0];
- if ( in_len && ( command & ARBEL_HCR_IN_MBOX ) ) {
- in_buffer = arbel->mailbox_in;
- MLX_FILL_1 ( &hcr, 1, in_param_l, virt_to_bus ( in_buffer ) );
- }
- memcpy ( in_buffer, in, in_len );
- MLX_FILL_1 ( &hcr, 2, input_modifier, in_mod );
- out_buffer = &hcr.u.dwords[3];
- if ( out_len && ( command & ARBEL_HCR_OUT_MBOX ) ) {
- out_buffer = arbel->mailbox_out;
- MLX_FILL_1 ( &hcr, 4, out_param_l,
- virt_to_bus ( out_buffer ) );
- }
- MLX_FILL_3 ( &hcr, 6,
- opcode, opcode,
- opcode_modifier, op_mod,
- go, 1 );
- DBGC2_HD ( arbel, &hcr, sizeof ( hcr ) );
- if ( in_len ) {
- DBGC2 ( arbel, "Input:\n" );
- DBGC2_HD ( arbel, in, ( ( in_len < 512 ) ? in_len : 512 ) );
- }
-
- /* Issue command */
- for ( i = 0 ; i < ( sizeof ( hcr ) / sizeof ( hcr.u.dwords[0] ) ) ;
- i++ ) {
- writel ( hcr.u.dwords[i],
- arbel->config + ARBEL_HCR_REG ( i ) );
- barrier();
- }
-
- /* Wait for command completion */
- if ( ( rc = arbel_cmd_wait ( arbel, &hcr ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p timed out waiting for command:\n",
- arbel );
- DBGC_HD ( arbel, &hcr, sizeof ( hcr ) );
- return rc;
- }
-
- /* Check command status */
- status = MLX_GET ( &hcr, status );
- if ( status != 0 ) {
- DBGC ( arbel, "Arbel %p command failed with status %02x:\n",
- arbel, status );
- DBGC_HD ( arbel, &hcr, sizeof ( hcr ) );
- return -EIO;
- }
-
- /* Read output parameters, if any */
- hcr.u.dwords[3] = readl ( arbel->config + ARBEL_HCR_REG ( 3 ) );
- hcr.u.dwords[4] = readl ( arbel->config + ARBEL_HCR_REG ( 4 ) );
- memcpy ( out, out_buffer, out_len );
- if ( out_len ) {
- DBGC2 ( arbel, "Output:\n" );
- DBGC2_HD ( arbel, out, ( ( out_len < 512 ) ? out_len : 512 ) );
- }
-
- return 0;
-}
-
-static inline int
-arbel_cmd_query_dev_lim ( struct arbel *arbel,
- struct arbelprm_query_dev_lim *dev_lim ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_OUT_CMD ( ARBEL_HCR_QUERY_DEV_LIM,
- 1, sizeof ( *dev_lim ) ),
- 0, NULL, 0, dev_lim );
-}
-
-static inline int
-arbel_cmd_query_fw ( struct arbel *arbel, struct arbelprm_query_fw *fw ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_OUT_CMD ( ARBEL_HCR_QUERY_FW,
- 1, sizeof ( *fw ) ),
- 0, NULL, 0, fw );
-}
-
-static inline int
-arbel_cmd_init_hca ( struct arbel *arbel,
- const struct arbelprm_init_hca *init_hca ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_IN_CMD ( ARBEL_HCR_INIT_HCA,
- 1, sizeof ( *init_hca ) ),
- 0, init_hca, 0, NULL );
-}
-
-static inline int
-arbel_cmd_close_hca ( struct arbel *arbel ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_VOID_CMD ( ARBEL_HCR_CLOSE_HCA ),
- 0, NULL, 0, NULL );
-}
-
-static inline int
-arbel_cmd_init_ib ( struct arbel *arbel, unsigned int port,
- const struct arbelprm_init_ib *init_ib ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_IN_CMD ( ARBEL_HCR_INIT_IB,
- 1, sizeof ( *init_ib ) ),
- 0, init_ib, port, NULL );
-}
-
-static inline int
-arbel_cmd_close_ib ( struct arbel *arbel, unsigned int port ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_VOID_CMD ( ARBEL_HCR_CLOSE_IB ),
- 0, NULL, port, NULL );
-}
-
-static inline int
-arbel_cmd_sw2hw_mpt ( struct arbel *arbel, unsigned int index,
- const struct arbelprm_mpt *mpt ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_IN_CMD ( ARBEL_HCR_SW2HW_MPT,
- 1, sizeof ( *mpt ) ),
- 0, mpt, index, NULL );
-}
-
-static inline int
-arbel_cmd_sw2hw_eq ( struct arbel *arbel, unsigned int index,
- const struct arbelprm_eqc *eqc ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_IN_CMD ( ARBEL_HCR_SW2HW_EQ,
- 1, sizeof ( *eqc ) ),
- 0, eqc, index, NULL );
-}
-
-static inline int
-arbel_cmd_hw2sw_eq ( struct arbel *arbel, unsigned int index ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_VOID_CMD ( ARBEL_HCR_HW2SW_EQ ),
- 1, NULL, index, NULL );
-}
-
-static inline int
-arbel_cmd_sw2hw_cq ( struct arbel *arbel, unsigned long cqn,
- const struct arbelprm_completion_queue_context *cqctx ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_IN_CMD ( ARBEL_HCR_SW2HW_CQ,
- 1, sizeof ( *cqctx ) ),
- 0, cqctx, cqn, NULL );
-}
-
-static inline int
-arbel_cmd_hw2sw_cq ( struct arbel *arbel, unsigned long cqn,
- struct arbelprm_completion_queue_context *cqctx) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_OUT_CMD ( ARBEL_HCR_HW2SW_CQ,
- 1, sizeof ( *cqctx ) ),
- 0, NULL, cqn, cqctx );
-}
-
-static inline int
-arbel_cmd_rst2init_qpee ( struct arbel *arbel, unsigned long qpn,
- const struct arbelprm_qp_ee_state_transitions *ctx ){
- return arbel_cmd ( arbel,
- ARBEL_HCR_IN_CMD ( ARBEL_HCR_RST2INIT_QPEE,
- 1, sizeof ( *ctx ) ),
- 0, ctx, qpn, NULL );
-}
-
-static inline int
-arbel_cmd_init2rtr_qpee ( struct arbel *arbel, unsigned long qpn,
- const struct arbelprm_qp_ee_state_transitions *ctx ){
- return arbel_cmd ( arbel,
- ARBEL_HCR_IN_CMD ( ARBEL_HCR_INIT2RTR_QPEE,
- 1, sizeof ( *ctx ) ),
- 0, ctx, qpn, NULL );
-}
-
-static inline int
-arbel_cmd_rtr2rts_qpee ( struct arbel *arbel, unsigned long qpn,
- const struct arbelprm_qp_ee_state_transitions *ctx ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_IN_CMD ( ARBEL_HCR_RTR2RTS_QPEE,
- 1, sizeof ( *ctx ) ),
- 0, ctx, qpn, NULL );
-}
-
-static inline int
-arbel_cmd_2rst_qpee ( struct arbel *arbel, unsigned long qpn ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_VOID_CMD ( ARBEL_HCR_2RST_QPEE ),
- 0x03, NULL, qpn, NULL );
-}
-
-static inline int
-arbel_cmd_mad_ifc ( struct arbel *arbel, union arbelprm_mad *mad ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_INOUT_CMD ( ARBEL_HCR_MAD_IFC,
- 1, sizeof ( *mad ),
- 1, sizeof ( *mad ) ),
- 0x03, mad, PXE_IB_PORT, mad );
-}
-
-static inline int
-arbel_cmd_read_mgm ( struct arbel *arbel, unsigned int index,
- struct arbelprm_mgm_entry *mgm ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_OUT_CMD ( ARBEL_HCR_READ_MGM,
- 1, sizeof ( *mgm ) ),
- 0, NULL, index, mgm );
-}
-
-static inline int
-arbel_cmd_write_mgm ( struct arbel *arbel, unsigned int index,
- const struct arbelprm_mgm_entry *mgm ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_IN_CMD ( ARBEL_HCR_WRITE_MGM,
- 1, sizeof ( *mgm ) ),
- 0, mgm, index, NULL );
-}
-
-static inline int
-arbel_cmd_mgid_hash ( struct arbel *arbel, const struct ib_gid *gid,
- struct arbelprm_mgm_hash *hash ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_INOUT_CMD ( ARBEL_HCR_MGID_HASH,
- 1, sizeof ( *gid ),
- 0, sizeof ( *hash ) ),
- 0, gid, 0, hash );
-}
-
-static inline int
-arbel_cmd_run_fw ( struct arbel *arbel ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_VOID_CMD ( ARBEL_HCR_RUN_FW ),
- 0, NULL, 0, NULL );
-}
-
-static inline int
-arbel_cmd_disable_lam ( struct arbel *arbel ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_VOID_CMD ( ARBEL_HCR_DISABLE_LAM ),
- 0, NULL, 0, NULL );
-}
-
-static inline int
-arbel_cmd_enable_lam ( struct arbel *arbel, struct arbelprm_access_lam *lam ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_OUT_CMD ( ARBEL_HCR_ENABLE_LAM,
- 1, sizeof ( *lam ) ),
- 1, NULL, 0, lam );
-}
-
-static inline int
-arbel_cmd_unmap_icm ( struct arbel *arbel, unsigned int page_count ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_VOID_CMD ( ARBEL_HCR_UNMAP_ICM ),
- 0, NULL, page_count, NULL );
-}
-
-static inline int
-arbel_cmd_map_icm ( struct arbel *arbel,
- const struct arbelprm_virtual_physical_mapping *map ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_IN_CMD ( ARBEL_HCR_MAP_ICM,
- 1, sizeof ( *map ) ),
- 0, map, 1, NULL );
-}
-
-static inline int
-arbel_cmd_unmap_icm_aux ( struct arbel *arbel ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_VOID_CMD ( ARBEL_HCR_UNMAP_ICM_AUX ),
- 0, NULL, 0, NULL );
-}
-
-static inline int
-arbel_cmd_map_icm_aux ( struct arbel *arbel,
- const struct arbelprm_virtual_physical_mapping *map ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_IN_CMD ( ARBEL_HCR_MAP_ICM_AUX,
- 1, sizeof ( *map ) ),
- 0, map, 1, NULL );
-}
-
-static inline int
-arbel_cmd_set_icm_size ( struct arbel *arbel,
- const struct arbelprm_scalar_parameter *icm_size,
- struct arbelprm_scalar_parameter *icm_aux_size ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_INOUT_CMD ( ARBEL_HCR_SET_ICM_SIZE,
- 0, sizeof ( *icm_size ),
- 0, sizeof ( *icm_aux_size ) ),
- 0, icm_size, 0, icm_aux_size );
-}
-
-static inline int
-arbel_cmd_unmap_fa ( struct arbel *arbel ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_VOID_CMD ( ARBEL_HCR_UNMAP_FA ),
- 0, NULL, 0, NULL );
-}
-
-static inline int
-arbel_cmd_map_fa ( struct arbel *arbel,
- const struct arbelprm_virtual_physical_mapping *map ) {
- return arbel_cmd ( arbel,
- ARBEL_HCR_IN_CMD ( ARBEL_HCR_MAP_FA,
- 1, sizeof ( *map ) ),
- 0, map, 1, NULL );
-}
-
-/***************************************************************************
- *
- * Completion queue operations
- *
- ***************************************************************************
- */
-
-/**
- * Create completion queue
- *
- * @v ibdev Infiniband device
- * @v cq Completion queue
- * @ret rc Return status code
- */
-static int arbel_create_cq ( struct ib_device *ibdev,
- struct ib_completion_queue *cq ) {
- struct arbel *arbel = ibdev->dev_priv;
- struct arbel_completion_queue *arbel_cq;
- struct arbelprm_completion_queue_context cqctx;
- struct arbelprm_cq_ci_db_record *ci_db_rec;
- struct arbelprm_cq_arm_db_record *arm_db_rec;
- int cqn_offset;
- unsigned int i;
- int rc;
-
- /* Find a free completion queue number */
- cqn_offset = arbel_alloc_qn_offset ( arbel->cq_inuse, ARBEL_MAX_CQS );
- if ( cqn_offset < 0 ) {
- DBGC ( arbel, "Arbel %p out of completion queues\n", arbel );
- rc = cqn_offset;
- goto err_cqn_offset;
- }
- cq->cqn = ( arbel->limits.reserved_cqs + cqn_offset );
-
- /* Allocate control structures */
- arbel_cq = zalloc ( sizeof ( *arbel_cq ) );
- if ( ! arbel_cq ) {
- rc = -ENOMEM;
- goto err_arbel_cq;
- }
- arbel_cq->ci_doorbell_idx = arbel_cq_ci_doorbell_idx ( cqn_offset );
- arbel_cq->arm_doorbell_idx = arbel_cq_arm_doorbell_idx ( cqn_offset );
-
- /* Allocate completion queue itself */
- arbel_cq->cqe_size = ( cq->num_cqes * sizeof ( arbel_cq->cqe[0] ) );
- arbel_cq->cqe = malloc_dma ( arbel_cq->cqe_size,
- sizeof ( arbel_cq->cqe[0] ) );
- if ( ! arbel_cq->cqe ) {
- rc = -ENOMEM;
- goto err_cqe;
- }
- memset ( arbel_cq->cqe, 0, arbel_cq->cqe_size );
- for ( i = 0 ; i < cq->num_cqes ; i++ ) {
- MLX_FILL_1 ( &arbel_cq->cqe[i].normal, 7, owner, 1 );
- }
- barrier();
-
- /* Initialise doorbell records */
- ci_db_rec = &arbel->db_rec[arbel_cq->ci_doorbell_idx].cq_ci;
- MLX_FILL_1 ( ci_db_rec, 0, counter, 0 );
- MLX_FILL_2 ( ci_db_rec, 1,
- res, ARBEL_UAR_RES_CQ_CI,
- cq_number, cq->cqn );
- arm_db_rec = &arbel->db_rec[arbel_cq->arm_doorbell_idx].cq_arm;
- MLX_FILL_1 ( arm_db_rec, 0, counter, 0 );
- MLX_FILL_2 ( arm_db_rec, 1,
- res, ARBEL_UAR_RES_CQ_ARM,
- cq_number, cq->cqn );
-
- /* Hand queue over to hardware */
- memset ( &cqctx, 0, sizeof ( cqctx ) );
- MLX_FILL_1 ( &cqctx, 0, st, 0xa /* "Event fired" */ );
- MLX_FILL_1 ( &cqctx, 2, start_address_l,
- virt_to_bus ( arbel_cq->cqe ) );
- MLX_FILL_2 ( &cqctx, 3,
- usr_page, arbel->limits.reserved_uars,
- log_cq_size, fls ( cq->num_cqes - 1 ) );
- MLX_FILL_1 ( &cqctx, 5, c_eqn, ARBEL_NO_EQ );
- MLX_FILL_1 ( &cqctx, 6, pd, ARBEL_GLOBAL_PD );
- MLX_FILL_1 ( &cqctx, 7, l_key, arbel->reserved_lkey );
- MLX_FILL_1 ( &cqctx, 12, cqn, cq->cqn );
- MLX_FILL_1 ( &cqctx, 13,
- cq_ci_db_record, arbel_cq->ci_doorbell_idx );
- MLX_FILL_1 ( &cqctx, 14,
- cq_state_db_record, arbel_cq->arm_doorbell_idx );
- if ( ( rc = arbel_cmd_sw2hw_cq ( arbel, cq->cqn, &cqctx ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p SW2HW_CQ failed: %s\n",
- arbel, strerror ( rc ) );
- goto err_sw2hw_cq;
- }
-
- DBGC ( arbel, "Arbel %p CQN %#lx ring at [%p,%p)\n",
- arbel, cq->cqn, arbel_cq->cqe,
- ( ( ( void * ) arbel_cq->cqe ) + arbel_cq->cqe_size ) );
- cq->dev_priv = arbel_cq;
- return 0;
-
- err_sw2hw_cq:
- MLX_FILL_1 ( ci_db_rec, 1, res, ARBEL_UAR_RES_NONE );
- MLX_FILL_1 ( arm_db_rec, 1, res, ARBEL_UAR_RES_NONE );
- free_dma ( arbel_cq->cqe, arbel_cq->cqe_size );
- err_cqe:
- free ( arbel_cq );
- err_arbel_cq:
- arbel_free_qn_offset ( arbel->cq_inuse, cqn_offset );
- err_cqn_offset:
- return rc;
-}
-
-/**
- * Destroy completion queue
- *
- * @v ibdev Infiniband device
- * @v cq Completion queue
- */
-static void arbel_destroy_cq ( struct ib_device *ibdev,
- struct ib_completion_queue *cq ) {
- struct arbel *arbel = ibdev->dev_priv;
- struct arbel_completion_queue *arbel_cq = cq->dev_priv;
- struct arbelprm_completion_queue_context cqctx;
- struct arbelprm_cq_ci_db_record *ci_db_rec;
- struct arbelprm_cq_arm_db_record *arm_db_rec;
- int cqn_offset;
- int rc;
-
- /* Take ownership back from hardware */
- if ( ( rc = arbel_cmd_hw2sw_cq ( arbel, cq->cqn, &cqctx ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p FATAL HW2SW_CQ failed on CQN %#lx: "
- "%s\n", arbel, cq->cqn, strerror ( rc ) );
- /* Leak memory and return; at least we avoid corruption */
- return;
- }
-
- /* Clear doorbell records */
- ci_db_rec = &arbel->db_rec[arbel_cq->ci_doorbell_idx].cq_ci;
- arm_db_rec = &arbel->db_rec[arbel_cq->arm_doorbell_idx].cq_arm;
- MLX_FILL_1 ( ci_db_rec, 1, res, ARBEL_UAR_RES_NONE );
- MLX_FILL_1 ( arm_db_rec, 1, res, ARBEL_UAR_RES_NONE );
-
- /* Free memory */
- free_dma ( arbel_cq->cqe, arbel_cq->cqe_size );
- free ( arbel_cq );
-
- /* Mark queue number as free */
- cqn_offset = ( cq->cqn - arbel->limits.reserved_cqs );
- arbel_free_qn_offset ( arbel->cq_inuse, cqn_offset );
-
- cq->dev_priv = NULL;
-}
-
-/***************************************************************************
- *
- * Queue pair operations
- *
- ***************************************************************************
- */
-
-/**
- * Create send work queue
- *
- * @v arbel_send_wq Send work queue
- * @v num_wqes Number of work queue entries
- * @ret rc Return status code
- */
-static int arbel_create_send_wq ( struct arbel_send_work_queue *arbel_send_wq,
- unsigned int num_wqes ) {
- struct arbelprm_ud_send_wqe *wqe;
- struct arbelprm_ud_send_wqe *next_wqe;
- unsigned int wqe_idx_mask;
- unsigned int i;
-
- /* Allocate work queue */
- arbel_send_wq->wqe_size = ( num_wqes *
- sizeof ( arbel_send_wq->wqe[0] ) );
- arbel_send_wq->wqe = malloc_dma ( arbel_send_wq->wqe_size,
- sizeof ( arbel_send_wq->wqe[0] ) );
- if ( ! arbel_send_wq->wqe )
- return -ENOMEM;
- memset ( arbel_send_wq->wqe, 0, arbel_send_wq->wqe_size );
-
- /* Link work queue entries */
- wqe_idx_mask = ( num_wqes - 1 );
- for ( i = 0 ; i < num_wqes ; i++ ) {
- wqe = &arbel_send_wq->wqe[i].ud;
- next_wqe = &arbel_send_wq->wqe[ ( i + 1 ) & wqe_idx_mask ].ud;
- MLX_FILL_1 ( &wqe->next, 0, nda_31_6,
- ( virt_to_bus ( next_wqe ) >> 6 ) );
- }
-
- return 0;
-}
-
-/**
- * Create receive work queue
- *
- * @v arbel_recv_wq Receive work queue
- * @v num_wqes Number of work queue entries
- * @ret rc Return status code
- */
-static int arbel_create_recv_wq ( struct arbel_recv_work_queue *arbel_recv_wq,
- unsigned int num_wqes ) {
- struct arbelprm_recv_wqe *wqe;
- struct arbelprm_recv_wqe *next_wqe;
- unsigned int wqe_idx_mask;
- size_t nds;
- unsigned int i;
- unsigned int j;
-
- /* Allocate work queue */
- arbel_recv_wq->wqe_size = ( num_wqes *
- sizeof ( arbel_recv_wq->wqe[0] ) );
- arbel_recv_wq->wqe = malloc_dma ( arbel_recv_wq->wqe_size,
- sizeof ( arbel_recv_wq->wqe[0] ) );
- if ( ! arbel_recv_wq->wqe )
- return -ENOMEM;
- memset ( arbel_recv_wq->wqe, 0, arbel_recv_wq->wqe_size );
-
- /* Link work queue entries */
- wqe_idx_mask = ( num_wqes - 1 );
- nds = ( ( offsetof ( typeof ( *wqe ), data ) +
- sizeof ( wqe->data[0] ) ) >> 4 );
- for ( i = 0 ; i < num_wqes ; i++ ) {
- wqe = &arbel_recv_wq->wqe[i].recv;
- next_wqe = &arbel_recv_wq->wqe[( i + 1 ) & wqe_idx_mask].recv;
- MLX_FILL_1 ( &wqe->next, 0, nda_31_6,
- ( virt_to_bus ( next_wqe ) >> 6 ) );
- MLX_FILL_1 ( &wqe->next, 1, nds, ( sizeof ( *wqe ) / 16 ) );
- for ( j = 0 ; ( ( ( void * ) &wqe->data[j] ) <
- ( ( void * ) ( wqe + 1 ) ) ) ; j++ ) {
- MLX_FILL_1 ( &wqe->data[j], 1,
- l_key, ARBEL_INVALID_LKEY );
+/* NIC specific static variables go here */
+
+int prompt_key(int secs, unsigned char *ch_p)
+{
+ unsigned long tmo;
+ unsigned char ch;
+
+ for (tmo = currticks() + secs * TICKS_PER_SEC; currticks() < tmo;) {
+ if (iskey()) {
+ ch = getchar();
+ /* toupper does not work ... */
+ if (ch == 'v')
+ ch = 'V';
+ if (ch == 'i')
+ ch = 'I';
+ if ((ch=='V') || (ch=='I')) {
+ *ch_p = ch;
+ return 1;
+ }
}
}
-
- return 0;
-}
-/**
- * Create queue pair
- *
- * @v ibdev Infiniband device
- * @v qp Queue pair
- * @ret rc Return status code
- */
-static int arbel_create_qp ( struct ib_device *ibdev,
- struct ib_queue_pair *qp ) {
- struct arbel *arbel = ibdev->dev_priv;
- struct arbel_queue_pair *arbel_qp;
- struct arbelprm_qp_ee_state_transitions qpctx;
- struct arbelprm_qp_db_record *send_db_rec;
- struct arbelprm_qp_db_record *recv_db_rec;
- int qpn_offset;
- int rc;
-
- /* Find a free queue pair number */
- qpn_offset = arbel_alloc_qn_offset ( arbel->qp_inuse, ARBEL_MAX_QPS );
- if ( qpn_offset < 0 ) {
- DBGC ( arbel, "Arbel %p out of queue pairs\n", arbel );
- rc = qpn_offset;
- goto err_qpn_offset;
- }
- qp->qpn = ( ARBEL_QPN_BASE + arbel->limits.reserved_qps + qpn_offset );
-
- /* Allocate control structures */
- arbel_qp = zalloc ( sizeof ( *arbel_qp ) );
- if ( ! arbel_qp ) {
- rc = -ENOMEM;
- goto err_arbel_qp;
- }
- arbel_qp->send.doorbell_idx = arbel_send_doorbell_idx ( qpn_offset );
- arbel_qp->recv.doorbell_idx = arbel_recv_doorbell_idx ( qpn_offset );
-
- /* Create send and receive work queues */
- if ( ( rc = arbel_create_send_wq ( &arbel_qp->send,
- qp->send.num_wqes ) ) != 0 )
- goto err_create_send_wq;
- if ( ( rc = arbel_create_recv_wq ( &arbel_qp->recv,
- qp->recv.num_wqes ) ) != 0 )
- goto err_create_recv_wq;
-
- /* Initialise doorbell records */
- send_db_rec = &arbel->db_rec[arbel_qp->send.doorbell_idx].qp;
- MLX_FILL_1 ( send_db_rec, 0, counter, 0 );
- MLX_FILL_2 ( send_db_rec, 1,
- res, ARBEL_UAR_RES_SQ,
- qp_number, qp->qpn );
- recv_db_rec = &arbel->db_rec[arbel_qp->recv.doorbell_idx].qp;
- MLX_FILL_1 ( recv_db_rec, 0, counter, 0 );
- MLX_FILL_2 ( recv_db_rec, 1,
- res, ARBEL_UAR_RES_RQ,
- qp_number, qp->qpn );
-
- /* Hand queue over to hardware */
- memset ( &qpctx, 0, sizeof ( qpctx ) );
- MLX_FILL_3 ( &qpctx, 2,
- qpc_eec_data.de, 1,
- qpc_eec_data.pm_state, 0x03 /* Always 0x03 for UD */,
- qpc_eec_data.st, ARBEL_ST_UD );
- MLX_FILL_6 ( &qpctx, 4,
- qpc_eec_data.mtu, ARBEL_MTU_2048,
- qpc_eec_data.msg_max, 11 /* 2^11 = 2048 */,
- qpc_eec_data.log_rq_size, fls ( qp->recv.num_wqes - 1 ),
- qpc_eec_data.log_rq_stride,
- ( fls ( sizeof ( arbel_qp->recv.wqe[0] ) - 1 ) - 4 ),
- qpc_eec_data.log_sq_size, fls ( qp->send.num_wqes - 1 ),
- qpc_eec_data.log_sq_stride,
- ( fls ( sizeof ( arbel_qp->send.wqe[0] ) - 1 ) - 4 ) );
- MLX_FILL_1 ( &qpctx, 5,
- qpc_eec_data.usr_page, arbel->limits.reserved_uars );
- MLX_FILL_1 ( &qpctx, 10, qpc_eec_data.primary_address_path.port_number,
- PXE_IB_PORT );
- MLX_FILL_1 ( &qpctx, 27, qpc_eec_data.pd, ARBEL_GLOBAL_PD );
- MLX_FILL_1 ( &qpctx, 29, qpc_eec_data.wqe_lkey, arbel->reserved_lkey );
- MLX_FILL_1 ( &qpctx, 30, qpc_eec_data.ssc, 1 );
- MLX_FILL_1 ( &qpctx, 33, qpc_eec_data.cqn_snd, qp->send.cq->cqn );
- MLX_FILL_1 ( &qpctx, 34, qpc_eec_data.snd_wqe_base_adr_l,
- ( virt_to_bus ( arbel_qp->send.wqe ) >> 6 ) );
- MLX_FILL_1 ( &qpctx, 35, qpc_eec_data.snd_db_record_index,
- arbel_qp->send.doorbell_idx );
- MLX_FILL_1 ( &qpctx, 38, qpc_eec_data.rsc, 1 );
- MLX_FILL_1 ( &qpctx, 41, qpc_eec_data.cqn_rcv, qp->recv.cq->cqn );
- MLX_FILL_1 ( &qpctx, 42, qpc_eec_data.rcv_wqe_base_adr_l,
- ( virt_to_bus ( arbel_qp->recv.wqe ) >> 6 ) );
- MLX_FILL_1 ( &qpctx, 43, qpc_eec_data.rcv_db_record_index,
- arbel_qp->recv.doorbell_idx );
- MLX_FILL_1 ( &qpctx, 44, qpc_eec_data.q_key, qp->qkey );
- if ( ( rc = arbel_cmd_rst2init_qpee ( arbel, qp->qpn, &qpctx )) != 0 ){
- DBGC ( arbel, "Arbel %p RST2INIT_QPEE failed: %s\n",
- arbel, strerror ( rc ) );
- goto err_rst2init_qpee;
- }
- memset ( &qpctx, 0, sizeof ( qpctx ) );
- MLX_FILL_2 ( &qpctx, 4,
- qpc_eec_data.mtu, ARBEL_MTU_2048,
- qpc_eec_data.msg_max, 11 /* 2^11 = 2048 */ );
- if ( ( rc = arbel_cmd_init2rtr_qpee ( arbel, qp->qpn, &qpctx )) != 0 ){
- DBGC ( arbel, "Arbel %p INIT2RTR_QPEE failed: %s\n",
- arbel, strerror ( rc ) );
- goto err_init2rtr_qpee;
- }
- memset ( &qpctx, 0, sizeof ( qpctx ) );
- if ( ( rc = arbel_cmd_rtr2rts_qpee ( arbel, qp->qpn, &qpctx ) ) != 0 ){
- DBGC ( arbel, "Arbel %p RTR2RTS_QPEE failed: %s\n",
- arbel, strerror ( rc ) );
- goto err_rtr2rts_qpee;
- }
-
- DBGC ( arbel, "Arbel %p QPN %#lx send ring at [%p,%p)\n",
- arbel, qp->qpn, arbel_qp->send.wqe,
- ( ( (void *) arbel_qp->send.wqe ) + arbel_qp->send.wqe_size ) );
- DBGC ( arbel, "Arbel %p QPN %#lx receive ring at [%p,%p)\n",
- arbel, qp->qpn, arbel_qp->recv.wqe,
- ( ( (void *) arbel_qp->recv.wqe ) + arbel_qp->recv.wqe_size ) );
- qp->dev_priv = arbel_qp;
return 0;
-
- err_rtr2rts_qpee:
- err_init2rtr_qpee:
- arbel_cmd_2rst_qpee ( arbel, qp->qpn );
- err_rst2init_qpee:
- MLX_FILL_1 ( send_db_rec, 1, res, ARBEL_UAR_RES_NONE );
- MLX_FILL_1 ( recv_db_rec, 1, res, ARBEL_UAR_RES_NONE );
- free_dma ( arbel_qp->recv.wqe, arbel_qp->recv.wqe_size );
- err_create_recv_wq:
- free_dma ( arbel_qp->send.wqe, arbel_qp->send.wqe_size );
- err_create_send_wq:
- free ( arbel_qp );
- err_arbel_qp:
- arbel_free_qn_offset ( arbel->qp_inuse, qpn_offset );
- err_qpn_offset:
- return rc;
-}
-
-/**
- * Destroy queue pair
- *
- * @v ibdev Infiniband device
- * @v qp Queue pair
- */
-static void arbel_destroy_qp ( struct ib_device *ibdev,
- struct ib_queue_pair *qp ) {
- struct arbel *arbel = ibdev->dev_priv;
- struct arbel_queue_pair *arbel_qp = qp->dev_priv;
- struct arbelprm_qp_db_record *send_db_rec;
- struct arbelprm_qp_db_record *recv_db_rec;
- int qpn_offset;
- int rc;
-
- /* Take ownership back from hardware */
- if ( ( rc = arbel_cmd_2rst_qpee ( arbel, qp->qpn ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p FATAL 2RST_QPEE failed on QPN %#lx: "
- "%s\n", arbel, qp->qpn, strerror ( rc ) );
- /* Leak memory and return; at least we avoid corruption */
- return;
- }
-
- /* Clear doorbell records */
- send_db_rec = &arbel->db_rec[arbel_qp->send.doorbell_idx].qp;
- recv_db_rec = &arbel->db_rec[arbel_qp->recv.doorbell_idx].qp;
- MLX_FILL_1 ( send_db_rec, 1, res, ARBEL_UAR_RES_NONE );
- MLX_FILL_1 ( recv_db_rec, 1, res, ARBEL_UAR_RES_NONE );
-
- /* Free memory */
- free_dma ( arbel_qp->send.wqe, arbel_qp->send.wqe_size );
- free_dma ( arbel_qp->recv.wqe, arbel_qp->recv.wqe_size );
- free ( arbel_qp );
-
- /* Mark queue number as free */
- qpn_offset = ( qp->qpn - ARBEL_QPN_BASE - arbel->limits.reserved_qps );
- arbel_free_qn_offset ( arbel->qp_inuse, qpn_offset );
-
- qp->dev_priv = NULL;
-}
-
-/***************************************************************************
- *
- * Work request operations
- *
- ***************************************************************************
- */
-
-/**
- * Ring doorbell register in UAR
- *
- * @v arbel Arbel device
- * @v db_reg Doorbell register structure
- * @v offset Address of doorbell
- */
-static void arbel_ring_doorbell ( struct arbel *arbel,
- union arbelprm_doorbell_register *db_reg,
- unsigned int offset ) {
-
- DBGC2 ( arbel, "Arbel %p ringing doorbell %08lx:%08lx at %lx\n",
- arbel, db_reg->dword[0], db_reg->dword[1],
- virt_to_phys ( arbel->uar + offset ) );
-
- barrier();
- writel ( db_reg->dword[0], ( arbel->uar + offset + 0 ) );
- barrier();
- writel ( db_reg->dword[1], ( arbel->uar + offset + 4 ) );
-}
-
-/** GID used for GID-less send work queue entries */
-static const struct ib_gid arbel_no_gid = {
- { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0 } }
-};
-
-/**
- * Post send work queue entry
- *
- * @v ibdev Infiniband device
- * @v qp Queue pair
- * @v av Address vector
- * @v iobuf I/O buffer
- * @ret rc Return status code
- */
-static int arbel_post_send ( struct ib_device *ibdev,
- struct ib_queue_pair *qp,
- struct ib_address_vector *av,
- struct io_buffer *iobuf ) {
- struct arbel *arbel = ibdev->dev_priv;
- struct arbel_queue_pair *arbel_qp = qp->dev_priv;
- struct ib_work_queue *wq = &qp->send;
- struct arbel_send_work_queue *arbel_send_wq = &arbel_qp->send;
- struct arbelprm_ud_send_wqe *prev_wqe;
- struct arbelprm_ud_send_wqe *wqe;
- struct arbelprm_qp_db_record *qp_db_rec;
- union arbelprm_doorbell_register db_reg;
- const struct ib_gid *gid;
- unsigned int wqe_idx_mask;
- size_t nds;
-
- /* Allocate work queue entry */
- wqe_idx_mask = ( wq->num_wqes - 1 );
- if ( wq->iobufs[wq->next_idx & wqe_idx_mask] ) {
- DBGC ( arbel, "Arbel %p send queue full", arbel );
- return -ENOBUFS;
- }
- wq->iobufs[wq->next_idx & wqe_idx_mask] = iobuf;
- prev_wqe = &arbel_send_wq->wqe[(wq->next_idx - 1) & wqe_idx_mask].ud;
- wqe = &arbel_send_wq->wqe[wq->next_idx & wqe_idx_mask].ud;
-
- /* Construct work queue entry */
- MLX_FILL_1 ( &wqe->next, 1, always1, 1 );
- memset ( &wqe->ctrl, 0, sizeof ( wqe->ctrl ) );
- MLX_FILL_1 ( &wqe->ctrl, 0, always1, 1 );
- memset ( &wqe->ud, 0, sizeof ( wqe->ud ) );
- MLX_FILL_2 ( &wqe->ud, 0,
- ud_address_vector.pd, ARBEL_GLOBAL_PD,
- ud_address_vector.port_number, PXE_IB_PORT );
- MLX_FILL_2 ( &wqe->ud, 1,
- ud_address_vector.rlid, av->dlid,
- ud_address_vector.g, av->gid_present );
- MLX_FILL_2 ( &wqe->ud, 2,
- ud_address_vector.max_stat_rate,
- ( ( av->rate >= 3 ) ? 0 : 1 ),
- ud_address_vector.msg, 3 );
- MLX_FILL_1 ( &wqe->ud, 3, ud_address_vector.sl, av->sl );
- gid = ( av->gid_present ? &av->gid : &arbel_no_gid );
- memcpy ( &wqe->ud.u.dwords[4], gid, sizeof ( *gid ) );
- MLX_FILL_1 ( &wqe->ud, 8, destination_qp, av->dest_qp );
- MLX_FILL_1 ( &wqe->ud, 9, q_key, av->qkey );
- MLX_FILL_1 ( &wqe->data[0], 0, byte_count, iob_len ( iobuf ) );
- MLX_FILL_1 ( &wqe->data[0], 1, l_key, arbel->reserved_lkey );
- MLX_FILL_1 ( &wqe->data[0], 3,
- local_address_l, virt_to_bus ( iobuf->data ) );
-
- /* Update previous work queue entry's "next" field */
- nds = ( ( offsetof ( typeof ( *wqe ), data ) +
- sizeof ( wqe->data[0] ) ) >> 4 );
- MLX_SET ( &prev_wqe->next, nopcode, ARBEL_OPCODE_SEND );
- MLX_FILL_3 ( &prev_wqe->next, 1,
- nds, nds,
- f, 1,
- always1, 1 );
-
- /* Update doorbell record */
- barrier();
- qp_db_rec = &arbel->db_rec[arbel_send_wq->doorbell_idx].qp;
- MLX_FILL_1 ( qp_db_rec, 0,
- counter, ( ( wq->next_idx + 1 ) & 0xffff ) );
-
- /* Ring doorbell register */
- MLX_FILL_4 ( &db_reg.send, 0,
- nopcode, ARBEL_OPCODE_SEND,
- f, 1,
- wqe_counter, ( wq->next_idx & 0xffff ),
- wqe_cnt, 1 );
- MLX_FILL_2 ( &db_reg.send, 1,
- nds, nds,
- qpn, qp->qpn );
- arbel_ring_doorbell ( arbel, &db_reg, POST_SND_OFFSET );
-
- /* Update work queue's index */
- wq->next_idx++;
-
- return 0;
-}
-
-/**
- * Post receive work queue entry
- *
- * @v ibdev Infiniband device
- * @v qp Queue pair
- * @v iobuf I/O buffer
- * @ret rc Return status code
- */
-static int arbel_post_recv ( struct ib_device *ibdev,
- struct ib_queue_pair *qp,
- struct io_buffer *iobuf ) {
- struct arbel *arbel = ibdev->dev_priv;
- struct arbel_queue_pair *arbel_qp = qp->dev_priv;
- struct ib_work_queue *wq = &qp->recv;
- struct arbel_recv_work_queue *arbel_recv_wq = &arbel_qp->recv;
- struct arbelprm_recv_wqe *wqe;
- union arbelprm_doorbell_record *db_rec;
- unsigned int wqe_idx_mask;
-
- /* Allocate work queue entry */
- wqe_idx_mask = ( wq->num_wqes - 1 );
- if ( wq->iobufs[wq->next_idx & wqe_idx_mask] ) {
- DBGC ( arbel, "Arbel %p receive queue full", arbel );
- return -ENOBUFS;
- }
- wq->iobufs[wq->next_idx & wqe_idx_mask] = iobuf;
- wqe = &arbel_recv_wq->wqe[wq->next_idx & wqe_idx_mask].recv;
-
- /* Construct work queue entry */
- MLX_FILL_1 ( &wqe->data[0], 0, byte_count, iob_tailroom ( iobuf ) );
- MLX_FILL_1 ( &wqe->data[0], 1, l_key, arbel->reserved_lkey );
- MLX_FILL_1 ( &wqe->data[0], 3,
- local_address_l, virt_to_bus ( iobuf->data ) );
-
- /* Update doorbell record */
- barrier();
- db_rec = &arbel->db_rec[arbel_recv_wq->doorbell_idx];
- MLX_FILL_1 ( &db_rec->qp, 0,
- counter, ( ( wq->next_idx + 1 ) & 0xffff ) );
-
- /* Update work queue's index */
- wq->next_idx++;
-
- return 0;
-}
-
-/**
- * Handle completion
- *
- * @v ibdev Infiniband device
- * @v cq Completion queue
- * @v cqe Hardware completion queue entry
- * @v complete_send Send completion handler
- * @v complete_recv Receive completion handler
- * @ret rc Return status code
- */
-static int arbel_complete ( struct ib_device *ibdev,
- struct ib_completion_queue *cq,
- union arbelprm_completion_entry *cqe,
- ib_completer_t complete_send,
- ib_completer_t complete_recv ) {
- struct arbel *arbel = ibdev->dev_priv;
- struct ib_completion completion;
- struct ib_work_queue *wq;
- struct ib_queue_pair *qp;
- struct arbel_queue_pair *arbel_qp;
- struct arbel_send_work_queue *arbel_send_wq;
- struct arbel_recv_work_queue *arbel_recv_wq;
- struct arbelprm_recv_wqe *recv_wqe;
- struct io_buffer *iobuf;
- ib_completer_t complete;
- unsigned int opcode;
- unsigned long qpn;
- int is_send;
- unsigned long wqe_adr;
- unsigned int wqe_idx;
- int rc = 0;
-
- /* Parse completion */
- memset ( &completion, 0, sizeof ( completion ) );
- qpn = MLX_GET ( &cqe->normal, my_qpn );
- is_send = MLX_GET ( &cqe->normal, s );
- wqe_adr = ( MLX_GET ( &cqe->normal, wqe_adr ) << 6 );
- opcode = MLX_GET ( &cqe->normal, opcode );
- if ( opcode >= ARBEL_OPCODE_RECV_ERROR ) {
- /* "s" field is not valid for error opcodes */
- is_send = ( opcode == ARBEL_OPCODE_SEND_ERROR );
- completion.syndrome = MLX_GET ( &cqe->error, syndrome );
- DBGC ( arbel, "Arbel %p CPN %lx syndrome %x vendor %lx\n",
- arbel, cq->cqn, completion.syndrome,
- MLX_GET ( &cqe->error, vendor_code ) );
- rc = -EIO;
- /* Don't return immediately; propagate error to completer */
- }
-
- /* Identify work queue */
- wq = ib_find_wq ( cq, qpn, is_send );
- if ( ! wq ) {
- DBGC ( arbel, "Arbel %p CQN %lx unknown %s QPN %lx\n",
- arbel, cq->cqn, ( is_send ? "send" : "recv" ), qpn );
- return -EIO;
- }
- qp = wq->qp;
- arbel_qp = qp->dev_priv;
- arbel_send_wq = &arbel_qp->send;
- arbel_recv_wq = &arbel_qp->recv;
-
- /* Identify work queue entry index */
- if ( is_send ) {
- wqe_idx = ( ( wqe_adr - virt_to_bus ( arbel_send_wq->wqe ) ) /
- sizeof ( arbel_send_wq->wqe[0] ) );
- assert ( wqe_idx < qp->send.num_wqes );
- } else {
- wqe_idx = ( ( wqe_adr - virt_to_bus ( arbel_recv_wq->wqe ) ) /
- sizeof ( arbel_recv_wq->wqe[0] ) );
- assert ( wqe_idx < qp->recv.num_wqes );
- }
-
- /* Identify I/O buffer */
- iobuf = wq->iobufs[wqe_idx];
- if ( ! iobuf ) {
- DBGC ( arbel, "Arbel %p CQN %lx QPN %lx empty WQE %x\n",
- arbel, cq->cqn, qpn, wqe_idx );
- return -EIO;
- }
- wq->iobufs[wqe_idx] = NULL;
-
- /* Fill in length for received packets */
- if ( ! is_send ) {
- completion.len = MLX_GET ( &cqe->normal, byte_cnt );
- recv_wqe = &arbel_recv_wq->wqe[wqe_idx].recv;
- assert ( MLX_GET ( &recv_wqe->data[0], local_address_l ) ==
- virt_to_bus ( iobuf->data ) );
- assert ( MLX_GET ( &recv_wqe->data[0], byte_count ) ==
- iob_tailroom ( iobuf ) );
- MLX_FILL_1 ( &recv_wqe->data[0], 0, byte_count, 0 );
- MLX_FILL_1 ( &recv_wqe->data[0], 1,
- l_key, ARBEL_INVALID_LKEY );
- if ( completion.len > iob_tailroom ( iobuf ) ) {
- DBGC ( arbel, "Arbel %p CQN %lx QPN %lx IDX %x "
- "overlength received packet length %zd\n",
- arbel, cq->cqn, qpn, wqe_idx, completion.len );
- return -EIO;
- }
- }
-
- /* Pass off to caller's completion handler */
- complete = ( is_send ? complete_send : complete_recv );
- complete ( ibdev, qp, &completion, iobuf );
-
- return rc;
-}
-
-/**
- * Drain event queue
- *
- * @v arbel Arbel device
- */
-static void arbel_drain_eq ( struct arbel *arbel ) {
-#warning "drain the event queue"
- drain_eq();
-}
-
-/**
- * Poll completion queue
- *
- * @v ibdev Infiniband device
- * @v cq Completion queue
- * @v complete_send Send completion handler
- * @v complete_recv Receive completion handler
- */
-static void arbel_poll_cq ( struct ib_device *ibdev,
- struct ib_completion_queue *cq,
- ib_completer_t complete_send,
- ib_completer_t complete_recv ) {
- struct arbel *arbel = ibdev->dev_priv;
- struct arbel_completion_queue *arbel_cq = cq->dev_priv;
- struct arbelprm_cq_ci_db_record *ci_db_rec;
- union arbelprm_completion_entry *cqe;
- unsigned int cqe_idx_mask;
- int rc;
-
- /* Drain the event queue */
- arbel_drain_eq ( arbel );
-
- while ( 1 ) {
- /* Look for completion entry */
- cqe_idx_mask = ( cq->num_cqes - 1 );
- cqe = &arbel_cq->cqe[cq->next_idx & cqe_idx_mask];
- if ( MLX_GET ( &cqe->normal, owner ) != 0 ) {
- /* Entry still owned by hardware; end of poll */
- break;
- }
-
- /* Handle completion */
- if ( ( rc = arbel_complete ( ibdev, cq, cqe, complete_send,
- complete_recv ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p failed to complete: %s\n",
- arbel, strerror ( rc ) );
- DBGC_HD ( arbel, cqe, sizeof ( *cqe ) );
- }
-
- /* Return ownership to hardware */
- MLX_FILL_1 ( &cqe->normal, 7, owner, 1 );
- barrier();
- /* Update completion queue's index */
- cq->next_idx++;
- /* Update doorbell record */
- ci_db_rec = &arbel->db_rec[arbel_cq->ci_doorbell_idx].cq_ci;
- MLX_FILL_1 ( ci_db_rec, 0,
- counter, ( cq->next_idx & 0xffffffffUL ) );
- }
}
-/***************************************************************************
- *
- * Multicast group operations
- *
- ***************************************************************************
- */
-
-/**
- * Attach to multicast group
- *
- * @v ibdev Infiniband device
- * @v qp Queue pair
- * @v gid Multicast GID
- * @ret rc Return status code
- */
-static int arbel_mcast_attach ( struct ib_device *ibdev,
- struct ib_queue_pair *qp,
- struct ib_gid *gid ) {
- struct arbel *arbel = ibdev->dev_priv;
- struct arbelprm_mgm_hash hash;
- struct arbelprm_mgm_entry mgm;
- unsigned int index;
- int rc;
-
- /* Generate hash table index */
- if ( ( rc = arbel_cmd_mgid_hash ( arbel, gid, &hash ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not hash GID: %s\n",
- arbel, strerror ( rc ) );
- return rc;
- }
- index = MLX_GET ( &hash, hash );
+/**************************************************************************
+IRQ - handle interrupts
+***************************************************************************/
+static void mt25218_irq(struct nic *nic, irq_action_t action)
+{
+ /* This routine is somewhat optional. Etherboot itself
+ * doesn't use interrupts, but they are required under some
+ * circumstances when we're acting as a PXE stack.
+ *
+ * If you don't implement this routine, the only effect will
+ * be that your driver cannot be used via Etherboot's UNDI
+ * API. This won't affect programs that use only the UDP
+ * portion of the PXE API, such as pxelinux.
+ */
- /* Check for existing hash table entry */
- if ( ( rc = arbel_cmd_read_mgm ( arbel, index, &mgm ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not read MGM %#x: %s\n",
- arbel, index, strerror ( rc ) );
- return rc;
+ if (0) {
+ nic = NULL;
}
- if ( MLX_GET ( &mgm, mgmqp_0.qi ) != 0 ) {
- /* FIXME: this implementation allows only a single QP
- * per multicast group, and doesn't handle hash
- * collisions. Sufficient for IPoIB but may need to
- * be extended in future.
+ switch (action) {
+ case DISABLE:
+ case ENABLE:
+ /* Set receive interrupt enabled/disabled state */
+ /*
+ outb ( action == ENABLE ? IntrMaskEnabled : IntrMaskDisabled,
+ nic->ioaddr + IntrMaskRegister );
*/
- DBGC ( arbel, "Arbel %p MGID index %#x already in use\n",
- arbel, index );
- return -EBUSY;
- }
-
- /* Update hash table entry */
- MLX_FILL_2 ( &mgm, 8,
- mgmqp_0.qpn_i, qp->qpn,
- mgmqp_0.qi, 1 );
- memcpy ( &mgm.u.dwords[4], gid, sizeof ( *gid ) );
- if ( ( rc = arbel_cmd_write_mgm ( arbel, index, &mgm ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not write MGM %#x: %s\n",
- arbel, index, strerror ( rc ) );
- return rc;
- }
-
- return 0;
-}
-
-/**
- * Detach from multicast group
- *
- * @v ibdev Infiniband device
- * @v qp Queue pair
- * @v gid Multicast GID
- */
-static void arbel_mcast_detach ( struct ib_device *ibdev,
- struct ib_queue_pair *qp __unused,
- struct ib_gid *gid ) {
- struct arbel *arbel = ibdev->dev_priv;
- struct arbelprm_mgm_hash hash;
- struct arbelprm_mgm_entry mgm;
- unsigned int index;
- int rc;
-
- /* Generate hash table index */
- if ( ( rc = arbel_cmd_mgid_hash ( arbel, gid, &hash ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not hash GID: %s\n",
- arbel, strerror ( rc ) );
- return;
- }
- index = MLX_GET ( &hash, hash );
-
- /* Clear hash table entry */
- memset ( &mgm, 0, sizeof ( mgm ) );
- if ( ( rc = arbel_cmd_write_mgm ( arbel, index, &mgm ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not write MGM %#x: %s\n",
- arbel, index, strerror ( rc ) );
- return;
- }
-}
-
-/** Arbel Infiniband operations */
-static struct ib_device_operations arbel_ib_operations = {
- .create_cq = arbel_create_cq,
- .destroy_cq = arbel_destroy_cq,
- .create_qp = arbel_create_qp,
- .destroy_qp = arbel_destroy_qp,
- .post_send = arbel_post_send,
- .post_recv = arbel_post_recv,
- .poll_cq = arbel_poll_cq,
- .mcast_attach = arbel_mcast_attach,
- .mcast_detach = arbel_mcast_detach,
-};
-
-/***************************************************************************
- *
- * MAD IFC operations
- *
- ***************************************************************************
- */
-
-static int arbel_mad_ifc ( struct arbel *arbel,
- union arbelprm_mad *mad ) {
- struct ib_mad_hdr *hdr = &mad->mad.mad_hdr;
- int rc;
-
- hdr->base_version = IB_MGMT_BASE_VERSION;
- if ( ( rc = arbel_cmd_mad_ifc ( arbel, mad ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not issue MAD IFC: %s\n",
- arbel, strerror ( rc ) );
- return rc;
- }
- if ( hdr->status != 0 ) {
- DBGC ( arbel, "Arbel %p MAD IFC status %04x\n",
- arbel, ntohs ( hdr->status ) );
- return -EIO;
- }
- return 0;
-}
-
-static int arbel_get_port_info ( struct arbel *arbel,
- struct ib_mad_port_info *port_info ) {
- union arbelprm_mad mad;
- struct ib_mad_hdr *hdr = &mad.mad.mad_hdr;
- int rc;
-
- memset ( &mad, 0, sizeof ( mad ) );
- hdr->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
- hdr->class_version = 1;
- hdr->method = IB_MGMT_METHOD_GET;
- hdr->attr_id = htons ( IB_SMP_ATTR_PORT_INFO );
- hdr->attr_mod = htonl ( PXE_IB_PORT );
- if ( ( rc = arbel_mad_ifc ( arbel, &mad ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not get port info: %s\n",
- arbel, strerror ( rc ) );
- return rc;
- }
- memcpy ( port_info, &mad.mad.port_info, sizeof ( *port_info ) );
- return 0;
-}
-
-static int arbel_get_guid_info ( struct arbel *arbel,
- struct ib_mad_guid_info *guid_info ) {
- union arbelprm_mad mad;
- struct ib_mad_hdr *hdr = &mad.mad.mad_hdr;
- int rc;
-
- memset ( &mad, 0, sizeof ( mad ) );
- hdr->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
- hdr->class_version = 1;
- hdr->method = IB_MGMT_METHOD_GET;
- hdr->attr_id = htons ( IB_SMP_ATTR_GUID_INFO );
- if ( ( rc = arbel_mad_ifc ( arbel, &mad ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not get GUID info: %s\n",
- arbel, strerror ( rc ) );
- return rc;
- }
- memcpy ( guid_info, &mad.mad.guid_info, sizeof ( *guid_info ) );
- return 0;
-}
-
-static int arbel_get_pkey_table ( struct arbel *arbel,
- struct ib_mad_pkey_table *pkey_table ) {
- union arbelprm_mad mad;
- struct ib_mad_hdr *hdr = &mad.mad.mad_hdr;
- int rc;
-
- memset ( &mad, 0, sizeof ( mad ) );
- hdr->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
- hdr->class_version = 1;
- hdr->method = IB_MGMT_METHOD_GET;
- hdr->attr_id = htons ( IB_SMP_ATTR_PKEY_TABLE );
- if ( ( rc = arbel_mad_ifc ( arbel, &mad ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not get pkey table: %s\n",
- arbel, strerror ( rc ) );
- return rc;
- }
- memcpy ( pkey_table, &mad.mad.pkey_table, sizeof ( *pkey_table ) );
- return 0;
-}
-
-static int arbel_get_port_gid ( struct arbel *arbel,
- struct ib_gid *port_gid ) {
- union {
- /* This union exists just to save stack space */
- struct ib_mad_port_info port_info;
- struct ib_mad_guid_info guid_info;
- } u;
- int rc;
-
- /* Port info gives us the first half of the port GID */
- if ( ( rc = arbel_get_port_info ( arbel, &u.port_info ) ) != 0 )
- return rc;
- memcpy ( &port_gid->u.bytes[0], u.port_info.gid_prefix, 8 );
-
- /* GUID info gives us the second half of the port GID */
- if ( ( rc = arbel_get_guid_info ( arbel, &u.guid_info ) ) != 0 )
- return rc;
- memcpy ( &port_gid->u.bytes[8], u.guid_info.gid_local, 8 );
-
- return 0;
-}
-
-static int arbel_get_sm_lid ( struct arbel *arbel,
- unsigned long *sm_lid ) {
- struct ib_mad_port_info port_info;
- int rc;
-
- if ( ( rc = arbel_get_port_info ( arbel, &port_info ) ) != 0 )
- return rc;
- *sm_lid = ntohs ( port_info.mastersm_lid );
- return 0;
-}
-
-static int arbel_get_pkey ( struct arbel *arbel, unsigned int *pkey ) {
- struct ib_mad_pkey_table pkey_table;
- int rc;
-
- if ( ( rc = arbel_get_pkey_table ( arbel, &pkey_table ) ) != 0 )
- return rc;
- *pkey = ntohs ( pkey_table.pkey[0][0] );
- return 0;
-}
-
-/**
- * Wait for link up
- *
- * @v arbel Arbel device
- * @ret rc Return status code
- *
- * This function shouldn't really exist. Unfortunately, IB links take
- * a long time to come up, and we can't get various key parameters
- * e.g. our own IPoIB MAC address without information from the subnet
- * manager). We should eventually make link-up an asynchronous event.
- */
-static int arbel_wait_for_link ( struct arbel *arbel ) {
- struct ib_mad_port_info port_info;
- unsigned int retries;
- int rc;
-
- printf ( "Waiting for Infiniband link-up..." );
- for ( retries = 20 ; retries ; retries-- ) {
- if ( ( rc = arbel_get_port_info ( arbel, &port_info ) ) != 0 )
- continue;
- if ( ( ( port_info.port_state__link_speed_supported ) & 0xf )
- == 4 ) {
- printf ( "ok\n" );
- return 0;
- }
- printf ( "." );
- sleep ( 1 );
- }
- printf ( "failed\n" );
- return -ENODEV;
-};
-
-/**
- * Get MAD parameters
- *
- * @v arbel Arbel device
- * @ret rc Return status code
- */
-static int arbel_get_mad_params ( struct ib_device *ibdev ) {
- struct arbel *arbel = ibdev->dev_priv;
- int rc;
-
- /* Get subnet manager LID */
- if ( ( rc = arbel_get_sm_lid ( arbel, &ibdev->sm_lid ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not determine subnet manager "
- "LID: %s\n", arbel, strerror ( rc ) );
- return rc;
- }
-
- /* Get port GID */
- if ( ( rc = arbel_get_port_gid ( arbel, &ibdev->port_gid ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not determine port GID: %s\n",
- arbel, strerror ( rc ) );
- return rc;
- }
-
- /* Get partition key */
- if ( ( rc = arbel_get_pkey ( arbel, &ibdev->pkey ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not determine partition key: "
- "%s\n", arbel, strerror ( rc ) );
- return rc;
+ break;
+ case FORCE:
+ /* Force NIC to generate a receive interrupt */
+ /*
+ outb ( ForceInterrupt, nic->ioaddr + IntrForceRegister );
+ */
+ break;
}
-
- return 0;
}
-/***************************************************************************
- *
- * Firmware control
- *
- ***************************************************************************
- */
-
-/**
- * Start firmware running
- *
- * @v arbel Arbel device
- * @ret rc Return status code
- */
-static int arbel_start_firmware ( struct arbel *arbel ) {
- struct arbelprm_query_fw fw;
- struct arbelprm_access_lam lam;
- struct arbelprm_virtual_physical_mapping map_fa;
- unsigned int fw_pages;
- unsigned int log2_fw_pages;
- size_t fw_size;
- physaddr_t fw_base;
- int rc;
-
- /* Get firmware parameters */
- if ( ( rc = arbel_cmd_query_fw ( arbel, &fw ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not query firmware: %s\n",
- arbel, strerror ( rc ) );
- goto err_query_fw;
- }
- DBGC ( arbel, "Arbel %p firmware version %ld.%ld.%ld\n", arbel,
- MLX_GET ( &fw, fw_rev_major ), MLX_GET ( &fw, fw_rev_minor ),
- MLX_GET ( &fw, fw_rev_subminor ) );
- fw_pages = MLX_GET ( &fw, fw_pages );
- log2_fw_pages = fls ( fw_pages - 1 );
- fw_pages = ( 1 << log2_fw_pages );
- DBGC ( arbel, "Arbel %p requires %d kB for firmware\n",
- arbel, ( fw_pages * 4 ) );
-
- /* Enable locally-attached memory. Ignore failure; there may
- * be no attached memory.
+/**************************************************************************
+POLL - Wait for a frame
+***************************************************************************/
+static int mt25218_poll(struct nic *nic, int retrieve)
+{
+ /* Work out whether or not there's an ethernet packet ready to
+ * read. Return 0 if not.
+ */
+ /*
+ if ( ! <packet_ready> ) return 0;
*/
- arbel_cmd_enable_lam ( arbel, &lam );
-
- /* Allocate firmware pages and map firmware area */
- fw_size = ( fw_pages * 4096 );
- arbel->firmware_area = umalloc ( fw_size );
- if ( ! arbel->firmware_area ) {
- rc = -ENOMEM;
- goto err_alloc_fa;
- }
- fw_base = ( user_to_phys ( arbel->firmware_area, fw_size ) &
- ~( fw_size - 1 ) );
- DBGC ( arbel, "Arbel %p firmware area at physical [%lx,%lx)\n",
- arbel, fw_base, ( fw_base + fw_size ) );
- memset ( &map_fa, 0, sizeof ( map_fa ) );
- MLX_FILL_2 ( &map_fa, 3,
- log2size, log2_fw_pages,
- pa_l, ( fw_base >> 12 ) );
- if ( ( rc = arbel_cmd_map_fa ( arbel, &map_fa ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not map firmware: %s\n",
- arbel, strerror ( rc ) );
- goto err_map_fa;
- }
-
- /* Start firmware */
- if ( ( rc = arbel_cmd_run_fw ( arbel ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not run firmware: %s\n",
- arbel, strerror ( rc ) );
- goto err_run_fw;
- }
-
- DBGC ( arbel, "Arbel %p firmware started\n", arbel );
- return 0;
-
- err_run_fw:
- arbel_cmd_unmap_fa ( arbel );
- err_map_fa:
- ufree ( arbel->firmware_area );
- arbel->firmware_area = UNULL;
- err_alloc_fa:
- err_query_fw:
- return rc;
-}
-
-/**
- * Stop firmware running
- *
- * @v arbel Arbel device
- */
-static void arbel_stop_firmware ( struct arbel *arbel ) {
- int rc;
-
- if ( ( rc = arbel_cmd_unmap_fa ( arbel ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p FATAL could not stop firmware: %s\n",
- arbel, strerror ( rc ) );
- /* Leak memory and return; at least we avoid corruption */
- return;
- }
- ufree ( arbel->firmware_area );
- arbel->firmware_area = UNULL;
-}
-
-/***************************************************************************
- *
- * Infinihost Context Memory management
- *
- ***************************************************************************
- */
-
-/**
- * Get device limits
- *
- * @v arbel Arbel device
- * @ret rc Return status code
- */
-static int arbel_get_limits ( struct arbel *arbel ) {
- struct arbelprm_query_dev_lim dev_lim;
- int rc;
-
- if ( ( rc = arbel_cmd_query_dev_lim ( arbel, &dev_lim ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not get device limits: %s\n",
- arbel, strerror ( rc ) );
- return rc;
- }
-
- arbel->limits.reserved_qps =
- ( 1 << MLX_GET ( &dev_lim, log2_rsvd_qps ) );
- arbel->limits.qpc_entry_size = MLX_GET ( &dev_lim, qpc_entry_sz );
- arbel->limits.eqpc_entry_size = MLX_GET ( &dev_lim, eqpc_entry_sz );
- arbel->limits.reserved_srqs =
- ( 1 << MLX_GET ( &dev_lim, log2_rsvd_srqs ) );
- arbel->limits.srqc_entry_size = MLX_GET ( &dev_lim, srq_entry_sz );
- arbel->limits.reserved_ees =
- ( 1 << MLX_GET ( &dev_lim, log2_rsvd_ees ) );
- arbel->limits.eec_entry_size = MLX_GET ( &dev_lim, eec_entry_sz );
- arbel->limits.eeec_entry_size = MLX_GET ( &dev_lim, eeec_entry_sz );
- arbel->limits.reserved_cqs =
- ( 1 << MLX_GET ( &dev_lim, log2_rsvd_cqs ) );
- arbel->limits.cqc_entry_size = MLX_GET ( &dev_lim, cqc_entry_sz );
- arbel->limits.reserved_mtts =
- ( 1 << MLX_GET ( &dev_lim, log2_rsvd_mtts ) );
- arbel->limits.mtt_entry_size = MLX_GET ( &dev_lim, mtt_entry_sz );
- arbel->limits.reserved_mrws =
- ( 1 << MLX_GET ( &dev_lim, log2_rsvd_mrws ) );
- arbel->limits.mpt_entry_size = MLX_GET ( &dev_lim, mpt_entry_sz );
- arbel->limits.reserved_rdbs =
- ( 1 << MLX_GET ( &dev_lim, log2_rsvd_rdbs ) );
- arbel->limits.eqc_entry_size = MLX_GET ( &dev_lim, eqc_entry_sz );
- arbel->limits.reserved_uars = MLX_GET ( &dev_lim, num_rsvd_uars );
-
- return 0;
-}
-
-/**
- * Get ICM usage
- *
- * @v log_num_entries Log2 of the number of entries
- * @v entry_size Entry size
- * @ret usage Usage size in ICM
- */
-static size_t icm_usage ( unsigned int log_num_entries, size_t entry_size ) {
- size_t usage;
- usage = ( ( 1 << log_num_entries ) * entry_size );
- usage = ( ( usage + 4095 ) & ~4095 );
- return usage;
-}
+ /* retrieve==0 indicates that we are just checking for the
+ * presence of a packet but don't want to read it just yet.
+ */
+ /*
+ if ( ! retrieve ) return 1;
+ */
-/**
- * Allocate ICM
- *
- * @v arbel Arbel device
- * @v init_hca INIT_HCA structure to fill in
- * @ret rc Return status code
- */
-static int arbel_alloc_icm ( struct arbel *arbel,
- struct arbelprm_init_hca *init_hca ) {
- struct arbelprm_scalar_parameter icm_size;
- struct arbelprm_scalar_parameter icm_aux_size;
- struct arbelprm_virtual_physical_mapping map_icm_aux;
- struct arbelprm_virtual_physical_mapping map_icm;
- size_t icm_offset = 0;
- unsigned int log_num_qps, log_num_srqs, log_num_ees, log_num_cqs;
- unsigned int log_num_mtts, log_num_mpts, log_num_rdbs, log_num_eqs;
+ /* Copy data to nic->packet. Data should include the
+ * link-layer header (dest MAC, source MAC, type).
+ * Store length of data in nic->packetlen.
+ * Return true to indicate a packet has been read.
+ */
+ /*
+ nic->packetlen = <packet_length>;
+ memcpy ( nic->packet, <packet_data>, <packet_length> );
+ return 1;
+ */
+ unsigned int size;
int rc;
-
- icm_offset = ( ( arbel->limits.reserved_uars + 1 ) << 12 );
-
- /* Queue pair contexts */
- log_num_qps = fls ( arbel->limits.reserved_qps + ARBEL_MAX_QPS - 1 );
- MLX_FILL_2 ( init_hca, 13,
- qpc_eec_cqc_eqc_rdb_parameters.qpc_base_addr_l,
- ( icm_offset >> 7 ),
- qpc_eec_cqc_eqc_rdb_parameters.log_num_of_qp,
- log_num_qps );
- DBGC ( arbel, "Arbel %p ICM QPC base = %zx\n", arbel, icm_offset );
- icm_offset += icm_usage ( log_num_qps, arbel->limits.qpc_entry_size );
-
- /* Extended queue pair contexts */
- MLX_FILL_1 ( init_hca, 25,
- qpc_eec_cqc_eqc_rdb_parameters.eqpc_base_addr_l,
- icm_offset );
- DBGC ( arbel, "Arbel %p ICM EQPC base = %zx\n", arbel, icm_offset );
- // icm_offset += icm_usage ( log_num_qps, arbel->limits.eqpc_entry_size );
- icm_offset += icm_usage ( log_num_qps, arbel->limits.qpc_entry_size );
-
- /* Shared receive queue contexts */
- log_num_srqs = fls ( arbel->limits.reserved_srqs - 1 );
- MLX_FILL_2 ( init_hca, 19,
- qpc_eec_cqc_eqc_rdb_parameters.srqc_base_addr_l,
- ( icm_offset >> 5 ),
- qpc_eec_cqc_eqc_rdb_parameters.log_num_of_srq,
- log_num_srqs );
- DBGC ( arbel, "Arbel %p ICM SRQC base = %zx\n", arbel, icm_offset );
- icm_offset += icm_usage ( log_num_srqs, arbel->limits.srqc_entry_size );
-
- /* End-to-end contexts */
- log_num_ees = fls ( arbel->limits.reserved_ees - 1 );
- MLX_FILL_2 ( init_hca, 17,
- qpc_eec_cqc_eqc_rdb_parameters.eec_base_addr_l,
- ( icm_offset >> 7 ),
- qpc_eec_cqc_eqc_rdb_parameters.log_num_of_ee,
- log_num_ees );
- DBGC ( arbel, "Arbel %p ICM EEC base = %zx\n", arbel, icm_offset );
- icm_offset += icm_usage ( log_num_ees, arbel->limits.eec_entry_size );
-
- /* Extended end-to-end contexts */
- MLX_FILL_1 ( init_hca, 29,
- qpc_eec_cqc_eqc_rdb_parameters.eeec_base_addr_l,
- icm_offset );
- DBGC ( arbel, "Arbel %p ICM EEEC base = %zx\n", arbel, icm_offset );
- icm_offset += icm_usage ( log_num_ees, arbel->limits.eeec_entry_size );
-
- /* Completion queue contexts */
- log_num_cqs = fls ( arbel->limits.reserved_cqs + ARBEL_MAX_CQS - 1 );
- MLX_FILL_2 ( init_hca, 21,
- qpc_eec_cqc_eqc_rdb_parameters.cqc_base_addr_l,
- ( icm_offset >> 6 ),
- qpc_eec_cqc_eqc_rdb_parameters.log_num_of_cq,
- log_num_cqs );
- DBGC ( arbel, "Arbel %p ICM CQC base = %zx\n", arbel, icm_offset );
- icm_offset += icm_usage ( log_num_cqs, arbel->limits.cqc_entry_size );
-
- /* Memory translation table */
- log_num_mtts = fls ( arbel->limits.reserved_mtts - 1 );
- MLX_FILL_1 ( init_hca, 65,
- tpt_parameters.mtt_base_addr_l, icm_offset );
- DBGC ( arbel, "Arbel %p ICM MTT base = %zx\n", arbel, icm_offset );
- icm_offset += icm_usage ( log_num_mtts, arbel->limits.mtt_entry_size );
-
- /* Memory protection table */
- log_num_mpts = fls ( arbel->limits.reserved_mrws + 1 - 1 );
- MLX_FILL_1 ( init_hca, 61,
- tpt_parameters.mpt_base_adr_l, icm_offset );
- MLX_FILL_1 ( init_hca, 62,
- tpt_parameters.log_mpt_sz, log_num_mpts );
- DBGC ( arbel, "Arbel %p ICM MTT base = %zx\n", arbel, icm_offset );
- icm_offset += icm_usage ( log_num_mpts, arbel->limits.mpt_entry_size );
-
- /* RDMA something or other */
- log_num_rdbs = fls ( arbel->limits.reserved_rdbs - 1 );
- MLX_FILL_1 ( init_hca, 37,
- qpc_eec_cqc_eqc_rdb_parameters.rdb_base_addr_l,
- icm_offset );
- DBGC ( arbel, "Arbel %p ICM RDB base = %zx\n", arbel, icm_offset );
- icm_offset += icm_usage ( log_num_rdbs, 32 );
-
- /* Event queue contexts */
- log_num_eqs = 6;
- MLX_FILL_2 ( init_hca, 33,
- qpc_eec_cqc_eqc_rdb_parameters.eqc_base_addr_l,
- ( icm_offset >> 6 ),
- qpc_eec_cqc_eqc_rdb_parameters.log_num_eq,
- log_num_eqs );
- DBGC ( arbel, "Arbel %p ICM EQ base = %zx\n", arbel, icm_offset );
- icm_offset += ( ( 1 << log_num_eqs ) * arbel->limits.eqc_entry_size );
-
- /* Multicast table */
- MLX_FILL_1 ( init_hca, 49,
- multicast_parameters.mc_base_addr_l, icm_offset );
- MLX_FILL_1 ( init_hca, 52,
- multicast_parameters.log_mc_table_entry_sz,
- fls ( sizeof ( struct arbelprm_mgm_entry ) - 1 ) );
- MLX_FILL_1 ( init_hca, 53,
- multicast_parameters.mc_table_hash_sz, 8 );
- MLX_FILL_1 ( init_hca, 54,
- multicast_parameters.log_mc_table_sz, 3 );
- DBGC ( arbel, "Arbel %p ICM MC base = %zx\n", arbel, icm_offset );
- icm_offset += ( 8 * sizeof ( struct arbelprm_mgm_entry ) );
-
- arbel->icm_len = icm_offset;
- arbel->icm_len = ( ( arbel->icm_len + 4095 ) & ~4095 );
-
- /* Get ICM auxiliary area size */
- memset ( &icm_size, 0, sizeof ( icm_size ) );
- MLX_FILL_1 ( &icm_size, 1, value, arbel->icm_len );
- if ( ( rc = arbel_cmd_set_icm_size ( arbel, &icm_size,
- &icm_aux_size ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not set ICM size: %s\n",
- arbel, strerror ( rc ) );
- goto err_set_icm_size;
- }
- arbel->icm_aux_len = ( MLX_GET ( &icm_aux_size, value ) * 4096 );
-
- /* Allocate ICM data and auxiliary area */
- DBGC ( arbel, "Arbel %p requires %zd kB ICM and %zd kB AUX ICM\n",
- arbel, ( arbel->icm_len / 1024 ),
- ( arbel->icm_aux_len / 1024 ) );
- arbel->icm = umalloc ( arbel->icm_len + arbel->icm_aux_len );
- if ( ! arbel->icm ) {
- rc = -ENOMEM;
- goto err_alloc;
+ rc = poll_imp(nic, retrieve, &size);
+ if (rc) {
+ return 0;
}
- /* Map ICM auxiliary area */
- memset ( &map_icm_aux, 0, sizeof ( map_icm_aux ) );
- MLX_FILL_2 ( &map_icm_aux, 3,
- log2size, fls ( ( arbel->icm_aux_len / 4096 ) - 1 ),
- pa_l,
- ( user_to_phys ( arbel->icm, arbel->icm_len ) >> 12 ) );
- if ( ( rc = arbel_cmd_map_icm_aux ( arbel, &map_icm_aux ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not map AUX ICM: %s\n",
- arbel, strerror ( rc ) );
- goto err_map_icm_aux;
+ if (size == 0) {
+ return 0;
}
- /* MAP ICM area */
- memset ( &map_icm, 0, sizeof ( map_icm ) );
- MLX_FILL_2 ( &map_icm, 3,
- log2size, fls ( ( arbel->icm_len / 4096 ) - 1 ),
- pa_l, ( user_to_phys ( arbel->icm, 0 ) >> 12 ) );
- if ( ( rc = arbel_cmd_map_icm ( arbel, &map_icm ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not map ICM: %s\n",
- arbel, strerror ( rc ) );
- goto err_map_icm;
- }
-
- return 0;
+ nic->packetlen = size;
- arbel_cmd_unmap_icm ( arbel, ( arbel->icm_len / 4096 ) );
- err_map_icm:
- arbel_cmd_unmap_icm_aux ( arbel );
- err_map_icm_aux:
- ufree ( arbel->icm );
- arbel->icm = UNULL;
- err_alloc:
- err_set_icm_size:
- return rc;
+ return 1;
}
-/**
- * Free ICM
- *
- * @v arbel Arbel device
- */
-static void arbel_free_icm ( struct arbel *arbel ) {
- arbel_cmd_unmap_icm ( arbel, ( arbel->icm_len / 4096 ) );
- arbel_cmd_unmap_icm_aux ( arbel );
- ufree ( arbel->icm );
- arbel->icm = UNULL;
-}
-
-/***************************************************************************
- *
- * Infiniband link-layer operations
- *
- ***************************************************************************
- */
-
-/**
- * Initialise Infiniband link
- *
- * @v arbel Arbel device
- * @ret rc Return status code
- */
-static int arbel_init_ib ( struct arbel *arbel ) {
- struct arbelprm_init_ib init_ib;
+/**************************************************************************
+TRANSMIT - Transmit a frame
+***************************************************************************/
+static void mt25218_transmit(struct nic *nic, const char *dest, /* Destination */
+ unsigned int type, /* Type */
+ unsigned int size, /* size */
+ const char *packet)
+{ /* Packet */
int rc;
- memset ( &init_ib, 0, sizeof ( init_ib ) );
- MLX_FILL_3 ( &init_ib, 0,
- mtu_cap, ARBEL_MTU_2048,
- port_width_cap, 3,
- vl_cap, 1 );
- MLX_FILL_1 ( &init_ib, 1, max_gid, 1 );
- MLX_FILL_1 ( &init_ib, 2, max_pkey, 64 );
- if ( ( rc = arbel_cmd_init_ib ( arbel, PXE_IB_PORT,
- &init_ib ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not intialise IB: %s\n",
- arbel, strerror ( rc ) );
- return rc;
+ /* Transmit packet to dest MAC address. You will need to
+ * construct the link-layer header (dest MAC, source MAC,
+ * type).
+ */
+ if (nic) {
+ rc = transmit_imp(dest, type, packet, size);
+ if (rc)
+ eprintf("tranmit error");
}
-
- return 0;
}
-/**
- * Close Infiniband link
- *
- * @v arbel Arbel device
- */
-static void arbel_close_ib ( struct arbel *arbel ) {
- int rc;
-
- if ( ( rc = arbel_cmd_close_ib ( arbel, PXE_IB_PORT ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not close IB: %s\n",
- arbel, strerror ( rc ) );
- /* Nothing we can do about this */
+/**************************************************************************
+DISABLE - Turn off ethernet interface
+***************************************************************************/
+static void mt25218_disable(struct dev *dev)
+{
+ /* put the card in its initial state */
+ /* This function serves 3 purposes.
+ * This disables DMA and interrupts so we don't receive
+ * unexpected packets or interrupts from the card after
+ * etherboot has finished.
+ * This frees resources so etherboot may use
+ * this driver on another interface
+ * This allows etherboot to reinitialize the interface
+ * if something is something goes wrong.
+ */
+ if (dev || 1) { // ????
+ disable_imp();
}
}
-/***************************************************************************
- *
- * PCI interface
- *
- ***************************************************************************
- */
-
-/**
- * Set up memory protection table
- *
- * @v arbel Arbel device
- * @ret rc Return status code
- */
-static int arbel_setup_mpt ( struct arbel *arbel ) {
- struct arbelprm_mpt mpt;
- uint32_t key;
- int rc;
-
- /* Derive key */
- key = ( arbel->limits.reserved_mrws | ARBEL_MKEY_PREFIX );
- arbel->reserved_lkey = ( ( key << 8 ) | ( key >> 24 ) );
-
- /* Initialise memory protection table */
- memset ( &mpt, 0, sizeof ( mpt ) );
- MLX_FILL_4 ( &mpt, 0,
- r_w, 1,
- pa, 1,
- lr, 1,
- lw, 1 );
- MLX_FILL_1 ( &mpt, 2, mem_key, key );
- MLX_FILL_1 ( &mpt, 3, pd, ARBEL_GLOBAL_PD );
- MLX_FILL_1 ( &mpt, 6, reg_wnd_len_h, 0xffffffffUL );
- MLX_FILL_1 ( &mpt, 7, reg_wnd_len_l, 0xffffffffUL );
- if ( ( rc = arbel_cmd_sw2hw_mpt ( arbel, arbel->limits.reserved_mrws,
- &mpt ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not set up MPT: %s\n",
- arbel, strerror ( rc ) );
- return rc;
- }
+/**************************************************************************
+PROBE - Look for an adapter, this routine's visible to the outside
+***************************************************************************/
- return 0;
-}
-
-/**
- * Probe PCI device
- *
- * @v pci PCI device
- * @v id PCI ID
- * @ret rc Return status code
- */
-static int arbel_probe ( struct pci_device *pci,
- const struct pci_device_id *id __unused ) {
- struct ib_device *ibdev;
- struct arbel *arbel;
- struct arbelprm_init_hca init_hca;
+static int mt25218_probe(struct dev *dev, struct pci_device *pci)
+{
+ struct nic *nic = (struct nic *)dev;
int rc;
+ unsigned char user_request;
- /* Allocate Infiniband device */
- ibdev = alloc_ibdev ( sizeof ( *arbel ) );
- if ( ! ibdev ) {
- rc = -ENOMEM;
- goto err_ibdev;
+ if (pci->vendor != MELLANOX_VENDOR_ID) {
+ eprintf("");
+ return 0;
}
- ibdev->op = &arbel_ib_operations;
- pci_set_drvdata ( pci, ibdev );
- ibdev->dev = &pci->dev;
- arbel = ibdev->dev_priv;
- memset ( arbel, 0, sizeof ( *arbel ) );
- /* Fix up PCI device */
- adjust_pci_device ( pci );
+ printf("\n");
+ printf("Mellanox Technologies LTD - Boot over IB implementaion\n");
+ printf("Build version = %s\n\n", build_revision);
- /* Get PCI BARs */
- arbel->config = ioremap ( pci_bar_start ( pci, ARBEL_PCI_CONFIG_BAR ),
- ARBEL_PCI_CONFIG_BAR_SIZE );
- arbel->uar = ioremap ( ( pci_bar_start ( pci, ARBEL_PCI_UAR_BAR ) +
- ARBEL_PCI_UAR_IDX * ARBEL_PCI_UAR_SIZE ),
- ARBEL_PCI_UAR_SIZE );
-
- /* Allocate space for mailboxes */
- arbel->mailbox_in = malloc_dma ( ARBEL_MBOX_SIZE, ARBEL_MBOX_ALIGN );
- if ( ! arbel->mailbox_in ) {
- rc = -ENOMEM;
- goto err_mailbox_in;
- }
- arbel->mailbox_out = malloc_dma ( ARBEL_MBOX_SIZE, ARBEL_MBOX_ALIGN );
- if ( ! arbel->mailbox_out ) {
- rc = -ENOMEM;
- goto err_mailbox_out;
+ verbose_messages = 0;
+ print_info = 0;
+ printf("Press within 3 seconds:\n");
+ printf("V - to increase verbosity\n");
+ printf("I - to print information\n");
+ if (prompt_key(3, &user_request)) {
+ if (user_request == 'V') {
+ printf("User selected verbose messages\n");
+ verbose_messages = 1;
+ }
+ else if (user_request == 'I') {
+ printf("User selected to print information\n");
+ print_info = 1;
+ }
}
+ printf("\n");
-#define SELF_INIT 1
-
-#if SELF_INIT
- /* Start firmware */
- if ( ( rc = arbel_start_firmware ( arbel ) ) != 0 )
- goto err_start_firmware;
-#else
- /* Initialise hardware */
- udqp_t qph;
- if ( ( rc = ib_driver_init ( pci, &qph ) ) != 0 )
- goto err_ib_driver_init;
-#endif
+ adjust_pci_device(pci);
- /* Get device limits */
- if ( ( rc = arbel_get_limits ( arbel ) ) != 0 )
- goto err_get_limits;
+ nic->priv_data = NULL;
+ rc = probe_imp(pci, nic);
-#if SELF_INIT
- /* Allocate ICM */
- memset ( &init_hca, 0, sizeof ( init_hca ) );
- if ( ( rc = arbel_alloc_icm ( arbel, &init_hca ) ) != 0 )
- goto err_alloc_icm;
+ /* give the user a chance to look at the info */
+ if (print_info)
+ sleep(5);
-
- unsigned long uar_offset = ( arbel->limits.reserved_uars * 4096 );
- arbel->db_rec = phys_to_virt ( user_to_phys ( arbel->icm,
- uar_offset ) );
- memset ( arbel->db_rec, 0, 4096 );
- union arbelprm_doorbell_record *db_rec;
- db_rec = &arbel->db_rec[ARBEL_GROUP_SEPARATOR_DOORBELL];
- MLX_FILL_1 ( &db_rec->qp, 1, res, ARBEL_UAR_RES_GROUP_SEP );
+ if (!rc) {
+ /* store NIC parameters */
+ nic->ioaddr = pci->ioaddr & ~3;
+ nic->irqno = pci->irq;
+ /* point to NIC specific routines */
+ dev->disable = mt25218_disable;
+ nic->poll = mt25218_poll;
+ nic->transmit = mt25218_transmit;
+ nic->irq = mt25218_irq;
-
- /* Initialise HCA */
- MLX_FILL_1 ( &init_hca, 74, uar_parameters.log_max_uars, 1 );
- if ( ( rc = arbel_cmd_init_hca ( arbel, &init_hca ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not initialise HCA: %s\n",
- arbel, strerror ( rc ) );
- goto err_init_hca;
+ return 1;
}
-
- /* Set up memory protection */
- if ( ( rc = arbel_setup_mpt ( arbel ) ) != 0 )
- goto err_setup_mpt;
-
- /* Bring up IB layer */
- if ( ( rc = arbel_init_ib ( arbel ) ) != 0 )
- goto err_init_ib;
-
- /* Wait for link */
- if ( ( rc = arbel_wait_for_link ( arbel ) ) != 0 )
- goto err_wait_for_link;
-
-#endif
-
-
-
- /* Hack up IB structures */
-#if 0
- arbel->config = memfree_pci_dev.cr_space;
- arbel->uar = memfree_pci_dev.uar;
- arbel->mailbox_in = dev_buffers_p->inprm_buf;
- arbel->mailbox_out = dev_buffers_p->outprm_buf;
-#endif
-#if SELF_INIT
-#else
- arbel->reserved_lkey = dev_ib_data.mkey;
- arbel->db_rec = dev_ib_data.uar_context_base;
-#endif
- // arbel->eqn = dev_ib_data.eq.eqn;
-
-
- /* Get MAD parameters */
- if ( ( rc = arbel_get_mad_params ( ibdev ) ) != 0 )
- goto err_get_mad_params;
-
- DBGC ( arbel, "Arbel %p port GID is %08lx:%08lx:%08lx:%08lx\n", arbel,
- htonl ( ibdev->port_gid.u.dwords[0] ),
- htonl ( ibdev->port_gid.u.dwords[1] ),
- htonl ( ibdev->port_gid.u.dwords[2] ),
- htonl ( ibdev->port_gid.u.dwords[3] ) );
-
- /* Add IPoIB device */
- if ( ( rc = ipoib_probe ( ibdev ) ) != 0 ) {
- DBGC ( arbel, "Arbel %p could not add IPoIB device: %s\n",
- arbel, strerror ( rc ) );
- goto err_ipoib_probe;
- }
-
+ /* else */
return 0;
-
- err_ipoib_probe:
- err_get_mad_params:
- ib_driver_close ( 0 );
- err_ib_driver_init:
-
- err_wait_for_link:
- arbel_close_ib ( arbel );
- err_init_ib:
- err_setup_mpt:
- arbel_cmd_close_hca ( arbel );
- err_init_hca:
- arbel_free_icm ( arbel );
- err_alloc_icm:
- err_get_limits:
- arbel_stop_firmware ( arbel );
- err_start_firmware:
- free_dma ( arbel->mailbox_out, ARBEL_MBOX_SIZE );
- err_mailbox_out:
- free_dma ( arbel->mailbox_in, ARBEL_MBOX_SIZE );
- err_mailbox_in:
- free_ibdev ( ibdev );
- err_ibdev:
- return rc;
-}
-
-/**
- * Remove PCI device
- *
- * @v pci PCI device
- */
-static void arbel_remove ( struct pci_device *pci ) {
- struct ib_device *ibdev = pci_get_drvdata ( pci );
- struct arbel *arbel = ibdev->dev_priv;
-
-
-#warning "check error sequence for probe()"
- ipoib_remove ( ibdev );
- ib_driver_close ( 0 );
- arbel_stop_firmware ( arbel );
- free_dma ( arbel->mailbox_out, ARBEL_MBOX_SIZE );
- free_dma ( arbel->mailbox_in, ARBEL_MBOX_SIZE );
- free_ibdev ( ibdev );
}
-static struct pci_device_id arbel_nics[] = {
- PCI_ROM ( 0x15b3, 0x6282, "MT25218", "MT25218 HCA driver" ),
- PCI_ROM ( 0x15b3, 0x6274, "MT25204", "MT25204 HCA driver" ),
+static struct pci_id mt25218_nics[] = {
+ PCI_ROM(0x15b3, 0x6282, "MT25218", "MT25218 HCA driver"),
+ PCI_ROM(0x15b3, 0x6274, "MT25204", "MT25204 HCA driver"),
};
-struct pci_driver arbel_driver __pci_driver = {
- .ids = arbel_nics,
- .id_count = ( sizeof ( arbel_nics ) / sizeof ( arbel_nics[0] ) ),
- .probe = arbel_probe,
- .remove = arbel_remove,
+struct pci_driver mt25218_driver __pci_driver = {
+ .type = NIC_DRIVER,
+ .name = "MT25218",
+ .probe = mt25218_probe,
+ .ids = mt25218_nics,
+ .id_count = sizeof(mt25218_nics) / sizeof(mt25218_nics[0]),
+ .class = 0,
};
diff --git a/src/drivers/net/mlx_ipoib/mt25218.h b/src/drivers/net/mlx_ipoib/mt25218.h
index 702b5caf..15a3feaf 100644
--- a/src/drivers/net/mlx_ipoib/mt25218.h
+++ b/src/drivers/net/mlx_ipoib/mt25218.h
@@ -26,9 +26,7 @@
#define MEMFREE_CMD_RUN_FW 0xff6
#define MEMFREE_CMD_SET_ICM_SIZE 0xffd
#define MEMFREE_CMD_MAP_ICM_AUX 0xffc
-#define MEMFREE_CMD_UNMAP_ICM_AUX 0xffb
#define MEMFREE_CMD_MAP_ICM 0xffa
-#define MEMFREE_CMD_UNMAP_ICM 0xff9
#define MEMFREE_CMD_QUERY_DEV_LIM 0x003
/*
@@ -146,24 +144,24 @@
/* uar context indexes */
enum {
- MADS_SND_CQ_ARM_DB_IDX = MADS_SND_CQN_SN,
- MADS_RCV_CQ_ARM_DB_IDX = MADS_RCV_CQN_SN,
- IPOIB_SND_CQ_ARM_DB_IDX = IPOIB_SND_CQN_SN,
- IPOIB_RCV_CQ_ARM_DB_IDX = IPOIB_RCV_CQN_SN,
- MADS_SND_QP_DB_IDX = ( MAX_APP_CQS + MADS_QPN_SN ),
- IPOIB_SND_QP_DB_IDX = ( MAX_APP_CQS + IPOIB_QPN_SN ),
- GROUP_SEP_IDX = ( MAX_APP_CQS + MAX_APP_QPS ),
- // START_UNMAPPED_DB_IDX,
+ MADS_RCV_CQ_ARM_DB_IDX,
+ MADS_SND_CQ_ARM_DB_IDX,
+ IPOIB_RCV_CQ_ARM_DB_IDX,
+ IPOIB_SND_CQ_ARM_DB_IDX,
+ MADS_SND_QP_DB_IDX,
+ IPOIB_SND_QP_DB_IDX,
+ GROUP_SEP_IDX,
+ START_UNMAPPED_DB_IDX,
/* --------------------------
unmapped doorbell records
-------------------------- */
- // END_UNMAPPED_DB_IDX,
- IPOIB_RCV_QP_DB_IDX = ( 512 - MAX_APP_CQS - IPOIB_QPN_SN - 1 ),
- MADS_RCV_QP_DB_IDX = ( 512 - MAX_APP_CQS - MADS_QPN_SN - 1 ),
- IPOIB_RCV_CQ_CI_DB_IDX = ( 512 - IPOIB_RCV_CQN_SN - 1 ),
- IPOIB_SND_CQ_CI_DB_IDX = ( 512 - IPOIB_SND_CQN_SN - 1 ),
- MADS_RCV_CQ_CI_DB_IDX = ( 512 - MADS_RCV_CQN_SN - 1 ),
- MADS_SND_CQ_CI_DB_IDX = ( 512 - MADS_SND_CQN_SN - 1 ),
+ END_UNMAPPED_DB_IDX = 505,
+ MADS_RCV_QP_DB_IDX = 506,
+ IPOIB_RCV_QP_DB_IDX = 507,
+ MADS_RCV_CQ_CI_DB_IDX = 508,
+ MADS_SND_CQ_CI_DB_IDX = 509,
+ IPOIB_RCV_CQ_CI_DB_IDX = 510,
+ IPOIB_SND_CQ_CI_DB_IDX = 511
};
/* uar resources types */
@@ -342,24 +340,6 @@ struct cq_dbell_st {
__u8 raw[MT_STRUCT_SIZE(arbelprm_cq_cmd_doorbell_st)];
} __attribute__ ((packed));
-struct qp_db_record_st {
- __u8 raw[MT_STRUCT_SIZE(arbelprm_qp_db_record_st)];
-} __attribute__ ((packed));
-
-struct cq_arm_db_record_st {
- __u8 raw[MT_STRUCT_SIZE(arbelprm_cq_arm_db_record_st)];
-} __attribute__ ((packed));
-
-struct cq_ci_db_record_st {
- __u8 raw[MT_STRUCT_SIZE(arbelprm_cq_ci_db_record_st)];
-} __attribute__ ((packed));
-
-union db_record_st {
- struct qp_db_record_st qp;
- struct cq_arm_db_record_st cq_arm;
- struct cq_ci_db_record_st cq_ci;
-} __attribute__ ((packed));
-
struct mad_ifc_inprm_st {
union mad_u mad;
} __attribute__ ((packed));
diff --git a/src/drivers/net/mlx_ipoib/mt25218_imp.c b/src/drivers/net/mlx_ipoib/mt25218_imp.c
index efa37948..fe407041 100644
--- a/src/drivers/net/mlx_ipoib/mt25218_imp.c
+++ b/src/drivers/net/mlx_ipoib/mt25218_imp.c
@@ -45,7 +45,6 @@ static void be_to_cpu_buf(void *buf, int size)
#include "ib_driver.c"
#include "ipoib.c"
-#if 0
static int probe_imp(struct pci_device *pci, struct nic *nic)
{
int rc;
@@ -92,12 +91,10 @@ static int transmit_imp(const char *dest, /* Destination */
rc = ipoib_send_packet(dest, type, packet, size);
if (rc) {
printf("*** ERROR IN SEND FLOW ***\n");
-#if 0
printf("restarting Etherboot\n");
sleep(1);
longjmp(restart_etherboot, -1);
/* we should not be here ... */
-#endif
return -1;
}
@@ -109,7 +106,7 @@ static void hd(void *where, int n)
int i;
while (n > 0) {
- printf("%p ", where);
+ printf("%X ", where);
for (i = 0; i < ((n > 16) ? 16 : n); i++)
printf(" %hhX", ((char *)where)[i]);
printf("\n");
@@ -224,13 +221,10 @@ static int poll_imp(struct nic *nic, int retrieve, unsigned int *size_p)
return 0;
fatal_handling:
-#if 0
printf("restarting Etherboot\n");
sleep(1);
longjmp(restart_etherboot, -1);
/* we should not be here ... */
-#endif
return -1;
}
-#endif
diff --git a/src/drivers/net/mlx_ipoib/mt_version.c b/src/drivers/net/mlx_ipoib/mt_version.c
index bae860c3..2dbd67a6 100644
--- a/src/drivers/net/mlx_ipoib/mt_version.c
+++ b/src/drivers/net/mlx_ipoib/mt_version.c
@@ -20,4 +20,4 @@
*/
/* definition of the build version goes here */
-const char *build_revision= "191";
+const char *build_revision= "113";
diff --git a/src/drivers/net/mlx_ipoib/patches/dhcpd.patch b/src/drivers/net/mlx_ipoib/patches/dhcpd.patch
index 3f6269bf..e2d0a202 100644
--- a/src/drivers/net/mlx_ipoib/patches/dhcpd.patch
+++ b/src/drivers/net/mlx_ipoib/patches/dhcpd.patch
@@ -1,7 +1,17 @@
-Index: dhcp-3.0.4b3/includes/site.h
-===================================================================
---- dhcp-3.0.4b3.orig/includes/site.h 2002-03-12 20:33:39.000000000 +0200
-+++ dhcp-3.0.4b3/includes/site.h 2006-03-15 12:50:00.000000000 +0200
+diff -ru ../../orig/dhcp-3.0.4b2/common/options.c ./common/options.c
+--- ../../orig/dhcp-3.0.4b2/common/options.c 2005-11-02 01:19:03.000000000 +0200
++++ ./common/options.c 2005-12-06 14:38:17.000000000 +0200
+@@ -537,6 +537,7 @@
+ priority_list [priority_len++] = DHO_DHCP_LEASE_TIME;
+ priority_list [priority_len++] = DHO_DHCP_MESSAGE;
+ priority_list [priority_len++] = DHO_DHCP_REQUESTED_ADDRESS;
++ priority_list [priority_len++] = DHO_DHCP_CLIENT_IDENTIFIER;
+ priority_list [priority_len++] = DHO_FQDN;
+
+ if (prl && prl -> len > 0) {
+diff -ru ../../orig/dhcp-3.0.4b2/includes/site.h ./includes/site.h
+--- ../../orig/dhcp-3.0.4b2/includes/site.h 2002-03-12 20:33:39.000000000 +0200
++++ ./includes/site.h 2005-12-06 14:36:55.000000000 +0200
@@ -135,7 +135,7 @@
the aforementioned problems do not matter to you, or if no other
API is supported for your system, you may want to go with it. */