1331772Shselasky/*- 2331772Shselasky * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0 3331772Shselasky * 4319974Shselasky * Copyright (c) 2014 Intel Corporation. All rights reserved. 5319974Shselasky * 6319974Shselasky * This software is available to you under a choice of one of two 7319974Shselasky * licenses. You may choose to be licensed under the terms of the GNU 8319974Shselasky * General Public License (GPL) Version 2, available from the file 9319974Shselasky * COPYING in the main directory of this source tree, or the 10319974Shselasky * OpenIB.org BSD license below: 11319974Shselasky * 12319974Shselasky * Redistribution and use in source and binary forms, with or 13319974Shselasky * without modification, are permitted provided that the following 14319974Shselasky * conditions are met: 15319974Shselasky * 16319974Shselasky * - Redistributions of source code must retain the above 17319974Shselasky * copyright notice, this list of conditions and the following 18319974Shselasky * disclaimer. 19319974Shselasky * 20319974Shselasky * - Redistributions in binary form must reproduce the above 21319974Shselasky * copyright notice, this list of conditions and the following 22319974Shselasky * disclaimer in the documentation and/or other materials 23319974Shselasky * provided with the distribution. 24319974Shselasky * 25319974Shselasky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26319974Shselasky * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27319974Shselasky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28319974Shselasky * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29319974Shselasky * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30319974Shselasky * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31319974Shselasky * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32319974Shselasky * SOFTWARE. 33319974Shselasky * 34331772Shselasky * $FreeBSD: stable/11/sys/ofed/drivers/infiniband/core/opa_smi.h 331772 2018-03-30 18:17:33Z hselasky $ 35319974Shselasky */ 36319974Shselasky 37319974Shselasky#ifndef __OPA_SMI_H_ 38319974Shselasky#define __OPA_SMI_H_ 39319974Shselasky 40319974Shselasky#include <rdma/ib_smi.h> 41319974Shselasky#include <rdma/opa_smi.h> 42319974Shselasky 43319974Shselasky#include "smi.h" 44319974Shselasky 45319974Shselaskyenum smi_action opa_smi_handle_dr_smp_recv(struct opa_smp *smp, bool is_switch, 46319974Shselasky int port_num, int phys_port_cnt); 47319974Shselaskyint opa_smi_get_fwd_port(struct opa_smp *smp); 48319974Shselaskyextern enum smi_forward_action opa_smi_check_forward_dr_smp(struct opa_smp *smp); 49319974Shselaskyextern enum smi_action opa_smi_handle_dr_smp_send(struct opa_smp *smp, 50319974Shselasky bool is_switch, int port_num); 51319974Shselasky 52319974Shselasky/* 53319974Shselasky * Return IB_SMI_HANDLE if the SMP should be handled by the local SMA/SM 54319974Shselasky * via process_mad 55319974Shselasky */ 56319974Shselaskystatic inline enum smi_action opa_smi_check_local_smp(struct opa_smp *smp, 57319974Shselasky struct ib_device *device) 58319974Shselasky{ 59319974Shselasky /* C14-9:3 -- We're at the end of the DR segment of path */ 60319974Shselasky /* C14-9:4 -- Hop Pointer = Hop Count + 1 -> give to SMA/SM */ 61319974Shselasky return (device->process_mad && 62319974Shselasky !opa_get_smp_direction(smp) && 63319974Shselasky (smp->hop_ptr == smp->hop_cnt + 1)) ? 64319974Shselasky IB_SMI_HANDLE : IB_SMI_DISCARD; 65319974Shselasky} 66319974Shselasky 67319974Shselasky/* 68319974Shselasky * Return IB_SMI_HANDLE if the SMP should be handled by the local SMA/SM 69319974Shselasky * via process_mad 70319974Shselasky */ 71319974Shselaskystatic inline enum smi_action opa_smi_check_local_returning_smp(struct opa_smp *smp, 72319974Shselasky struct ib_device *device) 73319974Shselasky{ 74319974Shselasky /* C14-13:3 -- We're at the end of the DR segment of path */ 75319974Shselasky /* C14-13:4 -- Hop Pointer == 0 -> give to SM */ 76319974Shselasky return (device->process_mad && 77319974Shselasky opa_get_smp_direction(smp) && 78319974Shselasky !smp->hop_ptr) ? IB_SMI_HANDLE : IB_SMI_DISCARD; 79319974Shselasky} 80319974Shselasky 81319974Shselasky#endif /* __OPA_SMI_H_ */ 82