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 <contrib/zlib/zlib.h> | ||||
#include <dev/zlib/zcalloc.h> | |||||
#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 81 Lines • ▼ Show 20 Lines | static driver_t mxge_driver = | ||||
sizeof(mxge_softc_t), | sizeof(mxge_softc_t), | ||||
}; | }; | ||||
static devclass_t mxge_devclass; | static devclass_t mxge_devclass; | ||||
/* Declare ourselves to be a child of the PCI bus.*/ | /* Declare ourselves to be a child of the PCI bus.*/ | ||||
DRIVER_MODULE(mxge, pci, mxge_driver, mxge_devclass, 0, 0); | DRIVER_MODULE(mxge, pci, mxge_driver, mxge_devclass, 0, 0); | ||||
MODULE_DEPEND(mxge, firmware, 1, 1, 1); | MODULE_DEPEND(mxge, firmware, 1, 1, 1); | ||||
MODULE_DEPEND(mxge, zlib, 1, 1, 1); | MODULE_DEPEND(mxge, zlib, 1, 1, 1); | ||||
ota_j.email.ne.jp: We have had zlib dependency here. | |||||
static int mxge_load_firmware(mxge_softc_t *sc, int adopt); | static int mxge_load_firmware(mxge_softc_t *sc, int adopt); | ||||
static int mxge_send_cmd(mxge_softc_t *sc, uint32_t cmd, mxge_cmd_t *data); | static int mxge_send_cmd(mxge_softc_t *sc, uint32_t cmd, mxge_cmd_t *data); | ||||
static int mxge_close(mxge_softc_t *sc, int down); | static int mxge_close(mxge_softc_t *sc, int down); | ||||
static int mxge_open(mxge_softc_t *sc); | static int mxge_open(mxge_softc_t *sc); | ||||
static void mxge_tick(void *arg); | static void mxge_tick(void *arg); | ||||
static int | static int | ||||
▲ Show 20 Lines • Show All 521 Lines • ▼ Show 20 Lines | if (!(sc->fw_ver_major == MXGEFW_VERSION_MAJOR | ||||
device_printf(sc->dev, "Driver needs %d.%d\n", | 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 * | |||||
z_alloc(void *nil, u_int items, u_int size) | |||||
{ | |||||
void *ptr; | |||||
ptr = malloc(items * size, M_TEMP, M_NOWAIT); | |||||
return ptr; | |||||
} | |||||
static void | |||||
z_free(void *nil, void *ptr) | |||||
{ | |||||
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) | ||||
{ | { | ||||
z_stream zs; | z_stream zs; | ||||
char *inflate_buffer; | char *inflate_buffer; | ||||
const struct firmware *fw; | const struct firmware *fw; | ||||
const mcp_gen_header_t *hdr; | const mcp_gen_header_t *hdr; | ||||
unsigned hdr_offset; | unsigned hdr_offset; | ||||
int status; | int status; | ||||
unsigned int i; | unsigned int i; | ||||
char dummy; | char dummy; | ||||
size_t fw_len; | size_t fw_len; | ||||
fw = firmware_get(sc->fw_name); | fw = firmware_get(sc->fw_name); | ||||
if (fw == NULL) { | if (fw == NULL) { | ||||
device_printf(sc->dev, "Could not find firmware image %s\n", | 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 = zcalloc_nowait; | ||||
zs.zfree = z_free; | |||||
delphijUnsubmitted Not Done Inline ActionsI think inflateInit() still expects zfree be set? delphij: I think inflateInit() still expects zfree be set? | |||||
status = inflateInit(&zs); | status = 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 */ | ||||
▲ Show 20 Lines • Show All 4,358 Lines • Show Last 20 Lines |
We have had zlib dependency here.