Browse Source

[linda] Add support for QLogic 7220-based Infiniband HCAs

These cards very nearly support our current IB Verbs model.  There is
one minor difference: multicast packets will always be delivered by
the hardware to QP0, so the driver has to redirect them to the
appropriate QP.  This means that QP owners may see receive completions
for buffers that they never posted.  Nothing in our current codebase
will break because of this.
tags/v0.9.6
Michael Brown 16 years ago
parent
commit
125c6d66a8

+ 2396
- 0
src/drivers/infiniband/linda.c
File diff suppressed because it is too large
View File


+ 253
- 0
src/drivers/infiniband/linda.h View File

1
+#ifndef _LINDA_H
2
+#define _LINDA_H
3
+
4
+/**
5
+ * @file
6
+ *
7
+ * QLogic Linda Infiniband HCA
8
+ *
9
+ */
10
+
11
+#define BITOPS_LITTLE_ENDIAN
12
+#include <gpxe/bitops.h>
13
+#include "qib_7220_regs.h"
14
+
15
+struct ib_device;
16
+
17
+/** A Linda GPIO register */
18
+struct QIB_7220_GPIO_pb {
19
+	pseudo_bit_t GPIO[16];
20
+	pseudo_bit_t Reserved[48];
21
+};
22
+struct QIB_7220_GPIO {
23
+	PSEUDO_BIT_STRUCT ( struct QIB_7220_GPIO_pb );
24
+};
25
+
26
+/** A Linda general scalar register */
27
+struct QIB_7220_scalar_pb {
28
+	pseudo_bit_t Value[64];
29
+};
30
+struct QIB_7220_scalar {
31
+	PSEUDO_BIT_STRUCT ( struct QIB_7220_scalar_pb );
32
+};
33
+
34
+/** Linda send per-buffer control word */
35
+struct QIB_7220_SendPbc_pb {
36
+	pseudo_bit_t LengthP1_toibc[11];
37
+	pseudo_bit_t Reserved1[4];
38
+	pseudo_bit_t LengthP1_trigger[11];
39
+	pseudo_bit_t Reserved2[3];
40
+	pseudo_bit_t TestEbp[1];
41
+	pseudo_bit_t Test[1];
42
+	pseudo_bit_t Intr[1];
43
+	pseudo_bit_t Reserved3[31];
44
+	pseudo_bit_t VL15[1];
45
+};
46
+struct QIB_7220_SendPbc {
47
+	PSEUDO_BIT_STRUCT ( struct QIB_7220_SendPbc_pb );
48
+};
49
+
50
+/** Linda send buffer availability */
51
+struct QIB_7220_SendBufAvail_pb {
52
+	pseudo_bit_t InUseCheck[144][2];
53
+	pseudo_bit_t Reserved[32];
54
+};
55
+struct QIB_7220_SendBufAvail {
56
+	PSEUDO_BIT_STRUCT ( struct QIB_7220_SendBufAvail_pb );
57
+};
58
+
59
+/** DMA alignment for send buffer availability */
60
+#define LINDA_SENDBUFAVAIL_ALIGN 64
61
+
62
+/** A Linda eager receive descriptor */
63
+struct QIB_7220_RcvEgr_pb {
64
+	pseudo_bit_t Addr[37];
65
+	pseudo_bit_t BufSize[3];
66
+	pseudo_bit_t Reserved[24];
67
+};
68
+struct QIB_7220_RcvEgr {
69
+	PSEUDO_BIT_STRUCT ( struct QIB_7220_RcvEgr_pb );
70
+};
71
+
72
+/** Linda receive header flags */
73
+struct QIB_7220_RcvHdrFlags_pb {
74
+	pseudo_bit_t PktLen[11];
75
+	pseudo_bit_t RcvType[3];
76
+	pseudo_bit_t SoftB[1];
77
+	pseudo_bit_t SoftA[1];
78
+	pseudo_bit_t EgrIndex[12];
79
+	pseudo_bit_t Reserved1[3];
80
+	pseudo_bit_t UseEgrBfr[1];
81
+	pseudo_bit_t RcvSeq[4];
82
+	pseudo_bit_t HdrqOffset[11];
83
+	pseudo_bit_t Reserved2[8];
84
+	pseudo_bit_t IBErr[1];
85
+	pseudo_bit_t MKErr[1];
86
+	pseudo_bit_t TIDErr[1];
87
+	pseudo_bit_t KHdrErr[1];
88
+	pseudo_bit_t MTUErr[1];
89
+	pseudo_bit_t LenErr[1];
90
+	pseudo_bit_t ParityErr[1];
91
+	pseudo_bit_t VCRCErr[1];
92
+	pseudo_bit_t ICRCErr[1];
93
+};
94
+struct QIB_7220_RcvHdrFlags {
95
+	PSEUDO_BIT_STRUCT ( struct QIB_7220_RcvHdrFlags_pb );
96
+};
97
+
98
+/** Linda memory BAR size */
99
+#define LINDA_BAR0_SIZE 0x400000
100
+
101
+/** Linda I2C SCL line GPIO number */
102
+#define LINDA_GPIO_SCL 0
103
+
104
+/** Linda I2C SDA line GPIO number */
105
+#define LINDA_GPIO_SDA 1
106
+
107
+/** GUID offset within EEPROM */
108
+#define LINDA_EEPROM_GUID_OFFSET 3
109
+
110
+/** GUID size within EEPROM */
111
+#define LINDA_EEPROM_GUID_SIZE 8
112
+
113
+/** Board serial number offset within EEPROM */
114
+#define LINDA_EEPROM_SERIAL_OFFSET 12
115
+
116
+/** Board serial number size within EEPROM */
117
+#define LINDA_EEPROM_SERIAL_SIZE 12
118
+
119
+/** Maximum number of send buffers used
120
+ *
121
+ * This is a policy decision.  Must be less than or equal to the total
122
+ * number of send buffers supported by the hardware (128).
123
+ */
124
+#define LINDA_MAX_SEND_BUFS 32
125
+
126
+/** Linda send buffer size */
127
+#define LINDA_SEND_BUF_SIZE 4096
128
+
129
+/** Number of contexts (including kernel context)
130
+ *
131
+ * This is a policy decision.  Must be 5, 9 or 17.
132
+ */
133
+#define LINDA_NUM_CONTEXTS 5
134
+
135
+/** PortCfg values for different numbers of contexts */
136
+enum linda_portcfg {
137
+	LINDA_PORTCFG_5CTX = 0,
138
+	LINDA_PORTCFG_9CTX = 1,
139
+	LINDA_PORTCFG_17CTX = 2,
140
+};
141
+
142
+/** PortCfg values for different numbers of contexts */
143
+#define LINDA_EAGER_ARRAY_SIZE_5CTX_0 2048
144
+#define LINDA_EAGER_ARRAY_SIZE_5CTX_OTHER 4096
145
+#define LINDA_EAGER_ARRAY_SIZE_9CTX_0 2048
146
+#define LINDA_EAGER_ARRAY_SIZE_9CTX_OTHER 2048
147
+#define LINDA_EAGER_ARRAY_SIZE_17CTX_0 2048
148
+#define LINDA_EAGER_ARRAY_SIZE_17CTX_OTHER 1024
149
+
150
+/** Eager buffer required alignment */
151
+#define LINDA_EAGER_BUFFER_ALIGN 2048
152
+
153
+/** Eager buffer size encodings */
154
+enum linda_eager_buffer_size {
155
+	LINDA_EAGER_BUFFER_NONE = 0,
156
+	LINDA_EAGER_BUFFER_2K = 1,
157
+	LINDA_EAGER_BUFFER_4K = 2,
158
+	LINDA_EAGER_BUFFER_8K = 3,
159
+	LINDA_EAGER_BUFFER_16K = 4,
160
+	LINDA_EAGER_BUFFER_32K = 5,
161
+	LINDA_EAGER_BUFFER_64K = 6,
162
+};
163
+
164
+/** Number of RX headers per context
165
+ *
166
+ * This is a policy decision.
167
+ */
168
+#define LINDA_RECV_HEADER_COUNT 8
169
+
170
+/** Maximum size of each RX header
171
+ *
172
+ * This is a policy decision.  Must be divisible by 4.
173
+ */
174
+#define LINDA_RECV_HEADER_SIZE 96
175
+
176
+/** Total size of an RX header ring */
177
+#define LINDA_RECV_HEADERS_SIZE \
178
+	( LINDA_RECV_HEADER_SIZE * LINDA_RECV_HEADER_COUNT )
179
+
180
+/** RX header alignment */
181
+#define LINDA_RECV_HEADERS_ALIGN 64
182
+
183
+/** RX payload size
184
+ *
185
+ * This is a policy decision.  Must be a valid eager buffer size.
186
+ */
187
+#define LINDA_RECV_PAYLOAD_SIZE 2048
188
+
189
+/** QPN used for Infinipath Packets
190
+ *
191
+ * This is a policy decision.  Must have bit 0 clear.  Must not be a
192
+ * QPN that we will use.
193
+ */
194
+#define LINDA_QP_IDETH 0xdead0
195
+
196
+/** Maximum time for wait for external parallel bus request, in us */
197
+#define LINDA_EPB_REQUEST_MAX_WAIT_US 500
198
+
199
+/** Maximum time for wait for external parallel bus transaction, in us */
200
+#define LINDA_EPB_XACT_MAX_WAIT_US 500
201
+
202
+/** Linda external parallel bus chip selects */
203
+#define LINDA_EPB_CS_SERDES 1
204
+#define LINDA_EPB_CS_8051 2
205
+
206
+/** Linda external parallel bus read/write operations */
207
+#define LINDA_EPB_WRITE 0
208
+#define LINDA_EPB_READ 1
209
+
210
+/** Linda external parallel bus register addresses */
211
+#define LINDA_EPB_ADDRESS( _channel, _element, _reg ) \
212
+	( (_element) | ( (_channel) << 4 ) | ( (_reg) << 9 ) )
213
+#define LINDA_EPB_ADDRESS_CHANNEL( _address )	( ( (_address) >> 4 ) & 0x1f )
214
+#define LINDA_EPB_ADDRESS_ELEMENT( _address )	( ( (_address) >> 0 ) & 0x0f )
215
+#define LINDA_EPB_ADDRESS_REG( _address )	( ( (_address) >> 9 ) & 0x3f )
216
+
217
+/** Linda external parallel bus locations
218
+ *
219
+ * The location is used by the driver to encode both the chip select
220
+ * and the EPB address.
221
+ */
222
+#define LINDA_EPB_LOC( _cs, _channel, _element, _reg) \
223
+	( ( (_cs) << 16 ) | LINDA_EPB_ADDRESS ( _channel, _element, _reg ) )
224
+#define LINDA_EPB_LOC_ADDRESS( _loc )	( (_loc) & 0xffff )
225
+#define LINDA_EPB_LOC_CS( _loc )	( (_loc) >> 16 )
226
+
227
+/** Linda external parallel bus 8051 microcontroller register addresses */
228
+#define LINDA_EPB_UC_CHANNEL 6
229
+#define LINDA_EPB_UC_LOC( _reg ) \
230
+	LINDA_EPB_LOC ( LINDA_EPB_CS_8051, LINDA_EPB_UC_CHANNEL, 0, (_reg) )
231
+#define LINDA_EPB_UC_CTL	LINDA_EPB_UC_LOC ( 0 )
232
+#define LINDA_EPB_UC_CTL_WRITE	1
233
+#define LINDA_EPB_UC_CTL_READ	2
234
+#define LINDA_EPB_UC_ADDR_LO	LINDA_EPB_UC_LOC ( 2 )
235
+#define LINDA_EPB_UC_ADDR_HI	LINDA_EPB_UC_LOC ( 3 )
236
+#define LINDA_EPB_UC_DATA	LINDA_EPB_UC_LOC ( 4 )
237
+#define LINDA_EPB_UC_CHUNK_SIZE	64
238
+
239
+extern uint8_t linda_ib_fw[8192];
240
+
241
+/** Maximum time to wait for "trim done" signal, in ms */
242
+#define LINDA_TRIM_DONE_MAX_WAIT_MS 1000
243
+
244
+/** Linda link states */
245
+enum linda_link_state {
246
+	LINDA_LINK_STATE_DOWN = 0,
247
+	LINDA_LINK_STATE_INIT = 1,
248
+	LINDA_LINK_STATE_ARM = 2,
249
+	LINDA_LINK_STATE_ACTIVE = 3,
250
+	LINDA_LINK_STATE_ACT_DEFER = 4,
251
+};
252
+
253
+#endif /* _LINDA_H */

