Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/mxge/if_mxge.c
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
#include <sys/kdb.h> | #include <sys/kdb.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/sx.h> | #include <sys/sx.h> | ||||
#include <sys/taskqueue.h> | #include <sys/taskqueue.h> | ||||
#include <sys/zlib.h> | #include <zlib.h> | ||||
ota_j.email.ne.jp: I've seen the header file ordering policy somewhere and stating to order by alphabetic order. | |||||
#include <net/if.h> | #include <net/if.h> | ||||
#include <net/if_var.h> | #include <net/if_var.h> | ||||
#include <net/if_arp.h> | #include <net/if_arp.h> | ||||
#include <net/ethernet.h> | #include <net/ethernet.h> | ||||
#include <net/if_dl.h> | #include <net/if_dl.h> | ||||
#include <net/if_media.h> | #include <net/if_media.h> | ||||
▲ Show 20 Lines • Show All 620 Lines • ▼ Show 20 Lines | device_printf(sc->dev, "Driver needs %d.%d\n", | ||||
MXGEFW_VERSION_MAJOR, MXGEFW_VERSION_MINOR); | MXGEFW_VERSION_MAJOR, MXGEFW_VERSION_MINOR); | ||||
return EINVAL; | return EINVAL; | ||||
} | } | ||||
return 0; | return 0; | ||||
} | } | ||||
static void * | static void * | ||||
z_alloc(void *nil, u_int items, u_int size) | mxge_zalloc(void *nil, u_int items, u_int size) | ||||
{ | { | ||||
void *ptr; | void *ptr; | ||||
ptr = malloc(items * size, M_TEMP, M_NOWAIT); | ptr = malloc(items * size, M_TEMP, M_NOWAIT); | ||||
return ptr; | return ptr; | ||||
} | } | ||||
static void | static void | ||||
z_free(void *nil, void *ptr) | mxge_zfree(void *nil, void *ptr) | ||||
{ | { | ||||
free(ptr, M_TEMP); | free(ptr, M_TEMP); | ||||
} | } | ||||
static int | static int | ||||
mxge_load_firmware_helper(mxge_softc_t *sc, uint32_t *limit) | mxge_load_firmware_helper(mxge_softc_t *sc, uint32_t *limit) | ||||
{ | { | ||||
Show All 13 Lines | device_printf(sc->dev, "Could not find firmware image %s\n", | ||||
sc->fw_name); | sc->fw_name); | ||||
return ENOENT; | return ENOENT; | ||||
} | } | ||||
/* setup zlib and decompress f/w */ | /* setup zlib and decompress f/w */ | ||||
bzero(&zs, sizeof (zs)); | bzero(&zs, sizeof (zs)); | ||||
zs.zalloc = z_alloc; | zs.zalloc = mxge_zalloc; | ||||
zs.zfree = z_free; | zs.zfree = mxge_zfree; | ||||
status = inflateInit(&zs); | status = z_inflateInit(&zs); | ||||
if (status != Z_OK) { | if (status != Z_OK) { | ||||
status = EIO; | status = EIO; | ||||
goto abort_with_fw; | goto abort_with_fw; | ||||
} | } | ||||
/* the uncompressed size is stored as the firmware version, | /* the uncompressed size is stored as the firmware version, | ||||
which would otherwise go unused */ | which would otherwise go unused */ | ||||
fw_len = (size_t) fw->version; | fw_len = (size_t) fw->version; | ||||
inflate_buffer = malloc(fw_len, M_TEMP, M_NOWAIT); | inflate_buffer = malloc(fw_len, M_TEMP, M_NOWAIT); | ||||
if (inflate_buffer == NULL) | if (inflate_buffer == NULL) | ||||
goto abort_with_zs; | goto abort_with_zs; | ||||
zs.avail_in = fw->datasize; | zs.avail_in = fw->datasize; | ||||
zs.next_in = __DECONST(char *, fw->data); | zs.next_in = __DECONST(char *, fw->data); | ||||
zs.avail_out = fw_len; | zs.avail_out = fw_len; | ||||
zs.next_out = inflate_buffer; | zs.next_out = inflate_buffer; | ||||
status = inflate(&zs, Z_FINISH); | status = z_inflate(&zs, Z_FINISH); | ||||
if (status != Z_STREAM_END) { | if (status != Z_STREAM_END) { | ||||
device_printf(sc->dev, "zlib %d\n", status); | device_printf(sc->dev, "zlib %d\n", status); | ||||
status = EIO; | status = EIO; | ||||
goto abort_with_buffer; | goto abort_with_buffer; | ||||
} | } | ||||
/* check id */ | /* check id */ | ||||
hdr_offset = htobe32(*(const uint32_t *) | hdr_offset = htobe32(*(const uint32_t *) | ||||
Show All 19 Lines | for (i = 0; i < fw_len; i += 256) { | ||||
wmb(); | wmb(); | ||||
} | } | ||||
*limit = fw_len; | *limit = fw_len; | ||||
status = 0; | status = 0; | ||||
abort_with_buffer: | abort_with_buffer: | ||||
free(inflate_buffer, M_TEMP); | free(inflate_buffer, M_TEMP); | ||||
abort_with_zs: | abort_with_zs: | ||||
inflateEnd(&zs); | z_inflateEnd(&zs); | ||||
abort_with_fw: | abort_with_fw: | ||||
firmware_put(fw, FIRMWARE_UNLOAD); | firmware_put(fw, FIRMWARE_UNLOAD); | ||||
return status; | return status; | ||||
} | } | ||||
/* | /* | ||||
* Enable or disable periodic RDMAs from the host to make certain | * Enable or disable periodic RDMAs from the host to make certain | ||||
* chipsets resend dropped PCIe messages | * chipsets resend dropped PCIe messages | ||||
▲ Show 20 Lines • Show All 4,305 Lines • Show Last 20 Lines |
I've seen the header file ordering policy somewhere and stating to order by alphabetic order.
Should I move zlib.h lower?