freebsd_iflib: Upgrade to that of FreeBSD 13.

ipro1000 still works.
This commit is contained in:
Augustin Cavalier
2021-10-20 19:13:19 -04:00
parent 034d500610
commit b14f1ca97c
7 changed files with 1222 additions and 834 deletions
@@ -48,7 +48,7 @@ typedef uint16_t qidx_t;
struct iflib_ctx;
typedef struct iflib_ctx *if_ctx_t;
struct if_shared_ctx;
typedef struct if_shared_ctx *if_shared_ctx_t;
typedef const struct if_shared_ctx *if_shared_ctx_t;
struct if_int_delay_info;
typedef struct if_int_delay_info *if_int_delay_info_t;
struct if_pseudo;
@@ -94,7 +94,6 @@ typedef struct if_rxd_info {
typedef struct if_rxd_update {
uint64_t *iru_paddrs;
caddr_t *iru_vaddrs;
qidx_t *iru_idxs;
qidx_t iru_pidx;
uint16_t iru_qsidx;
@@ -167,13 +166,13 @@ typedef struct pci_vendor_info {
uint32_t pvi_class_mask;
const char *pvi_name;
} pci_vendor_info_t;
#define PVID(vendor, devid, name) {vendor, devid, 0, 0, 0, 0, name}
#define PVID_OEM(vendor, devid, svid, sdevid, revid, name) {vendor, devid, svid, sdevid, revid, 0, name}
#define PVID_END {0, 0, 0, 0, 0, 0, NULL}
#define IFLIB_PNP_DESCR "U32:vendor;U32:device;U32:subvendor;U32:subdevice;" \
"U32:revision;U32:class;D:#"
/* No drivers in tree currently match on anything except vendor:device. */
#define IFLIB_PNP_DESCR "U32:vendor;U32:device;U32:#;U32:#;" \
"U32:#;U32:#;D:#"
#define IFLIB_PNP_INFO(b, u, t) \
MODULE_PNP_INFO(IFLIB_PNP_DESCR, b, u, t, nitems(t) - 1)
@@ -219,6 +218,9 @@ typedef struct if_softc_ctx {
uint32_t __spare2__;
iflib_intr_mode_t isc_intr;
uint16_t isc_rxd_buf_size[8]; /* set at init time by driver, 0
means use iflib-calculated size
based on isc_max_frame_size */
uint16_t isc_max_frame_size; /* set at init time by driver */
uint16_t isc_min_frame_size; /* set at init time by driver, only used if
IFLIB_NEED_ETHER_PAD is set. */
@@ -285,15 +287,32 @@ typedef struct iflib_dma_info {
#define IFLIB_MAGIC 0xCAFEF00D
typedef enum {
/* Interrupt or softirq handles only receive */
IFLIB_INTR_RX,
/* Interrupt or softirq handles only transmit */
IFLIB_INTR_TX,
/*
* Interrupt will check for both pending receive
* and available tx credits and dispatch a task
* for one or both depending on the disposition
* of the respective queues.
*/
IFLIB_INTR_RXTX,
/*
* Other interrupt - typically link status and
* or error conditions.
*/
IFLIB_INTR_ADMIN,
/* Softirq (task) for iov handling */
IFLIB_INTR_IOV,
} iflib_intr_type_t;
/*
* Interface has a separate command queue for RX
* Interface has a separate completion queue for RX
*/
#define IFLIB_HAS_RXCQ 0x01
/*
@@ -305,7 +324,7 @@ typedef enum {
*/
#define IFLIB_IS_VF 0x04
/*
* Interface has a separate command queue for TX
* Interface has a separate completion queue for TX
*/
#define IFLIB_HAS_TXCQ 0x08
/*
@@ -365,6 +384,25 @@ typedef enum {
* Driver will pass the media
*/
#define IFLIB_DRIVER_MEDIA 0x20000
/*
* When using a single hardware interrupt for the interface, only process RX
* interrupts instead of doing combined RX/TX processing.
*/
#define IFLIB_SINGLE_IRQ_RX_ONLY 0x40000
/*
* Don't need/want most of the niceties of
* emulating ethernet
*/
#define IFLIB_PSEUDO_ETHER 0x80000
/*
* These enum values are used in iflib_needs_restart to indicate to iflib
* functions whether or not the interface needs restarting when certain events
* happen.
*/
enum iflib_restart_event {
IFLIB_RESTART_VLAN_CONFIG,
};
/*
* field accessors
File diff suppressed because it is too large Load Diff
-4
View File
@@ -109,7 +109,6 @@ drain_ring_locked(struct ifmp_ring *r, union ring_state os, uint16_t prev, int b
total = 0;
while (cidx != pidx) {
/* Items from cidx to pidx are available for consumption. */
n = r->drain(r, cidx, pidx);
if (n == 0) {
@@ -184,7 +183,6 @@ drain_ring_lockless(struct ifmp_ring *r, union ring_state os, uint16_t prev, int
total = 0;
while (cidx != pidx) {
/* Items from cidx to pidx are available for consumption. */
n = r->drain(r, cidx, pidx);
if (n == 0) {
@@ -491,7 +489,6 @@ ifmp_ring_check_drainage(struct ifmp_ring *r, int budget)
ns.state = os.state;
ns.flags = BUSY;
#ifdef MP_RING_NO_64BIT_ATOMICS
mtx_lock(&r->lock);
if (r->state != os.state) {
@@ -509,7 +506,6 @@ ifmp_ring_check_drainage(struct ifmp_ring *r, int budget)
if (!atomic_cmpset_acq_64(&r->state, os.state, ns.state))
return;
drain_ring_lockless(r, ns, os.flags, budget);
#endif
}
+5 -4
View File
@@ -52,13 +52,13 @@ typedef struct nvpair nvpair_t;
#define NV_FLAG_IN_ARRAY 0x100
#ifdef _KERNEL
#define nv_malloc(size) malloc((size), M_NVLIST, M_WAITOK)
#define nv_malloc(size) malloc((size), M_NVLIST, M_NOWAIT)
#define nv_calloc(n, size) mallocarray((n), (size), M_NVLIST, \
M_WAITOK | M_ZERO)
M_NOWAIT | M_ZERO)
#define nv_realloc(buf, size) realloc((buf), (size), M_NVLIST, \
M_WAITOK)
M_NOWAIT)
#define nv_free(buf) free((buf), M_NVLIST)
#define nv_strdup(buf) strdup((buf), M_NVLIST)
#define nv_strdup(buf) strdup_flags((buf), M_NVLIST, M_NOWAIT)
#define nv_vasprintf(ptr, ...) vasprintf(ptr, M_NVLIST, __VA_ARGS__)
#define ERRNO_SET(var) do { } while (0)
@@ -103,6 +103,7 @@ bool nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp);
void nvlist_set_parent(nvlist_t *nvl, nvpair_t *parent);
void nvlist_set_array_next(nvlist_t *nvl, nvpair_t *ele);
nvpair_t *nvlist_get_array_next_nvpair(nvlist_t *nvl);
const nvpair_t *nvlist_get_nvpair(const nvlist_t *nvl, const char *name);
+64 -77
View File
@@ -99,6 +99,7 @@ struct nvlist {
int nvl_magic;
int nvl_error;
int nvl_flags;
size_t nvl_datasize;
nvpair_t *nvl_parent;
nvpair_t *nvl_array_next;
struct nvl_head nvl_head;
@@ -139,6 +140,7 @@ nvlist_create(int flags)
nvl->nvl_flags = flags;
nvl->nvl_parent = NULL;
nvl->nvl_array_next = NULL;
nvl->nvl_datasize = sizeof(struct nvlist_header);
TAILQ_INIT(&nvl->nvl_head);
nvl->nvl_magic = NVLIST_MAGIC;
@@ -247,6 +249,60 @@ nvlist_set_array_next(nvlist_t *nvl, nvpair_t *ele)
nvl->nvl_array_next = ele;
}
static void
nvlist_update_size(nvlist_t *nvl, nvpair_t *new, ssize_t mul)
{
ssize_t size;
size_t nitems;
const nvlist_t *nvlistnew;
const nvlist_t * const *nvlarray;
nvlist_t *parent;
unsigned int ii;
NVLIST_ASSERT(nvl);
NVPAIR_ASSERT(new);
PJDLOG_ASSERT(mul == 1 || mul == -1);
size = nvpair_header_size();
size += strlen(nvpair_name(new)) + 1;
if (nvpair_type(new) == NV_TYPE_NVLIST) {
nvlistnew = nvpair_get_nvlist(new);
size += nvlistnew->nvl_datasize;
size += nvpair_header_size() + 1;
} else if (nvpair_type(new) == NV_TYPE_NVLIST_ARRAY) {
nvlarray = nvpair_get_nvlist_array(new, &nitems);
PJDLOG_ASSERT(nitems > 0);
size += (nvpair_header_size() + 1) * nitems;
for (ii = 0; ii < nitems; ii++) {
PJDLOG_ASSERT(nvlarray[ii]->nvl_error == 0);
size += nvlarray[ii]->nvl_datasize;
}
} else {
size += nvpair_size(new);
}
size *= mul;
nvl->nvl_datasize += size;
parent = nvl;
while ((parent = __DECONST(nvlist_t *,
nvlist_get_parent(parent, NULL))) != NULL) {
parent->nvl_datasize += size;
}
}
nvpair_t *
nvlist_get_array_next_nvpair(nvlist_t *nvl)
{
NVLIST_ASSERT(nvl);
return (nvl->nvl_array_next);
}
bool
nvlist_in_array(const nvlist_t *nvl)
{
@@ -631,78 +687,8 @@ nvlist_fdump(const nvlist_t *nvl, FILE *fp)
size_t
nvlist_size(const nvlist_t *nvl)
{
const nvlist_t *tmpnvl;
const nvlist_t * const *nvlarray;
const nvpair_t *nvp, *tmpnvp;
void *cookie;
size_t size, nitems;
unsigned int ii;
NVLIST_ASSERT(nvl);
PJDLOG_ASSERT(nvl->nvl_error == 0);
size = sizeof(struct nvlist_header);
nvp = nvlist_first_nvpair(nvl);
while (nvp != NULL) {
size += nvpair_header_size();
size += strlen(nvpair_name(nvp)) + 1;
if (nvpair_type(nvp) == NV_TYPE_NVLIST) {
size += sizeof(struct nvlist_header);
size += nvpair_header_size() + 1;
tmpnvl = nvpair_get_nvlist(nvp);
PJDLOG_ASSERT(tmpnvl->nvl_error == 0);
tmpnvp = nvlist_first_nvpair(tmpnvl);
if (tmpnvp != NULL) {
nvl = tmpnvl;
nvp = tmpnvp;
continue;
}
} else if (nvpair_type(nvp) == NV_TYPE_NVLIST_ARRAY) {
nvlarray = nvpair_get_nvlist_array(nvp, &nitems);
PJDLOG_ASSERT(nitems > 0);
size += (nvpair_header_size() + 1) * nitems;
size += sizeof(struct nvlist_header) * nitems;
tmpnvl = NULL;
tmpnvp = NULL;
for (ii = 0; ii < nitems; ii++) {
PJDLOG_ASSERT(nvlarray[ii]->nvl_error == 0);
tmpnvp = nvlist_first_nvpair(nvlarray[ii]);
if (tmpnvp != NULL) {
tmpnvl = nvlarray[ii];
break;
}
}
if (tmpnvp != NULL) {
nvp = tmpnvp;
nvl = tmpnvl;
continue;
}
} else {
size += nvpair_size(nvp);
}
while ((nvp = nvlist_next_nvpair(nvl, nvp)) == NULL) {
do {
cookie = NULL;
nvl = nvlist_get_pararr(nvl, &cookie);
if (nvl == NULL)
goto out;
if (nvlist_in_array(nvl) && cookie == NULL) {
nvp = nvlist_first_nvpair(nvl);
} else {
nvp = cookie;
}
} while (nvp == NULL);
if (nvlist_in_array(nvl) && cookie == NULL)
break;
}
}
out:
return (size);
return (nvl->nvl_datasize);
}
#ifndef _KERNEL
@@ -1365,7 +1351,7 @@ nvlist_first_nvpair(const nvlist_t *nvl)
}
nvpair_t *
nvlist_next_nvpair(const nvlist_t *nvl, const nvpair_t *nvp)
nvlist_next_nvpair(const nvlist_t *nvl __unused, const nvpair_t *nvp)
{
nvpair_t *retnvp;
@@ -1381,7 +1367,7 @@ nvlist_next_nvpair(const nvlist_t *nvl, const nvpair_t *nvp)
}
nvpair_t *
nvlist_prev_nvpair(const nvlist_t *nvl, const nvpair_t *nvp)
nvlist_prev_nvpair(const nvlist_t *nvl __unused, const nvpair_t *nvp)
{
nvpair_t *retnvp;
@@ -1474,12 +1460,9 @@ nvlist_add_nvpair(nvlist_t *nvl, const nvpair_t *nvp)
}
nvpair_insert(&nvl->nvl_head, newnvp, nvl);
nvlist_update_size(nvl, newnvp, 1);
}
void
nvlist_add_stringv(nvlist_t *nvl, const char *name, const char *valuefmt,
va_list valueap);
void
nvlist_add_stringf(nvlist_t *nvl, const char *name, const char *valuefmt, ...)
{
@@ -1626,10 +1609,12 @@ nvlist_append_##type##_array(nvlist_t *nvl, const char *name, vtype value)\
nvlist_add_##type##_array(nvl, name, &value, 1); \
return; \
} \
nvlist_update_size(nvl, nvp, -1); \
if (nvpair_append_##type##_array(nvp, value) == -1) { \
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM); \
ERRNO_SET(nvl->nvl_error); \
} \
nvlist_update_size(nvl, nvp, 1); \
}
NVLIST_APPEND_ARRAY(const bool, bool, BOOL)
@@ -1664,6 +1649,7 @@ nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp)
}
nvpair_insert(&nvl->nvl_head, nvp, nvl);
nvlist_update_size(nvl, nvp, 1);
return (true);
}
@@ -2015,6 +2001,7 @@ nvlist_remove_nvpair(nvlist_t *nvl, nvpair_t *nvp)
PJDLOG_ASSERT(nvpair_nvlist(nvp) == nvl);
nvpair_remove(&nvl->nvl_head, nvp, nvl);
nvlist_update_size(nvl, nvp, -1);
}
void
@@ -0,0 +1,14 @@
/*
* Copyright 2021, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _FBSD_COMPAT_NET_DEBUGNET_H
#define _FBSD_COMPAT_NET_DEBUGNET_H
#define DEBUGNET_DEFINE(driver)
#define DEBUGNET_REINIT(ifp)
#define DEBUGNET_SET(ifp, driver)
#endif /* _FBSD_COMPAT_NET_DEBUGNET_H */
@@ -1,14 +0,0 @@
/*
* Copyright 2018, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _FBSD_COMPAT_NETINET_NETDUMP_H_
#define _FBSD_COMPAT_NETINET_NETDUMP_H_
#define NETDUMP_DEFINE(driver)
#define NETDUMP_REINIT(ifp)
#define NETDUMP_SET(ifp, driver)
#endif /* _FBSD_COMPAT_NETINET_NETDUMP_H_ */