+ 1067
- 0
src/drivers/infiniband/linda_fw.c
File diff suppressed because it is too large
View File


+ 1763
- 0
src/drivers/infiniband/qib_7220_regs.h
File diff suppressed because it is too large
View File


+ 79
- 0
src/drivers/infiniband/qib_genbits.pl View File

1
+#!/usr/bin/perl -w
2
+
3
+use strict;
4
+use warnings;
5
+
6
+my $offsets = {};
7
+my $structures = {};
8
+my $structure = "";
9
+
10
+while ( <> ) {
11
+  chomp;
12
+  if ( /^\#define (\S+)_OFFS (\S+)$/ ) {
13
+    $structure = $1;
14
+    $offsets->{$structure} = $2;
15
+  } elsif ( /^\#define ${structure}_(\S+)_LSB (\S+)$/ ) {
16
+    $structures->{$structure}->{$1}->{LSB} = $2;
17
+  } elsif ( /^\#define ${structure}_(\S+)_RMASK (\S+)$/ ) {
18
+    $structures->{$structure}->{$1}->{RMASK} = $2;
19
+  } elsif ( /^\s*$/ ) {
20
+    # Do nothing
21
+  } else {
22
+    print "$_\n";
23
+  }
24
+}
25
+
26
+my $data = [ map { { name => $_, offset => $offsets->{$_} }; }
27
+	     sort { hex ( $offsets->{$a} ) <=> hex ( $offsets->{$b} ) }
28
+	     keys %$offsets ];
29
+
30
+foreach my $datum ( @$data ) {
31
+  next unless exists $structures->{$datum->{name}};
32
+  $structure = $structures->{$datum->{name}};
33
+  my $fields = [ map { { name => $_, lsb => $structure->{$_}->{LSB},
34
+			 rmask => $structure->{$_}->{RMASK} }; }
35
+		 sort { hex ( $structure->{$a}->{LSB} ) <=>
36
+			    hex ( $structure->{$b}->{LSB} ) }
37
+		 keys %$structure ];
38
+  $datum->{fields} = $fields;
39
+}
40
+
41
+print "\n/* This file has been further processed by $0 */\n\n\n";
42
+
43
+foreach my $datum ( @$data ) {
44
+  printf "#define %s_offset 0x%08xUL\n",
45
+      $datum->{name}, hex ( $datum->{offset} );
46
+  if ( exists $datum->{fields} ) {
47
+    my $lsb = 0;
48
+    my $reserved_idx = 0;
49
+    printf "struct %s_pb {\n", $datum->{name};
50
+    foreach my $field ( @{$datum->{fields}} ) {
51
+      my $pad_width = ( hex ( $field->{lsb} ) - $lsb );
52
+      die "Inconsistent LSB/RMASK in $datum->{name}\n" if $pad_width < 0;
53
+      printf "\tpseudo_bit_t _unused_%u[%u];\n", $reserved_idx++, $pad_width
54
+	  if $pad_width;
55
+      # Damn Perl can't cope with 64-bit hex constants
56
+      my $width = 0;
57
+      my $rmask = $field->{rmask};
58
+      while ( $rmask =~ /^(0x.+)f$/i ) {
59
+	$width += 4;
60
+	$rmask = $1;
61
+      }
62
+      $rmask = hex ( $rmask );
63
+      while ( $rmask ) {
64
+	$width++;
65
+	$rmask >>= 1;
66
+      }
67
+      printf "\tpseudo_bit_t %s[%u];\n", $field->{name}, $width;
68
+      $lsb += $width;
69
+    }
70
+    my $pad_width = ( 64 - $lsb );
71
+    die "Inconsistent LSB/RMASK in $datum->{name}\n" if $pad_width < 0;
72
+    printf "\tpseudo_bit_t _unused_%u[%u];\n", $reserved_idx++, $pad_width
73
+	if $pad_width;
74
+    printf "};\n";
75
+    printf "struct %s {\n\tPSEUDO_BIT_STRUCT ( struct %s_pb );\n};\n",
76
+	$datum->{name}, $datum->{name};
77
+  }
78
+  print "\n";
79
+}

