4 * Copyright(c) 2017 Cavium, Inc.. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Cavium, Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #include <sys/param.h>
39 #include <sys/gsb_crc32.h>
40 #include <sys/eventhandler.h>
41 #include <sys/socket.h>
42 #include <sys/kernel.h>
43 #include <sys/module.h>
44 #include <sys/sockio.h>
47 #include <net/if_var.h>
49 #include <net/ethernet.h>
50 #include <net/if_dl.h>
51 #include <net/if_media.h>
53 #include <net/if_types.h>
54 #include <net/if_vlan_var.h>
56 #include <netinet/in.h>
57 #include <netinet/tcp_lro.h>
60 #include <machine/bus.h>
64 #include <dev/pci/pcivar.h>
65 #include <dev/pci/pcireg.h>
66 #include <sys/sysctl.h>
67 #include <sys/taskqueue.h>
69 #include <sys/kthread.h>
70 #include <sys/firmware.h>
72 #include <vm/vm_extern.h>
73 #include <vm/vm_kern.h>
75 #ifndef PCI_VENDOR_ID_CAVIUM
76 #define PCI_VENDOR_ID_CAVIUM 0x177D
79 #define BIT(nr) (1UL << (nr))
81 #define lio_check_timeout(a, b) ((int)((b) - (a)) < 0)
83 #define lio_ms_to_ticks(x) \
84 ((hz > 1000) ? ((x) * (hz/1000)) : ((x) / (1000/hz)))
86 #define lio_mdelay(x) do { \
90 pause("Wait", lio_ms_to_ticks(x)); \
93 #define lio_sleep_timeout(timeout) lio_mdelay((timeout))
95 typedef uint32_t __be32;
96 typedef uint64_t __be64;
98 #define lio_dev_info(oct, format, args...) \
99 device_printf(oct->device, "Info: " format, ##args)
100 #define lio_dev_warn(oct, format, args...) \
101 device_printf(oct->device, "Warn: " format, ##args)
102 #define lio_dev_err(oct, format, args...) \
103 device_printf(oct->device, "Error: " format, ##args)
106 #define lio_dev_dbg(oct, format, args...) \
107 device_printf(oct->device, "Debug: " format, ##args)
109 #define lio_dev_dbg(oct, format, args...) {do { } while (0); }
112 struct lio_stailq_node {
113 STAILQ_ENTRY (lio_stailq_node) entries;
115 STAILQ_HEAD (lio_stailq_head, lio_stailq_node);
117 static inline struct lio_stailq_node *
118 lio_delete_first_node(struct lio_stailq_head *root)
120 struct lio_stailq_node *node;
122 if (STAILQ_EMPTY(root))
125 node = STAILQ_FIRST(root);
128 STAILQ_REMOVE_HEAD(root, entries);
133 #endif /* __LIO_BSD_H__ */