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
20 FILE_LICENCE ( GPL2_OR_LATER );
26 #include <ipxe/fcels.h>
27 #include <ipxe/monojob.h>
28 #include <usr/fcmgmt.h>
32 * Fibre Channel management
37 * Print status of Fibre Channel port
39 * @v port Fibre Channel port
41 void fcportstat ( struct fc_port *port ) {
42 printf ( "%s: %s id %s", port->name, fc_ntoa ( &port->port_wwn ),
43 fc_id_ntoa ( &port->port_id ) );
44 printf ( " node %s\n [Link:", fc_ntoa ( &port->node_wwn ) );
45 if ( fc_link_ok ( &port->link ) ) {
46 printf ( " up, %s", fc_ntoa ( &port->link_port_wwn ) );
47 if ( ( port->flags & FC_PORT_HAS_FABRIC ) ) {
51 fc_id_ntoa ( &port->ptp_link_port_id ) );
53 printf ( " node %s]\n", fc_ntoa ( &port->link_node_wwn ) );
55 printf ( " down: %s]\n", strerror ( port->link.rc ) );
60 * Print status of Fibre Channel peer
62 * @v peer Fibre Channel peer
64 void fcpeerstat ( struct fc_peer *peer ) {
69 printf ( "%s:\n [Link:", fc_ntoa ( &peer->port_wwn ) );
70 if ( fc_link_ok ( &peer->link ) ) {
71 printf ( " up, port %s id %s]\n", peer->port->name,
72 fc_id_ntoa ( &peer->port_id ) );
74 printf ( " down: %s]\n", strerror ( peer->link.rc ) );
77 list_for_each_entry ( ulp, &peer->ulps, list ) {
78 printf ( " [Type %02x link:", ulp->type );
79 if ( fc_link_ok ( &ulp->link ) ) {
80 printf ( " up, params" );
82 for ( i = 0 ; i < ulp->param_len ; i++ ) {
83 printf ( "%c%02x", ( ( i == 0 ) ? ' ' : ':' ),
87 printf ( " down: %s", strerror ( ulp->link.rc ) );
94 * Issue Fibre Channel ELS
96 * @v port Fibre Channel port
97 * @v peer_port_id Peer port ID
98 * @v handler ELS handler
99 * @ret rc Return status code
101 int fcels ( struct fc_port *port, struct fc_port_id *peer_port_id,
102 struct fc_els_handler *handler ) {
106 printf ( "%s %s to %s...",
107 port->name, handler->name, fc_id_ntoa ( peer_port_id ) );
108 if ( ( rc = fc_els_request ( &monojob, port, peer_port_id,
110 printf ( "%s\n", strerror ( rc ) );
114 /* Wait for ELS to complete */
115 return monojob_wait ( "", 0 );