iPXE
ib_srp.c File Reference

SCSI RDMA Protocol over Infiniband. More...

#include <stdlib.h>
#include <errno.h>
#include <ipxe/interface.h>
#include <ipxe/uri.h>
#include <ipxe/open.h>
#include <ipxe/base16.h>
#include <ipxe/acpi.h>
#include <ipxe/efi/efi_path.h>
#include <ipxe/srp.h>
#include <ipxe/infiniband.h>
#include <ipxe/ib_cmrc.h>
#include <ipxe/ib_srp.h>

Go to the source code of this file.

Data Structures

struct  ib_srp_root_path
 IB SRP root path parameters. More...
struct  ib_srp_root_path_parser
 IB SRP root path component parser. More...

Macros

#define EINVAL_BYTE_STRING_LEN   __einfo_error ( EINFO_EINVAL_BYTE_STRING_LEN )
#define EINFO_EINVAL_BYTE_STRING_LEN
#define EINVAL_INTEGER   __einfo_error ( EINFO_EINVAL_INTEGER )
#define EINFO_EINVAL_INTEGER
#define EINVAL_RP_TOO_SHORT   __einfo_error ( EINFO_EINVAL_RP_TOO_SHORT )
#define EINFO_EINVAL_RP_TOO_SHORT
#define IB_SRP_NUM_RP_COMPONENTS    ( sizeof ( ib_srp_rp_parser ) / sizeof ( ib_srp_rp_parser[0] ) )
 Number of IB SRP root path components.

Enumerations

enum  ib_srp_parse_flags { IB_SRP_PARSE_REQUIRED = 0x0000 , IB_SRP_PARSE_OPTIONAL = 0x8000 , IB_SRP_PARSE_FLAG_MASK = 0xf000 }
 IB SRP parse flags. More...

Functions

 FILE_LICENCE (BSD2)
static void ib_srp_free (struct refcnt *refcnt)
 Free IB SRP device.
static void ib_srp_close (struct ib_srp_device *ib_srp, int rc)
 Close IB SRP device.
static struct acpi_descriptorib_srp_describe (struct ib_srp_device *ib_srp)
 Get IB SRP ACPI descriptor.
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.
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.
static int ib_srp_parse_integer (const char *rp_comp, int default_value)
 Parse IB SRP root path integer value.
static int ib_srp_parse_sgid (const char *rp_comp, struct ib_srp_root_path *rp)
 Parse IB SRP root path source GID.
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.
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.
static int ib_srp_parse_dgid (const char *rp_comp, struct ib_srp_root_path *rp)
 Parse IB SRP root path destination GID.
static int ib_srp_parse_pkey (const char *rp_comp, struct ib_srp_root_path *rp)
 Parse IB SRP root path partition key.
static int ib_srp_parse_service_id (const char *rp_comp, struct ib_srp_root_path *rp)
 Parse IB SRP root path service ID.
static int ib_srp_parse_lun (const char *rp_comp, struct ib_srp_root_path *rp)
 Parse IB SRP root path LUN.
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.
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.
static int ib_srp_parse_root_path (const char *rp_string, struct ib_srp_root_path *rp)
 Parse IB SRP root path.
static int ib_srp_open_uri (struct interface *parent, struct uri *uri)
 Open IB SRP URI.
static int ib_sbft_complete (struct acpi_descriptor *desc __unused)
 Check if IB SRP boot firmware table descriptor is complete.
static int ib_sbft_install (int(*install)(struct acpi_header *acpi))
 Install IB SRP boot firmware table(s)

Variables

struct acpi_model ib_sbft_model __acpi_model
 IB sBFT model.
static struct interface_operation ib_srp_cmrc_op []
 IB SRP CMRC interface operations.
static struct interface_descriptor ib_srp_cmrc_desc
 IB SRP CMRC interface descriptor.
static struct interface_operation ib_srp_srp_op []
 IB SRP SRP interface operations.
static struct interface_descriptor ib_srp_srp_desc
 IB SRP SRP interface descriptor.
static struct ib_srp_root_path_parser ib_srp_rp_parser []
 IB SRP root path components.
struct uri_opener ib_srp_uri_opener __uri_opener
 IB SRP URI opener.

Detailed Description

SCSI RDMA Protocol over Infiniband.

Definition in file ib_srp.c.

Macro Definition Documentation

◆ EINVAL_BYTE_STRING_LEN

#define EINVAL_BYTE_STRING_LEN   __einfo_error ( EINFO_EINVAL_BYTE_STRING_LEN )

Definition at line 54 of file ib_srp.c.

Referenced by ib_srp_parse_byte_string().

◆ EINFO_EINVAL_BYTE_STRING_LEN

#define EINFO_EINVAL_BYTE_STRING_LEN
Value:
( EINFO_EINVAL, 0x01, "Invalid byte string length" )
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition errno.h:181
#define EINFO_EINVAL
Definition errno.h:430

Definition at line 55 of file ib_srp.c.

55#define EINFO_EINVAL_BYTE_STRING_LEN __einfo_uniqify \
56 ( EINFO_EINVAL, 0x01, "Invalid byte string length" )

◆ EINVAL_INTEGER

#define EINVAL_INTEGER   __einfo_error ( EINFO_EINVAL_INTEGER )

