iPXE
ib_srp.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 Fen Systems Ltd <mbrown@fensystems.co.uk>.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28  * OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 FILE_LICENCE ( BSD2 );
32 
33 #include <stdlib.h>
34 #include <errno.h>
35 #include <ipxe/interface.h>
36 #include <ipxe/uri.h>
37 #include <ipxe/open.h>
38 #include <ipxe/base16.h>
39 #include <ipxe/acpi.h>
40 #include <ipxe/srp.h>
41 #include <ipxe/infiniband.h>
42 #include <ipxe/ib_cmrc.h>
43 #include <ipxe/ib_srp.h>
44 
45 /**
46  * @file
47  *
48  * SCSI RDMA Protocol over Infiniband
49  *
50  */
51 
52 /* Disambiguate the various possible EINVALs */
53 #define EINVAL_BYTE_STRING_LEN __einfo_error ( EINFO_EINVAL_BYTE_STRING_LEN )
54 #define EINFO_EINVAL_BYTE_STRING_LEN __einfo_uniqify \
55  ( EINFO_EINVAL, 0x01, "Invalid byte string length" )
56 #define EINVAL_INTEGER __einfo_error ( EINFO_EINVAL_INTEGER )
57 #define EINFO_EINVAL_INTEGER __einfo_uniqify \
58  ( EINFO_EINVAL, 0x03, "Invalid integer" )
59 #define EINVAL_RP_TOO_SHORT __einfo_error ( EINFO_EINVAL_RP_TOO_SHORT )
60 #define EINFO_EINVAL_RP_TOO_SHORT __einfo_uniqify \
61  ( EINFO_EINVAL, 0x04, "Root path too short" )
62 
63 struct acpi_model ib_sbft_model __acpi_model;
64 
65 /******************************************************************************
66  *
67  * IB SRP devices
68  *
69  ******************************************************************************
70  */
71 
72 /**
73  * An IB SRP sBFT created by iPXE
74  */
75 struct ipxe_ib_sbft {
76  /** The table header */
77  struct sbft_table table;
78  /** The SCSI subtable */
80  /** The SRP subtable */
82  /** The Infiniband subtable */
84 };
85 
86 /** An Infiniband SRP device */
87 struct ib_srp_device {
88  /** Reference count */
89  struct refcnt refcnt;
90 
91  /** SRP transport interface */
92  struct interface srp;
93  /** CMRC interface */
94  struct interface cmrc;
95 
96  /** Infiniband device */
97  struct ib_device *ibdev;
98 
99  /** ACPI descriptor */
101  /** Boot firmware table parameters */
103 };
104 
105 /**
106  * Free IB SRP device
107  *
108  * @v refcnt Reference count
109  */
110 static void ib_srp_free ( struct refcnt *refcnt ) {
111  struct ib_srp_device *ib_srp =
113 
114  ibdev_put ( ib_srp->ibdev );
115  free ( ib_srp );
116 }
117 
118 /**
119  * Close IB SRP device
120  *
121  * @v ib_srp IB SRP device
122  * @v rc Reason for close
123  */
124 static void ib_srp_close ( struct ib_srp_device *ib_srp, int rc ) {
125 
126  /* Shut down interfaces */
127  intf_shutdown ( &ib_srp->cmrc, rc );
128  intf_shutdown ( &ib_srp->srp, rc );
129 }
130 
131 /**
132  * Get IB SRP ACPI descriptor
133  *
134  * @v ib_srp IB SRP device
135  * @ret desc ACPI descriptor
136  */
137 static struct acpi_descriptor *
138 ib_srp_describe ( struct ib_srp_device *ib_srp ) {
139 
140  return &ib_srp->desc;
141 }
142 
143 /** IB SRP CMRC interface operations */
146 };
147 
148 /** IB SRP CMRC interface descriptor */
150  INTF_DESC_PASSTHRU ( struct ib_srp_device, cmrc, ib_srp_cmrc_op, srp );
151 
152 /** IB SRP SRP interface operations */
156 };
157 
158 /** IB SRP SRP interface descriptor */
160  INTF_DESC_PASSTHRU ( struct ib_srp_device, srp, ib_srp_srp_op, cmrc );
161 
162 /**
163  * Open IB SRP device
164  *
165  * @v block Block control interface
166  * @v ibdev Infiniband device
167  * @v dgid Destination GID
168  * @v service_id Service ID
169  * @v initiator Initiator port ID
170  * @v target Target port ID
171  * @v lun SCSI LUN
172  * @ret rc Return status code
173  */
174 static int ib_srp_open ( struct interface *block, struct ib_device *ibdev,
175  union ib_gid *dgid, union ib_guid *service_id,
176  union srp_port_id *initiator,
177  union srp_port_id *target, struct scsi_lun *lun ) {
178  struct ib_srp_device *ib_srp;
179  struct ipxe_ib_sbft *sbft;
180  int rc;
181 
182  /* Allocate and initialise structure */
183  ib_srp = zalloc ( sizeof ( *ib_srp ) );
184  if ( ! ib_srp ) {
185  rc = -ENOMEM;
186  goto err_zalloc;
187  }
188  ref_init ( &ib_srp->refcnt, ib_srp_free );
189  intf_init ( &ib_srp->srp, &ib_srp_srp_desc, &ib_srp->refcnt );
190  intf_init ( &ib_srp->cmrc, &ib_srp_cmrc_desc, &ib_srp->refcnt );
191  ib_srp->ibdev = ibdev_get ( ibdev );
192  acpi_init ( &ib_srp->desc, &ib_sbft_model, &ib_srp->refcnt );
193  DBGC ( ib_srp, "IBSRP %p for " IB_GID_FMT " " IB_GUID_FMT "\n",
194  ib_srp, IB_GID_ARGS ( dgid ), IB_GUID_ARGS ( service_id ) );
195 
196  /* Preserve parameters required for boot firmware table */
197  sbft = &ib_srp->sbft;
198  memcpy ( &sbft->scsi.lun, lun, sizeof ( sbft->scsi.lun ) );
199  memcpy ( &sbft->srp.initiator, initiator,
200  sizeof ( sbft->srp.initiator ) );
201  memcpy ( &sbft->srp.target, target, sizeof ( sbft->srp.target ) );
202  memcpy ( &sbft->ib.dgid, dgid, sizeof ( sbft->ib.dgid ) );
203  memcpy ( &sbft->ib.service_id, service_id,
204  sizeof ( sbft->ib.service_id ) );
205 
206  /* Open CMRC socket */
207  if ( ( rc = ib_cmrc_open ( &ib_srp->cmrc, ibdev, dgid,
208  service_id, "SRP" ) ) != 0 ) {
209  DBGC ( ib_srp, "IBSRP %p could not open CMRC socket: %s\n",
210  ib_srp, strerror ( rc ) );
211  goto err_cmrc_open;
212  }
213 
214  /* Attach SRP device to parent interface */
215  if ( ( rc = srp_open ( block, &ib_srp->srp, initiator, target,
216  ibdev->rdma_key, lun ) ) != 0 ) {
217  DBGC ( ib_srp, "IBSRP %p could not create SRP device: %s\n",
218  ib_srp, strerror ( rc ) );
219  goto err_srp_open;
220  }
221 
222  /* Mortalise self and return */
223  ref_put ( &ib_srp->refcnt );
224  return 0;
225 
226  err_srp_open:
227  err_cmrc_open:
228  ib_srp_close ( ib_srp, rc );
229  ref_put ( &ib_srp->refcnt );
230  err_zalloc:
231  return rc;
232 }
233 
234 /******************************************************************************
235  *
236  * IB SRP URIs
237  *
238  ******************************************************************************
239  */
240 
241 /** IB SRP parse flags */
246 };
247 
248 /** IB SRP root path parameters */
250  /** Source GID */
251  union ib_gid sgid;
252  /** Initiator port ID */
254  /** Destination GID */
255  union ib_gid dgid;
256  /** Partition key */
258  /** Service ID */
260  /** SCSI LUN */
261  struct scsi_lun lun;
262  /** Target port ID */
264 };
265 
266 /**
267  * Parse IB SRP root path byte-string value
268  *
269  * @v rp_comp Root path component string
270  * @v default_value Default value to use if component string is empty
271  * @ret value Value
272  */
273 static int ib_srp_parse_byte_string ( const char *rp_comp, uint8_t *bytes,
274  unsigned int size_flags ) {
275  size_t size = ( size_flags & ~IB_SRP_PARSE_FLAG_MASK );
276  size_t rp_comp_len = strlen ( rp_comp );
277  int decoded_size;
278 
279  /* Allow optional components to be empty */
280  if ( ( rp_comp_len == 0 ) &&
281  ( size_flags & IB_SRP_PARSE_OPTIONAL ) )
282  return 0;
283 
284  /* Check string length */
285  if ( rp_comp_len != ( 2 * size ) )
286  return -EINVAL_BYTE_STRING_LEN;
287 
288  /* Parse byte string */
289  decoded_size = base16_decode ( rp_comp, bytes, size );
290  if ( decoded_size < 0 )
291  return decoded_size;
292 
293  return 0;
294 }
295 
296 /**
297  * Parse IB SRP root path integer value
298  *
299  * @v rp_comp Root path component string
300  * @v default_value Default value to use if component string is empty
301  * @ret value Value
302  */
303 static int ib_srp_parse_integer ( const char *rp_comp, int default_value ) {
304  int value;
305  char *end;
306 
307  value = strtoul ( rp_comp, &end, 16 );
308  if ( *end )
309  return -EINVAL_INTEGER;
310 
311  if ( end == rp_comp )
312  return default_value;
313 
314  return value;
315 }
316 
317 /**
318  * Parse IB SRP root path source GID
319  *
320  * @v rp_comp Root path component string
321  * @v rp IB SRP root path
322  * @ret rc Return status code
323  */
324 static int ib_srp_parse_sgid ( const char *rp_comp,
325  struct ib_srp_root_path *rp ) {
326  struct ib_device *ibdev;
327 
328  /* Default to the GID of the last opened Infiniband device */
329  if ( ( ibdev = last_opened_ibdev() ) != NULL )
330  memcpy ( &rp->sgid, &ibdev->gid, sizeof ( rp->sgid ) );
331 
332  return ib_srp_parse_byte_string ( rp_comp, rp->sgid.bytes,
333  ( sizeof ( rp->sgid ) |
335 }
336 
337 /**
338  * Parse IB SRP root path initiator identifier extension
339  *
340  * @v rp_comp Root path component string
341  * @v rp IB SRP root path
342  * @ret rc Return status code
343  */
344 static int ib_srp_parse_initiator_id_ext ( const char *rp_comp,
345  struct ib_srp_root_path *rp ) {
346  union ib_srp_initiator_port_id *port_id = &rp->initiator;
347 
348  return ib_srp_parse_byte_string ( rp_comp, port_id->ib.id_ext.bytes,
349  ( sizeof ( port_id->ib.id_ext ) |
351 }
352 
353 /**
354  * Parse IB SRP root path initiator HCA GUID
355  *
356  * @v rp_comp Root path component string
357  * @v rp IB SRP root path
358  * @ret rc Return status code
359  */
360 static int ib_srp_parse_initiator_hca_guid ( const char *rp_comp,
361  struct ib_srp_root_path *rp ) {
362  union ib_srp_initiator_port_id *port_id = &rp->initiator;
363 
364  /* Default to the GUID portion of the source GID */
365  memcpy ( &port_id->ib.hca_guid, &rp->sgid.s.guid,
366  sizeof ( port_id->ib.hca_guid ) );
367 
368  return ib_srp_parse_byte_string ( rp_comp, port_id->ib.hca_guid.bytes,
369  ( sizeof ( port_id->ib.hca_guid ) |
371 }
372 
373 /**
374  * Parse IB SRP root path destination GID
375  *
376  * @v rp_comp Root path component string
377  * @v rp IB SRP root path
378  * @ret rc Return status code
379  */
380 static int ib_srp_parse_dgid ( const char *rp_comp,
381  struct ib_srp_root_path *rp ) {
382  return ib_srp_parse_byte_string ( rp_comp, rp->dgid.bytes,
383  ( sizeof ( rp->dgid ) |
385 }
386 
387 /**
388  * Parse IB SRP root path partition key
389  *
390  * @v rp_comp Root path component string
391  * @v rp IB SRP root path
392  * @ret rc Return status code
393  */
394 static int ib_srp_parse_pkey ( const char *rp_comp,
395  struct ib_srp_root_path *rp ) {
396  int pkey;
397 
398  if ( ( pkey = ib_srp_parse_integer ( rp_comp, IB_PKEY_DEFAULT ) ) < 0 )
399  return pkey;
400  rp->pkey = pkey;
401  return 0;
402 }
403 
404 /**
405  * Parse IB SRP root path service ID
406  *
407  * @v rp_comp Root path component string
408  * @v rp IB SRP root path
409  * @ret rc Return status code
410  */
411 static int ib_srp_parse_service_id ( const char *rp_comp,
412  struct ib_srp_root_path *rp ) {
413  return ib_srp_parse_byte_string ( rp_comp, rp->service_id.bytes,
414  ( sizeof ( rp->service_id ) |
416 }
417 
418 /**
419  * Parse IB SRP root path LUN
420  *
421  * @v rp_comp Root path component string
422  * @v rp IB SRP root path
423  * @ret rc Return status code
424  */
425 static int ib_srp_parse_lun ( const char *rp_comp,
426  struct ib_srp_root_path *rp ) {
427  return scsi_parse_lun ( rp_comp, &rp->lun );
428 }
429 
430 /**
431  * Parse IB SRP root path target identifier extension
432  *
433  * @v rp_comp Root path component string
434  * @v rp IB SRP root path
435  * @ret rc Return status code
436  */
437 static int ib_srp_parse_target_id_ext ( const char *rp_comp,
438  struct ib_srp_root_path *rp ) {
439  union ib_srp_target_port_id *port_id = &rp->target;
440 
441  return ib_srp_parse_byte_string ( rp_comp, port_id->ib.id_ext.bytes,
442  ( sizeof ( port_id->ib.id_ext ) |
444 }
445 
446 /**
447  * Parse IB SRP root path target I/O controller GUID
448  *
449  * @v rp_comp Root path component string
450  * @v rp IB SRP root path
451  * @ret rc Return status code
452  */
453 static int ib_srp_parse_target_ioc_guid ( const char *rp_comp,
454  struct ib_srp_root_path *rp ) {
455  union ib_srp_target_port_id *port_id = &rp->target;
456 
457  return ib_srp_parse_byte_string ( rp_comp, port_id->ib.ioc_guid.bytes,
458  ( sizeof ( port_id->ib.ioc_guid ) |
460 }
461 
462 /** IB SRP root path component parser */
464  /**
465  * Parse IB SRP root path component
466  *
467  * @v rp_comp Root path component string
468  * @v rp IB SRP root path
469  * @ret rc Return status code
470  */
471  int ( * parse ) ( const char *rp_comp, struct ib_srp_root_path *rp );
472 };
473 
474 /** IB SRP root path components */
476  { ib_srp_parse_sgid },
479  { ib_srp_parse_dgid },
480  { ib_srp_parse_pkey },
482  { ib_srp_parse_lun },
485 };
486 
487 /** Number of IB SRP root path components */
488 #define IB_SRP_NUM_RP_COMPONENTS \
489  ( sizeof ( ib_srp_rp_parser ) / sizeof ( ib_srp_rp_parser[0] ) )
490 
491 /**
492  * Parse IB SRP root path
493  *
494  * @v rp_string Root path string
495  * @v rp IB SRP root path
496  * @ret rc Return status code
497  */
498 static int ib_srp_parse_root_path ( const char *rp_string,
499  struct ib_srp_root_path *rp ) {
500  struct ib_srp_root_path_parser *parser;
501  char *rp_comp[IB_SRP_NUM_RP_COMPONENTS];
502  char *rp_string_copy;
503  char *rp_string_tmp;
504  unsigned int i = 0;
505  int rc;
506 
507  /* Create modifiable copy of root path */
508  rp_string_copy = strdup ( rp_string );
509  if ( ! rp_string_copy ) {
510  rc = -ENOMEM;
511  goto err_strdup;
512  }
513  rp_string_tmp = rp_string_copy;
514 
515  /* Split root path into component parts */
516  while ( 1 ) {
517  rp_comp[i++] = rp_string_tmp;
518  if ( i == IB_SRP_NUM_RP_COMPONENTS )
519  break;
520  for ( ; *rp_string_tmp != ':' ; rp_string_tmp++ ) {
521  if ( ! *rp_string_tmp ) {
522  DBG ( "IBSRP root path \"%s\" too short\n",
523  rp_string );
525  goto err_split;
526  }
527  }
528  *(rp_string_tmp++) = '\0';
529  }
530 
531  /* Parse root path components */
532  for ( i = 0 ; i < IB_SRP_NUM_RP_COMPONENTS ; i++ ) {
533  parser = &ib_srp_rp_parser[i];
534  if ( ( rc = parser->parse ( rp_comp[i], rp ) ) != 0 ) {
535  DBG ( "IBSRP could not parse \"%s\" in root path "
536  "\"%s\": %s\n", rp_comp[i], rp_string,
537  strerror ( rc ) );
538  goto err_parse;
539  }
540  }
541 
542  err_parse:
543  err_split:
544  free ( rp_string_copy );
545  err_strdup:
546  return rc;
547 }
548 
549 /**
550  * Open IB SRP URI
551  *
552  * @v parent Parent interface
553  * @v uri URI
554  * @ret rc Return status code
555  */
556 static int ib_srp_open_uri ( struct interface *parent, struct uri *uri ) {
557  struct ib_srp_root_path rp;
558  struct ib_device *ibdev;
559  int rc;
560 
561  /* Parse URI */
562  if ( ! uri->opaque )
563  return -EINVAL;
564  memset ( &rp, 0, sizeof ( rp ) );
565  if ( ( rc = ib_srp_parse_root_path ( uri->opaque, &rp ) ) != 0 )
566  return rc;
567 
568  /* Identify Infiniband device */
569  ibdev = find_ibdev ( &rp.sgid );
570  if ( ! ibdev ) {
571  DBG ( "IBSRP could not identify Infiniband device\n" );
572  return -ENODEV;
573  }
574 
575  /* Open IB SRP device */
576  if ( ( rc = ib_srp_open ( parent, ibdev, &rp.dgid, &rp.service_id,
577  &rp.initiator.srp, &rp.target.srp,
578  &rp.lun ) ) != 0 )
579  return rc;
580 
581  return 0;
582 }
583 
584 /** IB SRP URI opener */
585 struct uri_opener ib_srp_uri_opener __uri_opener = {
586  .scheme = "ib_srp",
587  .open = ib_srp_open_uri,
588 };
589 
590 /******************************************************************************
591  *
592  * IB SRP boot firmware table (sBFT)
593  *
594  ******************************************************************************
595  */
596 
597 /**
598  * Check if IB SRP boot firmware table descriptor is complete
599  *
600  * @v desc ACPI descriptor
601  * @ret rc Return status code
602  */
603 static int ib_sbft_complete ( struct acpi_descriptor *desc __unused ) {
604  return 0;
605 }
606 
607 /**
608  * Install IB SRP boot firmware table(s)
609  *
610  * @v install Installation method
611  * @ret rc Return status code
612  */
613 static int ib_sbft_install ( int ( * install ) ( struct acpi_header *acpi ) ) {
614  struct ib_srp_device *ib_srp;
615  struct ipxe_ib_sbft *sbft;
616  struct ib_device *ibdev;
617  int rc;
618 
619  list_for_each_entry ( ib_srp, &ib_sbft_model.descs, desc.list ) {
620 
621  /* Complete table */
622  sbft = &ib_srp->sbft;
623  ibdev = ib_srp->ibdev;
625  sbft->table.acpi.length = cpu_to_le32 ( sizeof ( *sbft ) );
626  sbft->table.acpi.revision = 1;
627  sbft->table.scsi_offset =
628  cpu_to_le16 ( offsetof ( typeof ( *sbft ), scsi ) );
629  sbft->table.srp_offset =
630  cpu_to_le16 ( offsetof ( typeof ( *sbft ), srp ) );
631  sbft->table.ib_offset =
632  cpu_to_le16 ( offsetof ( typeof ( *sbft ), ib ) );
633  memcpy ( &sbft->ib.sgid, &ibdev->gid, sizeof ( sbft->ib.sgid ));
634  sbft->ib.pkey = cpu_to_le16 ( ibdev->pkey );
635 
636  /* Install table */
637  if ( ( rc = install ( &sbft->table.acpi ) ) != 0 ) {
638  DBGC ( ib_srp, "IBSRP %p could not install sBFT: %s\n",
639  ib_srp, strerror ( rc ) );
640  return rc;
641  }
642  }
643 
644  return 0;
645 }
646 
647 /** IB sBFT model */
648 struct acpi_model ib_sbft_model __acpi_model = {
649  .descs = LIST_HEAD_INIT ( ib_sbft_model.descs ),
650  .complete = ib_sbft_complete,
651  .install = ib_sbft_install,
652 };
static int ib_srp_open_uri(struct interface *parent, struct uri *uri)
Open IB SRP URI.
Definition: ib_srp.c:556
#define EINVAL
Invalid argument.
Definition: errno.h:428
An SRP port ID.
Definition: srp.h:36
An object interface operation.
Definition: interface.h:17
static int ib_srp_parse_dgid(const char *rp_comp, struct ib_srp_root_path *rp)
Parse IB SRP root path destination GID.
Definition: ib_srp.c:380
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
Infiniband protocol.
unsigned short uint16_t
Definition: stdint.h:11
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition: interface.c:244
union srp_port_id srp
SRP version of port identifier.
Definition: ib_srp.h:32
int ib_cmrc_open(struct interface *xfer, struct ib_device *ibdev, union ib_gid *dgid, union ib_guid *service_id, const char *name)
Open CMRC connection.
Definition: ib_cmrc.c:397
static struct ib_srp_root_path_parser ib_srp_rp_parser[]
IB SRP root path components.
Definition: ib_srp.c:475
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
Definition: interface.c:273
union ib_guid service_id
Service ID.
Definition: ib_srp.c:259
static int ib_srp_parse_initiator_hca_guid(const char *rp_comp, struct ib_srp_root_path *rp)
Parse IB SRP root path initiator HCA GUID.
Definition: ib_srp.c:360
int(* parse)(const char *rp_comp, struct ib_srp_root_path *rp)
Parse IB SRP root path component.
Definition: ib_srp.c:471
int srp_open(struct interface *block, struct interface *socket, union srp_port_id *initiator, union srp_port_id *target, uint32_t memory_handle, struct scsi_lun *lun)
Open SRP device.
Definition: srp.c:713
union ib_guid guid
Definition: ib_packet.h:40
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:439
struct ipxe_ib_sbft sbft
Boot firmware table parameters.
Definition: ib_srp.c:102
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
Definition: string.c:441
static int ib_srp_parse_initiator_id_ext(const char *rp_comp, struct ib_srp_root_path *rp)
Parse IB SRP root path initiator identifier extension.
Definition: ib_srp.c:344
uint32_t signature
ACPI signature (4 ASCII characters)
Definition: acpi.h:30
struct ib_device * last_opened_ibdev(void)
Get most recently opened Infiniband device.
Definition: infiniband.c:1043
union ib_srp_initiator_port_id initiator
Initiator port ID.
Definition: ib_srp.c:253
union srp_port_id initiator
Initiator port identifier.
Definition: srp.h:817
#define EINVAL_INTEGER
Definition: ib_srp.c:56
struct ib_srp_target_port_id::@538 ib
Infiniband version of port identifier.
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
Error codes.
struct list_head descs
List of descriptors.
Definition: acpi.h:171
struct ib_srp_initiator_port_id::@537 ib
Infiniband version of port identifier.
uint16_t block
Definition: tftp.h:12
struct interface cmrc
CMRC interface.
Definition: ib_srp.c:94
SRP target port identifier for Infiniband.
Definition: ib_srp.h:30
struct interface srp
SRP transport interface.
Definition: ib_srp.c:92
#define DBGC(...)
Definition: compiler.h:505
static int ib_srp_parse_sgid(const char *rp_comp, struct ib_srp_root_path *rp)
Parse IB SRP root path source GID.
Definition: ib_srp.c:324
static int ib_srp_parse_service_id(const char *rp_comp, struct ib_srp_root_path *rp)
Parse IB SRP root path service ID.
Definition: ib_srp.c:411
#define IB_GUID_ARGS(guid)
Infiniband Globally Unique Identifier debug message arguments.
Definition: ib_packet.h:29
union srp_port_id target
Target port identifier.
Definition: srp.h:819
IB SRP root path component parser.
Definition: ib_srp.c:463
#define IB_PKEY_DEFAULT
Default Infiniband partition key.
Definition: infiniband.h:39
sBFT Infiniband subtable
Definition: ib_srp.h:45
union ib_gid dgid
Destination GID.
Definition: ib_srp.h:49
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
Uniform Resource Identifiers.
static struct interface_descriptor ib_srp_srp_desc
IB SRP SRP interface descriptor.
Definition: ib_srp.c:159
sBFT SCSI subtable
Definition: srp.h:807
union srp_port_id srp
SRP version of port identifier.
Definition: ib_srp.h:19
static __always_inline struct ib_device * ibdev_get(struct ib_device *ibdev)
Get reference to Infiniband device.
Definition: infiniband.h:586
An Infiniband Global Identifier.
Definition: ib_packet.h:33
#define SBFT_SIG
SRP Boot Firmware Table signature.
Definition: srp.h:783
A reference counter.
Definition: refcnt.h:26
SCSI RDMA Protocol.
An Infiniband device.
Definition: infiniband.h:398
SRP Boot Firmware Table.
Definition: srp.h:791
static struct interface_operation ib_srp_srp_op[]
IB SRP SRP interface operations.
Definition: ib_srp.c:153
#define ENOMEM
Not enough space.
Definition: errno.h:534
struct refcnt refcnt
Reference count.
Definition: ib_srp.c:89
uint8_t bytes[16]
Definition: ib_packet.h:34
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define IB_GUID_FMT
Infiniband Globally Unique Identifier debug message format.
Definition: ib_packet.h:26
struct acpi_header acpi
ACPI header.
Definition: srp.h:793
static struct acpi_descriptor * ib_srp_describe(struct ib_srp_device *ib_srp)
Get IB SRP ACPI descriptor.
Definition: ib_srp.c:138
SRP initiator port identifier for Infiniband.
Definition: ib_srp.h:17
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
An object interface.
Definition: interface.h:109
struct sbft_table table
The table header.
Definition: ib_srp.c:77
int scsi_parse_lun(const char *lun_string, struct scsi_lun *lun)
Parse SCSI LUN.
Definition: scsi.c:117
An ACPI table model.
Definition: acpi.h:169
uint32_t length
Length of table, in bytes, including header.
Definition: acpi.h:32
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
Object interfaces.
static EFI_ACPI_TABLE_PROTOCOL * acpi
ACPI table protocol protocol.
Definition: efi_block.c:61
struct sbft_srp_subtable srp
The SRP subtable.
Definition: ib_srp.c:81
const char * scheme
URI protocol name.
Definition: open.h:53
static int ib_sbft_complete(struct acpi_descriptor *desc __unused)
Check if IB SRP boot firmware table descriptor is complete.
Definition: ib_srp.c:603
static int ib_srp_parse_root_path(const char *rp_string, struct ib_srp_root_path *rp)
Parse IB SRP root path.
Definition: ib_srp.c:498
sBFT SRP subtable
Definition: srp.h:815
An IB SRP sBFT created by iPXE.
Definition: ib_srp.c:75
union ib_gid sgid
Source GID.
Definition: ib_srp.h:47
FILE_LICENCE(BSD2)
uint8_t lun
Logical Unit Number.
Definition: edd.h:32
union ib_guid service_id
Service ID.
Definition: ib_srp.h:51
#define cpu_to_le32(value)
Definition: byteswap.h:107
IB SRP root path parameters.
Definition: ib_srp.c:249
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
#define IB_GID_ARGS(gid)
Infiniband Global Identifier debug message arguments.
Definition: ib_packet.h:48
uint32_t rdma_key
RDMA key.
Definition: infiniband.h:454
#define EINVAL_RP_TOO_SHORT
Definition: ib_srp.c:59
#define EINVAL_BYTE_STRING_LEN
Definition: ib_srp.c:53
An object interface descriptor.
Definition: interface.h:40
struct scsi_lun lun
SCSI LUN.
Definition: ib_srp.c:261
static __always_inline void ibdev_put(struct ib_device *ibdev)
Drop reference to Infiniband device.
Definition: infiniband.h:597
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
ACPI data structures.
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
#define IB_SRP_NUM_RP_COMPONENTS
Number of IB SRP root path components.
Definition: ib_srp.c:488
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
struct ib_device * find_ibdev(union ib_gid *gid)
Find Infiniband device by GID.
Definition: infiniband.c:1028
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
Definition: interface.h:32
An Infiniband Globally Unique Identifier.
Definition: ib_packet.h:18
char * strdup(const char *src)
Duplicate string.
Definition: string.c:350
#define ENODEV
No such device.
Definition: errno.h:509
size_t strlen(const char *src)
Get length of string.
Definition: string.c:213
unsigned char uint8_t
Definition: stdint.h:10
struct sbft_scsi_subtable scsi
The SCSI subtable.
Definition: ib_srp.c:79
Data transfer interface opening.
ib_srp_parse_flags
IB SRP parse flags.
Definition: ib_srp.c:242
struct scsi_lun lun
LUN.
Definition: srp.h:809
static int ib_srp_parse_target_ioc_guid(const char *rp_comp, struct ib_srp_root_path *rp)
Parse IB SRP root path target I/O controller GUID.
Definition: ib_srp.c:453
An ACPI description header.
Definition: acpi.h:28
An Infiniband SRP device.
Definition: ib_srp.c:87
struct acpi_descriptor * acpi_describe(struct interface *intf)
Get object's ACPI descriptor.
Definition: acpi.c:334
sbft_off_t ib_offset
Offset to IB subtable, if present.
Definition: srp.h:799
static void ib_srp_close(struct ib_srp_device *ib_srp, int rc)
Close IB SRP device.
Definition: ib_srp.c:124
union ib_guid ioc_guid
I/O controller GUID.
Definition: ib_srp.h:38
union ib_gid dgid
Definition: ib_mad.h:12
static int ib_srp_parse_target_id_ext(const char *rp_comp, struct ib_srp_root_path *rp)
Parse IB SRP root path target identifier extension.
Definition: ib_srp.c:437
union ib_gid dgid
Destination GID.
Definition: ib_srp.c:255
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
An ACPI descriptor (used to construct ACPI tables)
Definition: acpi.h:143
sbft_off_t scsi_offset
Offset to SCSI subtable.
Definition: srp.h:795
union ib_guid hca_guid
IB channel adapter GUID.
Definition: ib_srp.h:25
Infiniband Communication-managed Reliable Connections.
struct acpi_model ib_sbft_model __acpi_model
IB sBFT model.
Definition: ib_srp.c:63
uint16_t pkey
Partition key.
Definition: ib_srp.c:257
SCSI RDMA Protocol over Infiniband.
const char * opaque
Opaque part.
Definition: uri.h:56
struct ib_device * ibdev
Infiniband device.
Definition: ib_srp.c:97
union ib_gid sgid
Source GID.
Definition: ib_srp.c:251
static void ib_srp_free(struct refcnt *refcnt)
Free IB SRP device.
Definition: ib_srp.c:110
static int ib_srp_open(struct interface *block, struct ib_device *ibdev, union ib_gid *dgid, union ib_guid *service_id, union srp_port_id *initiator, union srp_port_id *target, struct scsi_lun *lun)
Open IB SRP device.
Definition: ib_srp.c:174
#define IB_GID_FMT
Infiniband Global Identifier debug message format.
Definition: ib_packet.h:45
#define cpu_to_le16(value)
Definition: byteswap.h:106
uint16_t pkey[32]
Partition key.
Definition: ib_mad.h:11
static int ib_srp_parse_integer(const char *rp_comp, int default_value)
Parse IB SRP root path integer value.
Definition: ib_srp.c:303
uint32_t end
Ending offset.
Definition: netvsc.h:18
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
struct sbft_ib_subtable ib
The Infiniband subtable.
Definition: ib_srp.c:83
static struct interface_descriptor ib_srp_cmrc_desc
IB SRP CMRC interface descriptor.
Definition: ib_srp.c:149
uint8_t bytes[8]
Definition: ib_packet.h:19
uint16_t pkey
Partition key.
Definition: infiniband.h:447
A Uniform Resource Identifier.
Definition: uri.h:50
#define INTF_DESC_PASSTHRU(object_type, intf, operations, passthru)
Define an object interface descriptor with pass-through interface.
Definition: interface.h:82
static struct interface_operation ib_srp_cmrc_op[]
IB SRP CMRC interface operations.
Definition: ib_srp.c:144
A SCSI LUN.
Definition: scsi.h:236
uint8_t revision
ACPI Specification minor version number.
Definition: acpi.h:34
static int ib_srp_parse_byte_string(const char *rp_comp, uint8_t *bytes, unsigned int size_flags)
Parse IB SRP root path byte-string value.
Definition: ib_srp.c:273
struct uri_opener ib_srp_uri_opener __uri_opener
IB SRP URI opener.
Definition: ib_srp.c:585
union ib_guid service_id
Service ID.
Definition: ib_mad.h:16
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static int ib_sbft_install(int(*install)(struct acpi_header *acpi))
Install IB SRP boot firmware table(s)
Definition: ib_srp.c:613
#define LIST_HEAD_INIT(list)
Initialise a static list head.
Definition: list.h:30
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition: interface.h:173
static int ib_srp_parse_lun(const char *rp_comp, struct ib_srp_root_path *rp)
Parse IB SRP root path LUN.
Definition: ib_srp.c:425
uint16_t pkey
Partition key.
Definition: ib_srp.h:53
A URI opener.
Definition: open.h:47
union ib_srp_target_port_id target
Target port ID.
Definition: ib_srp.c:263
uint8_t bytes[64]
Definition: ib_mad.h:16
union ib_guid id_ext
Identifier extension.
Definition: ib_srp.h:36
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
sbft_off_t srp_offset
Offset to SRP subtable.
Definition: srp.h:797
union ib_guid id_ext
Identifier extension.
Definition: ib_srp.h:23
static int ib_srp_parse_pkey(const char *rp_comp, struct ib_srp_root_path *rp)
Parse IB SRP root path partition key.
Definition: ib_srp.c:394
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106
static void acpi_init(struct acpi_descriptor *desc, struct acpi_model *model, struct refcnt *refcnt)
Initialise ACPI descriptor.
Definition: acpi.h:160
void * memset(void *dest, int character, size_t len) __nonnull
Base16 encoding.
struct ib_gid::@532 s
struct acpi_descriptor desc
ACPI descriptor.
Definition: ib_srp.c:100