1*9d40cf60SHans Petter Selasky /*- 2*9d40cf60SHans Petter Selasky * Copyright (c) 2020 Mellanox Technologies. All rights reserved. 3*9d40cf60SHans Petter Selasky * 4*9d40cf60SHans Petter Selasky * Redistribution and use in source and binary forms, with or without 5*9d40cf60SHans Petter Selasky * modification, are permitted provided that the following conditions 6*9d40cf60SHans Petter Selasky * are met: 7*9d40cf60SHans Petter Selasky * 1. Redistributions of source code must retain the above copyright 8*9d40cf60SHans Petter Selasky * notice, this list of conditions and the following disclaimer. 9*9d40cf60SHans Petter Selasky * 2. Redistributions in binary form must reproduce the above copyright 10*9d40cf60SHans Petter Selasky * notice, this list of conditions and the following disclaimer in the 11*9d40cf60SHans Petter Selasky * documentation and/or other materials provided with the distribution. 12*9d40cf60SHans Petter Selasky * 13*9d40cf60SHans Petter Selasky * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND 14*9d40cf60SHans Petter Selasky * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15*9d40cf60SHans Petter Selasky * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16*9d40cf60SHans Petter Selasky * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 17*9d40cf60SHans Petter Selasky * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18*9d40cf60SHans Petter Selasky * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19*9d40cf60SHans Petter Selasky * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20*9d40cf60SHans Petter Selasky * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21*9d40cf60SHans Petter Selasky * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22*9d40cf60SHans Petter Selasky * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23*9d40cf60SHans Petter Selasky * SUCH DAMAGE. 24*9d40cf60SHans Petter Selasky */ 25*9d40cf60SHans Petter Selasky 26*9d40cf60SHans Petter Selasky #ifndef __INFINIBAND_H__ 27*9d40cf60SHans Petter Selasky #define __INFINIBAND_H__ 28*9d40cf60SHans Petter Selasky 29*9d40cf60SHans Petter Selasky #include <sys/cdefs.h> 30*9d40cf60SHans Petter Selasky #include <sys/stdint.h> 31*9d40cf60SHans Petter Selasky 32*9d40cf60SHans Petter Selasky #define INFINIBAND_ADDR_LEN 20 /* bytes */ 33*9d40cf60SHans Petter Selasky #define INFINIBAND_MTU 1500 /* bytes - default value */ 34*9d40cf60SHans Petter Selasky 35*9d40cf60SHans Petter Selasky #define INFINIBAND_ENC_LEN 4 /* bytes */ 36*9d40cf60SHans Petter Selasky #define INFINIBAND_HDR_LEN \ 37*9d40cf60SHans Petter Selasky (INFINIBAND_ADDR_LEN + INFINIBAND_ENC_LEN) 38*9d40cf60SHans Petter Selasky 39*9d40cf60SHans Petter Selasky #define INFINIBAND_IS_MULTICAST(addr) \ 40*9d40cf60SHans Petter Selasky ((addr)[4] == 0xff) 41*9d40cf60SHans Petter Selasky 42*9d40cf60SHans Petter Selasky struct infiniband_header { 43*9d40cf60SHans Petter Selasky uint8_t ib_hwaddr[INFINIBAND_ADDR_LEN]; 44*9d40cf60SHans Petter Selasky uint16_t ib_protocol; /* big endian */ 45*9d40cf60SHans Petter Selasky uint16_t ib_reserved; /* zero */ 46*9d40cf60SHans Petter Selasky } __packed; 47*9d40cf60SHans Petter Selasky 48*9d40cf60SHans Petter Selasky struct infiniband_address { 49*9d40cf60SHans Petter Selasky uint8_t octet[INFINIBAND_ADDR_LEN]; 50*9d40cf60SHans Petter Selasky } __packed; 51*9d40cf60SHans Petter Selasky 52*9d40cf60SHans Petter Selasky #ifdef _KERNEL 53*9d40cf60SHans Petter Selasky 54*9d40cf60SHans Petter Selasky #include <sys/_eventhandler.h> 55*9d40cf60SHans Petter Selasky 56*9d40cf60SHans Petter Selasky struct ifnet; 57*9d40cf60SHans Petter Selasky struct mbuf; 58*9d40cf60SHans Petter Selasky 59*9d40cf60SHans Petter Selasky extern void infiniband_ifattach(struct ifnet *, const uint8_t *hwaddr, const uint8_t *bcaddr); 60*9d40cf60SHans Petter Selasky extern void infiniband_ifdetach(struct ifnet *); 61*9d40cf60SHans Petter Selasky extern void infiniband_bpf_mtap(struct ifnet *, struct mbuf *); 62*9d40cf60SHans Petter Selasky 63*9d40cf60SHans Petter Selasky /* new infiniband interface attached event */ 64*9d40cf60SHans Petter Selasky typedef void (*infiniband_ifattach_event_handler_t)(void *, struct ifnet *); 65*9d40cf60SHans Petter Selasky 66*9d40cf60SHans Petter Selasky EVENTHANDLER_DECLARE(infiniband_ifattach_event, infiniband_ifattach_event_handler_t); 67*9d40cf60SHans Petter Selasky 68*9d40cf60SHans Petter Selasky #endif 69*9d40cf60SHans Petter Selasky 70*9d40cf60SHans Petter Selasky #endif /* __INFINIBAND_H__ */ 71