/* * This file is part of the Chelsio FCoE driver for Linux. * * Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include <linux/string.h> #include <scsi/scsi_device.h> #include <scsi/scsi_transport_fc.h> #include <scsi/fc/fc_els.h> #include <scsi/fc/fc_fs.h> #include "csio_hw.h" #include "csio_lnode.h" #include "csio_rnode.h" static int csio_rnode_init(struct csio_rnode *, struct csio_lnode *); static void csio_rnode_exit(struct csio_rnode *); /* Static machine forward declarations */ static void csio_rns_uninit(struct csio_rnode *, enum csio_rn_ev); static void csio_rns_ready(struct csio_rnode *, enum csio_rn_ev); static void csio_rns_offline(struct csio_rnode *, enum csio_rn_ev); static void csio_rns_disappeared(struct csio_rnode *, enum csio_rn_ev); /* RNF event mapping */ static enum csio_rn_ev fwevt_to_rnevt[] = …; #define CSIO_FWE_TO_RNFE(_evt) … int csio_is_rnode_ready(struct csio_rnode *rn) { … } static int csio_is_rnode_uninit(struct csio_rnode *rn) { … } static int csio_is_rnode_wka(uint8_t rport_type) { … } /* * csio_rn_lookup - Finds the rnode with the given flowid * @ln - lnode * @flowid - flowid. * * Does the rnode lookup on the given lnode and flowid.If no matching entry * found, NULL is returned. */ static struct csio_rnode * csio_rn_lookup(struct csio_lnode *ln, uint32_t flowid) { … } /* * csio_rn_lookup_wwpn - Finds the rnode with the given wwpn * @ln: lnode * @wwpn: wwpn * * Does the rnode lookup on the given lnode and wwpn. If no matching entry * found, NULL is returned. */ static struct csio_rnode * csio_rn_lookup_wwpn(struct csio_lnode *ln, uint8_t *wwpn) { … } /** * csio_rnode_lookup_portid - Finds the rnode with the given portid * @ln: lnode * @portid: port id * * Lookup the rnode list for a given portid. If no matching entry * found, NULL is returned. */ struct csio_rnode * csio_rnode_lookup_portid(struct csio_lnode *ln, uint32_t portid) { … } static int csio_rn_dup_flowid(struct csio_lnode *ln, uint32_t rdev_flowid, uint32_t *vnp_flowid) { … } static struct csio_rnode * csio_alloc_rnode(struct csio_lnode *ln) { … } static void csio_free_rnode(struct csio_rnode *rn) { … } /* * csio_get_rnode - Gets rnode with the given flowid * @ln - lnode * @flowid - flow id. * * Does the rnode lookup on the given lnode and flowid. If no matching * rnode found, then new rnode with given npid is allocated and returned. */ static struct csio_rnode * csio_get_rnode(struct csio_lnode *ln, uint32_t flowid) { … } /* * csio_put_rnode - Frees the given rnode * @ln - lnode * @flowid - flow id. * * Does the rnode lookup on the given lnode and flowid. If no matching * rnode found, then new rnode with given npid is allocated and returned. */ void csio_put_rnode(struct csio_lnode *ln, struct csio_rnode *rn) { … } /* * csio_confirm_rnode - confirms rnode based on wwpn. * @ln: lnode * @rdev_flowid: remote device flowid * @rdevp: remote device params * This routines searches other rnode in list having same wwpn of new rnode. * If there is a match, then matched rnode is returned and otherwise new rnode * is returned. * returns rnode. */ struct csio_rnode * csio_confirm_rnode(struct csio_lnode *ln, uint32_t rdev_flowid, struct fcoe_rdev_entry *rdevp) { … } /* * csio_rn_verify_rparams - verify rparams. * @ln: lnode * @rn: rnode * @rdevp: remote device params * returns success if rparams are verified. */ static int csio_rn_verify_rparams(struct csio_lnode *ln, struct csio_rnode *rn, struct fcoe_rdev_entry *rdevp) { … } static void __csio_reg_rnode(struct csio_rnode *rn) { … } static void __csio_unreg_rnode(struct csio_rnode *rn) { … } /*****************************************************************************/ /* START: Rnode SM */ /*****************************************************************************/ /* * csio_rns_uninit - * @rn - rnode * @evt - SM event. * */ static void csio_rns_uninit(struct csio_rnode *rn, enum csio_rn_ev evt) { … } /* * csio_rns_ready - * @rn - rnode * @evt - SM event. * */ static void csio_rns_ready(struct csio_rnode *rn, enum csio_rn_ev evt) { … } /* * csio_rns_offline - * @rn - rnode * @evt - SM event. * */ static void csio_rns_offline(struct csio_rnode *rn, enum csio_rn_ev evt) { … } /* * csio_rns_disappeared - * @rn - rnode * @evt - SM event. * */ static void csio_rns_disappeared(struct csio_rnode *rn, enum csio_rn_ev evt) { … } /*****************************************************************************/ /* END: Rnode SM */ /*****************************************************************************/ /* * csio_rnode_devloss_handler - Device loss event handler * @rn: rnode * * Post event to close rnode SM and free rnode. */ void csio_rnode_devloss_handler(struct csio_rnode *rn) { … } /** * csio_rnode_fwevt_handler - Event handler for firmware rnode events. * @rn: rnode * @fwevt: firmware event to handle */ void csio_rnode_fwevt_handler(struct csio_rnode *rn, uint8_t fwevt) { … } /* * csio_rnode_init - Initialize rnode. * @rn: RNode * @ln: Associated lnode * * Caller is responsible for holding the lock. The lock is required * to be held for inserting the rnode in ln->rnhead list. */ static int csio_rnode_init(struct csio_rnode *rn, struct csio_lnode *ln) { … } static void csio_rnode_exit(struct csio_rnode *rn) { … }