19d40cf60SHans Petter Selasky /*- 29d40cf60SHans Petter Selasky * Copyright (c) 2020 Mellanox Technologies. All rights reserved. 39d40cf60SHans Petter Selasky * 49d40cf60SHans Petter Selasky * Redistribution and use in source and binary forms, with or without 59d40cf60SHans Petter Selasky * modification, are permitted provided that the following conditions 69d40cf60SHans Petter Selasky * are met: 79d40cf60SHans Petter Selasky * 1. Redistributions of source code must retain the above copyright 89d40cf60SHans Petter Selasky * notice, this list of conditions and the following disclaimer. 99d40cf60SHans Petter Selasky * 2. Redistributions in binary form must reproduce the above copyright 109d40cf60SHans Petter Selasky * notice, this list of conditions and the following disclaimer in the 119d40cf60SHans Petter Selasky * documentation and/or other materials provided with the distribution. 129d40cf60SHans Petter Selasky * 139d40cf60SHans Petter Selasky * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND 149d40cf60SHans Petter Selasky * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 159d40cf60SHans Petter Selasky * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 169d40cf60SHans Petter Selasky * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 179d40cf60SHans Petter Selasky * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 189d40cf60SHans Petter Selasky * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 199d40cf60SHans Petter Selasky * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 209d40cf60SHans Petter Selasky * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 219d40cf60SHans Petter Selasky * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 229d40cf60SHans Petter Selasky * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 239d40cf60SHans Petter Selasky * SUCH DAMAGE. 249d40cf60SHans Petter Selasky * 259d40cf60SHans Petter Selasky * $FreeBSD$ 269d40cf60SHans Petter Selasky */ 279d40cf60SHans Petter Selasky 289d40cf60SHans Petter Selasky #ifndef __INFINIBAND_H__ 299d40cf60SHans Petter Selasky #define __INFINIBAND_H__ 309d40cf60SHans Petter Selasky 319d40cf60SHans Petter Selasky #include <sys/cdefs.h> 329d40cf60SHans Petter Selasky #include <sys/stdint.h> 339d40cf60SHans Petter Selasky 349d40cf60SHans Petter Selasky #define INFINIBAND_ADDR_LEN 20 /* bytes */ 359d40cf60SHans Petter Selasky #define INFINIBAND_MTU 1500 /* bytes - default value */ 369d40cf60SHans Petter Selasky 379d40cf60SHans Petter Selasky #define INFINIBAND_ENC_LEN 4 /* bytes */ 389d40cf60SHans Petter Selasky #define INFINIBAND_HDR_LEN \ 399d40cf60SHans Petter Selasky (INFINIBAND_ADDR_LEN + INFINIBAND_ENC_LEN) 409d40cf60SHans Petter Selasky 419d40cf60SHans Petter Selasky #define INFINIBAND_IS_MULTICAST(addr) \ 429d40cf60SHans Petter Selasky ((addr)[4] == 0xff) 439d40cf60SHans Petter Selasky 449d40cf60SHans Petter Selasky #define INFINIBAND_BPF_MTAP(_ifp, _m) \ 459d40cf60SHans Petter Selasky do { \ 469d40cf60SHans Petter Selasky if (bpf_peers_present((_ifp)->if_bpf)) { \ 479d40cf60SHans Petter Selasky M_ASSERTVALID(_m); \ 489d40cf60SHans Petter Selasky infiniband_bpf_mtap(_ifp, _m); \ 499d40cf60SHans Petter Selasky } \ 509d40cf60SHans Petter Selasky } while (0) 519d40cf60SHans Petter Selasky 529d40cf60SHans Petter Selasky struct infiniband_header { 539d40cf60SHans Petter Selasky uint8_t ib_hwaddr[INFINIBAND_ADDR_LEN]; 549d40cf60SHans Petter Selasky uint16_t ib_protocol; /* big endian */ 559d40cf60SHans Petter Selasky uint16_t ib_reserved; /* zero */ 569d40cf60SHans Petter Selasky } __packed; 579d40cf60SHans Petter Selasky 589d40cf60SHans Petter Selasky struct infiniband_address { 599d40cf60SHans Petter Selasky uint8_t octet[INFINIBAND_ADDR_LEN]; 609d40cf60SHans Petter Selasky } __packed; 619d40cf60SHans Petter Selasky 629d40cf60SHans Petter Selasky #ifdef _KERNEL 639d40cf60SHans Petter Selasky 649d40cf60SHans Petter Selasky #include <sys/_eventhandler.h> 659d40cf60SHans Petter Selasky 669d40cf60SHans Petter Selasky struct ifnet; 679d40cf60SHans Petter Selasky struct mbuf; 689d40cf60SHans Petter Selasky 699d40cf60SHans Petter Selasky extern void infiniband_ifattach(struct ifnet *, const uint8_t *hwaddr, const uint8_t *bcaddr); 709d40cf60SHans Petter Selasky extern void infiniband_ifdetach(struct ifnet *); 719d40cf60SHans Petter Selasky extern void infiniband_bpf_mtap(struct ifnet *, struct mbuf *); 729d40cf60SHans Petter Selasky 739d40cf60SHans Petter Selasky /* new infiniband interface attached event */ 749d40cf60SHans Petter Selasky typedef void (*infiniband_ifattach_event_handler_t)(void *, struct ifnet *); 759d40cf60SHans Petter Selasky 769d40cf60SHans Petter Selasky EVENTHANDLER_DECLARE(infiniband_ifattach_event, infiniband_ifattach_event_handler_t); 779d40cf60SHans Petter Selasky 789d40cf60SHans Petter Selasky #endif 799d40cf60SHans Petter Selasky 809d40cf60SHans Petter Selasky #endif /* __INFINIBAND_H__ */ 81