Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2004 Mellanox Technologies Ltd.  All rights reserved.
0003  * Copyright (c) 2004 Infinicon Corporation.  All rights reserved.
0004  * Copyright (c) 2004 Intel Corporation.  All rights reserved.
0005  * Copyright (c) 2004 Topspin Corporation.  All rights reserved.
0006  * Copyright (c) 2004-2007 Voltaire Corporation.  All rights reserved.
0007  *
0008  * This software is available to you under a choice of one of two
0009  * licenses.  You may choose to be licensed under the terms of the GNU
0010  * General Public License (GPL) Version 2, available from the file
0011  * COPYING in the main directory of this source tree, or the
0012  * OpenIB.org BSD license below:
0013  *
0014  *     Redistribution and use in source and binary forms, with or
0015  *     without modification, are permitted provided that the following
0016  *     conditions are met:
0017  *
0018  *      - Redistributions of source code must retain the above
0019  *        copyright notice, this list of conditions and the following
0020  *        disclaimer.
0021  *
0022  *      - Redistributions in binary form must reproduce the above
0023  *        copyright notice, this list of conditions and the following
0024  *        disclaimer in the documentation and/or other materials
0025  *        provided with the distribution.
0026  *
0027  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0028  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0029  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0030  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0031  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0032  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0033  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0034  * SOFTWARE.
0035  *
0036  */
0037 
0038 #ifndef __SMI_H_
0039 #define __SMI_H_
0040 
0041 #include <rdma/ib_smi.h>
0042 
0043 enum smi_action {
0044     IB_SMI_DISCARD,
0045     IB_SMI_HANDLE
0046 };
0047 
0048 enum smi_forward_action {
0049     IB_SMI_LOCAL,   /* SMP should be completed up the stack */
0050     IB_SMI_SEND,    /* received DR SMP should be forwarded to the send queue */
0051     IB_SMI_FORWARD  /* SMP should be forwarded (for switches only) */
0052 };
0053 
0054 enum smi_action smi_handle_dr_smp_recv(struct ib_smp *smp, bool is_switch,
0055                        u32 port_num, int phys_port_cnt);
0056 int smi_get_fwd_port(struct ib_smp *smp);
0057 extern enum smi_forward_action smi_check_forward_dr_smp(struct ib_smp *smp);
0058 extern enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp,
0059                           bool is_switch, u32 port_num);
0060 
0061 /*
0062  * Return IB_SMI_HANDLE if the SMP should be handled by the local SMA/SM
0063  * via process_mad
0064  */
0065 static inline enum smi_action smi_check_local_smp(struct ib_smp *smp,
0066                           struct ib_device *device)
0067 {
0068     /* C14-9:3 -- We're at the end of the DR segment of path */
0069     /* C14-9:4 -- Hop Pointer = Hop Count + 1 -> give to SMA/SM */
0070     return ((device->ops.process_mad &&
0071         !ib_get_smp_direction(smp) &&
0072         (smp->hop_ptr == smp->hop_cnt + 1)) ?
0073         IB_SMI_HANDLE : IB_SMI_DISCARD);
0074 }
0075 
0076 /*
0077  * Return IB_SMI_HANDLE if the SMP should be handled by the local SMA/SM
0078  * via process_mad
0079  */
0080 static inline enum smi_action smi_check_local_returning_smp(struct ib_smp *smp,
0081                            struct ib_device *device)
0082 {
0083     /* C14-13:3 -- We're at the end of the DR segment of path */
0084     /* C14-13:4 -- Hop Pointer == 0 -> give to SM */
0085     return ((device->ops.process_mad &&
0086         ib_get_smp_direction(smp) &&
0087         !smp->hop_ptr) ? IB_SMI_HANDLE : IB_SMI_DISCARD);
0088 }
0089 
0090 #endif  /* __SMI_H_ */