Annotation of qemu/roms/ipxe/src/usr/fcmgmt.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (C) 2010 Michael Brown <[email protected]>.
                      3:  *
                      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.
                      8:  *
                      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.
                     13:  *
                     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., 675 Mass Ave, Cambridge, MA 02139, USA.
                     17:  */
                     18: 
                     19: FILE_LICENCE ( GPL2_OR_LATER );
                     20: 
                     21: #include <string.h>
                     22: #include <stdio.h>
                     23: #include <errno.h>
                     24: #include <ipxe/fc.h>
                     25: #include <ipxe/fcels.h>
                     26: #include <ipxe/monojob.h>
                     27: #include <usr/fcmgmt.h>
                     28: 
                     29: /** @file
                     30:  *
                     31:  * Fibre Channel management
                     32:  *
                     33:  */
                     34: 
                     35: /**
                     36:  * Print status of Fibre Channel port
                     37:  *
                     38:  * @v port             Fibre Channel port
                     39:  */
                     40: void fcportstat ( struct fc_port *port ) {
                     41:        printf ( "%s: %s id %s", port->name, fc_ntoa ( &port->port_wwn ),
                     42:                 fc_id_ntoa ( &port->port_id ) );
                     43:        printf ( " node %s\n  [Link:", fc_ntoa ( &port->node_wwn ) );
                     44:        if ( fc_link_ok ( &port->link ) ) {
                     45:                printf ( " up, %s", fc_ntoa ( &port->link_port_wwn ) );
                     46:                if ( ( port->flags & FC_PORT_HAS_FABRIC ) ) {
                     47:                        printf ( " fabric" );
                     48:                } else {
                     49:                        printf ( " id %s",
                     50:                                 fc_id_ntoa ( &port->ptp_link_port_id ) );
                     51:                }
                     52:                printf ( " node %s]\n", fc_ntoa ( &port->link_node_wwn ) );
                     53:        } else {
                     54:                printf ( " down: %s]\n", strerror ( port->link.rc ) );
                     55:        }
                     56: }
                     57: 
                     58: /**
                     59:  * Print status of Fibre Channel peer
                     60:  *
                     61:  * @v peer             Fibre Channel peer
                     62:  */
                     63: void fcpeerstat ( struct fc_peer *peer ) {
                     64:        struct fc_ulp *ulp;
                     65:        uint8_t *param;
                     66:        unsigned int i;
                     67: 
                     68:        printf ( "%s:\n  [Link:", fc_ntoa ( &peer->port_wwn ) );
                     69:        if ( fc_link_ok ( &peer->link ) ) {
                     70:                printf ( " up, port %s id %s]\n", peer->port->name,
                     71:                         fc_id_ntoa ( &peer->port_id ) );
                     72:        } else {
                     73:                printf ( " down: %s]\n", strerror ( peer->link.rc ) );
                     74:        }
                     75: 
                     76:        list_for_each_entry ( ulp, &peer->ulps, list ) {
                     77:                printf ( "  [Type %02x usage %d link:",
                     78:                         ulp->type, ulp->usage );
                     79:                if ( fc_link_ok ( &ulp->link ) ) {
                     80:                        printf ( " up, params" );
                     81:                        param = ulp->param;
                     82:                        for ( i = 0 ; i < ulp->param_len ; i++ ) {
                     83:                                printf ( "%c%02x", ( ( i == 0 ) ? ' ' : ':' ),
                     84:                                         param[i] );
                     85:                        }
                     86:                } else {
                     87:                        printf ( " down: %s", strerror ( ulp->link.rc ) );
                     88:                }
                     89:                printf ( "]\n" );
                     90:        }
                     91: }
                     92: 
                     93: /**
                     94:  * Issue Fibre Channel ELS
                     95:  *
                     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
                    100:  */
                    101: int fcels ( struct fc_port *port, struct fc_port_id *peer_port_id,
                    102:            struct fc_els_handler *handler ) {
                    103:        int rc;
                    104: 
                    105:        /* Initiate ELS */
                    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,
                    109:                                     handler ) ) != 0 ) {
                    110:                printf ( "%s\n", strerror ( rc ) );
                    111:                return rc;
                    112:        }
                    113: 
                    114:        /* Wait for ELS to complete */
                    115:        return monojob_wait ( "" );
                    116: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.