2 * Copyright (C) 2010 Michael Brown <mbrown@fensystems.co.uk>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * You can also choose to distribute this program under the terms of
20 * the Unmodified Binary Distribution Licence (as given in the file
21 * COPYING.UBDL), provided that you have satisfied its requirements.
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL
);
30 #include <ipxe/fcels.h>
31 #include <ipxe/monojob.h>
32 #include <usr/fcmgmt.h>
36 * Fibre Channel management
41 * Print status of Fibre Channel port
43 * @v port Fibre Channel port
45 void fcportstat ( struct fc_port
*port
) {
46 printf ( "%s: %s id %s", port
->name
, fc_ntoa ( &port
->port_wwn
),
47 fc_id_ntoa ( &port
->port_id
) );
48 printf ( " node %s\n [Link:", fc_ntoa ( &port
->node_wwn
) );
49 if ( fc_link_ok ( &port
->link
) ) {
50 printf ( " up, %s", fc_ntoa ( &port
->link_port_wwn
) );
51 if ( ( port
->flags
& FC_PORT_HAS_FABRIC
) ) {
55 fc_id_ntoa ( &port
->ptp_link_port_id
) );
57 printf ( " node %s]\n", fc_ntoa ( &port
->link_node_wwn
) );
59 printf ( " down: %s]\n", strerror ( port
->link
.rc
) );
64 * Print status of Fibre Channel peer
66 * @v peer Fibre Channel peer
68 void fcpeerstat ( struct fc_peer
*peer
) {
73 printf ( "%s:\n [Link:", fc_ntoa ( &peer
->port_wwn
) );
74 if ( fc_link_ok ( &peer
->link
) ) {
75 printf ( " up, port %s id %s]\n", peer
->port
->name
,
76 fc_id_ntoa ( &peer
->port_id
) );
78 printf ( " down: %s]\n", strerror ( peer
->link
.rc
) );
81 list_for_each_entry ( ulp
, &peer
->ulps
, list
) {
82 printf ( " [Type %02x link:", ulp
->type
);
83 if ( fc_link_ok ( &ulp
->link
) ) {
84 printf ( " up, params" );
86 for ( i
= 0 ; i
< ulp
->param_len
; i
++ ) {
87 printf ( "%c%02x", ( ( i
== 0 ) ?
' ' : ':' ),
91 printf ( " down: %s", strerror ( ulp
->link
.rc
) );
98 * Issue Fibre Channel ELS
100 * @v port Fibre Channel port
101 * @v peer_port_id Peer port ID
102 * @v handler ELS handler
103 * @ret rc Return status code
105 int fcels ( struct fc_port
*port
, struct fc_port_id
*peer_port_id
,
106 struct fc_els_handler
*handler
) {
110 printf ( "%s %s to %s...",
111 port
->name
, handler
->name
, fc_id_ntoa ( peer_port_id
) );
112 if ( ( rc
= fc_els_request ( &monojob
, port
, peer_port_id
,
114 printf ( "%s\n", strerror ( rc
) );
118 /* Wait for ELS to complete */
119 return monojob_wait ( "", 0 );