xref: /freebsd/sys/net/infiniband.h (revision 95ee2897)
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 
269d40cf60SHans Petter Selasky #ifndef __INFINIBAND_H__
279d40cf60SHans Petter Selasky #define	__INFINIBAND_H__
289d40cf60SHans Petter Selasky 
299d40cf60SHans Petter Selasky #include <sys/cdefs.h>
309d40cf60SHans Petter Selasky #include <sys/stdint.h>
319d40cf60SHans Petter Selasky 
329d40cf60SHans Petter Selasky #define	INFINIBAND_ADDR_LEN	20	/* bytes */
339d40cf60SHans Petter Selasky #define	INFINIBAND_MTU		1500	/* bytes - default value */
349d40cf60SHans Petter Selasky 
359d40cf60SHans Petter Selasky #define	INFINIBAND_ENC_LEN	4	/* bytes */
369d40cf60SHans Petter Selasky #define	INFINIBAND_HDR_LEN \
379d40cf60SHans Petter Selasky     (INFINIBAND_ADDR_LEN + INFINIBAND_ENC_LEN)
389d40cf60SHans Petter Selasky 
399d40cf60SHans Petter Selasky #define	INFINIBAND_IS_MULTICAST(addr) \
409d40cf60SHans Petter Selasky     ((addr)[4] == 0xff)
419d40cf60SHans Petter Selasky 
429d40cf60SHans Petter Selasky struct infiniband_header {
439d40cf60SHans Petter Selasky 	uint8_t	ib_hwaddr[INFINIBAND_ADDR_LEN];
449d40cf60SHans Petter Selasky 	uint16_t ib_protocol;		/* big endian */
459d40cf60SHans Petter Selasky 	uint16_t ib_reserved;		/* zero */
469d40cf60SHans Petter Selasky } __packed;
479d40cf60SHans Petter Selasky 
489d40cf60SHans Petter Selasky struct infiniband_address {
499d40cf60SHans Petter Selasky 	uint8_t	octet[INFINIBAND_ADDR_LEN];
509d40cf60SHans Petter Selasky } __packed;
519d40cf60SHans Petter Selasky 
529d40cf60SHans Petter Selasky #ifdef _KERNEL
539d40cf60SHans Petter Selasky 
549d40cf60SHans Petter Selasky #include <sys/_eventhandler.h>
559d40cf60SHans Petter Selasky 
569d40cf60SHans Petter Selasky struct ifnet;
579d40cf60SHans Petter Selasky struct mbuf;
589d40cf60SHans Petter Selasky 
599d40cf60SHans Petter Selasky extern void infiniband_ifattach(struct ifnet *, const uint8_t *hwaddr, const uint8_t *bcaddr);
609d40cf60SHans Petter Selasky extern void infiniband_ifdetach(struct ifnet *);
619d40cf60SHans Petter Selasky extern void infiniband_bpf_mtap(struct ifnet *, struct mbuf *);
629d40cf60SHans Petter Selasky 
639d40cf60SHans Petter Selasky /* new infiniband interface attached event */
649d40cf60SHans Petter Selasky typedef void (*infiniband_ifattach_event_handler_t)(void *, struct ifnet *);
659d40cf60SHans Petter Selasky 
669d40cf60SHans Petter Selasky EVENTHANDLER_DECLARE(infiniband_ifattach_event, infiniband_ifattach_event_handler_t);
679d40cf60SHans Petter Selasky 
689d40cf60SHans Petter Selasky #endif
699d40cf60SHans Petter Selasky 
709d40cf60SHans Petter Selasky #endif					/* __INFINIBAND_H__ */
71