| @@ -1,41 +1,41 @@ | | | @@ -1,41 +1,41 @@ |
1 | /* $NetBSD: xennetback_xenbus.c,v 1.121 2023/08/09 08:38:37 riastradh Exp $ */ | | 1 | /* $NetBSD: xennetback_xenbus.c,v 1.122 2023/08/09 08:38:47 riastradh Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2006 Manuel Bouyer. | | 4 | * Copyright (c) 2006 Manuel Bouyer. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * | | 14 | * |
15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 | */ | | 25 | */ |
26 | | | 26 | |
27 | #include <sys/cdefs.h> | | 27 | #include <sys/cdefs.h> |
28 | __KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.121 2023/08/09 08:38:37 riastradh Exp $"); | | 28 | __KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.122 2023/08/09 08:38:47 riastradh Exp $"); |
29 | | | 29 | |
30 | #include <sys/types.h> | | 30 | #include <sys/types.h> |
31 | #include <sys/param.h> | | 31 | #include <sys/param.h> |
32 | #include <sys/systm.h> | | 32 | #include <sys/systm.h> |
33 | #include <sys/kmem.h> | | 33 | #include <sys/kmem.h> |
34 | #include <sys/queue.h> | | 34 | #include <sys/queue.h> |
35 | #include <sys/kernel.h> | | 35 | #include <sys/kernel.h> |
36 | #include <sys/mbuf.h> | | 36 | #include <sys/mbuf.h> |
37 | #include <sys/protosw.h> | | 37 | #include <sys/protosw.h> |
38 | #include <sys/socket.h> | | 38 | #include <sys/socket.h> |
39 | #include <sys/ioctl.h> | | 39 | #include <sys/ioctl.h> |
40 | #include <sys/errno.h> | | 40 | #include <sys/errno.h> |
41 | #include <sys/device.h> | | 41 | #include <sys/device.h> |
| @@ -1014,34 +1014,32 @@ xennetback_ifstart(struct ifnet *ifp) | | | @@ -1014,34 +1014,32 @@ xennetback_ifstart(struct ifnet *ifp) |
1014 | static void | | 1014 | static void |
1015 | xennetback_rx_copy_process(struct ifnet *ifp, struct xnetback_instance *xneti, | | 1015 | xennetback_rx_copy_process(struct ifnet *ifp, struct xnetback_instance *xneti, |
1016 | int queued, int copycnt) | | 1016 | int queued, int copycnt) |
1017 | { | | 1017 | { |
1018 | int notify; | | 1018 | int notify; |
1019 | struct xnetback_xstate *xst; | | 1019 | struct xnetback_xstate *xst; |
1020 | | | 1020 | |
1021 | if (xennetback_copy(ifp, xneti->xni_gop_copy, copycnt, "Rx") != 0) { | | 1021 | if (xennetback_copy(ifp, xneti->xni_gop_copy, copycnt, "Rx") != 0) { |
1022 | /* message already displayed */ | | 1022 | /* message already displayed */ |
1023 | goto free_mbufs; | | 1023 | goto free_mbufs; |
1024 | } | | 1024 | } |
1025 | | | 1025 | |
1026 | /* update pointer */ | | 1026 | /* update pointer */ |
1027 | xen_rmb(); | | | |
1028 | xneti->xni_rxring.req_cons += queued; | | 1027 | xneti->xni_rxring.req_cons += queued; |
1029 | xneti->xni_rxring.rsp_prod_pvt += queued; | | 1028 | xneti->xni_rxring.rsp_prod_pvt += queued; |
1030 | RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&xneti->xni_rxring, notify); | | 1029 | RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&xneti->xni_rxring, notify); |
1031 | | | 1030 | |
1032 | /* send event */ | | 1031 | /* send event */ |
1033 | if (notify) { | | 1032 | if (notify) { |
1034 | xen_rmb(); | | | |
1035 | XENPRINTF(("%s receive event\n", | | 1033 | XENPRINTF(("%s receive event\n", |
1036 | xneti->xni_if.if_xname)); | | 1034 | xneti->xni_if.if_xname)); |
1037 | hypervisor_notify_via_evtchn(xneti->xni_evtchn); | | 1035 | hypervisor_notify_via_evtchn(xneti->xni_evtchn); |
1038 | } | | 1036 | } |
1039 | | | 1037 | |
1040 | free_mbufs: | | 1038 | free_mbufs: |
1041 | /* now that data was copied we can free the mbufs */ | | 1039 | /* now that data was copied we can free the mbufs */ |
1042 | for (int j = 0; j < queued; j++) { | | 1040 | for (int j = 0; j < queued; j++) { |
1043 | xst = &xneti->xni_xstate[j]; | | 1041 | xst = &xneti->xni_xstate[j]; |
1044 | if (xst->xs_loaded) { | | 1042 | if (xst->xs_loaded) { |
1045 | bus_dmamap_unload(xneti->xni_xbusd->xbusd_dmat, | | 1043 | bus_dmamap_unload(xneti->xni_xbusd->xbusd_dmat, |
1046 | xst->xs_dmamap); | | 1044 | xst->xs_dmamap); |
1047 | xst->xs_loaded = false; | | 1045 | xst->xs_loaded = false; |