Definition at line 57 of file ib_srp.c.

◆ EINFO_EINVAL_INTEGER

#define EINFO_EINVAL_INTEGER
Value:
( EINFO_EINVAL, 0x03, "Invalid integer" )

Definition at line 58 of file ib_srp.c.

58#define EINFO_EINVAL_INTEGER __einfo_uniqify \
59 ( EINFO_EINVAL, 0x03, "Invalid integer" )

◆ EINVAL_RP_TOO_SHORT

#define EINVAL_RP_TOO_SHORT   __einfo_error ( EINFO_EINVAL_RP_TOO_SHORT )

Definition at line 60 of file ib_srp.c.

Referenced by ib_srp_parse_root_path().

◆ EINFO_EINVAL_RP_TOO_SHORT

#define EINFO_EINVAL_RP_TOO_SHORT
Value:
( EINFO_EINVAL, 0x04, "Root path too short" )

Definition at line 61 of file ib_srp.c.

61#define EINFO_EINVAL_RP_TOO_SHORT __einfo_uniqify \
62 ( EINFO_EINVAL, 0x04, "Root path too short" )

◆ IB_SRP_NUM_RP_COMPONENTS

#define IB_SRP_NUM_RP_COMPONENTS    ( sizeof ( ib_srp_rp_parser ) / sizeof ( ib_srp_rp_parser[0] ) )

Number of IB SRP root path components.

Definition at line 457 of file ib_srp.c.

457#define IB_SRP_NUM_RP_COMPONENTS \
458 ( sizeof ( ib_srp_rp_parser ) / sizeof ( ib_srp_rp_parser[0] ) )

Referenced by ib_srp_parse_root_path().

Enumeration Type Documentation

◆ ib_srp_parse_flags

IB SRP parse flags.

Enumerator
IB_SRP_PARSE_REQUIRED 
IB_SRP_PARSE_OPTIONAL 
IB_SRP_PARSE_FLAG_MASK 

Definition at line 211 of file ib_srp.c.

211 {
212 IB_SRP_PARSE_REQUIRED = 0x0000,
213 IB_SRP_PARSE_OPTIONAL = 0x8000,
214 IB_SRP_PARSE_FLAG_MASK = 0xf000,
215};
@ IB_SRP_PARSE_REQUIRED
Definition ib_srp.c:212
@ IB_SRP_PARSE_OPTIONAL
Definition ib_srp.c:213
@ IB_SRP_PARSE_FLAG_MASK
Definition ib_srp.c:214

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( BSD2 )

◆ ib_srp_free()

void ib_srp_free ( struct refcnt * refcnt)
static

Free IB SRP device.

Parameters
refcntReference count

Definition at line 78 of file ib_srp.c.

78 {
79 struct ib_srp_device *ib_srp =
81
82 ibdev_put ( ib_srp->ibdev );
83 free ( ib_srp );
84}
static __always_inline void ibdev_put(struct ib_device *ibdev)
Drop reference to Infiniband device.
Definition infiniband.h:599
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
#define container_of(ptr, type, field)
Get containing structure.
Definition stddef.h:36
An Infiniband SRP device.
Definition ib_srp.h:76
struct ib_device * ibdev
Infiniband device.
Definition ib_srp.h:86
A reference counter.
Definition refcnt.h:27

References container_of, free, ib_srp_device::ibdev, and ibdev_put().

Referenced by ib_srp_open().

◆ ib_srp_close()

void ib_srp_close ( struct ib_srp_device * ib_srp,
int rc )
static

Close IB SRP device.

Parameters
ib_srpIB SRP device
rcReason for close

Definition at line 92 of file ib_srp.c.

92 {
93
94 /* Shut down interfaces */
95 intf_shutdown ( &ib_srp->cmrc, rc );
96 intf_shutdown ( &ib_srp->srp, rc );
97}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
Definition interface.c:279
struct interface cmrc
CMRC interface.
Definition ib_srp.h:83
struct interface srp
SRP transport interface.
Definition ib_srp.h:81

References ib_srp_device::cmrc, intf_shutdown(), rc, and ib_srp_device::srp.

Referenced by ib_srp_open().

◆ ib_srp_describe()

struct acpi_descriptor * ib_srp_describe ( struct ib_srp_device * ib_srp)
static

Get IB SRP ACPI descriptor.

Parameters
ib_srpIB SRP device
Return values
descACPI descriptor

Definition at line 106 of file ib_srp.c.

106 {
107
108 return &ib_srp->desc;
109}
struct acpi_descriptor desc
ACPI descriptor.
Definition ib_srp.h:89

References ib_srp_device::desc.

◆ ib_srp_open()

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 )
static

Open IB SRP device.

Parameters
blockBlock control interface
ibdevInfiniband device
dgidDestination GID
service_idService ID
initiatorInitiator port ID
targetTarget port ID
lunSCSI LUN
Return values
rcReturn status code

Definition at line 143 of file ib_srp.c.

