2 * Copyright (c) 2017-2018 Cavium, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
33 * Author : David C Somayajulu, Cavium, Inc., San Jose, CA 95131.
39 #include <sys/param.h>
40 #include <sys/systm.h>
42 #include <sys/protosw.h>
43 #include <sys/socket.h>
44 #include <sys/malloc.h>
45 #include <sys/module.h>
46 #include <sys/kernel.h>
47 #include <sys/sockio.h>
48 #include <sys/types.h>
49 #include <machine/atomic.h>
50 #include <machine/_inttypes.h>
53 #if __FreeBSD_version < 1000000
54 #error FreeBSD Version not supported - use version >= 1000000
58 #include <net/if_var.h>
59 #include <net/if_arp.h>
60 #include <net/ethernet.h>
61 #include <net/if_dl.h>
62 #include <net/if_media.h>
64 #include <net/if_types.h>
65 #include <net/if_vlan_var.h>
67 #include <netinet/in_systm.h>
68 #include <netinet/in.h>
69 #include <netinet/if_ether.h>
70 #include <netinet/ip.h>
71 #include <netinet/ip6.h>
72 #include <netinet/tcp.h>
73 #include <netinet/udp.h>
74 #include <netinet/in_var.h>
75 #include <netinet/tcp_lro.h>
78 #include <machine/bus.h>
80 #include <machine/resource.h>
81 #include <dev/pci/pcireg.h>
82 #include <dev/pci/pcivar.h>
83 #include <sys/mutex.h>
84 #include <sys/condvar.h>
86 #include <sys/sysctl.h>
87 #include <sys/endian.h>
88 #include <sys/taskqueue.h>
91 #include <sys/unistd.h>
92 #include <sys/kthread.h>
93 #include <sys/libkern.h>
95 #include <sys/sched.h>
97 #ifdef CONFIG_ECORE_SRIOV
99 #include <sys/iov_schema.h>
100 #include <dev/pci/pci_iov.h>
101 #endif /* #ifdef CONFIG_ECORE_SRIOV */
103 static __inline int qlnx_ms_to_hz(int ms)
109 t.tv_sec = ms / 1000;
110 t.tv_usec = (ms % 1000) * 1000;
112 qlnx_hz = tvtohz(&t);
115 qlnx_hz = 0x7fffffff;
122 static __inline int qlnx_sec_to_hz(int sec)
132 MALLOC_DECLARE(M_QLNXBUF);
134 #define qlnx_mdelay(fn, msecs) \
137 DELAY((msecs * 1000)); \
139 pause(fn, qlnx_ms_to_hz(msecs)); \
145 #define QLNX_LOCK(ha) mtx_lock(&ha->hw_lock)
146 #define QLNX_UNLOCK(ha) mtx_unlock(&ha->hw_lock)
149 * structure encapsulating a DMA buffer
152 bus_size_t alignment;
156 bus_dmamap_t dma_map;
157 bus_dma_tag_t dma_tag;
159 typedef struct qlnx_dma qlnx_dma_t;
162 #endif /* #ifndef _QLNX_OS_H_ */