33#ifndef __CXGBE_OSDEP_H_
34#define __CXGBE_OSDEP_H_
40#include <sys/endian.h>
42#include <sys/syslog.h>
43#include <dev/pci/pcireg.h>
45#define CH_ERR(adap, fmt, ...) log(LOG_ERR, "%s: " fmt, \
46 device_get_nameunit((adap)->dev), ##__VA_ARGS__)
47#define CH_WARN(adap, fmt, ...) log(LOG_WARNING, "%s: " fmt, \
48 device_get_nameunit((adap)->dev), ##__VA_ARGS__)
49#define CH_ALERT(adap, fmt, ...) log(LOG_ALERT, "%s: " fmt, \
50 device_get_nameunit((adap)->dev), ##__VA_ARGS__)
51#define CH_WARN_RATELIMIT(adap, fmt, ...) log(LOG_WARNING, "%s: " fmt, \
52 device_get_nameunit((adap)->dev), ##__VA_ARGS__)
54#ifndef LINUX_TYPES_DEFINED
72#if BYTE_ORDER == BIG_ENDIAN
73#define __BIG_ENDIAN_BITFIELD
74#elif BYTE_ORDER == LITTLE_ENDIAN
75#define __LITTLE_ENDIAN_BITFIELD
77#error "Must set BYTE_ORDER"
80#ifndef __bool_true_false_are_defined
88#define mdelay(x) DELAY((x) * 1000)
89#define udelay(x) DELAY(x)
91#define simple_strtoul strtoul
92#define DIV_ROUND_UP(x, y) howmany(x, y)
94#define ARRAY_SIZE(x) nitems(x)
95#define container_of(p, s, f) ((s *)(((uint8_t *)(p)) - offsetof(s, f)))
97#define swab16(x) bswap16(x)
98#define swab32(x) bswap32(x)
99#define swab64(x) bswap64(x)
100#define le16_to_cpu(x) le16toh(x)
101#define le32_to_cpu(x) le32toh(x)
102#define le64_to_cpu(x) le64toh(x)
103#define cpu_to_le16(x) htole16(x)
104#define cpu_to_le32(x) htole32(x)
105#define cpu_to_le64(x) htole64(x)
106#define be16_to_cpu(x) be16toh(x)
107#define be32_to_cpu(x) be32toh(x)
108#define be64_to_cpu(x) be64toh(x)
109#define cpu_to_be16(x) htobe16(x)
110#define cpu_to_be32(x) htobe32(x)
111#define cpu_to_be64(x) htobe64(x)
115#define AUTONEG_AUTO (-1)
116#define AUTONEG_DISABLE 0
117#define AUTONEG_ENABLE 1
119#define PCI_DEVICE_ID PCIR_DEVICE
120#define PCI_CAP_ID_VPD PCIY_VPD
121#define PCI_VPD_ADDR PCIR_VPD_ADDR
122#define PCI_VPD_ADDR_F 0x8000
123#define PCI_VPD_DATA PCIR_VPD_DATA
125#define PCI_CAP_ID_EXP PCIY_EXPRESS
126#define PCI_EXP_DEVCTL PCIER_DEVICE_CTL
127#define PCI_EXP_DEVCTL_PAYLOAD PCIEM_CTL_MAX_PAYLOAD
128#define PCI_EXP_DEVCTL_READRQ PCIEM_CTL_MAX_READ_REQUEST
129#define PCI_EXP_LNKCTL PCIER_LINK_CTL
130#define PCI_EXP_LNKSTA PCIER_LINK_STA
131#define PCI_EXP_LNKSTA_CLS PCIEM_LINK_STA_SPEED
132#define PCI_EXP_LNKSTA_NLW PCIEM_LINK_STA_WIDTH
133#define PCI_EXP_DEVCTL2 PCIER_DEVICE_CTL2
138 KASSERT(x > 0 && powerof2(x), (
"%s: invalid arg %ld", __func__, x));
140 return (flsl(x) - 1);
146 char c, *
r, *trim_at;
152 while ((c = *s++) != 0) {
static char * strstrip(char *s)