| @@ -1,34 +1,34 @@ | | | @@ -1,34 +1,34 @@ |
1 | /* $NetBSD: if_rge.c,v 1.7 2020/02/27 22:58:57 sevan Exp $ */ | | 1 | /* $NetBSD: if_rge.c,v 1.8 2020/02/27 23:15:34 sevan Exp $ */ |
2 | /* $OpenBSD: if_rge.c,v 1.2 2020/01/02 09:00:45 kevlo Exp $ */ | | 2 | /* $OpenBSD: if_rge.c,v 1.2 2020/01/02 09:00:45 kevlo Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (c) 2019 Kevin Lo <kevlo@openbsd.org> | | 5 | * Copyright (c) 2019 Kevin Lo <kevlo@openbsd.org> |
6 | * | | 6 | * |
7 | * Permission to use, copy, modify, and distribute this software for any | | 7 | * Permission to use, copy, modify, and distribute this software for any |
8 | * purpose with or without fee is hereby granted, provided that the above | | 8 | * purpose with or without fee is hereby granted, provided that the above |
9 | * copyright notice and this permission notice appear in all copies. | | 9 | * copyright notice and this permission notice appear in all copies. |
10 | * | | 10 | * |
11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | | 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
18 | */ | | 18 | */ |
19 | | | 19 | |
20 | #include <sys/cdefs.h> | | 20 | #include <sys/cdefs.h> |
21 | __KERNEL_RCSID(0, "$NetBSD: if_rge.c,v 1.7 2020/02/27 22:58:57 sevan Exp $"); | | 21 | __KERNEL_RCSID(0, "$NetBSD: if_rge.c,v 1.8 2020/02/27 23:15:34 sevan Exp $"); |
22 | | | 22 | |
23 | /* #include "vlan.h" Sevan */ | | 23 | /* #include "vlan.h" Sevan */ |
24 | | | 24 | |
25 | #include <sys/types.h> | | 25 | #include <sys/types.h> |
26 | | | 26 | |
27 | #include <sys/param.h> | | 27 | #include <sys/param.h> |
28 | #include <sys/systm.h> | | 28 | #include <sys/systm.h> |
29 | #include <sys/sockio.h> | | 29 | #include <sys/sockio.h> |
30 | #include <sys/mbuf.h> | | 30 | #include <sys/mbuf.h> |
31 | #include <sys/malloc.h> | | 31 | #include <sys/malloc.h> |
32 | #include <sys/kernel.h> | | 32 | #include <sys/kernel.h> |
33 | #include <sys/socket.h> | | 33 | #include <sys/socket.h> |
34 | #include <sys/device.h> | | 34 | #include <sys/device.h> |
| @@ -958,27 +958,27 @@ rge_allocmem(struct rge_softc *sc) | | | @@ -958,27 +958,27 @@ rge_allocmem(struct rge_softc *sc) |
958 | return (error); | | 958 | return (error); |
959 | } | | 959 | } |
960 | error = bus_dmamem_alloc(sc->sc_dmat, RGE_TX_LIST_SZ, RGE_ALIGN, 0, | | 960 | error = bus_dmamem_alloc(sc->sc_dmat, RGE_TX_LIST_SZ, RGE_ALIGN, 0, |
961 | &sc->rge_ldata.rge_tx_listseg, 1, &sc->rge_ldata.rge_tx_listnseg, | | 961 | &sc->rge_ldata.rge_tx_listseg, 1, &sc->rge_ldata.rge_tx_listnseg, |
962 | BUS_DMA_NOWAIT); /* XXX OpenBSD adds BUS_DMA_ZERO */ | | 962 | BUS_DMA_NOWAIT); /* XXX OpenBSD adds BUS_DMA_ZERO */ |
963 | if (error) { | | 963 | if (error) { |
964 | printf("%s: can't alloc TX list\n", sc->sc_dev.dv_xname); | | 964 | printf("%s: can't alloc TX list\n", sc->sc_dev.dv_xname); |
965 | return (error); | | 965 | return (error); |
966 | } | | 966 | } |
967 | | | 967 | |
968 | /* Load the map for the TX ring. */ | | 968 | /* Load the map for the TX ring. */ |
969 | error = bus_dmamem_map(sc->sc_dmat, &sc->rge_ldata.rge_tx_listseg, | | 969 | error = bus_dmamem_map(sc->sc_dmat, &sc->rge_ldata.rge_tx_listseg, |
970 | sc->rge_ldata.rge_tx_listnseg, RGE_TX_LIST_SZ, | | 970 | sc->rge_ldata.rge_tx_listnseg, RGE_TX_LIST_SZ, |
971 | &sc->rge_ldata.rge_tx_list, | | 971 | (void **) &sc->rge_ldata.rge_tx_list, |
972 | BUS_DMA_NOWAIT); /* XXX OpenBSD adds BUS_DMA_COHERENT */ | | 972 | BUS_DMA_NOWAIT); /* XXX OpenBSD adds BUS_DMA_COHERENT */ |
973 | if (error) { | | 973 | if (error) { |
974 | printf("%s: can't map TX dma buffers\n", sc->sc_dev.dv_xname); | | 974 | printf("%s: can't map TX dma buffers\n", sc->sc_dev.dv_xname); |
975 | bus_dmamem_free(sc->sc_dmat, &sc->rge_ldata.rge_tx_listseg, | | 975 | bus_dmamem_free(sc->sc_dmat, &sc->rge_ldata.rge_tx_listseg, |
976 | sc->rge_ldata.rge_tx_listnseg); | | 976 | sc->rge_ldata.rge_tx_listnseg); |
977 | return (error); | | 977 | return (error); |
978 | } | | 978 | } |
979 | error = bus_dmamap_load(sc->sc_dmat, sc->rge_ldata.rge_tx_list_map, | | 979 | error = bus_dmamap_load(sc->sc_dmat, sc->rge_ldata.rge_tx_list_map, |
980 | sc->rge_ldata.rge_tx_list, RGE_TX_LIST_SZ, NULL, BUS_DMA_NOWAIT); | | 980 | sc->rge_ldata.rge_tx_list, RGE_TX_LIST_SZ, NULL, BUS_DMA_NOWAIT); |
981 | if (error) { | | 981 | if (error) { |
982 | printf("%s: can't load TX dma map\n", sc->sc_dev.dv_xname); | | 982 | printf("%s: can't load TX dma map\n", sc->sc_dev.dv_xname); |
983 | bus_dmamap_destroy(sc->sc_dmat, sc->rge_ldata.rge_tx_list_map); | | 983 | bus_dmamap_destroy(sc->sc_dmat, sc->rge_ldata.rge_tx_list_map); |
984 | bus_dmamem_unmap(sc->sc_dmat, | | 984 | bus_dmamem_unmap(sc->sc_dmat, |
| @@ -1008,27 +1008,27 @@ rge_allocmem(struct rge_softc *sc) | | | @@ -1008,27 +1008,27 @@ rge_allocmem(struct rge_softc *sc) |
1008 | return (error); | | 1008 | return (error); |
1009 | } | | 1009 | } |
1010 | error = bus_dmamem_alloc(sc->sc_dmat, RGE_RX_LIST_SZ, RGE_ALIGN, 0, | | 1010 | error = bus_dmamem_alloc(sc->sc_dmat, RGE_RX_LIST_SZ, RGE_ALIGN, 0, |
1011 | &sc->rge_ldata.rge_rx_listseg, 1, &sc->rge_ldata.rge_rx_listnseg, | | 1011 | &sc->rge_ldata.rge_rx_listseg, 1, &sc->rge_ldata.rge_rx_listnseg, |
1012 | BUS_DMA_NOWAIT); /* XXX OpenBSD adds BUS_DMA_ZERO */ | | 1012 | BUS_DMA_NOWAIT); /* XXX OpenBSD adds BUS_DMA_ZERO */ |
1013 | if (error) { | | 1013 | if (error) { |
1014 | printf("%s: can't alloc RX list\n", sc->sc_dev.dv_xname); | | 1014 | printf("%s: can't alloc RX list\n", sc->sc_dev.dv_xname); |
1015 | return (error); | | 1015 | return (error); |
1016 | } | | 1016 | } |
1017 | | | 1017 | |
1018 | /* Load the map for the RX ring. */ | | 1018 | /* Load the map for the RX ring. */ |
1019 | error = bus_dmamem_map(sc->sc_dmat, &sc->rge_ldata.rge_rx_listseg, | | 1019 | error = bus_dmamem_map(sc->sc_dmat, &sc->rge_ldata.rge_rx_listseg, |
1020 | sc->rge_ldata.rge_rx_listnseg, RGE_RX_LIST_SZ, | | 1020 | sc->rge_ldata.rge_rx_listnseg, RGE_RX_LIST_SZ, |
1021 | &sc->rge_ldata.rge_rx_list, | | 1021 | (void **) &sc->rge_ldata.rge_rx_list, |
1022 | BUS_DMA_NOWAIT); /* XXX OpenBSD adds BUS_DMA_COHERENT */ | | 1022 | BUS_DMA_NOWAIT); /* XXX OpenBSD adds BUS_DMA_COHERENT */ |
1023 | if (error) { | | 1023 | if (error) { |
1024 | printf("%s: can't map RX dma buffers\n", sc->sc_dev.dv_xname); | | 1024 | printf("%s: can't map RX dma buffers\n", sc->sc_dev.dv_xname); |
1025 | bus_dmamem_free(sc->sc_dmat, &sc->rge_ldata.rge_rx_listseg, | | 1025 | bus_dmamem_free(sc->sc_dmat, &sc->rge_ldata.rge_rx_listseg, |
1026 | sc->rge_ldata.rge_rx_listnseg); | | 1026 | sc->rge_ldata.rge_rx_listnseg); |
1027 | return (error); | | 1027 | return (error); |
1028 | } | | 1028 | } |
1029 | error = bus_dmamap_load(sc->sc_dmat, sc->rge_ldata.rge_rx_list_map, | | 1029 | error = bus_dmamap_load(sc->sc_dmat, sc->rge_ldata.rge_rx_list_map, |
1030 | sc->rge_ldata.rge_rx_list, RGE_RX_LIST_SZ, NULL, BUS_DMA_NOWAIT); | | 1030 | sc->rge_ldata.rge_rx_list, RGE_RX_LIST_SZ, NULL, BUS_DMA_NOWAIT); |
1031 | if (error) { | | 1031 | if (error) { |
1032 | printf("%s: can't load RX dma map\n", sc->sc_dev.dv_xname); | | 1032 | printf("%s: can't load RX dma map\n", sc->sc_dev.dv_xname); |
1033 | bus_dmamap_destroy(sc->sc_dmat, sc->rge_ldata.rge_rx_list_map); | | 1033 | bus_dmamap_destroy(sc->sc_dmat, sc->rge_ldata.rge_rx_list_map); |
1034 | bus_dmamem_unmap(sc->sc_dmat, | | 1034 | bus_dmamem_unmap(sc->sc_dmat, |