/*1* Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved.2* Copyright (c) 2004 Infinicon Corporation. All rights reserved.3* Copyright (c) 2004 Intel Corporation. All rights reserved.4* Copyright (c) 2004 Topspin Corporation. All rights reserved.5* Copyright (c) 2004-2007 Voltaire Corporation. All rights reserved.6*7* This software is available to you under a choice of one of two8* licenses. You may choose to be licensed under the terms of the GNU9* General Public License (GPL) Version 2, available from the file10* COPYING in the main directory of this source tree, or the11* OpenIB.org BSD license below:12*13* Redistribution and use in source and binary forms, with or14* without modification, are permitted provided that the following15* conditions are met:16*17* - Redistributions of source code must retain the above18* copyright notice, this list of conditions and the following19* disclaimer.20*21* - Redistributions in binary form must reproduce the above22* copyright notice, this list of conditions and the following23* disclaimer in the documentation and/or other materials24* provided with the distribution.25*26* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,27* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF28* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND29* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS30* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN31* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN32* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE33* SOFTWARE.34*35*/3637#ifndef __SMI_H_38#define __SMI_H_3940#include <rdma/ib_smi.h>4142enum smi_action {43IB_SMI_DISCARD,44IB_SMI_HANDLE45};4647enum smi_forward_action {48IB_SMI_LOCAL, /* SMP should be completed up the stack */49IB_SMI_SEND, /* received DR SMP should be forwarded to the send queue */50IB_SMI_FORWARD /* SMP should be forwarded (for switches only) */51};5253enum smi_action smi_handle_dr_smp_recv(struct ib_smp *smp, u8 node_type,54int port_num, int phys_port_cnt);55int smi_get_fwd_port(struct ib_smp *smp);56extern enum smi_forward_action smi_check_forward_dr_smp(struct ib_smp *smp);57extern enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp,58u8 node_type, int port_num);5960/*61* Return IB_SMI_HANDLE if the SMP should be handled by the local SMA/SM62* via process_mad63*/64static inline enum smi_action smi_check_local_smp(struct ib_smp *smp,65struct ib_device *device)66{67/* C14-9:3 -- We're at the end of the DR segment of path */68/* C14-9:4 -- Hop Pointer = Hop Count + 1 -> give to SMA/SM */69return ((device->process_mad &&70!ib_get_smp_direction(smp) &&71(smp->hop_ptr == smp->hop_cnt + 1)) ?72IB_SMI_HANDLE : IB_SMI_DISCARD);73}7475/*76* Return IB_SMI_HANDLE if the SMP should be handled by the local SMA/SM77* via process_mad78*/79static inline enum smi_action smi_check_local_returning_smp(struct ib_smp *smp,80struct ib_device *device)81{82/* C14-13:3 -- We're at the end of the DR segment of path */83/* C14-13:4 -- Hop Pointer == 0 -> give to SM */84return ((device->process_mad &&85ib_get_smp_direction(smp) &&86!smp->hop_ptr) ? IB_SMI_HANDLE : IB_SMI_DISCARD);87}8889#endif /* __SMI_H_ */909192