diff options
author | yongari <yongari@FreeBSD.org> | 2010-08-28 00:34:22 +0000 |
---|---|---|
committer | yongari <yongari@FreeBSD.org> | 2010-08-28 00:34:22 +0000 |
commit | 8203781f0e877f100602ff4676f0e5da09890261 (patch) | |
tree | afd3011d44393f04dc0215f819448c55b43cd532 /sys/dev/ixgb | |
parent | c4045967a29d41b5ba3c97b74ba4a05831e19c48 (diff) | |
download | FreeBSD-src-8203781f0e877f100602ff4676f0e5da09890261.zip FreeBSD-src-8203781f0e877f100602ff4676f0e5da09890261.tar.gz |
Do not allocate multicast array memory in multicast filter
configuration function. For failed memory allocations, em(4)/lem(4)
called panic(9) which is not acceptable on production box.
igb(4)/ixgb(4)/ix(4) allocated the required memory in stack which
consumed 768 bytes of stack memory which looks too big.
To address these issues, allocate multicast array memory in device
attach time and make multicast configuration success under any
conditions. This change also removes the excessive use of memory in
stack.
Reviewed by: jfv
Diffstat (limited to 'sys/dev/ixgb')
-rw-r--r-- | sys/dev/ixgb/if_ixgb.c | 17 | ||||
-rw-r--r-- | sys/dev/ixgb/if_ixgb.h | 2 |
2 files changed, 18 insertions, 1 deletions
diff --git a/sys/dev/ixgb/if_ixgb.c b/sys/dev/ixgb/if_ixgb.c index edb352f..e5cddb3 100644 --- a/sys/dev/ixgb/if_ixgb.c +++ b/sys/dev/ixgb/if_ixgb.c @@ -324,6 +324,15 @@ ixgb_attach(device_t dev) } adapter->rx_desc_base = (struct ixgb_rx_desc *) adapter->rxdma.dma_vaddr; + /* Allocate multicast array memory. */ + adapter->mta = malloc(sizeof(u_int8_t) * IXGB_ETH_LENGTH_OF_ADDRESS * + MAX_NUM_MULTICAST_ADDRESSES, M_DEVBUF, M_NOWAIT); + if (adapter->mta == NULL) { + device_printf(dev, "Can not allocate multicast setup array\n"); + error = ENOMEM; + goto err_hw_init; + } + /* Initialize the hardware */ if (ixgb_hardware_init(adapter)) { device_printf(dev, "Unable to initialize the hardware\n"); @@ -351,6 +360,7 @@ err_pci: if_free(adapter->ifp); ixgb_free_pci_resources(adapter); sysctl_ctx_free(&adapter->sysctl_ctx); + free(adapter->mta, M_DEVBUF); return (error); } @@ -412,6 +422,7 @@ ixgb_detach(device_t dev) adapter->next->prev = adapter->prev; if (adapter->prev != NULL) adapter->prev->next = adapter->next; + free(adapter->mta, M_DEVBUF); IXGB_LOCK_DESTROY(adapter); return (0); @@ -1069,13 +1080,17 @@ static void ixgb_set_multi(struct adapter * adapter) { u_int32_t reg_rctl = 0; - u_int8_t mta[MAX_NUM_MULTICAST_ADDRESSES * IXGB_ETH_LENGTH_OF_ADDRESS]; + u_int8_t *mta; struct ifmultiaddr *ifma; int mcnt = 0; struct ifnet *ifp = adapter->ifp; IOCTL_DEBUGOUT("ixgb_set_multi: begin"); + mta = adapter->mta; + bzero(mta, sizeof(u_int8_t) * IXGB_ETH_LENGTH_OF_ADDRESS * + MAX_NUM_MULTICAST_ADDRESSES); + if_maddr_rlock(ifp); #if __FreeBSD_version < 500000 LIST_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { diff --git a/sys/dev/ixgb/if_ixgb.h b/sys/dev/ixgb/if_ixgb.h index 9e5355a..4e88db7 100644 --- a/sys/dev/ixgb/if_ixgb.h +++ b/sys/dev/ixgb/if_ixgb.h @@ -344,6 +344,8 @@ struct adapter { struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; + /* Multicast array memory */ + u_int8_t *mta; /* Misc stats maintained by the driver */ unsigned long dropped_pkts; unsigned long mbuf_alloc_failed; |