146 {
147 struct ib_srp_device *ib_srp;
148 struct ipxe_ib_sbft *sbft;
149 int rc;
150
151 /* Allocate and initialise structure */
152 ib_srp = zalloc ( sizeof ( *ib_srp ) );
153 if ( ! ib_srp ) {
154 rc = -ENOMEM;
155 goto err_zalloc;
156 }
157 ref_init ( &ib_srp->refcnt, ib_srp_free );
158 intf_init ( &ib_srp->srp, &ib_srp_srp_desc, &ib_srp->refcnt );
159 intf_init ( &ib_srp->cmrc, &ib_srp_cmrc_desc, &ib_srp->refcnt );
160 ib_srp->ibdev = ibdev_get ( ibdev );
161 acpi_init ( &ib_srp->desc, &ib_sbft_model, &ib_srp->refcnt );
162 DBGC ( ib_srp, "IBSRP %p for " IB_GID_FMT " " IB_GUID_FMT "\n",
163 ib_srp, IB_GID_ARGS ( dgid ), IB_GUID_ARGS ( service_id ) );
164
165 /* Preserve parameters required for boot firmware table */
166 sbft = &ib_srp->sbft;
167 memcpy ( &sbft->scsi.lun, lun, sizeof ( sbft->scsi.lun ) );
168 memcpy ( &sbft->srp.initiator, initiator,
169 sizeof ( sbft->srp.initiator ) );
170 memcpy ( &sbft->srp.target, target, sizeof ( sbft->srp.target ) );
171 memcpy ( &sbft->ib.dgid, dgid, sizeof ( sbft->ib.dgid ) );
172 memcpy ( &sbft->ib.service_id, service_id,
173 sizeof ( sbft->ib.service_id ) );
174
175 /* Open CMRC socket */
176 if ( ( rc = ib_cmrc_open ( &ib_srp->cmrc, ibdev, dgid,
177 service_id, "SRP" ) ) != 0 ) {
178 DBGC ( ib_srp, "IBSRP %p could not open CMRC socket: %s\n",
179 ib_srp, strerror ( rc ) );
180 goto err_cmrc_open;
181 }
182
183 /* Attach SRP device to parent interface */
184 if ( ( rc = srp_open ( block, &ib_srp->srp, initiator, target,
185 ibdev->rdma_key, lun ) ) != 0 ) {
186 DBGC ( ib_srp, "IBSRP %p could not create SRP device: %s\n",
187 ib_srp, strerror ( rc ) );
188 goto err_srp_open;
189 }
190
191 /* Mortalise self and return */
192 ref_put ( &ib_srp->refcnt );
193 return 0;
194
195 err_srp_open:
196 err_cmrc_open:
197 ib_srp_close ( ib_srp, rc );
198 ref_put ( &ib_srp->refcnt );
199 err_zalloc:
200 return rc;
201}
uint8_t lun
Logical Unit Number.
Definition edd.h:3
#define DBGC(...)
Definition compiler.h:505
#define ENOMEM
Not enough space.
Definition errno.h:535
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
union ib_gid dgid
Definition ib_mad.h:1
union ib_guid service_id
Service ID.
Definition ib_mad.h:5
#define IB_GID_ARGS(gid)
Infiniband Global Identifier debug message arguments.
Definition ib_packet.h:49
#define IB_GID_FMT
Infiniband Global Identifier debug message format.
Definition ib_packet.h:46
#define IB_GUID_FMT
Infiniband Globally Unique Identifier debug message format.
Definition ib_packet.h:27
#define IB_GUID_ARGS(guid)
Infiniband Globally Unique Identifier debug message arguments.
Definition ib_packet.h:30
static void ib_srp_close(struct ib_srp_device *ib_srp, int rc)
Close IB SRP device.
Definition ib_srp.c:92
static struct interface_descriptor ib_srp_cmrc_desc
IB SRP CMRC interface descriptor.
Definition ib_srp.c:117
static struct interface_descriptor ib_srp_srp_desc
IB SRP SRP interface descriptor.
Definition ib_srp.c:128
static void ib_srp_free(struct refcnt *refcnt)
Free IB SRP device.
Definition ib_srp.c:78
static void acpi_init(struct acpi_descriptor *desc, struct acpi_model *model, struct refcnt *refcnt)
Initialise ACPI descriptor.
Definition acpi.h:312
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static __always_inline struct ib_device * ibdev_get(struct ib_device *ibdev)
Get reference to Infiniband device.
Definition infiniband.h:588
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition interface.h:204
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662
uint8_t block[3][8]
DES-encrypted blocks.
Definition mschapv2.h:1
#define ref_put(refcnt)
Drop reference to object.
Definition refcnt.h:107
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition refcnt.h:65
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
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
uint32_t rdma_key
RDMA key.
Definition infiniband.h:457
struct refcnt refcnt
Reference count.
Definition ib_srp.h:78
struct ipxe_ib_sbft sbft
Boot firmware table parameters.
Definition ib_srp.h:91
An Infiniband SRP sBFT created by iPXE.
Definition ib_srp.h:64
struct sbft_srp_subtable srp
The SRP subtable.
Definition ib_srp.h:70
struct sbft_ib_subtable ib
The Infiniband subtable.
Definition ib_srp.h:72
struct sbft_scsi_subtable scsi
The SCSI subtable.
Definition ib_srp.h:68
union ib_guid service_id
Service ID.
Definition ib_srp.h:54
union ib_gid dgid
Destination GID.
Definition ib_srp.h:52
struct scsi_lun lun
LUN.
Definition srp.h:810
union srp_port_id initiator
Initiator port identifier.
Definition srp.h:818
union srp_port_id target
Target port identifier.
Definition srp.h:820

