Back to home page

OSCL-LXR

 
 

    


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