+ 228
- 0
src/include/gpxe/bitops.h View File

1
+#ifndef _GPXE_BITOPS_H
2
+#define _GPXE_BITOPS_H
3
+
4
+/*
5
+ * Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
6
+ *
7
+ * This program is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU General Public License as
9
+ * published by the Free Software Foundation; either version 2 of the
10
+ * License, or any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful, but
13
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+ * General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program; if not, write to the Free Software
19
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
+ */
21
+
22
+/**
23
+ * @file
24
+ *
25
+ * Bit operations
26
+ *
27
+ */
28
+
29
+#include <stdint.h>
30
+#include <byteswap.h>
31
+
32
+/* Endianness selection.
33
+ *
34
+ * This is a property of the NIC, not a property of the host CPU.
35
+ */
36
+#ifdef BITOPS_LITTLE_ENDIAN
37
+#define cpu_to_BIT64	cpu_to_le64
38
+#define cpu_to_BIT32	cpu_to_le32
39
+#define BIT64_to_cpu	le64_to_cpu
40
+#define BIT32_to_cpu	le32_to_cpu
41
+#endif
42
+#ifdef BITOPS_BIG_ENDIAN
43
+#define cpu_to_BIT64	cpu_to_be64
44
+#define cpu_to_BIT32	cpu_to_be32
45
+#define BIT64_to_cpu	be64_to_cpu
46
+#define BIT32_to_cpu	be32_to_cpu
47
+#endif
48
+
49
+/** Datatype used to represent a bit in the pseudo-structures */
50
+typedef unsigned char pseudo_bit_t;
51
+
52
+/**
53
+ * Wrapper structure for pseudo_bit_t structures
54
+ *
55
+ * This structure provides a wrapper around pseudo_bit_t structures.
56
+ * It has the correct size, and also encapsulates type information
57
+ * about the underlying pseudo_bit_t-based structure, which allows the
58
+ * BIT_FILL() etc. macros to work without requiring explicit type
59
+ * information.
60
+ */
61
+#define PSEUDO_BIT_STRUCT( _structure )					      \
62
+	union {								      \
63
+		uint8_t bytes[ sizeof ( _structure ) / 8 ];		      \
64
+		uint32_t dwords[ sizeof ( _structure ) / 32 ];		      \
65
+		uint64_t qwords[ sizeof ( _structure ) / 64 ];		      \
66
+		_structure *dummy[0];					      \
67
+	} u
68
+
69
+/** Get pseudo_bit_t structure type from wrapper structure pointer */
70
+#define PSEUDO_BIT_STRUCT_TYPE( _ptr )					      \
71
+	typeof ( *((_ptr)->u.dummy[0]) )
72
+
73
+/** Bit offset of a field within a pseudo_bit_t structure */
74
+#define BIT_OFFSET( _ptr, _field )					      \
75
+	offsetof ( PSEUDO_BIT_STRUCT_TYPE ( _ptr ), _field )
76
+
77
+/** Bit width of a field within a pseudo_bit_t structure */
78
+#define BIT_WIDTH( _ptr, _field )					      \
79
+	sizeof ( ( ( PSEUDO_BIT_STRUCT_TYPE ( _ptr ) * ) NULL )->_field )
80
+
81
+/** Qword offset of a field within a pseudo_bit_t structure */
82
+#define QWORD_OFFSET( _ptr, _field )					      \
83
+	( BIT_OFFSET ( _ptr, _field ) / 64 )
84
+
85
+/** Qword bit offset of a field within a pseudo_bit_t structure */
86
+#define QWORD_BIT_OFFSET( _ptr, _index, _field )			      \
87
+	( BIT_OFFSET ( _ptr, _field ) - ( 64 * (_index) ) )
88
+
89
+/** Bit mask for a field within a pseudo_bit_t structure */
90
+#define BIT_MASK( _ptr, _field )					      \
91
+	( ( ~( ( uint64_t ) 0 ) ) >>					      \
92
+	  ( 64 - BIT_WIDTH ( _ptr, _field ) ) )
93
+
94
+/*
95
+ * Assemble native-endian qword from named fields and values
96
+ *
97
+ */
98
+
99
+#define BIT_ASSEMBLE_1( _ptr, _index, _field, _value )			      \
100
+	( ( ( uint64_t) (_value) ) <<					      \
101
+	  QWORD_BIT_OFFSET ( _ptr, _index, _field ) )
102
+
103
+#define BIT_ASSEMBLE_2( _ptr, _index, _field, _value, ... )		      \
104
+	( BIT_ASSEMBLE_1 ( _ptr, _index, _field, _value ) |		      \
105
+	  BIT_ASSEMBLE_1 ( _ptr, _index, __VA_ARGS__ ) )
106
+
107
+#define BIT_ASSEMBLE_3( _ptr, _index, _field, _value, ... )		      \
108
+	( BIT_ASSEMBLE_1 ( _ptr, _index, _field, _value ) |		      \
109
+	  BIT_ASSEMBLE_2 ( _ptr, _index, __VA_ARGS__ ) )
110
+
111
+#define BIT_ASSEMBLE_4( _ptr, _index, _field, _value, ... )		      \
112
+	( BIT_ASSEMBLE_1 ( _ptr, _index, _field, _value ) |		      \
113
+	  BIT_ASSEMBLE_3 ( _ptr, _index, __VA_ARGS__ ) )
114
+
115
+#define BIT_ASSEMBLE_5( _ptr, _index, _field, _value, ... )		      \
116
+	( BIT_ASSEMBLE_1 ( _ptr, _index, _field, _value ) |		      \
117
+	  BIT_ASSEMBLE_4 ( _ptr, _index, __VA_ARGS__ ) )
118
+
119
+#define BIT_ASSEMBLE_6( _ptr, _index, _field, _value, ... )		      \
120
+	( BIT_ASSEMBLE_1 ( _ptr, _index, _field, _value ) |		      \
121
+	  BIT_ASSEMBLE_5 ( _ptr, _index, __VA_ARGS__ ) )
122
+
123
+#define BIT_ASSEMBLE_7( _ptr, _index, _field, _value, ... )		      \
124
+	( BIT_ASSEMBLE_1 ( _ptr, _index, _field, _value ) |		      \
125
+	  BIT_ASSEMBLE_6 ( _ptr, _index, __VA_ARGS__ ) )
126
+
127
+/*
128
+ * Build native-endian (positive) qword bitmasks from named fields
129
+ *
130
+ */
131
+
132
+#define BIT_MASK_1( _ptr, _index, _field )				      \
133
+	( BIT_MASK ( _ptr, _field ) <<					      \
134
+	  QWORD_BIT_OFFSET ( _ptr, _index, _field ) )
135
+
136
+#define BIT_MASK_2( _ptr, _index, _field, ... )				      \
137
+	( BIT_MASK_1 ( _ptr, _index, _field ) |				      \
138
+	  BIT_MASK_1 ( _ptr, _index, __VA_ARGS__ ) )
139
+
140
+#define BIT_MASK_3( _ptr, _index, _field, ... )				      \
141
+	( BIT_MASK_1 ( _ptr, _index, _field ) |				      \
142
+	  BIT_MASK_2 ( _ptr, _index, __VA_ARGS__ ) )
143
+
144
+#define BIT_MASK_4( _ptr, _index, _field, ... )				      \
145
+	( BIT_MASK_1 ( _ptr, _index, _field ) |				      \
146
+	  BIT_MASK_3 ( _ptr, _index, __VA_ARGS__ ) )
147
+
148
+#define BIT_MASK_5( _ptr, _index, _field, ... )				      \
149
+	( BIT_MASK_1 ( _ptr, _index, _field ) |				      \
150
+	  BIT_MASK_4 ( _ptr, _index, __VA_ARGS__ ) )
151
+
152
+#define BIT_MASK_6( _ptr, _index, _field, ... )				      \
153
+	( BIT_MASK_1 ( _ptr, _index, _field ) |				      \
154
+	  BIT_MASK_5 ( _ptr, _index, __VA_ARGS__ ) )
155
+
156
+#define BIT_MASK_7( _ptr, _index, _field, ... )				      \
157
+	( BIT_MASK_1 ( _ptr, _index, _field ) |				      \
158
+	  BIT_MASK_6 ( _ptr, _index, __VA_ARGS__ ) )
159
+
160
+/*
161
+ * Populate little-endian qwords from named fields and values
162
+ *
163
+ */
164
+
165
+#define BIT_FILL( _ptr, _index, _assembled ) do {			      \
166
+		uint64_t *__ptr = &(_ptr)->u.qwords[(_index)];		      \
167
+		uint64_t __assembled = (_assembled);			      \
168
+		*__ptr = cpu_to_BIT64 ( __assembled );			      \
169
+	} while ( 0 )
170
+
171
+#define BIT_FILL_1( _ptr, _field1, ... )				      \
172
+	BIT_FILL ( _ptr, QWORD_OFFSET ( _ptr, _field1 ),		      \
173
+		   BIT_ASSEMBLE_1 ( _ptr, QWORD_OFFSET ( _ptr, _field1 ),     \
174
+				    _field1, __VA_ARGS__ ) )
175
+
176
+#define BIT_FILL_2( _ptr, _field1, ... )				      \
177
+	BIT_FILL ( _ptr, QWORD_OFFSET ( _ptr, _field1 ),		      \
178
+		   BIT_ASSEMBLE_2 ( _ptr, QWORD_OFFSET ( _ptr, _field1 ),     \
179
+				    _field1, __VA_ARGS__ ) )
180
+
181
+#define BIT_FILL_3( _ptr, _field1, ... )				      \
182
+	BIT_FILL ( _ptr, QWORD_OFFSET ( _ptr, _field1 ),		      \
183
+		   BIT_ASSEMBLE_3 ( _ptr, QWORD_OFFSET ( _ptr, _field1 ),     \
184
+				    _field1, __VA_ARGS__ ) )
185
+
186
+#define BIT_FILL_4( _ptr, _field1, ... )				      \
187
+	BIT_FILL ( _ptr, QWORD_OFFSET ( _ptr, _field1 ),		      \
188
+		   BIT_ASSEMBLE_4 ( _ptr, QWORD_OFFSET ( _ptr, _field1 ),     \
189
+				    _field1, __VA_ARGS__ ) )
190
+
191
+#define BIT_FILL_5( _ptr, _field1, ... )				      \
192
+	BIT_FILL ( _ptr, QWORD_OFFSET ( _ptr, _field1 ),		      \
193
+		   BIT_ASSEMBLE_5 ( _ptr, QWORD_OFFSET ( _ptr, _field1 ),     \
194
+				    _field1, __VA_ARGS__ ) )
195
+
196
+#define BIT_FILL_6( _ptr, _field1, ... )				      \
197
+	BIT_FILL ( _ptr, QWORD_OFFSET ( _ptr, _field1 ),		      \
198
+		   BIT_ASSEMBLE_6 ( _ptr, QWORD_OFFSET ( _ptr, _field1 ),     \
199
+				    _field1, __VA_ARGS__ ) )
200
+
201
+/** Extract value of named field */
202
+#define BIT_GET64( _ptr, _field )					      \
203
+	( {								      \
204
+		unsigned int __index = QWORD_OFFSET ( _ptr, _field );	      \
205
+		uint64_t *__ptr = &(_ptr)->u.qwords[__index];		      \
206
+		uint64_t __value = BIT64_to_cpu ( *__ptr );		      \
207
+		__value >>=						      \
208
+		    QWORD_BIT_OFFSET ( _ptr, __index, _field );		      \
209
+		__value &= BIT_MASK ( _ptr, _field );			      \
210
+		__value;						      \
211
+	} )
212
+
213
+/** Extract value of named field (for fields up to the size of a long) */
214
+#define BIT_GET( _ptr, _field )						      \
215
+	( ( unsigned long ) BIT_GET64 ( _ptr, _field ) )
216
+
217
+#define BIT_SET( _ptr, _field, _value ) do {				      \
218
+		unsigned int __index = QWORD_OFFSET ( _ptr, _field );	      \
219
+		uint64_t *__ptr = &(_ptr)->u.qwords[__index];		      \
220
+		unsigned int __shift =					      \
221
+			QWORD_BIT_OFFSET ( _ptr, __index, _field );	      \
222
+		uint64_t __value = (_value);				      \
223
+		*__ptr &= cpu_to_BIT64 ( ~( BIT_MASK ( _ptr, _field ) <<      \
224
+					    __shift ) );		      \
225
+		*__ptr |= cpu_to_BIT64 ( __value << __shift );		      \
226
+	} while ( 0 )
227
+
228
+#endif /* _GPXE_BITOPS_H */