References acpi_init(), block, ib_srp_device::cmrc, DBGC, ib_srp_device::desc, dgid, sbft_ib_subtable::dgid, ENOMEM, ipxe_ib_sbft::ib, ib_cmrc_open(), IB_GID_ARGS, IB_GID_FMT, IB_GUID_ARGS, IB_GUID_FMT, ib_srp_close(), ib_srp_cmrc_desc, ib_srp_free(), ib_srp_srp_desc, ib_srp_device::ibdev, ibdev_get(), sbft_srp_subtable::initiator, intf_init(), lun, sbft_scsi_subtable::lun, memcpy(), rc, ib_device::rdma_key, ref_init, ref_put, ib_srp_device::refcnt, ib_srp_device::sbft, ipxe_ib_sbft::scsi, sbft_ib_subtable::service_id, service_id, ib_srp_device::srp, ipxe_ib_sbft::srp, srp_open(), strerror(), sbft_srp_subtable::target, and zalloc().

Referenced by ib_srp_open_uri().

◆ ib_srp_parse_byte_string()

int ib_srp_parse_byte_string ( const char * rp_comp,
uint8_t * bytes,
unsigned int size_flags )
static

Parse IB SRP root path byte-string value.

Parameters
rp_compRoot path component string
default_valueDefault value to use if component string is empty
Return values
valueValue

Definition at line 242 of file ib_srp.c.

243 {
244 size_t size = ( size_flags & ~IB_SRP_PARSE_FLAG_MASK );
245 size_t rp_comp_len = strlen ( rp_comp );
246 int decoded_size;
247
248 /* Allow optional components to be empty */
249 if ( ( rp_comp_len == 0 ) &&
250 ( size_flags & IB_SRP_PARSE_OPTIONAL ) )
251 return 0;
252
253 /* Check string length */
254 if ( rp_comp_len != ( 2 * size ) )
256
257 /* Parse byte string */
258 decoded_size = base16_decode ( rp_comp, bytes, size );
259 if ( decoded_size < 0 )
260 return decoded_size;
261
262 return 0;
263}
uint16_t size
Buffer size.
Definition dwmac.h:3
uint8_t bytes[64]
Definition ib_mad.h:5
#define EINVAL_BYTE_STRING_LEN
Definition ib_srp.c:54
size_t strlen(const char *src)
Get length of string.
Definition string.c:244

References bytes, EINVAL_BYTE_STRING_LEN, IB_SRP_PARSE_FLAG_MASK, IB_SRP_PARSE_OPTIONAL, size, and strlen().

Referenced by ib_srp_parse_dgid(), ib_srp_parse_initiator_hca_guid(), ib_srp_parse_initiator_id_ext(), ib_srp_parse_service_id(), ib_srp_parse_sgid(), ib_srp_parse_target_id_ext(), and ib_srp_parse_target_ioc_guid().

◆ ib_srp_parse_integer()

int ib_srp_parse_integer ( const char * rp_comp,
int default_value )
static

Parse IB SRP root path integer value.

Parameters
rp_compRoot path component string
default_valueDefault value to use if component string is empty
Return values
valueValue

Definition at line 272 of file ib_srp.c.

272 {
273 int value;
274 char *end;
275
276 value = strtoul ( rp_comp, &end, 16 );
277 if ( *end )
278 return -EINVAL_INTEGER;
279
280 if ( end == rp_comp )
281 return default_value;
282
283 return value;
284}
pseudo_bit_t value[0x00020]
Definition arbel.h:2
uint32_t end
Ending offset.
Definition netvsc.h:7
#define EINVAL_INTEGER
Definition parseopt.c:57
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
Definition string.c:485

References EINVAL_INTEGER, end, strtoul(), and value.

Referenced by ib_srp_parse_pkey().

◆ ib_srp_parse_sgid()

int ib_srp_parse_sgid ( const char * rp_comp,
struct ib_srp_root_path * rp )
static

Parse IB SRP root path source GID.

Parameters
rp_compRoot path component string
rpIB SRP root path
Return values
rcReturn status code

Definition at line 293 of file ib_srp.c.

