1 1.1 rin /* $NetBSD: ether_sw_offload.h,v 1.1 2018/12/12 01:40:20 rin Exp $ */ 2 1.1 rin 3 1.1 rin /* 4 1.1 rin * Copyright (c) 2018 The NetBSD Foundation, Inc. 5 1.1 rin * All rights reserved. 6 1.1 rin * 7 1.1 rin * This code is derived from software contributed to The NetBSD Foundation 8 1.1 rin * by Rin Okuyama. 9 1.1 rin * 10 1.1 rin * Redistribution and use in source and binary forms, with or without 11 1.1 rin * modification, are permitted provided that the following conditions 12 1.1 rin * are met: 13 1.1 rin * 1. Redistributions of source code must retain the above copyright 14 1.1 rin * notice, this list of conditions and the following disclaimer. 15 1.1 rin * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 rin * notice, this list of conditions and the following disclaimer in the 17 1.1 rin * documentation and/or other materials provided with the distribution. 18 1.1 rin * 19 1.1 rin * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.1 rin * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.1 rin * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.1 rin * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.1 rin * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.1 rin * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.1 rin * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 rin * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.1 rin * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.1 rin * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.1 rin * POSSIBILITY OF SUCH DAMAGE. 30 1.1 rin */ 31 1.1 rin 32 1.1 rin #ifndef _NET_ETHER_SW_OFFLOAD_H_ 33 1.1 rin #define _NET_ETHER_SW_OFFLOAD_H_ 34 1.1 rin 35 1.1 rin #ifdef _KERNEL 36 1.1 rin #include <sys/mbuf.h> 37 1.1 rin #include <net/if.h> 38 1.1 rin 39 1.1 rin /* 40 1.1 rin * Whether given TX offload options are supported by the interface. 41 1.1 rin * We need to check TSO bits first; M_CSUM_IPv4 is turned on even if 42 1.1 rin * TSOv4 is enabled (and some drivers depend on this behavior). 43 1.1 rin * Therefore we cannot test 44 1.1 rin * m->m_pkthdr.csum_flags & ~ifp->if_csum_flags_tx 45 1.1 rin * for interfaces that do not support hw IPv4 checksum. 46 1.1 rin */ 47 1.1 rin #define TX_OFFLOAD_SUPPORTED(if_flags, mbuf_flags) \ 48 1.1 rin ((((mbuf_flags) & (M_CSUM_TSOv4 | M_CSUM_TSOv6)) & (if_flags)) || \ 49 1.1 rin !((mbuf_flags) & ~(if_flags))) 50 1.1 rin 51 1.1 rin struct mbuf *ether_sw_offload_tx(struct ifnet *, struct mbuf *); 52 1.1 rin struct mbuf *ether_sw_offload_rx(struct ifnet *, struct mbuf *); 53 1.1 rin #endif /* _KERNEL */ 54 1.1 rin 55 1.1 rin #endif /* !_NET_ETHER_SW_OFFLOAD_H_ */ 56