1/* $NetBSD: midway.c,v 1.30 1997/09/29 17:40:38 chuck Exp $ */
2/* (sync'd to midway.c 1.68) */
3
4/*-
5 * Copyright (c) 1996 Charles D. Cranor and Washington University.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
--- 18 unchanged lines hidden (view full) ---
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/dev/en/midway.c 170093 2007-05-29 11:28:28Z rwatson $");
36
37/*
38 *
39 * m i d w a y . c e n i 1 5 5 d r i v e r
40 *
41 * author: Chuck Cranor <chuck@ccrc.wustl.edu>
42 * started: spring, 1996 (written from scratch).
43 *
--- 786 unchanged lines hidden (view full) ---
830 *
831 * LOCK: any, not needed
832 */
833static struct mbuf *
834copy_mbuf(struct mbuf *m)
835{
836 struct mbuf *new;
837
838 MGET(new, M_TRYWAIT, MT_DATA);
839 if (new == NULL)
840 return (NULL);
841
842 if (m->m_flags & M_PKTHDR) {
843 M_MOVE_PKTHDR(new, m);
844 if (m->m_len > MHLEN) {
845 MCLGET(new, M_TRYWAIT);
846 if ((m->m_flags & M_EXT) == 0) {
847 m_free(new);
848 return (NULL);
849 }
850 }
851 } else {
852 if (m->m_len > MLEN) {
853 MCLGET(new, M_TRYWAIT);
854 if ((m->m_flags & M_EXT) == 0) {
855 m_free(new);
856 return (NULL);
857 }
858 }
859 }
860
861 bcopy(m->m_data, new->m_data, m->m_len);
862 new->m_len = m->m_len;
863 new->m_flags &= ~M_RDONLY;
864
865 return (new);
866}
--- 2060 unchanged lines hidden (view full) ---
2927#endif
2928
2929 IFP2IFATM(sc->ifp)->phy = &sc->utopia;
2930 utopia_attach(&sc->utopia, IFP2IFATM(sc->ifp), &sc->media, &sc->en_mtx,
2931 &sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree),
2932 &en_utopia_methods);
2933 utopia_init_media(&sc->utopia);
2934
2935 MGET(sc->padbuf, M_TRYWAIT, MT_DATA);
2936 if (sc->padbuf == NULL)
2937 goto fail;
2938 bzero(sc->padbuf->m_data, MLEN);
2939
2940 if (bus_dma_tag_create(NULL, 1, 0,
2941 BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
2942 EN_TXSZ * 1024, EN_MAX_DMASEG, EN_TXSZ * 1024, 0,
2943 NULL, NULL, &sc->txtag))
2944 goto fail;
2945
--- 429 unchanged lines hidden ---
2/* (sync'd to midway.c 1.68) */
3
4/*-
5 * Copyright (c) 1996 Charles D. Cranor and Washington University.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
--- 18 unchanged lines hidden (view full) ---
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/dev/en/midway.c 170093 2007-05-29 11:28:28Z rwatson $");
36
37/*
38 *
39 * m i d w a y . c e n i 1 5 5 d r i v e r
40 *
41 * author: Chuck Cranor <chuck@ccrc.wustl.edu>
42 * started: spring, 1996 (written from scratch).
43 *
--- 786 unchanged lines hidden (view full) ---
830 *
831 * LOCK: any, not needed
832 */
833static struct mbuf *
834copy_mbuf(struct mbuf *m)
835{
836 struct mbuf *new;
837
838 MGET(new, M_TRYWAIT, MT_DATA);
839 if (new == NULL)
840 return (NULL);
841
842 if (m->m_flags & M_PKTHDR) {
843 M_MOVE_PKTHDR(new, m);
844 if (m->m_len > MHLEN) {
845 MCLGET(new, M_TRYWAIT);
846 if ((m->m_flags & M_EXT) == 0) {
847 m_free(new);
848 return (NULL);
849 }
850 }
851 } else {
852 if (m->m_len > MLEN) {
853 MCLGET(new, M_TRYWAIT);
854 if ((m->m_flags & M_EXT) == 0) {
855 m_free(new);
856 return (NULL);
857 }
858 }
859 }
860
861 bcopy(m->m_data, new->m_data, m->m_len);
862 new->m_len = m->m_len;
863 new->m_flags &= ~M_RDONLY;
864
865 return (new);
866}
--- 2060 unchanged lines hidden (view full) ---
2927#endif
2928
2929 IFP2IFATM(sc->ifp)->phy = &sc->utopia;
2930 utopia_attach(&sc->utopia, IFP2IFATM(sc->ifp), &sc->media, &sc->en_mtx,
2931 &sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree),
2932 &en_utopia_methods);
2933 utopia_init_media(&sc->utopia);
2934
2935 MGET(sc->padbuf, M_TRYWAIT, MT_DATA);
2936 if (sc->padbuf == NULL)
2937 goto fail;
2938 bzero(sc->padbuf->m_data, MLEN);
2939
2940 if (bus_dma_tag_create(NULL, 1, 0,
2941 BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
2942 EN_TXSZ * 1024, EN_MAX_DMASEG, EN_TXSZ * 1024, 0,
2943 NULL, NULL, &sc->txtag))
2944 goto fail;
2945
--- 429 unchanged lines hidden ---