294 {
295 struct ib_device *ibdev;
296
297 /* Default to the GID of the last opened Infiniband device */
298 if ( ( ibdev = last_opened_ibdev() ) != NULL )
299 memcpy ( &rp->sgid, &ibdev->gid, sizeof ( rp->sgid ) );
300
301 return ib_srp_parse_byte_string ( rp_comp, rp->sgid.bytes,
302 ( sizeof ( rp->sgid ) |
304}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
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:242
struct ib_device * last_opened_ibdev(void)
Get most recently opened Infiniband device.
An Infiniband device.
Definition infiniband.h:399
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition infiniband.h:442
union ib_gid sgid
Source GID.
Definition ib_srp.c:220
uint8_t bytes[16]
Definition ib_packet.h:35

References ib_gid::bytes, ib_device::gid, ib_srp_parse_byte_string(), IB_SRP_PARSE_OPTIONAL, last_opened_ibdev(), memcpy(), NULL, and ib_srp_root_path::sgid.

◆ ib_srp_parse_initiator_id_ext()

int ib_srp_parse_initiator_id_ext ( const char * rp_comp,
struct ib_srp_root_path * rp )
static

Parse IB SRP root path initiator identifier extension.

Parameters
rp_compRoot path component string
rpIB SRP root path
Return values
rcReturn status code

Definition at line 313 of file ib_srp.c.

314 {
315 union ib_srp_initiator_port_id *port_id = &rp->initiator;
316
317 return ib_srp_parse_byte_string ( rp_comp, port_id->ib.id_ext.bytes,
318 ( sizeof ( port_id->ib.id_ext ) |
320}
union ib_srp_initiator_port_id initiator
Initiator port ID.
Definition ib_srp.c:222
uint8_t bytes[8]
Definition ib_packet.h:20
SRP initiator port identifier for Infiniband.
Definition ib_srp.h:20
struct ib_srp_initiator_port_id::@154343277104075276025160007054207111074167164107 ib
Infiniband version of port identifier.
union ib_guid id_ext
Identifier extension.
Definition ib_srp.h:26

References ib_guid::bytes, ib_srp_initiator_port_id::ib, ib_srp_parse_byte_string(), IB_SRP_PARSE_OPTIONAL, ib_srp_initiator_port_id::id_ext, and ib_srp_root_path::initiator.

◆ ib_srp_parse_initiator_hca_guid()

int ib_srp_parse_initiator_hca_guid ( const char * rp_comp,
struct ib_srp_root_path * rp )
static

Parse IB SRP root path initiator HCA GUID.

Parameters
rp_compRoot path component string
rpIB SRP root path
Return values
rcReturn status code

Definition at line 329 of file ib_srp.c.

330 {
331 union ib_srp_initiator_port_id *port_id = &rp->initiator;
332
333 /* Default to the GUID portion of the source GID */
334 memcpy ( &port_id->ib.hca_guid, &rp->sgid.s.guid,
335 sizeof ( port_id->ib.hca_guid ) );
336
337 return ib_srp_parse_byte_string ( rp_comp, port_id->ib.hca_guid.bytes,
338 ( sizeof ( port_id->ib.hca_guid ) |
340}
struct ib_gid::@251011351113275240012301235177256303262052134237 s
union ib_guid guid
Definition ib_packet.h:41
union ib_guid hca_guid
IB channel adapter GUID.
Definition ib_srp.h:28

References ib_guid::bytes, ib_gid::guid, ib_srp_initiator_port_id::hca_guid, ib_srp_initiator_port_id::ib, ib_srp_parse_byte_string(), IB_SRP_PARSE_OPTIONAL, ib_srp_root_path::initiator, memcpy(), ib_gid::s, and ib_srp_root_path::sgid.

◆ ib_srp_parse_dgid()

int ib_srp_parse_dgid ( const char * rp_comp,
struct ib_srp_root_path * rp )
static

Parse IB SRP root path destination GID.

Parameters
rp_compRoot path component string
rpIB SRP root path
Return values
rcReturn status code

Definition at line 349 of file ib_srp.c.

350 {
351 return ib_srp_parse_byte_string ( rp_comp, rp->dgid.bytes,
352 ( sizeof ( rp->dgid ) |
354}
union ib_gid dgid
Destination GID.
Definition ib_srp.c:224

References ib_gid::bytes, ib_srp_root_path::dgid, ib_srp_parse_byte_string(), and IB_SRP_PARSE_REQUIRED.

◆ ib_srp_parse_pkey()

int ib_srp_parse_pkey ( const char * rp_comp,
struct ib_srp_root_path * rp )
static

Parse IB SRP root path partition key.

Parameters
rp_compRoot path component string
rpIB SRP root path
Return values
rcReturn status code

Definition at line 363 of file ib_srp.c.

364 {
365 int pkey;
366
367 if ( ( pkey = ib_srp_parse_integer ( rp_comp, IB_PKEY_DEFAULT ) ) < 0 )
368 return pkey;
369 rp->pkey = pkey;
370 return 0;
371}
uint16_t pkey[32]
Partition key.
Definition ib_mad.h:0
static int ib_srp_parse_integer(const char *rp_comp, int default_value)
Parse IB SRP root path integer value.
Definition ib_srp.c:272
#define IB_PKEY_DEFAULT
Default Infiniband partition key.
Definition infiniband.h:40
uint16_t pkey
Partition key.
Definition ib_srp.c:226

References IB_PKEY_DEFAULT, ib_srp_parse_integer(), ib_srp_root_path::pkey, and pkey.

◆ ib_srp_parse_service_id()

int ib_srp_parse_service_id ( const char * rp_comp,
struct ib_srp_root_path * rp )
static

Parse IB SRP root path service ID.

Parameters
rp_compRoot path component string
rpIB SRP root path
Return values
rcReturn status code

Definition at line 380 of file ib_srp.c.

381 {
382 return ib_srp_parse_byte_string ( rp_comp, rp->service_id.bytes,
383 ( sizeof ( rp->service_id ) |
385}
union ib_guid service_id
Service ID.
Definition ib_srp.c:228

References ib_guid::bytes, ib_srp_parse_byte_string(), IB_SRP_PARSE_REQUIRED, and ib_srp_root_path::service_id.

◆ ib_srp_parse_lun()

int ib_srp_parse_lun ( const char * rp_comp,
struct ib_srp_root_path * rp )
static

Parse IB SRP root path LUN.

Parameters
rp_compRoot path component string
rpIB SRP root path
Return values
rcReturn status code

Definition at line 394 of file ib_srp.c.

395 {
396 return scsi_parse_lun ( rp_comp, &rp->lun );
397}
int scsi_parse_lun(const char *lun_string, struct scsi_lun *lun)
Parse SCSI LUN.
Definition scsi.c:118
struct scsi_lun lun
SCSI LUN.
Definition ib_srp.c:230

References ib_srp_root_path::lun, and scsi_parse_lun().

◆ ib_srp_parse_target_id_ext()

int ib_srp_parse_target_id_ext ( const char * rp_comp,
struct ib_srp_root_path * rp )
static

Parse IB SRP root path target identifier extension.

Parameters
rp_compRoot path component string
rpIB SRP root path
Return values
rcReturn status code

Definition at line 406 of file ib_srp.c.

407 {
408 union ib_srp_target_port_id *port_id = &rp->target;
409
410 return ib_srp_parse_byte_string ( rp_comp, port_id->ib.id_ext.bytes,
411 ( sizeof ( port_id->ib.id_ext ) |
413}
union ib_srp_target_port_id target
Target port ID.
Definition ib_srp.c:232
SRP target port identifier for Infiniband.
Definition ib_srp.h:33
union ib_guid id_ext
Identifier extension.
Definition ib_srp.h:39
struct ib_srp_target_port_id::@376146030212244076235315256321366362014223144055 ib
Infiniband version of port identifier.

References ib_guid::bytes, ib_srp_target_port_id::ib, ib_srp_parse_byte_string(), IB_SRP_PARSE_REQUIRED, ib_srp_target_port_id::id_ext, and ib_srp_root_path::target.

◆ ib_srp_parse_target_ioc_guid()

int ib_srp_parse_target_ioc_guid ( const char * rp_comp,
struct ib_srp_root_path * rp )
static

Parse IB SRP root path target I/O controller GUID.

Parameters
rp_compRoot path component string
rpIB SRP root path
Return values
rcReturn status code

Definition at line 422 of file ib_srp.c.

423 {
424 union ib_srp_target_port_id *port_id = &rp->target;
425
426 return ib_srp_parse_byte_string ( rp_comp, port_id->ib.ioc_guid.bytes,
427 ( sizeof ( port_id->ib.ioc_guid ) |
429}
union ib_guid ioc_guid
I/O controller GUID.
Definition ib_srp.h:41

References ib_guid::bytes, ib_srp_target_port_id::ib, ib_srp_parse_byte_string(), IB_SRP_PARSE_REQUIRED, ib_srp_target_port_id::ioc_guid, and ib_srp_root_path::target.

◆ ib_srp_parse_root_path()

int ib_srp_parse_root_path ( const char * rp_string,
struct ib_srp_root_path * rp )
static

Parse IB SRP root path.

Parameters
rp_stringRoot path string
rpIB SRP root path
Return values
rcReturn status code

Definition at line 467 of file ib_srp.c.

468 {
469 struct ib_srp_root_path_parser *parser;
470 char *rp_comp[IB_SRP_NUM_RP_COMPONENTS];
471 char *rp_string_copy;
472 char *rp_string_tmp;
473 unsigned int i = 0;
474 int rc;
475
476 /* Create modifiable copy of root path */
477 rp_string_copy = strdup ( rp_string );
478 if ( ! rp_string_copy ) {
479 rc = -ENOMEM;
480 goto err_strdup;
481 }
482 rp_string_tmp = rp_string_copy;
483
484 /* Split root path into component parts */
485 while ( 1 ) {
486 rp_comp[i++] = rp_string_tmp;
487 if ( i == IB_SRP_NUM_RP_COMPONENTS )
488 break;
489 for ( ; *rp_string_tmp != ':' ; rp_string_tmp++ ) {
490 if ( ! *rp_string_tmp ) {
491 DBG ( "IBSRP root path \"%s\" too short\n",
492 rp_string );
494 goto err_split;
495 }
496 }
497 *(rp_string_tmp++) = '\0';
498 }
499
500 /* Parse root path components */
501 for ( i = 0 ; i < IB_SRP_NUM_RP_COMPONENTS ; i++ ) {
502 parser = &ib_srp_rp_parser[i];
503 if ( ( rc = parser->parse ( rp_comp[i], rp ) ) != 0 ) {
504 DBG ( "IBSRP could not parse \"%s\" in root path "
505 "\"%s\": %s\n", rp_comp[i], rp_string,
506 strerror ( rc ) );
507 goto err_parse;
508 }
509 }
510
511 err_parse:
512 err_split:
513 free ( rp_string_copy );
514 err_strdup:
515 return rc;
516}
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
static struct ib_srp_root_path_parser ib_srp_rp_parser[]
IB SRP root path components.
Definition ib_srp.c:444
#define IB_SRP_NUM_RP_COMPONENTS
Number of IB SRP root path components.
Definition ib_srp.c:457
#define EINVAL_RP_TOO_SHORT
Definition ib_srp.c:60
char * strdup(const char *src)
Duplicate string.
Definition string.c:394
IB SRP root path component parser.
Definition ib_srp.c:432
int(* parse)(const char *rp_comp, struct ib_srp_root_path *rp)
Parse IB SRP root path component.
Definition ib_srp.c:440

References DBG, EINVAL_RP_TOO_SHORT, ENOMEM, free, IB_SRP_NUM_RP_COMPONENTS, ib_srp_rp_parser, ib_srp_root_path_parser::parse, rc, strdup(), and strerror().

Referenced by ib_srp_open_uri().

◆ ib_srp_open_uri()

int ib_srp_open_uri ( struct interface * parent,
struct uri * uri )
static

Open IB SRP URI.

Parameters
parentParent interface
uriURI
Return values
rcReturn status code

Definition at line 525 of file ib_srp.c.

525 {
526 struct ib_srp_root_path rp;
527 struct ib_device *ibdev;
528 int rc;
529
530 /* Parse URI */
531 if ( ! uri->opaque )
532 return -EINVAL;
533 memset ( &rp, 0, sizeof ( rp ) );
534 if ( ( rc = ib_srp_parse_root_path ( uri->opaque, &rp ) ) != 0 )
535 return rc;
536
537 /* Identify Infiniband device */
538 ibdev = find_ibdev ( &rp.sgid );
539 if ( ! ibdev ) {
540 DBG ( "IBSRP could not identify Infiniband device\n" );
541 return -ENODEV;
542 }
543
544 /* Open IB SRP device */
545 if ( ( rc = ib_srp_open ( parent, ibdev, &rp.dgid, &rp.service_id,
546 &rp.initiator.srp, &rp.target.srp,
547 &rp.lun ) ) != 0 )
548 return rc;
549
550 return 0;
551}
#define EINVAL
Invalid argument.
Definition errno.h:429
#define ENODEV
No such device.
Definition errno.h:510
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:143
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:467
void * memset(void *dest, int character, size_t len) __nonnull
struct ib_device * find_ibdev(union ib_gid *gid)
Find Infiniband device by GID.
IB SRP root path parameters.
Definition ib_srp.c:218
A Uniform Resource Identifier.
Definition uri.h:65
const char * opaque
Opaque part.
Definition uri.h:71

References DBG, ib_srp_root_path::dgid, EINVAL, ENODEV, find_ibdev(), ib_srp_open(), ib_srp_parse_root_path(), ib_srp_root_path::initiator, ib_srp_root_path::lun, memset(), uri::opaque, rc, ib_srp_root_path::service_id, ib_srp_root_path::sgid, ib_srp_initiator_port_id::srp, ib_srp_target_port_id::srp, and ib_srp_root_path::target.

◆ ib_sbft_complete()

int ib_sbft_complete ( struct acpi_descriptor *desc __unused)
static

Check if IB SRP boot firmware table descriptor is complete.

Parameters
descACPI descriptor
Return values
rcReturn status code

Definition at line 572 of file ib_srp.c.

572 {
573 return 0;
574}

References __unused, and desc.

◆ ib_sbft_install()

int ib_sbft_install ( int(* install )(struct acpi_header *acpi))
static

Install IB SRP boot firmware table(s)

Parameters
installInstallation method
Return values
rcReturn status code

Definition at line 582 of file ib_srp.c.

582 {
583 struct ib_srp_device *ib_srp;
584 struct ipxe_ib_sbft *sbft;
585 struct ib_device *ibdev;
586 int rc;
587
588 list_for_each_entry ( ib_srp, &ib_sbft_model.descs, desc.list ) {
589
590 /* Complete table */
591 sbft = &ib_srp->sbft;
592 ibdev = ib_srp->ibdev;
594 sbft->table.acpi.length = cpu_to_le32 ( sizeof ( *sbft ) );
595 sbft->table.acpi.revision = 1;
596 sbft->table.scsi_offset =
597 cpu_to_le16 ( offsetof ( typeof ( *sbft ), scsi ) );
598 sbft->table.srp_offset =
599 cpu_to_le16 ( offsetof ( typeof ( *sbft ), srp ) );
600 sbft->table.ib_offset =
601 cpu_to_le16 ( offsetof ( typeof ( *sbft ), ib ) );
602 memcpy ( &sbft->ib.sgid, &ibdev->gid, sizeof ( sbft->ib.sgid ));
603 sbft->ib.pkey = cpu_to_le16 ( ibdev->pkey );
604
605 /* Install table */
606 if ( ( rc = install ( &sbft->table.acpi ) ) != 0 ) {
607 DBGC ( ib_srp, "IBSRP %p could not install sBFT: %s\n",
608 ib_srp, strerror ( rc ) );
609 return rc;
610 }
611 }
612
613 return 0;
614}
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition acpi.c:48
struct ena_llq_option desc
Descriptor counts.
Definition ena.h:9
#define cpu_to_le32(value)
Definition byteswap.h:108
#define cpu_to_le16(value)
Definition byteswap.h:107
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition list.h:432
#define SBFT_SIG
SRP Boot Firmware Table signature.
Definition srp.h:784
#define offsetof(type, field)
Get offset of a field within a structure.
Definition stddef.h:25
uint32_t signature
ACPI signature (4 ASCII characters)
Definition acpi.h:182
uint32_t length
Length of table, in bytes, including header.
Definition acpi.h:184
uint8_t revision
ACPI Specification minor version number.
Definition acpi.h:186
uint16_t pkey
Partition key.
Definition infiniband.h:450
struct sbft_table table
The table header.
Definition ib_srp.h:66
uint16_t pkey
Partition key.
Definition ib_srp.h:56
union ib_gid sgid
Source GID.
Definition ib_srp.h:50
sbft_off_t srp_offset
Offset to SRP subtable.
Definition srp.h:798
sbft_off_t ib_offset
Offset to IB subtable, if present.
Definition srp.h:800
sbft_off_t scsi_offset
Offset to SCSI subtable.
Definition srp.h:796
struct acpi_header acpi
ACPI header.
Definition srp.h:794

References acpi, sbft_table::acpi, cpu_to_le16, cpu_to_le32, DBGC, desc, ib_device::gid, ipxe_ib_sbft::ib, sbft_table::ib_offset, ib_srp_device::ibdev, acpi_header::length, list_for_each_entry, memcpy(), offsetof, ib_device::pkey, sbft_ib_subtable::pkey, rc, acpi_header::revision, ib_srp_device::sbft, SBFT_SIG, sbft_table::scsi_offset, sbft_ib_subtable::sgid, acpi_header::signature, sbft_table::srp_offset, strerror(), ipxe_ib_sbft::table, and typeof().

Variable Documentation

◆ __acpi_model

struct acpi_model ib_sbft_model __acpi_model
Initial value:
= {
.descs = LIST_HEAD_INIT ( ib_sbft_model.descs ),
.complete = ib_sbft_complete,
.install = ib_sbft_install,
}
static int ib_sbft_complete(struct acpi_descriptor *desc __unused)
Check if IB SRP boot firmware table descriptor is complete.
Definition ib_srp.c:572
static int ib_sbft_install(int(*install)(struct acpi_header *acpi))
Install IB SRP boot firmware table(s)
Definition ib_srp.c:582
#define LIST_HEAD_INIT(list)
Initialise a static list head.
Definition list.h:31

IB sBFT model.

aBFT model

Definition at line 64 of file ib_srp.c.

◆ ib_srp_cmrc_op

struct interface_operation ib_srp_cmrc_op[]
static
Initial value:
= {
}
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition interface.c:250
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
Definition interface.h:33

IB SRP CMRC interface operations.

Definition at line 112 of file ib_srp.c.

112 {
114};

◆ ib_srp_cmrc_desc

struct interface_descriptor ib_srp_cmrc_desc
static
Initial value:
=
static struct interface_operation ib_srp_cmrc_op[]
IB SRP CMRC interface operations.
Definition ib_srp.c:112
#define INTF_DESC_PASSTHRU(object_type, intf, operations, passthru)
Define an object interface descriptor with pass-through interface.
Definition interface.h:98

IB SRP CMRC interface descriptor.

Definition at line 117 of file ib_srp.c.

Referenced by ib_srp_open().

◆ ib_srp_srp_op

struct interface_operation ib_srp_srp_op[]
static
Initial value:
= {
}
struct acpi_descriptor * acpi_describe(struct interface *intf)
Get object's ACPI descriptor.
Definition acpi.c:321
EFI_DEVICE_PATH_PROTOCOL * efi_describe(struct interface *intf)
Describe object as an EFI device path.
Definition efi_path.c:920
EFI_DEVICE_PATH_PROTOCOL * efi_ib_srp_path(struct ib_srp_device *ib_srp)
Construct EFI device path for Infiniband SRP device.
Definition efi_path.c:644
static struct acpi_descriptor * ib_srp_describe(struct ib_srp_device *ib_srp)
Get IB SRP ACPI descriptor.
Definition ib_srp.c:106
#define EFI_INTF_OP
Definition efi.h:374

IB SRP SRP interface operations.

Definition at line 121 of file ib_srp.c.

◆ ib_srp_srp_desc

struct interface_descriptor ib_srp_srp_desc
static
Initial value:
=
static struct interface_operation ib_srp_srp_op[]
IB SRP SRP interface operations.
Definition ib_srp.c:121

IB SRP SRP interface descriptor.

Definition at line 128 of file ib_srp.c.

Referenced by ib_srp_open().

◆ ib_srp_rp_parser

struct ib_srp_root_path_parser ib_srp_rp_parser[]
static
Initial value:
= {
}
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:406
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:394
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:313
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:329
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:422
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:349
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:380
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:363
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:293

IB SRP root path components.

Definition at line 444 of file ib_srp.c.

Referenced by ib_srp_parse_root_path().

◆ __uri_opener

struct uri_opener ib_srp_uri_opener __uri_opener
Initial value:
= {
.scheme = "ib_srp",
.open = ib_srp_open_uri,
}
static int ib_srp_open_uri(struct interface *parent, struct uri *uri)
Open IB SRP URI.
Definition ib_srp.c:525

IB SRP URI opener.

Definition at line 554 of file ib_srp.c.

554 {
555 .scheme = "ib_srp",
556 .open = ib_srp_open_uri,
557};