mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-24 07:40:52 +00:00
- Enable static building of mxge(4) and its firmware.
- Add custom .c wrappers for the firmware, rather than the standard firmware(9) generated firmware objects to work around toolchain problems on ia64 involving linking objects produced by ld -b -binary into the kernel. - Move from using Myricom's ".dat" firmware blobs to using Myricom's zlib compressed ".h" firmware header files. This is done to facilitate the custom wrappers, and saves a fair amount of wired memory in the case where the firmware is built in, or preloaded. - Fix two compile issues in mxge which only appear on non-i386/amd64. Reviewed by: mlaier, mav (earlier version with just zlib support) Glanced at by: sam Approved by: re (kensmith)
This commit is contained in:
parent
b68038fa8c
commit
f9ae02802f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=171500
@ -1899,6 +1899,7 @@ device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'')
|
||||
# PCI Ethernet NICs.
|
||||
device de # DEC/Intel DC21x4x (``Tulip'')
|
||||
device le # AMD Am7900 LANCE and Am79C9xx PCnet
|
||||
device mxge # Myricom Myri-10G 10GbE NIC
|
||||
device nxge # Neterion Xframe 10GbE Server/Storage Adapter
|
||||
device txp # 3Com 3cR990 (``Typhoon'')
|
||||
device vx # 3Com 3c590, 3c595 (``Vortex'')
|
||||
|
@ -812,6 +812,10 @@ dev/mpt/mpt_debug.c optional mpt
|
||||
dev/mpt/mpt_pci.c optional mpt pci
|
||||
dev/mpt/mpt_raid.c optional mpt
|
||||
dev/msk/if_msk.c optional msk
|
||||
dev/mxge/if_mxge.c optional mxge pci
|
||||
dev/mxge/mxge_lro.c optional mxge pci
|
||||
dev/mxge/mxge_eth_z8e.c optional mxge pci
|
||||
dev/mxge/mxge_ethp_z8e.c optional mxge pci
|
||||
dev/my/if_my.c optional my
|
||||
dev/ncv/ncr53c500.c optional ncv
|
||||
dev/ncv/ncr53c500_pccard.c optional ncv pccard
|
||||
@ -1630,7 +1634,7 @@ net/rtsock.c standard
|
||||
net/slcompress.c optional netgraph_vjc | ppp | sl | sppp | \
|
||||
netgraph_sppp
|
||||
net/zlib.c optional crypto | geom_uzip | ipsec | \
|
||||
ppp_deflate | netgraph_deflate
|
||||
mxge | ppp_deflate | netgraph_deflate
|
||||
net80211/ieee80211.c optional wlan
|
||||
net80211/ieee80211_acl.c optional wlan_acl
|
||||
net80211/ieee80211_amrr.c optional wlan_amrr
|
||||
|
File diff suppressed because it is too large
Load Diff
12386
sys/dev/mxge/eth_z8e.h
Normal file
12386
sys/dev/mxge/eth_z8e.h
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
12455
sys/dev/mxge/ethp_z8e.h
Normal file
12455
sys/dev/mxge/ethp_z8e.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -124,6 +124,7 @@ static devclass_t mxge_devclass;
|
||||
/* Declare ourselves to be a child of the PCI bus.*/
|
||||
DRIVER_MODULE(mxge, pci, mxge_driver, mxge_devclass, 0, 0);
|
||||
MODULE_DEPEND(mxge, firmware, 1, 1, 1);
|
||||
MODULE_DEPEND(mxge, zlib, 1, 1, 1);
|
||||
|
||||
static int mxge_load_firmware(mxge_softc_t *sc);
|
||||
static int mxge_send_cmd(mxge_softc_t *sc, uint32_t cmd, mxge_cmd_t *data);
|
||||
@ -145,6 +146,7 @@ mxge_probe(device_t dev)
|
||||
static void
|
||||
mxge_enable_wc(mxge_softc_t *sc)
|
||||
{
|
||||
#if defined(__i386) || defined(__amd64)
|
||||
struct mem_range_desc mrdesc;
|
||||
vm_paddr_t pa;
|
||||
vm_offset_t len;
|
||||
@ -152,7 +154,6 @@ mxge_enable_wc(mxge_softc_t *sc)
|
||||
|
||||
sc->wc = 1;
|
||||
len = rman_get_size(sc->mem_res);
|
||||
#if defined(__i386) || defined(__amd64)
|
||||
err = pmap_change_attr((vm_offset_t) sc->sram,
|
||||
len, PAT_WRITE_COMBINING);
|
||||
if (err == 0)
|
||||
@ -160,7 +161,6 @@ mxge_enable_wc(mxge_softc_t *sc)
|
||||
else
|
||||
device_printf(sc->dev, "pmap_change_attr failed, %d\n",
|
||||
err);
|
||||
#endif
|
||||
pa = rman_get_start(sc->mem_res);
|
||||
mrdesc.mr_base = pa;
|
||||
mrdesc.mr_len = len;
|
||||
@ -174,6 +174,7 @@ mxge_enable_wc(mxge_softc_t *sc)
|
||||
"w/c failed for pa 0x%lx, len 0x%lx, err = %d\n",
|
||||
(unsigned long)pa, (unsigned long)len, err);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -423,7 +424,7 @@ mxge_enable_nvidia_ecrc(mxge_softc_t *sc)
|
||||
}
|
||||
#else
|
||||
static void
|
||||
mxge_enable_nvidia_ecrc(mxge_softc_t *sc, device_t pdev)
|
||||
mxge_enable_nvidia_ecrc(mxge_softc_t *sc)
|
||||
{
|
||||
device_printf(sc->dev,
|
||||
"Nforce 4 chipset on non-x86/amd64!?!?!\n");
|
||||
@ -644,62 +645,101 @@ mxge_validate_firmware(mxge_softc_t *sc, const mcp_gen_header_t *hdr)
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
mxge_load_firmware_helper(mxge_softc_t *sc, uint32_t *limit)
|
||||
{
|
||||
z_stream zs;
|
||||
char *inflate_buffer;
|
||||
const struct firmware *fw;
|
||||
const mcp_gen_header_t *hdr;
|
||||
unsigned hdr_offset;
|
||||
const char *fw_data;
|
||||
union qualhack hack;
|
||||
int status;
|
||||
unsigned int i;
|
||||
char dummy;
|
||||
|
||||
size_t fw_len;
|
||||
|
||||
fw = firmware_get(sc->fw_name);
|
||||
|
||||
if (fw == NULL) {
|
||||
device_printf(sc->dev, "Could not find firmware image %s\n",
|
||||
sc->fw_name);
|
||||
return ENOENT;
|
||||
}
|
||||
if (fw->datasize > *limit ||
|
||||
fw->datasize < MCP_HEADER_PTR_OFFSET + 4) {
|
||||
device_printf(sc->dev, "Firmware image %s too large (%d/%d)\n",
|
||||
sc->fw_name, (int)fw->datasize, (int) *limit);
|
||||
status = ENOSPC;
|
||||
goto abort_with_fw;
|
||||
}
|
||||
*limit = fw->datasize;
|
||||
|
||||
/* check id */
|
||||
fw_data = (const char *)fw->data;
|
||||
hdr_offset = htobe32(*(const uint32_t *)
|
||||
(fw_data + MCP_HEADER_PTR_OFFSET));
|
||||
if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > fw->datasize) {
|
||||
device_printf(sc->dev, "Bad firmware file");
|
||||
|
||||
|
||||
/* setup zlib and decompress f/w */
|
||||
bzero(&zs, sizeof (zs));
|
||||
zs.zalloc = z_alloc;
|
||||
zs.zfree = z_free;
|
||||
status = inflateInit(&zs);
|
||||
if (status != Z_OK) {
|
||||
status = EIO;
|
||||
goto abort_with_fw;
|
||||
}
|
||||
hdr = (const void*)(fw_data + hdr_offset);
|
||||
|
||||
/* the uncompressed size is stored as the firmware version,
|
||||
which would otherwise go unused */
|
||||
fw_len = (size_t) fw->version;
|
||||
inflate_buffer = malloc(fw_len, M_TEMP, M_NOWAIT);
|
||||
if (inflate_buffer == NULL)
|
||||
goto abort_with_zs;
|
||||
zs.avail_in = fw->datasize;
|
||||
zs.next_in = __DECONST(char *, fw->data);
|
||||
zs.avail_out = fw_len;
|
||||
zs.next_out = inflate_buffer;
|
||||
status = inflate(&zs, Z_FINISH);
|
||||
if (status != Z_STREAM_END) {
|
||||
device_printf(sc->dev, "zlib %d\n", status);
|
||||
status = EIO;
|
||||
goto abort_with_buffer;
|
||||
}
|
||||
|
||||
/* check id */
|
||||
hdr_offset = htobe32(*(const uint32_t *)
|
||||
(inflate_buffer + MCP_HEADER_PTR_OFFSET));
|
||||
if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > fw_len) {
|
||||
device_printf(sc->dev, "Bad firmware file");
|
||||
status = EIO;
|
||||
goto abort_with_buffer;
|
||||
}
|
||||
hdr = (const void*)(inflate_buffer + hdr_offset);
|
||||
|
||||
status = mxge_validate_firmware(sc, hdr);
|
||||
if (status != 0)
|
||||
goto abort_with_fw;
|
||||
goto abort_with_buffer;
|
||||
|
||||
hack.ro_char = fw_data;
|
||||
/* Copy the inflated firmware to NIC SRAM. */
|
||||
for (i = 0; i < *limit; i += 256) {
|
||||
for (i = 0; i < fw_len; i += 256) {
|
||||
mxge_pio_copy(sc->sram + MXGE_FW_OFFSET + i,
|
||||
hack.rw_char + i,
|
||||
min(256U, (unsigned)(*limit - i)));
|
||||
inflate_buffer + i,
|
||||
min(256U, (unsigned)(fw_len - i)));
|
||||
mb();
|
||||
dummy = *sc->sram;
|
||||
mb();
|
||||
}
|
||||
|
||||
*limit = fw_len;
|
||||
status = 0;
|
||||
abort_with_buffer:
|
||||
free(inflate_buffer, M_TEMP);
|
||||
abort_with_zs:
|
||||
inflateEnd(&zs);
|
||||
abort_with_fw:
|
||||
firmware_put(fw, FIRMWARE_UNLOAD);
|
||||
return status;
|
||||
@ -3205,7 +3245,6 @@ mxge_fetch_tunables(mxge_softc_t *sc)
|
||||
&mxge_verbose);
|
||||
TUNABLE_INT_FETCH("hw.mxge.ticks", &mxge_ticks);
|
||||
TUNABLE_INT_FETCH("hw.mxge.lro_cnt", &sc->lro_cnt);
|
||||
printf("%d %d\n", sc->lro_cnt, mxge_lro_cnt);
|
||||
if (sc->lro_cnt != 0)
|
||||
mxge_lro_cnt = sc->lro_cnt;
|
||||
|
||||
|
47
sys/dev/mxge/mxge_eth_z8e.c
Normal file
47
sys/dev/mxge/mxge_eth_z8e.c
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* from: FreeBSD: src/sys/tools/fw_stub.awk,v 1.6 2007/03/02 11:42:53 flz
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#include <sys/param.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/linker.h>
|
||||
#include <sys/firmware.h>
|
||||
#include <sys/systm.h>
|
||||
#include <dev/mxge/eth_z8e.h>
|
||||
|
||||
static int
|
||||
mxge_eth_z8e_fw_modevent(module_t mod, int type, void *unused)
|
||||
{
|
||||
const struct firmware *fp, *parent;
|
||||
int error;
|
||||
switch (type) {
|
||||
case MOD_LOAD:
|
||||
|
||||
fp = firmware_register("mxge_eth_z8e", eth_z8e,
|
||||
(size_t)eth_z8e_length,
|
||||
eth_z8e_uncompressed_length, NULL);
|
||||
if (fp == NULL)
|
||||
goto fail_0;
|
||||
parent = fp;
|
||||
return (0);
|
||||
fail_0:
|
||||
return (ENXIO);
|
||||
case MOD_UNLOAD:
|
||||
error = firmware_unregister("mxge_eth_z8e");
|
||||
return (error);
|
||||
}
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
static moduledata_t mxge_eth_z8e_fw_mod = {
|
||||
"mxge_eth_z8e_fw",
|
||||
mxge_eth_z8e_fw_modevent,
|
||||
0
|
||||
};
|
||||
DECLARE_MODULE(mxge_eth_z8e_fw, mxge_eth_z8e_fw_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
|
||||
MODULE_VERSION(mxge_eth_z8e_fw, 1);
|
||||
MODULE_DEPEND(mxge_eth_z8e_fw, firmware, 1, 1, 1);
|
||||
|
47
sys/dev/mxge/mxge_ethp_z8e.c
Normal file
47
sys/dev/mxge/mxge_ethp_z8e.c
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* from: FreeBSD: src/sys/tools/fw_stub.awk,v 1.6 2007/03/02 11:42:53 flz
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#include <sys/param.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/linker.h>
|
||||
#include <sys/firmware.h>
|
||||
#include <sys/systm.h>
|
||||
#include <dev/mxge/ethp_z8e.h>
|
||||
|
||||
static int
|
||||
mxge_ethp_z8e_fw_modevent(module_t mod, int type, void *unused)
|
||||
{
|
||||
const struct firmware *fp, *parent;
|
||||
int error;
|
||||
switch (type) {
|
||||
case MOD_LOAD:
|
||||
|
||||
fp = firmware_register("mxge_ethp_z8e", ethp_z8e,
|
||||
(size_t)ethp_z8e_length,
|
||||
ethp_z8e_uncompressed_length, NULL);
|
||||
if (fp == NULL)
|
||||
goto fail_0;
|
||||
parent = fp;
|
||||
return (0);
|
||||
fail_0:
|
||||
return (ENXIO);
|
||||
case MOD_UNLOAD:
|
||||
error = firmware_unregister("mxge_ethp_z8e");
|
||||
return (error);
|
||||
}
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
static moduledata_t mxge_ethp_z8e_fw_mod = {
|
||||
"mxge_ethp_z8e_fw",
|
||||
mxge_ethp_z8e_fw_modevent,
|
||||
0
|
||||
};
|
||||
DECLARE_MODULE(mxge_ethp_z8e_fw, mxge_ethp_z8e_fw_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
|
||||
MODULE_VERSION(mxge_ethp_z8e_fw, 1);
|
||||
MODULE_DEPEND(mxge_ethp_z8e_fw, firmware, 1, 1, 1);
|
||||
|
@ -170,7 +170,7 @@ SUBDIR= ${_3dfx} \
|
||||
msdosfs_iconv \
|
||||
${_mse} \
|
||||
msk \
|
||||
${_mxge} \
|
||||
mxge \
|
||||
my \
|
||||
${_ncp} \
|
||||
${_ncv} \
|
||||
@ -454,7 +454,6 @@ _iwi= iwi
|
||||
_iwifw= iwifw
|
||||
_ixgb= ixgb
|
||||
_mly= mly
|
||||
_mxge= mxge
|
||||
_nfe= nfe
|
||||
_nve= nve
|
||||
_nxge= nxge
|
||||
@ -513,7 +512,6 @@ _linprocfs= linprocfs
|
||||
_linsysfs= linsysfs
|
||||
_linux= linux
|
||||
_mly= mly
|
||||
_mxge= mxge
|
||||
_ndis= ndis
|
||||
_nfe= nfe
|
||||
_nve= nve
|
||||
|
@ -1,13 +1,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
MXGE= ${.CURDIR}/../../../dev/mxge
|
||||
.PATH= ${MXGE}
|
||||
.PATH: ${.CURDIR}/../../../dev/mxge
|
||||
KMOD= mxge_eth_z8e
|
||||
FIRMWS= eth_z8e.dat:mxge_eth_z8e
|
||||
CLEANFILES+= eth_z8e.dat
|
||||
|
||||
eth_z8e.dat: ${MXGE}/eth_z8e.dat.gz.uu
|
||||
uudecode -p < ${MXGE}/eth_z8e.dat.gz.uu \
|
||||
| gzip -dc > ${.TARGET}
|
||||
SRCS= mxge_eth_z8e.c
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
|
@ -1,13 +1,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
MXGE= ${.CURDIR}/../../../dev/mxge
|
||||
.PATH= ${MXGE}
|
||||
.PATH: ${.CURDIR}/../../../dev/mxge
|
||||
KMOD= mxge_ethp_z8e
|
||||
FIRMWS= ethp_z8e.dat:mxge_ethp_z8e
|
||||
CLEANFILES+= ethp_z8e.dat
|
||||
|
||||
ethp_z8e.dat: ${MXGE}/ethp_z8e.dat.gz.uu
|
||||
uudecode -p < ${MXGE}/ethp_z8e.dat.gz.uu \
|
||||
| gzip -dc > ${.TARGET}
|
||||
SRCS= mxge_ethp_z8e.c
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
|
Loading…
Reference in New Issue
Block a user