| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: vnet.c,v 1.3 2021/03/11 19:34:11 palle Exp $ */ | | 1 | /* $NetBSD: vnet.c,v 1.4 2021/03/13 20:21:37 palle Exp $ */ |
2 | /* $OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $ */ | | 2 | /* $OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $ */ |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2009, 2015 Mark Kettenis | | 4 | * Copyright (c) 2009, 2015 Mark Kettenis |
5 | * | | 5 | * |
6 | * Permission to use, copy, modify, and distribute this software for any | | 6 | * Permission to use, copy, modify, and distribute this software for any |
7 | * purpose with or without fee is hereby granted, provided that the above | | 7 | * purpose with or without fee is hereby granted, provided that the above |
8 | * copyright notice and this permission notice appear in all copies. | | 8 | * copyright notice and this permission notice appear in all copies. |
9 | * | | 9 | * |
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| @@ -211,26 +211,27 @@ void vnet_attach (device_t, device_t, vo | | | @@ -211,26 +211,27 @@ void vnet_attach (device_t, device_t, vo |
211 | CFATTACH_DECL_NEW(vnet, sizeof(struct vnet_softc), | | 211 | CFATTACH_DECL_NEW(vnet, sizeof(struct vnet_softc), |
212 | vnet_match, vnet_attach, NULL, NULL); | | 212 | vnet_match, vnet_attach, NULL, NULL); |
213 | | | 213 | |
214 | int vnet_tx_intr(void *); | | 214 | int vnet_tx_intr(void *); |
215 | int vnet_rx_intr(void *); | | 215 | int vnet_rx_intr(void *); |
216 | void vnet_handshake(void *); | | 216 | void vnet_handshake(void *); |
217 | | | 217 | |
218 | void vio_rx_data(struct ldc_conn *, struct ldc_pkt *); | | 218 | void vio_rx_data(struct ldc_conn *, struct ldc_pkt *); |
219 | void vnet_rx_vio_ctrl(struct vnet_softc *, struct vio_msg *); | | 219 | void vnet_rx_vio_ctrl(struct vnet_softc *, struct vio_msg *); |
220 | void vnet_rx_vio_ver_info(struct vnet_softc *, struct vio_msg_tag *); | | 220 | void vnet_rx_vio_ver_info(struct vnet_softc *, struct vio_msg_tag *); |
221 | void vnet_rx_vio_attr_info(struct vnet_softc *, struct vio_msg_tag *); | | 221 | void vnet_rx_vio_attr_info(struct vnet_softc *, struct vio_msg_tag *); |
222 | void vnet_rx_vio_dring_reg(struct vnet_softc *, struct vio_msg_tag *); | | 222 | void vnet_rx_vio_dring_reg(struct vnet_softc *, struct vio_msg_tag *); |
223 | void vnet_rx_vio_rdx(struct vnet_softc *sc, struct vio_msg_tag *); | | 223 | void vnet_rx_vio_rdx(struct vnet_softc *sc, struct vio_msg_tag *); |
| | | 224 | void vnet_rx_vio_mcast_info(struct vnet_softc *sc, struct vio_msg_tag *); |
224 | void vnet_rx_vio_data(struct vnet_softc *sc, struct vio_msg *); | | 225 | void vnet_rx_vio_data(struct vnet_softc *sc, struct vio_msg *); |
225 | void vnet_rx_vio_desc_data(struct vnet_softc *sc, struct vio_msg_tag *); | | 226 | void vnet_rx_vio_desc_data(struct vnet_softc *sc, struct vio_msg_tag *); |
226 | void vnet_rx_vio_dring_data(struct vnet_softc *sc, struct vio_msg_tag *); | | 227 | void vnet_rx_vio_dring_data(struct vnet_softc *sc, struct vio_msg_tag *); |
227 | | | 228 | |
228 | void vnet_ldc_reset(struct ldc_conn *); | | 229 | void vnet_ldc_reset(struct ldc_conn *); |
229 | void vnet_ldc_start(struct ldc_conn *); | | 230 | void vnet_ldc_start(struct ldc_conn *); |
230 | | | 231 | |
231 | void vnet_sendmsg(struct vnet_softc *, void *, size_t); | | 232 | void vnet_sendmsg(struct vnet_softc *, void *, size_t); |
232 | void vnet_send_ver_info(struct vnet_softc *, uint16_t, uint16_t); | | 233 | void vnet_send_ver_info(struct vnet_softc *, uint16_t, uint16_t); |
233 | void vnet_send_attr_info(struct vnet_softc *); | | 234 | void vnet_send_attr_info(struct vnet_softc *); |
234 | void vnet_send_dring_reg(struct vnet_softc *); | | 235 | void vnet_send_dring_reg(struct vnet_softc *); |
235 | void vio_send_rdx(struct vnet_softc *); | | 236 | void vio_send_rdx(struct vnet_softc *); |
236 | void vnet_send_dring_data(struct vnet_softc *, uint32_t); | | 237 | void vnet_send_dring_data(struct vnet_softc *, uint32_t); |
| @@ -645,29 +646,35 @@ vnet_rx_vio_ctrl(struct vnet_softc *sc, | | | @@ -645,29 +646,35 @@ vnet_rx_vio_ctrl(struct vnet_softc *sc, |
645 | switch (tag->stype_env) { | | 646 | switch (tag->stype_env) { |
646 | case VIO_VER_INFO: | | 647 | case VIO_VER_INFO: |
647 | vnet_rx_vio_ver_info(sc, tag); | | 648 | vnet_rx_vio_ver_info(sc, tag); |
648 | break; | | 649 | break; |
649 | case VIO_ATTR_INFO: | | 650 | case VIO_ATTR_INFO: |
650 | vnet_rx_vio_attr_info(sc, tag); | | 651 | vnet_rx_vio_attr_info(sc, tag); |
651 | break; | | 652 | break; |
652 | case VIO_DRING_REG: | | 653 | case VIO_DRING_REG: |
653 | vnet_rx_vio_dring_reg(sc, tag); | | 654 | vnet_rx_vio_dring_reg(sc, tag); |
654 | break; | | 655 | break; |
655 | case VIO_RDX: | | 656 | case VIO_RDX: |
656 | vnet_rx_vio_rdx(sc, tag); | | 657 | vnet_rx_vio_rdx(sc, tag); |
657 | break; | | 658 | break; |
| | | 659 | case VNET_MCAST_INFO: |
| | | 660 | vnet_rx_vio_mcast_info(sc, tag); |
| | | 661 | break; |
658 | default: | | 662 | default: |
659 | printf("%s: CTRL/0x%02x/0x%04x FIXME\n", | | 663 | printf("%s: CTRL/0x%02x/0x%04x FIXME\n", |
660 | __func__, tag->stype, tag->stype_env); | | 664 | __func__, tag->stype, tag->stype_env); |
| | | 665 | #if 0 |
| | | 666 | Debugger(); |
| | | 667 | #endif |
661 | break; | | 668 | break; |
662 | } | | 669 | } |
663 | } | | 670 | } |
664 | | | 671 | |
665 | void | | 672 | void |
666 | vnet_rx_vio_ver_info(struct vnet_softc *sc, struct vio_msg_tag *tag) | | 673 | vnet_rx_vio_ver_info(struct vnet_softc *sc, struct vio_msg_tag *tag) |
667 | { | | 674 | { |
668 | #if 0 | | 675 | #if 0 |
669 | DPRINTF(("%s: entry\n", __func__)); | | 676 | DPRINTF(("%s: entry\n", __func__)); |
670 | #endif | | 677 | #endif |
671 | struct vio_ver_info *vi = (struct vio_ver_info *)tag; | | 678 | struct vio_ver_info *vi = (struct vio_ver_info *)tag; |
672 | | | 679 | |
673 | switch (vi->tag.stype) { | | 680 | switch (vi->tag.stype) { |
| @@ -729,27 +736,29 @@ void | | | @@ -729,27 +736,29 @@ void |
729 | vnet_rx_vio_attr_info(struct vnet_softc *sc, struct vio_msg_tag *tag) | | 736 | vnet_rx_vio_attr_info(struct vnet_softc *sc, struct vio_msg_tag *tag) |
730 | { | | 737 | { |
731 | #if 0 | | 738 | #if 0 |
732 | DPRINTF(("%s: entry\n", __func__)); | | 739 | DPRINTF(("%s: entry\n", __func__)); |
733 | #endif | | 740 | #endif |
734 | struct vnet_attr_info *ai = (struct vnet_attr_info *)tag; | | 741 | struct vnet_attr_info *ai = (struct vnet_attr_info *)tag; |
735 | | | 742 | |
736 | switch (ai->tag.stype) { | | 743 | switch (ai->tag.stype) { |
737 | case VIO_SUBTYPE_INFO: | | 744 | case VIO_SUBTYPE_INFO: |
738 | #if 0 | | 745 | #if 0 |
739 | DPRINTF(("CTRL/INFO/ATTR_INFO\n")); | | 746 | DPRINTF(("CTRL/INFO/ATTR_INFO\n")); |
740 | #endif | | 747 | #endif |
741 | sc->sc_xfer_mode = ai->xfer_mode; | | 748 | sc->sc_xfer_mode = ai->xfer_mode; |
| | | 749 | #if 0 |
742 | DPRINTF(("sc_xfer_mode %d\n", sc->sc_xfer_mode)); | | 750 | DPRINTF(("sc_xfer_mode %d\n", sc->sc_xfer_mode)); |
| | | 751 | #endif |
743 | | | 752 | |
744 | ai->tag.stype = VIO_SUBTYPE_ACK; | | 753 | ai->tag.stype = VIO_SUBTYPE_ACK; |
745 | ai->tag.sid = sc->sc_local_sid; | | 754 | ai->tag.sid = sc->sc_local_sid; |
746 | vnet_sendmsg(sc, ai, sizeof(*ai)); | | 755 | vnet_sendmsg(sc, ai, sizeof(*ai)); |
747 | sc->sc_vio_state |= VIO_RCV_ATTR_INFO; | | 756 | sc->sc_vio_state |= VIO_RCV_ATTR_INFO; |
748 | break; | | 757 | break; |
749 | | | 758 | |
750 | case VIO_SUBTYPE_ACK: | | 759 | case VIO_SUBTYPE_ACK: |
751 | #if 0 | | 760 | #if 0 |
752 | DPRINTF(("CTRL/ACK/ATTR_INFO\n")); | | 761 | DPRINTF(("CTRL/ACK/ATTR_INFO\n")); |
753 | #endif | | 762 | #endif |
754 | if (!ISSET(sc->sc_vio_state, VIO_SND_ATTR_INFO)) { | | 763 | if (!ISSET(sc->sc_vio_state, VIO_SND_ATTR_INFO)) { |
755 | ldc_reset(&sc->sc_lc); | | 764 | ldc_reset(&sc->sc_lc); |
| @@ -883,26 +892,60 @@ FIXME openbsd | | | @@ -883,26 +892,60 @@ FIXME openbsd |
883 | ifp->if_flags &= ~IFF_OACTIVE; | | 892 | ifp->if_flags &= ~IFF_OACTIVE; |
884 | #endif | | 893 | #endif |
885 | vnet_start(ifp); | | 894 | vnet_start(ifp); |
886 | #if 0 | | 895 | #if 0 |
887 | FIXME openbsd | | 896 | FIXME openbsd |
888 | KERNEL_UNLOCK(); | | 897 | KERNEL_UNLOCK(); |
889 | #else | | 898 | #else |
890 | KERNEL_UNLOCK_ONE(curlwp); | | 899 | KERNEL_UNLOCK_ONE(curlwp); |
891 | #endif | | 900 | #endif |
892 | } | | 901 | } |
893 | } | | 902 | } |
894 | | | 903 | |
895 | void | | 904 | void |
| | | 905 | vnet_rx_vio_mcast_info(struct vnet_softc *sc, struct vio_msg_tag *tag) |
| | | 906 | { |
| | | 907 | #if 0 |
| | | 908 | DPRINTF(("%s: entry\n", __func__)); |
| | | 909 | #endif |
| | | 910 | |
| | | 911 | switch(tag->stype) { |
| | | 912 | |
| | | 913 | case VIO_SUBTYPE_INFO: |
| | | 914 | #if 0 |
| | | 915 | DPRINTF(("CTRL/INFO/MCAST_INFO\n")); |
| | | 916 | #endif |
| | | 917 | break; |
| | | 918 | |
| | | 919 | case VIO_SUBTYPE_ACK: |
| | | 920 | #if 0 |
| | | 921 | DPRINTF(("CTRL/ACK/MCAST_INFO\n")); |
| | | 922 | #endif |
| | | 923 | break; |
| | | 924 | |
| | | 925 | case VIO_SUBTYPE_NACK: |
| | | 926 | #if 0 |
| | | 927 | DPRINTF(("CTRL/NACK/MCAST_INFO\n")); |
| | | 928 | #endif |
| | | 929 | break; |
| | | 930 | |
| | | 931 | default: |
| | | 932 | printf("%s: CTRL/0x%02x/0x%04x\n", |
| | | 933 | __func__, tag->stype, tag->stype_env); |
| | | 934 | break; |
| | | 935 | } |
| | | 936 | } |
| | | 937 | |
| | | 938 | void |
896 | vnet_rx_vio_data(struct vnet_softc *sc, struct vio_msg *vm) | | 939 | vnet_rx_vio_data(struct vnet_softc *sc, struct vio_msg *vm) |
897 | { | | 940 | { |
898 | #if 0 | | 941 | #if 0 |
899 | DPRINTF(("%s: entry\n", __func__)); | | 942 | DPRINTF(("%s: entry\n", __func__)); |
900 | #endif | | 943 | #endif |
901 | struct vio_msg_tag *tag = (struct vio_msg_tag *)&vm->type; | | 944 | struct vio_msg_tag *tag = (struct vio_msg_tag *)&vm->type; |
902 | | | 945 | |
903 | if (!ISSET(sc->sc_vio_state, VIO_RCV_RDX) || | | 946 | if (!ISSET(sc->sc_vio_state, VIO_RCV_RDX) || |
904 | !ISSET(sc->sc_vio_state, VIO_ACK_RDX)) { | | 947 | !ISSET(sc->sc_vio_state, VIO_ACK_RDX)) { |
905 | DPRINTF(("Spurious DATA/0x%02x/0x%04x\n", tag->stype, | | 948 | DPRINTF(("Spurious DATA/0x%02x/0x%04x\n", tag->stype, |
906 | tag->stype_env)); | | 949 | tag->stype_env)); |
907 | return; | | 950 | return; |
908 | } | | 951 | } |
| @@ -1067,27 +1110,27 @@ FIXME openbsd | | | @@ -1067,27 +1110,27 @@ FIXME openbsd |
1067 | #else | | 1110 | #else |
1068 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | | 1111 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; |
1069 | #endif | | 1112 | #endif |
1070 | #if 1 | | 1113 | #if 1 |
1071 | struct mbuf *m = NULL; | | 1114 | struct mbuf *m = NULL; |
1072 | #endif | | 1115 | #endif |
1073 | paddr_t pa; | | 1116 | paddr_t pa; |
1074 | psize_t nbytes; | | 1117 | psize_t nbytes; |
1075 | int err; | | 1118 | int err; |
1076 | | | 1119 | |
1077 | switch(tag->stype) { | | 1120 | switch(tag->stype) { |
1078 | case VIO_SUBTYPE_INFO: | | 1121 | case VIO_SUBTYPE_INFO: |
1079 | { | | 1122 | { |
1080 | #if 0 | | 1123 | #if 0 |
1081 | DPRINTF(("%s: VIO_SUBTYPE_INFO\n", __func__)); | | 1124 | DPRINTF(("%s: VIO_SUBTYPE_INFO\n", __func__)); |
1082 | #endif | | 1125 | #endif |
1083 | struct vnet_desc desc; | | 1126 | struct vnet_desc desc; |
1084 | uint64_t cookie; | | 1127 | uint64_t cookie; |
1085 | paddr_t desc_pa; | | 1128 | paddr_t desc_pa; |
1086 | int idx, ack_end_idx = -1; | | 1129 | int idx, ack_end_idx = -1; |
1087 | #if 0 | | 1130 | #if 0 |
1088 | FIXME openbsd | | 1131 | FIXME openbsd |
1089 | struct mbuf_list ml = MBUF_LIST_INITIALIZER(); | | 1132 | struct mbuf_list ml = MBUF_LIST_INITIALIZER(); |
1090 | #endif | | 1133 | #endif |
1091 | | | 1134 | |
1092 | idx = dm->start_idx; | | 1135 | idx = dm->start_idx; |
1093 | for (;;) { | | 1136 | for (;;) { |
| @@ -1138,54 +1181,56 @@ FIXME openbsd | | | @@ -1138,54 +1181,56 @@ FIXME openbsd |
1138 | #endif | | 1181 | #endif |
1139 | MCLGET(m, M_DONTWAIT); | | 1182 | MCLGET(m, M_DONTWAIT); |
1140 | if ((m->m_flags & M_EXT) == 0) | | 1183 | if ((m->m_flags & M_EXT) == 0) |
1141 | break; | | 1184 | break; |
1142 | #if 0 | | 1185 | #if 0 |
1143 | DPRINTF(("%s: after MCLGET\n", __func__)); | | 1186 | DPRINTF(("%s: after MCLGET\n", __func__)); |
1144 | #endif | | 1187 | #endif |
1145 | #endif | | 1188 | #endif |
1146 | #endif | | 1189 | #endif |
1147 | #if 1 | | 1190 | #if 1 |
1148 | m->m_len = m->m_pkthdr.len = desc.nbytes; | | 1191 | m->m_len = m->m_pkthdr.len = desc.nbytes; |
1149 | #endif | | 1192 | #endif |
1150 | nbytes = roundup(desc.nbytes + VNET_ETHER_ALIGN, 8); | | 1193 | nbytes = roundup(desc.nbytes + VNET_ETHER_ALIGN, 8); |
1151 | #if 1 | | 1194 | #if 0 |
1152 | DPRINTF(("%s: nbytes %" PRId64 " desc.nbytes %" PRId32 "\n", | | 1195 | DPRINTF(("%s: RX frame size %" PRId16 "\n", |
1153 | __func__, nbytes, desc.nbytes)); | | 1196 | __func__, (int)nbytes)); |
1154 | uint8_t buf[ETHER_MAX_LEN]; | | 1197 | uint8_t buf[ETHER_MAX_LEN]; |
1155 | pmap_extract(pmap_kernel(), (vaddr_t)buf, &pa); | | 1198 | pmap_extract(pmap_kernel(), (vaddr_t)buf, &pa); |
1156 | err = hv_ldc_copy(lc->lc_id, LDC_COPY_IN, | | 1199 | err = hv_ldc_copy(lc->lc_id, LDC_COPY_IN, |
1157 | desc.cookie[0].addr, pa, nbytes, &nbytes); | | 1200 | desc.cookie[0].addr, pa, nbytes, &nbytes); |
1158 | if (err != H_EOK) { | | 1201 | if (err != H_EOK) { |
1159 | //m_freem(m); | | 1202 | //m_freem(m); |
1160 | goto skip; | | 1203 | goto skip; |
1161 | } | | 1204 | } |
1162 | for (int i = 0; i < desc.nbytes; i++) { | | 1205 | for (int i = 0; i < desc.nbytes; i++) { |
1163 | if (i % 16 == 0) { | | 1206 | if (i % 16 == 0) { |
1164 | printf("\n"); | | 1207 | DPRINTF(("\n")); |
1165 | } | | 1208 | } |
1166 | printf("%02x ", buf[i]); | | 1209 | DPRINTF(("%02x ", buf[i])); |
1167 | } | | 1210 | } |
1168 | printf("\n"); | | 1211 | DPRINTF(("\n")); |
| | | 1212 | DPRINTF(("\n")); |
1169 | #endif | | 1213 | #endif |
1170 | #if 1 | | 1214 | #if 1 |
1171 | pmap_extract(pmap_kernel(), (vaddr_t)m->m_data, &pa); | | 1215 | pmap_extract(pmap_kernel(), (vaddr_t)m->m_data, &pa); |
1172 | err = hv_ldc_copy(lc->lc_id, LDC_COPY_IN, | | 1216 | err = hv_ldc_copy(lc->lc_id, LDC_COPY_IN, |
1173 | desc.cookie[0].addr, pa, nbytes, &nbytes); | | 1217 | desc.cookie[0].addr, pa, nbytes, &nbytes); |
1174 | if (err != H_EOK) { | | 1218 | if (err != H_EOK) { |
1175 | m_freem(m); | | 1219 | m_freem(m); |
1176 | goto skip; | | 1220 | goto skip; |
1177 | } | | 1221 | } |
1178 | m->m_data += VNET_ETHER_ALIGN; | | 1222 | m->m_data += VNET_ETHER_ALIGN; |
| | | 1223 | m_set_rcvif(m, ifp); |
1179 | | | 1224 | |
1180 | #if 0 | | 1225 | #if 0 |
1181 | FIXME openbsd | | 1226 | FIXME openbsd |
1182 | ml_enqueue(&ml, m); | | 1227 | ml_enqueue(&ml, m); |
1183 | #else | | 1228 | #else |
1184 | #if 0 | | 1229 | #if 0 |
1185 | DPRINTF(("%s: before if_percpuq_enqueue\n", __func__)); | | 1230 | DPRINTF(("%s: before if_percpuq_enqueue\n", __func__)); |
1186 | #endif | | 1231 | #endif |
1187 | if_percpuq_enqueue(ifp->if_percpuq, m); | | 1232 | if_percpuq_enqueue(ifp->if_percpuq, m); |
1188 | #if 0 | | 1233 | #if 0 |
1189 | DPRINTF(("%s: after if_percpuq_enqueue\n", __func__)); | | 1234 | DPRINTF(("%s: after if_percpuq_enqueue\n", __func__)); |
1190 | #endif | | 1235 | #endif |
1191 | #endif | | 1236 | #endif |
| @@ -1214,27 +1259,27 @@ FIXME openbd | | | @@ -1214,27 +1259,27 @@ FIXME openbd |
1214 | dm->tag.stype = VIO_SUBTYPE_NACK; | | 1259 | dm->tag.stype = VIO_SUBTYPE_NACK; |
1215 | } else { | | 1260 | } else { |
1216 | dm->tag.stype = VIO_SUBTYPE_ACK; | | 1261 | dm->tag.stype = VIO_SUBTYPE_ACK; |
1217 | dm->end_idx = ack_end_idx; | | 1262 | dm->end_idx = ack_end_idx; |
1218 | } | | 1263 | } |
1219 | dm->tag.sid = sc->sc_local_sid; | | 1264 | dm->tag.sid = sc->sc_local_sid; |
1220 | dm->proc_state = VIO_DP_STOPPED; | | 1265 | dm->proc_state = VIO_DP_STOPPED; |
1221 | vnet_sendmsg(sc, dm, sizeof(*dm)); | | 1266 | vnet_sendmsg(sc, dm, sizeof(*dm)); |
1222 | break; | | 1267 | break; |
1223 | } | | 1268 | } |
1224 | | | 1269 | |
1225 | case VIO_SUBTYPE_ACK: | | 1270 | case VIO_SUBTYPE_ACK: |
1226 | { | | 1271 | { |
1227 | #if 0 | | 1272 | #if 0 |
1228 | DPRINTF(("%s: VIO_SUBTYPE_ACK\n", __func__)); | | 1273 | DPRINTF(("%s: VIO_SUBTYPE_ACK\n", __func__)); |
1229 | #endif | | 1274 | #endif |
1230 | struct ldc_map *map = sc->sc_lm; | | 1275 | struct ldc_map *map = sc->sc_lm; |
1231 | u_int cons, count; | | 1276 | u_int cons, count; |
1232 | | | 1277 | |
1233 | sc->sc_peer_state = dm->proc_state; | | 1278 | sc->sc_peer_state = dm->proc_state; |
1234 | | | 1279 | |
1235 | cons = sc->sc_tx_cons & (sc->sc_vd->vd_nentries - 1); | | 1280 | cons = sc->sc_tx_cons & (sc->sc_vd->vd_nentries - 1); |
1236 | while (sc->sc_vd->vd_desc[cons].hdr.dstate == VIO_DESC_DONE) { | | 1281 | while (sc->sc_vd->vd_desc[cons].hdr.dstate == VIO_DESC_DONE) { |
1237 | map->lm_slot[sc->sc_vsd[cons].vsd_map_idx].entry = 0; | | 1282 | map->lm_slot[sc->sc_vsd[cons].vsd_map_idx].entry = 0; |
1238 | #if 0 | | 1283 | #if 0 |
1239 | FIXME openbsd | | 1284 | FIXME openbsd |
1240 | atomic_dec_int(&map->lm_count); | | 1285 | atomic_dec_int(&map->lm_count); |
| @@ -1389,97 +1434,112 @@ vnet_send_attr_info(struct vnet_softc *s | | | @@ -1389,97 +1434,112 @@ vnet_send_attr_info(struct vnet_softc *s |
1389 | ai.tag.type = VIO_TYPE_CTRL; | | 1434 | ai.tag.type = VIO_TYPE_CTRL; |
1390 | ai.tag.stype = VIO_SUBTYPE_INFO; | | 1435 | ai.tag.stype = VIO_SUBTYPE_INFO; |
1391 | ai.tag.stype_env = VIO_ATTR_INFO; | | 1436 | ai.tag.stype_env = VIO_ATTR_INFO; |
1392 | ai.tag.sid = sc->sc_local_sid; | | 1437 | ai.tag.sid = sc->sc_local_sid; |
1393 | ai.xfer_mode = VIO_DRING_MODE; | | 1438 | ai.xfer_mode = VIO_DRING_MODE; |
1394 | ai.addr_type = VNET_ADDR_ETHERMAC; | | 1439 | ai.addr_type = VNET_ADDR_ETHERMAC; |
1395 | ai.ack_freq = 0; | | 1440 | ai.ack_freq = 0; |
1396 | ai.addr = 0; | | 1441 | ai.addr = 0; |
1397 | for (i = 0; i < ETHER_ADDR_LEN; i++) { | | 1442 | for (i = 0; i < ETHER_ADDR_LEN; i++) { |
1398 | ai.addr <<= 8; | | 1443 | ai.addr <<= 8; |
1399 | ai.addr |= sc->sc_macaddr[i]; | | 1444 | ai.addr |= sc->sc_macaddr[i]; |
1400 | } | | 1445 | } |
1401 | ai.mtu = ETHER_MAX_LEN - ETHER_CRC_LEN; | | 1446 | ai.mtu = ETHER_MAX_LEN - ETHER_CRC_LEN; |
| | | 1447 | #if 0 |
| | | 1448 | DPRINTF(("%s: ai.addr %" PRIx64 "\n", |
| | | 1449 | __func__, ai.addr)); |
| | | 1450 | DPRINTF(("%s: ai.mtu %" PRId64 "\n", |
| | | 1451 | __func__, ai.mtu)); |
| | | 1452 | #endif |
1402 | vnet_sendmsg(sc, &ai, sizeof(ai)); | | 1453 | vnet_sendmsg(sc, &ai, sizeof(ai)); |
1403 | | | 1454 | |
1404 | sc->sc_vio_state |= VIO_SND_ATTR_INFO; | | 1455 | sc->sc_vio_state |= VIO_SND_ATTR_INFO; |
1405 | } | | 1456 | } |
1406 | | | 1457 | |
1407 | void | | 1458 | void |
1408 | vnet_send_dring_reg(struct vnet_softc *sc) | | 1459 | vnet_send_dring_reg(struct vnet_softc *sc) |
1409 | { | | 1460 | { |
1410 | #if 1 | | 1461 | #if 0 |
1411 | DPRINTF(("%s: entry\n", __func__)); | | 1462 | DPRINTF(("%s: entry\n", __func__)); |
1412 | #endif | | 1463 | #endif |
1413 | | | 1464 | |
1414 | struct vio_dring_reg dr; | | 1465 | struct vio_dring_reg dr; |
1415 | | | 1466 | |
1416 | bzero(&dr, sizeof(dr)); | | 1467 | bzero(&dr, sizeof(dr)); |
1417 | dr.tag.type = VIO_TYPE_CTRL; | | 1468 | dr.tag.type = VIO_TYPE_CTRL; |
1418 | dr.tag.stype = VIO_SUBTYPE_INFO; | | 1469 | dr.tag.stype = VIO_SUBTYPE_INFO; |
1419 | dr.tag.stype_env = VIO_DRING_REG; | | 1470 | dr.tag.stype_env = VIO_DRING_REG; |
1420 | dr.tag.sid = sc->sc_local_sid; | | 1471 | dr.tag.sid = sc->sc_local_sid; |
1421 | dr.dring_ident = 0; | | 1472 | dr.dring_ident = 0; |
1422 | dr.num_descriptors = sc->sc_vd->vd_nentries; | | 1473 | dr.num_descriptors = sc->sc_vd->vd_nentries; |
1423 | dr.descriptor_size = sizeof(struct vnet_desc); | | 1474 | dr.descriptor_size = sizeof(struct vnet_desc); |
1424 | dr.options = VIO_TX_RING; | | 1475 | dr.options = VIO_TX_RING; |
1425 | dr.ncookies = 1; | | 1476 | dr.ncookies = 1; |
1426 | dr.cookie[0].addr = 0; | | 1477 | dr.cookie[0].addr = 0; |
1427 | dr.cookie[0].size = PAGE_SIZE; | | 1478 | dr.cookie[0].size = PAGE_SIZE; |
1428 | vnet_sendmsg(sc, &dr, sizeof(dr)); | | 1479 | vnet_sendmsg(sc, &dr, sizeof(dr)); |
1429 | | | 1480 | |
1430 | sc->sc_vio_state |= VIO_SND_DRING_REG; | | 1481 | sc->sc_vio_state |= VIO_SND_DRING_REG; |
1431 | }; | | 1482 | }; |
1432 | | | 1483 | |
1433 | void | | 1484 | void |
1434 | vio_send_rdx(struct vnet_softc *sc) | | 1485 | vio_send_rdx(struct vnet_softc *sc) |
1435 | { | | 1486 | { |
1436 | #if 1 | | 1487 | #if 0 |
1437 | DPRINTF(("%s: entry\n", __func__)); | | 1488 | DPRINTF(("%s: entry\n", __func__)); |
1438 | #endif | | 1489 | #endif |
1439 | struct vio_msg_tag tag; | | 1490 | struct vio_msg_tag tag; |
1440 | | | 1491 | |
1441 | tag.type = VIO_TYPE_CTRL; | | 1492 | tag.type = VIO_TYPE_CTRL; |
1442 | tag.stype = VIO_SUBTYPE_INFO; | | 1493 | tag.stype = VIO_SUBTYPE_INFO; |
1443 | tag.stype_env = VIO_RDX; | | 1494 | tag.stype_env = VIO_RDX; |
1444 | tag.sid = sc->sc_local_sid; | | 1495 | tag.sid = sc->sc_local_sid; |
1445 | vnet_sendmsg(sc, &tag, sizeof(tag)); | | 1496 | vnet_sendmsg(sc, &tag, sizeof(tag)); |
1446 | | | 1497 | |
1447 | sc->sc_vio_state |= VIO_SND_RDX; | | 1498 | sc->sc_vio_state |= VIO_SND_RDX; |
1448 | } | | 1499 | } |
1449 | | | 1500 | |
1450 | void | | 1501 | void |
1451 | vnet_send_dring_data(struct vnet_softc *sc, uint32_t start_idx) | | 1502 | vnet_send_dring_data(struct vnet_softc *sc, uint32_t start_idx) |
1452 | { | | 1503 | { |
1453 | #if 0 | | 1504 | #if 0 |
1454 | DPRINTF(("%s: entry\n", __func__)); | | 1505 | DPRINTF(("%s: entry\n", __func__)); |
1455 | #endif | | 1506 | #endif |
1456 | struct vio_dring_msg dm; | | 1507 | struct vio_dring_msg dm; |
1457 | u_int peer_state; | | 1508 | u_int peer_state; |
1458 | | | 1509 | |
1459 | peer_state = atomic_swap_uint(&sc->sc_peer_state, VIO_DP_ACTIVE); | | 1510 | peer_state = atomic_swap_uint(&sc->sc_peer_state, VIO_DP_ACTIVE); |
1460 | if (peer_state == VIO_DP_ACTIVE) | | 1511 | if (peer_state == VIO_DP_ACTIVE) { |
| | | 1512 | DPRINTF(("%s: peer_state == VIO_DP_ACTIVE\n", __func__)); |
1461 | return; | | 1513 | return; |
| | | 1514 | } |
1462 | | | 1515 | |
1463 | bzero(&dm, sizeof(dm)); | | 1516 | bzero(&dm, sizeof(dm)); |
1464 | dm.tag.type = VIO_TYPE_DATA; | | 1517 | dm.tag.type = VIO_TYPE_DATA; |
1465 | dm.tag.stype = VIO_SUBTYPE_INFO; | | 1518 | dm.tag.stype = VIO_SUBTYPE_INFO; |
1466 | dm.tag.stype_env = VIO_DRING_DATA; | | 1519 | dm.tag.stype_env = VIO_DRING_DATA; |
1467 | dm.tag.sid = sc->sc_local_sid; | | 1520 | dm.tag.sid = sc->sc_local_sid; |
1468 | dm.seq_no = sc->sc_seq_no++; | | 1521 | dm.seq_no = sc->sc_seq_no++; |
| | | 1522 | #if 0 |
| | | 1523 | DPRINTF(("%s: dm.seq_no %" PRId64 "\n", |
| | | 1524 | __func__, dm.seq_no)); |
| | | 1525 | #endif |
1469 | dm.dring_ident = sc->sc_dring_ident; | | 1526 | dm.dring_ident = sc->sc_dring_ident; |
1470 | dm.start_idx = start_idx; | | 1527 | dm.start_idx = start_idx; |
1471 | dm.end_idx = -1; | | 1528 | dm.end_idx = -1; |
1472 | vnet_sendmsg(sc, &dm, sizeof(dm)); | | 1529 | vnet_sendmsg(sc, &dm, sizeof(dm)); |
| | | 1530 | #if 0 |
| | | 1531 | DPRINTF(("%s: exit\n", __func__)); |
| | | 1532 | #endif |
1473 | } | | 1533 | } |
1474 | | | 1534 | |
1475 | void | | 1535 | void |
1476 | vnet_start(struct ifnet *ifp) | | 1536 | vnet_start(struct ifnet *ifp) |
1477 | { | | 1537 | { |
1478 | #if 0 | | 1538 | #if 0 |
1479 | DPRINTF(("%s: entry\n", __func__)); | | 1539 | DPRINTF(("%s: entry\n", __func__)); |
1480 | #endif | | 1540 | #endif |
1481 | struct vnet_softc *sc = ifp->if_softc; | | 1541 | struct vnet_softc *sc = ifp->if_softc; |
1482 | struct ldc_conn *lc = &sc->sc_lc; | | 1542 | struct ldc_conn *lc = &sc->sc_lc; |
1483 | struct ldc_map *map = sc->sc_lm; | | 1543 | struct ldc_map *map = sc->sc_lm; |
1484 | struct mbuf *m; | | 1544 | struct mbuf *m; |
1485 | paddr_t pa; | | 1545 | paddr_t pa; |
| @@ -1505,36 +1565,40 @@ FIXME openbsd | | | @@ -1505,36 +1565,40 @@ FIXME openbsd |
1505 | #endif | | 1565 | #endif |
1506 | | | 1566 | |
1507 | #if 0 | | 1567 | #if 0 |
1508 | FIXME openbsd | | 1568 | FIXME openbsd |
1509 | if (ifq_empty(&ifp->if_snd)) | | 1569 | if (ifq_empty(&ifp->if_snd)) |
1510 | #else | | 1570 | #else |
1511 | if (IFQ_IS_EMPTY(&ifp->if_snd)) | | 1571 | if (IFQ_IS_EMPTY(&ifp->if_snd)) |
1512 | #endif | | 1572 | #endif |
1513 | { | | 1573 | { |
1514 | #if 0 | | 1574 | #if 0 |
1515 | DPRINTF(("%s: queue is empty\n", __func__)); | | 1575 | DPRINTF(("%s: queue is empty\n", __func__)); |
1516 | #endif | | 1576 | #endif |
1517 | return; | | 1577 | return; |
| | | 1578 | } else { |
| | | 1579 | #if 0 |
| | | 1580 | DPRINTF(("%s: queue size %d\n", __func__, ifp->if_snd.ifq_len)); |
| | | 1581 | #endif |
1518 | } | | 1582 | } |
1519 | | | 1583 | |
1520 | /* | | 1584 | /* |
1521 | * We cannot transmit packets until a VIO connection has been | | 1585 | * We cannot transmit packets until a VIO connection has been |
1522 | * established. | | 1586 | * established. |
1523 | */ | | 1587 | */ |
1524 | if (!ISSET(sc->sc_vio_state, VIO_RCV_RDX) || | | 1588 | if (!ISSET(sc->sc_vio_state, VIO_RCV_RDX) || |
1525 | !ISSET(sc->sc_vio_state, VIO_ACK_RDX)) | | 1589 | !ISSET(sc->sc_vio_state, VIO_ACK_RDX)) |
1526 | { | | 1590 | { |
1527 | #if 0 | | 1591 | #if 0 |
1528 | DPRINTF(("%s: vio connection not established yet\n", __func__)); | | 1592 | DPRINTF(("%s: vio connection not established yet\n", __func__)); |
1529 | #endif | | 1593 | #endif |
1530 | return; | | 1594 | return; |
1531 | } | | 1595 | } |
1532 | | | 1596 | |
1533 | /* | | 1597 | /* |
1534 | * Make sure there is room in the LDC transmit queue to send a | | 1598 | * Make sure there is room in the LDC transmit queue to send a |
1535 | * DRING_DATA message. | | 1599 | * DRING_DATA message. |
1536 | */ | | 1600 | */ |
1537 | err = hv_ldc_tx_get_state(lc->lc_id, &tx_head, &tx_tail, &tx_state); | | 1601 | err = hv_ldc_tx_get_state(lc->lc_id, &tx_head, &tx_tail, &tx_state); |
1538 | if (err != H_EOK) { | | 1602 | if (err != H_EOK) { |
1539 | DPRINTF(("%s: no room in ldc transmit queue\n", __func__)); | | 1603 | DPRINTF(("%s: no room in ldc transmit queue\n", __func__)); |
1540 | return; | | 1604 | return; |
| @@ -1553,69 +1617,106 @@ FIXME openbsd | | | @@ -1553,69 +1617,106 @@ FIXME openbsd |
1553 | return; | | 1617 | return; |
1554 | } | | 1618 | } |
1555 | } | | 1619 | } |
1556 | | | 1620 | |
1557 | if (sc->sc_xfer_mode == VIO_DESC_MODE) { | | 1621 | if (sc->sc_xfer_mode == VIO_DESC_MODE) { |
1558 | DPRINTF(("%s: vio_desc_mode\n", __func__)); | | 1622 | DPRINTF(("%s: vio_desc_mode\n", __func__)); |
1559 | vnet_start_desc(ifp); | | 1623 | vnet_start_desc(ifp); |
1560 | return; | | 1624 | return; |
1561 | } | | 1625 | } |
1562 | | | 1626 | |
1563 | start = prod = sc->sc_tx_prod & (sc->sc_vd->vd_nentries - 1); | | 1627 | start = prod = sc->sc_tx_prod & (sc->sc_vd->vd_nentries - 1); |
1564 | while (sc->sc_vd->vd_desc[prod].hdr.dstate == VIO_DESC_FREE) { | | 1628 | while (sc->sc_vd->vd_desc[prod].hdr.dstate == VIO_DESC_FREE) { |
1565 | count = sc->sc_tx_prod - sc->sc_tx_cons; | | 1629 | count = sc->sc_tx_prod - sc->sc_tx_cons; |
| | | 1630 | #if 0 |
| | | 1631 | DPRINTF(("%s: count %d\n", __func__, count)); |
| | | 1632 | #endif |
1566 | if (count >= (sc->sc_vd->vd_nentries - 1) || | | 1633 | if (count >= (sc->sc_vd->vd_nentries - 1) || |
1567 | map->lm_count >= map->lm_nentries) { | | 1634 | map->lm_count >= map->lm_nentries) { |
| | | 1635 | DPRINTF(("%s: count issue\n", __func__)); |
1568 | #if 0 | | 1636 | #if 0 |
1569 | FIXME openbsd | | 1637 | FIXME openbsd |
1570 | ifq_set_oactive(&ifp->if_snd); | | 1638 | ifq_set_oactive(&ifp->if_snd); |
1571 | #else | | 1639 | #else |
1572 | ifp->if_flags |= IFF_OACTIVE; | | 1640 | ifp->if_flags |= IFF_OACTIVE; |
1573 | #endif | | 1641 | #endif |
1574 | break; | | 1642 | break; |
1575 | } | | 1643 | } |
1576 | | | 1644 | |
1577 | buf = pool_get(&sc->sc_pool, PR_NOWAIT|PR_ZERO); | | 1645 | buf = pool_get(&sc->sc_pool, PR_NOWAIT|PR_ZERO); |
1578 | if (buf == NULL) { | | 1646 | if (buf == NULL) { |
| | | 1647 | DPRINTF(("%s: buff is NULL\n", __func__)); |
1579 | #if 0 | | 1648 | #if 0 |
1580 | FIXME openbsd | | 1649 | FIXME openbsd |
1581 | ifq_set_oactive(&ifp->if_snd); | | 1650 | ifq_set_oactive(&ifp->if_snd); |
1582 | #else | | 1651 | #else |
1583 | ifp->if_flags |= IFF_OACTIVE; | | 1652 | ifp->if_flags |= IFF_OACTIVE; |
1584 | #endif | | 1653 | #endif |
1585 | break; | | 1654 | break; |
1586 | } | | 1655 | } |
1587 | #if 0 | | 1656 | #if 0 |
1588 | FIXME openbsd | | 1657 | FIXME openbsd |
1589 | m = ifq_dequeue(&ifp->if_snd); | | 1658 | m = ifq_dequeue(&ifp->if_snd); |
1590 | #else | | 1659 | #else |
1591 | IFQ_DEQUEUE(&ifp->if_snd, m); | | 1660 | IFQ_DEQUEUE(&ifp->if_snd, m); |
1592 | #endif | | 1661 | #endif |
1593 | if (m == NULL) { | | 1662 | if (m == NULL) { |
| | | 1663 | #if 0 |
| | | 1664 | DPRINTF(("%s: m is NULL\n", __func__)); |
| | | 1665 | #endif |
1594 | pool_put(&sc->sc_pool, buf); | | 1666 | pool_put(&sc->sc_pool, buf); |
1595 | break; | | 1667 | break; |
| | | 1668 | } else { |
| | | 1669 | #if 0 |
| | | 1670 | DPRINTF(("%s: m is not NULL\n", __func__)); |
| | | 1671 | #endif |
1596 | } | | 1672 | } |
1597 | | | 1673 | |
| | | 1674 | #if 1 |
1598 | m_copydata(m, 0, m->m_pkthdr.len, buf + VNET_ETHER_ALIGN); | | 1675 | m_copydata(m, 0, m->m_pkthdr.len, buf + VNET_ETHER_ALIGN); |
1599 | | | 1676 | #if 0 |
| | | 1677 | DPRINTF(("%s: TX frame size %" PRId16 "\n", |
| | | 1678 | __func__, m->m_pkthdr.len)); |
| | | 1679 | for (int i = 0; i < m->m_pkthdr.len; i++) { |
| | | 1680 | if (i % 16 == 0) { |
| | | 1681 | DPRINTF(("\n")); |
| | | 1682 | } |
| | | 1683 | DPRINTF(("%02x ", buf[VNET_ETHER_ALIGN+i])); |
| | | 1684 | } |
| | | 1685 | DPRINTF(("\n")); |
| | | 1686 | #endif |
| | | 1687 | #else |
| | | 1688 | m_copydata(m, 0, m->m_pkthdr.len, buf); |
| | | 1689 | DPRINTF(("%s: TX frame size %" PRId16 "\n", |
| | | 1690 | __func__, m->m_pkthdr.len)); |
| | | 1691 | for (int i = 0; i < m->m_pkthdr.len; i++) { |
| | | 1692 | if (i % 16 == 0) { |
| | | 1693 | DPRINTF(("\n")); |
| | | 1694 | } |
| | | 1695 | DPRINTF(("%02x ", buf[i])); |
| | | 1696 | } |
| | | 1697 | DPRINTF(("\n")); |
| | | 1698 | #endif |
1600 | #if NBPFILTER > 0 | | 1699 | #if NBPFILTER > 0 |
1601 | /* | | 1700 | /* |
1602 | * If BPF is listening on this interface, let it see the | | 1701 | * If BPF is listening on this interface, let it see the |
1603 | * packet before we commit it to the wire. | | 1702 | * packet before we commit it to the wire. |
1604 | */ | | 1703 | */ |
1605 | if (ifp->if_bpf) | | 1704 | if (ifp->if_bpf) |
1606 | { | | 1705 | { |
| | | 1706 | DPRINTF(("%s: before bpf\n", __func__)); |
1607 | bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT); | | 1707 | bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT); |
1608 | } | | 1708 | DPRINTF(("%s: after bpf\n", __func__)); |
| | | 1709 | } |
1609 | #endif | | 1710 | #endif |
1610 | | | 1711 | |
1611 | pmap_extract(pmap_kernel(), (vaddr_t)buf, &pa); | | 1712 | pmap_extract(pmap_kernel(), (vaddr_t)buf, &pa); |
1612 | KASSERT((pa & ~PAGE_MASK) == (pa & LDC_MTE_RA_MASK)); | | 1713 | KASSERT((pa & ~PAGE_MASK) == (pa & LDC_MTE_RA_MASK)); |
1613 | while (map->lm_slot[map->lm_next].entry != 0) { | | 1714 | while (map->lm_slot[map->lm_next].entry != 0) { |
1614 | map->lm_next++; | | 1715 | map->lm_next++; |
1615 | map->lm_next &= (map->lm_nentries - 1); | | 1716 | map->lm_next &= (map->lm_nentries - 1); |
1616 | } | | 1717 | } |
1617 | map->lm_slot[map->lm_next].entry = (pa & LDC_MTE_RA_MASK); | | 1718 | map->lm_slot[map->lm_next].entry = (pa & LDC_MTE_RA_MASK); |
1618 | map->lm_slot[map->lm_next].entry |= LDC_MTE_CPR; | | 1719 | map->lm_slot[map->lm_next].entry |= LDC_MTE_CPR; |
1619 | #if 0 | | 1720 | #if 0 |
1620 | FIXME openbsd | | 1721 | FIXME openbsd |
1621 | atomic_inc_int(&map->lm_count); | | 1722 | atomic_inc_int(&map->lm_count); |
| @@ -1637,30 +1738,36 @@ FIXME openbsd | | | @@ -1637,30 +1738,36 @@ FIXME openbsd |
1637 | | | 1738 | |
1638 | sc->sc_vsd[prod].vsd_map_idx = map->lm_next; | | 1739 | sc->sc_vsd[prod].vsd_map_idx = map->lm_next; |
1639 | sc->sc_vsd[prod].vsd_buf = buf; | | 1740 | sc->sc_vsd[prod].vsd_buf = buf; |
1640 | | | 1741 | |
1641 | sc->sc_tx_prod++; | | 1742 | sc->sc_tx_prod++; |
1642 | prod = sc->sc_tx_prod & (sc->sc_vd->vd_nentries - 1); | | 1743 | prod = sc->sc_tx_prod & (sc->sc_vd->vd_nentries - 1); |
1643 | | | 1744 | |
1644 | m_freem(m); | | 1745 | m_freem(m); |
1645 | } | | 1746 | } |
1646 | | | 1747 | |
1647 | membar_producer(); | | 1748 | membar_producer(); |
1648 | | | 1749 | |
1649 | if (start != prod && sc->sc_peer_state != VIO_DP_ACTIVE) { | | 1750 | if (start != prod && sc->sc_peer_state != VIO_DP_ACTIVE) { |
| | | 1751 | #if 0 |
| | | 1752 | DPRINTF(("%s: before vnet_send_dring_data()\n", __func__)); |
| | | 1753 | #endif |
1650 | vnet_send_dring_data(sc, start); | | 1754 | vnet_send_dring_data(sc, start); |
1651 | ifp->if_timer = 5; | | 1755 | ifp->if_timer = 5; |
| | | 1756 | } else { |
| | | 1757 | DPRINTF(("%s: no vnet_send_dring_data()\n", __func__)); |
1652 | } | | 1758 | } |
1653 | #if 0 | | 1759 | |
| | | 1760 | #if 0 |
1654 | DPRINTF(("%s: exit\n", __func__)); | | 1761 | DPRINTF(("%s: exit\n", __func__)); |
1655 | #endif | | 1762 | #endif |
1656 | } | | 1763 | } |
1657 | | | 1764 | |
1658 | void | | 1765 | void |
1659 | vnet_start_desc(struct ifnet *ifp) | | 1766 | vnet_start_desc(struct ifnet *ifp) |
1660 | { | | 1767 | { |
1661 | | | 1768 | |
1662 | DPRINTF(("%s: entry\n", __func__)); | | 1769 | DPRINTF(("%s: entry\n", __func__)); |
1663 | | | 1770 | |
1664 | struct vnet_softc *sc = ifp->if_softc; | | 1771 | struct vnet_softc *sc = ifp->if_softc; |
1665 | struct ldc_map *map = sc->sc_lm; | | 1772 | struct ldc_map *map = sc->sc_lm; |
1666 | struct vnet_desc_msg dm; | | 1773 | struct vnet_desc_msg dm; |
| @@ -1819,37 +1926,39 @@ void | | | @@ -1819,37 +1926,39 @@ void |
1819 | vnet_watchdog(struct ifnet *ifp) | | 1926 | vnet_watchdog(struct ifnet *ifp) |
1820 | { | | 1927 | { |
1821 | | | 1928 | |
1822 | DPRINTF(("%s: entry\n", __func__)); | | 1929 | DPRINTF(("%s: entry\n", __func__)); |
1823 | | | 1930 | |
1824 | struct vnet_softc *sc = ifp->if_softc; | | 1931 | struct vnet_softc *sc = ifp->if_softc; |
1825 | | | 1932 | |
1826 | printf("%s: watchdog timeout\n", sc->sc_dv.dv_xname); | | 1933 | printf("%s: watchdog timeout\n", sc->sc_dv.dv_xname); |
1827 | } | | 1934 | } |
1828 | | | 1935 | |
1829 | int | | 1936 | int |
1830 | vnet_media_change(struct ifnet *ifp) | | 1937 | vnet_media_change(struct ifnet *ifp) |
1831 | { | | 1938 | { |
1832 | | | 1939 | #if 0 |
1833 | DPRINTF(("%s: entry\n", __func__)); | | 1940 | DPRINTF(("%s: entry\n", __func__)); |
| | | 1941 | #endif |
1834 | | | 1942 | |
1835 | return (0); | | 1943 | return (0); |
1836 | } | | 1944 | } |
1837 | | | 1945 | |
1838 | void | | 1946 | void |
1839 | vnet_media_status(struct ifnet *ifp, struct ifmediareq *imr) | | 1947 | vnet_media_status(struct ifnet *ifp, struct ifmediareq *imr) |
1840 | { | | 1948 | { |
1841 | | | 1949 | #if 0 |
1842 | DPRINTF(("%s: entry\n", __func__)); | | 1950 | DPRINTF(("%s: entry\n", __func__)); |
| | | 1951 | #endif |
1843 | | | 1952 | |
1844 | imr->ifm_active = IFM_ETHER | IFM_AUTO; | | 1953 | imr->ifm_active = IFM_ETHER | IFM_AUTO; |
1845 | imr->ifm_status = IFM_AVALID; | | 1954 | imr->ifm_status = IFM_AVALID; |
1846 | #if 0 | | 1955 | #if 0 |
1847 | FIXME openbsd | | 1956 | FIXME openbsd |
1848 | if (LINK_STATE_IS_UP(ifp->if_link_state) && | | 1957 | if (LINK_STATE_IS_UP(ifp->if_link_state) && |
1849 | #else | | 1958 | #else |
1850 | if (ifp->if_link_state == LINK_STATE_UP && | | 1959 | if (ifp->if_link_state == LINK_STATE_UP && |
1851 | #endif | | 1960 | #endif |
1852 | ifp->if_flags & IFF_UP) | | 1961 | ifp->if_flags & IFF_UP) |
1853 | imr->ifm_status |= IFM_ACTIVE; | | 1962 | imr->ifm_status |= IFM_ACTIVE; |
1854 | } | | 1963 | } |
1855 | | | 1964 | |