+ 1
- 0
src/include/gpxe/errfile.h View File

111
 #define ERRFILE_scsi		     ( ERRFILE_DRIVER | 0x00700000 )
111
 #define ERRFILE_scsi		     ( ERRFILE_DRIVER | 0x00700000 )
112
 #define ERRFILE_arbel		     ( ERRFILE_DRIVER | 0x00710000 )
112
 #define ERRFILE_arbel		     ( ERRFILE_DRIVER | 0x00710000 )
113
 #define ERRFILE_hermon		     ( ERRFILE_DRIVER | 0x00720000 )
113
 #define ERRFILE_hermon		     ( ERRFILE_DRIVER | 0x00720000 )
114
+#define ERRFILE_linda		     ( ERRFILE_DRIVER | 0x00730000 )
114
 
115
 
115
 #define ERRFILE_aoe			( ERRFILE_NET | 0x00000000 )
116
 #define ERRFILE_aoe			( ERRFILE_NET | 0x00000000 )
116
 #define ERRFILE_arp			( ERRFILE_NET | 0x00010000 )
117
 #define ERRFILE_arp			( ERRFILE_NET | 0x00010000 )

+ 18
- 0
src/include/gpxe/iobuf.h View File

181
 	return ( iobuf->end - iobuf->tail );
181
 	return ( iobuf->end - iobuf->tail );
182
 }
182
 }
183
 
183
 
184
+/**
185
+ * Create a temporary I/O buffer
186
+ *
187
+ * @v iobuf	I/O buffer
188
+ * @v data	Data buffer
189
+ * @v len	Length of data
190
+ * @v max_len	Length of buffer
191
+ *
192
+ * It is sometimes useful to use the iob_xxx() methods on temporary
193
+ * data buffers.
194
+ */
195
+static inline void iob_populate ( struct io_buffer *iobuf,
196
+				  void *data, size_t len, size_t max_len ) {
197
+	iobuf->head = iobuf->data = data;
198
+	iobuf->tail = ( data + len );
199
+	iobuf->end = ( data + max_len );
200
+}
201
+
184
 extern struct io_buffer * __malloc alloc_iob ( size_t len );
202
 extern struct io_buffer * __malloc alloc_iob ( size_t len );
185
 extern void free_iob ( struct io_buffer *iobuf );
203
 extern void free_iob ( struct io_buffer *iobuf );
186
 extern void iob_pad ( struct io_buffer *iobuf, size_t min_len );
204
 extern void iob_pad ( struct io_buffer *iobuf, size_t min_len );

Loading…
Cancel
Save