Lines Matching +full:txrx +full:-

2  * Copyright (C) 2013-2016 Universita` di Pisa
31 --- VALE SWITCH ---
44 On the rx ring, the per-port lock is grabbed initially to reserve
54 * OS-specific code that is used only within this file.
55 * Other OS-specific code that must be accessed by drivers
114 struct nm_bridge *b = vp->na_bdg; in netmap_bdg_name()
117 return b->bdg_basename; in netmap_bdg_name()
145 int colon_pos = -1; in nm_bdg_name_validate()
149 return -1; in nm_bdg_name_validate()
157 return -1; in nm_bdg_name_validate()
161 if (strlen(name) - colon_pos > IFNAMSIZ) { in nm_bdg_name_validate()
163 return -1; in nm_bdg_name_validate()
188 (ops != NULL ? strlen(ops->name) : 0)); in nm_find_bridge()
198 if ((x->bdg_flags & NM_BDG_ACTIVE) + x->bdg_active_ports == 0) { in nm_find_bridge()
201 } else if (x->bdg_namelen != namelen) { in nm_find_bridge()
203 } else if (strncmp(name, x->bdg_basename, namelen) == 0) { in nm_find_bridge()
211 nm_prdis("create new bridge %s with ports %d", b->bdg_basename, in nm_find_bridge()
212 b->bdg_active_ports); in nm_find_bridge()
213 b->ht = nm_os_malloc(sizeof(struct nm_hash_ent) * NM_BDG_HASH); in nm_find_bridge()
214 if (b->ht == NULL) { in nm_find_bridge()
218 strncpy(b->bdg_basename, name, namelen); in nm_find_bridge()
219 b->bdg_namelen = namelen; in nm_find_bridge()
220 b->bdg_active_ports = 0; in nm_find_bridge()
222 b->bdg_port_index[i] = i; in nm_find_bridge()
224 b->bdg_ops = b->bdg_saved_ops = *ops; in nm_find_bridge()
225 b->private_data = b->ht; in nm_find_bridge()
226 b->bdg_flags = 0; in nm_find_bridge()
236 if ((b->bdg_flags & NM_BDG_ACTIVE) + b->bdg_active_ports != 0) { in netmap_bdg_free()
240 nm_prdis("marking bridge %s as free", b->bdg_basename); in netmap_bdg_free()
241 nm_os_free(b->ht); in netmap_bdg_free()
242 memset(&b->bdg_ops, 0, sizeof(b->bdg_ops)); in netmap_bdg_free()
243 memset(&b->bdg_saved_ops, 0, sizeof(b->bdg_saved_ops)); in netmap_bdg_free()
244 b->bdg_flags = 0; in netmap_bdg_free()
274 private_data = callback(b->private_data, callback_data, &error); in netmap_bdg_update_private_data()
275 b->private_data = private_data; in netmap_bdg_update_private_data()
286 * (sw can be -1 if not needed)
292 int i, lim =b->bdg_active_ports; in netmap_bdg_detach_common()
293 uint32_t *tmp = b->tmp_bdg_port_index; in netmap_bdg_detach_common()
298 lookup NA(ifp)->bdg_port and SWNA(ifp)->bdg_port in netmap_bdg_detach_common()
310 memcpy(b->tmp_bdg_port_index, b->bdg_port_index, sizeof(b->tmp_bdg_port_index)); in netmap_bdg_detach_common()
314 lim--; /* point to last active port */ in netmap_bdg_detach_common()
317 hw = -1; in netmap_bdg_detach_common()
320 lim--; in netmap_bdg_detach_common()
323 sw = -1; in netmap_bdg_detach_common()
333 if (b->bdg_ops.dtor) in netmap_bdg_detach_common()
334 b->bdg_ops.dtor(b->bdg_ports[s_hw]); in netmap_bdg_detach_common()
335 b->bdg_ports[s_hw] = NULL; in netmap_bdg_detach_common()
337 b->bdg_ports[s_sw] = NULL; in netmap_bdg_detach_common()
339 memcpy(b->bdg_port_index, b->tmp_bdg_port_index, sizeof(b->tmp_bdg_port_index)); in netmap_bdg_detach_common()
340 b->bdg_active_ports = lim; in netmap_bdg_detach_common()
353 struct nm_bridge *b = vpna->na_bdg; in netmap_vp_bdg_ctl()
355 if (hdr->nr_reqtype == NETMAP_REQ_VALE_ATTACH) { in netmap_vp_bdg_ctl()
360 netmap_bdg_detach_common(b, vpna->bdg_port, -1); in netmap_vp_bdg_ctl()
361 vpna->na_bdg = NULL; in netmap_vp_bdg_ctl()
389 char *nr_name = hdr->nr_name; in netmap_get_bdg_na()
403 if (strncmp(nr_name, ops->name, strlen(ops->name) - 1)) { in netmap_get_bdg_na()
412 if (strlen(nr_name) < b->bdg_namelen) /* impossible */ in netmap_get_bdg_na()
423 for (j = 0; j < b->bdg_active_ports; j++) { in netmap_get_bdg_na()
424 i = b->bdg_port_index[j]; in netmap_get_bdg_na()
425 vpna = b->bdg_ports[i]; in netmap_get_bdg_na()
426 nm_prdis("checking %s", vpna->up.name); in netmap_get_bdg_na()
427 if (!strcmp(vpna->up.name, nr_name)) { in netmap_get_bdg_na()
428 netmap_adapter_get(&vpna->up); in netmap_get_bdg_na()
430 *na = &vpna->up; in netmap_get_bdg_na()
439 if (b->bdg_active_ports + needed >= NM_BDG_MAXPORTS) { in netmap_get_bdg_na()
440 nm_prerr("bridge full %d, cannot create new port", b->bdg_active_ports); in netmap_get_bdg_na()
444 cand = b->bdg_port_index[b->bdg_active_ports]; in netmap_get_bdg_na()
445 cand2 = b->bdg_port_index[b->bdg_active_ports + 1]; in netmap_get_bdg_na()
447 b->bdg_basename, ifname, b->bdg_active_ports, cand, cand2); in netmap_get_bdg_na()
453 ifname = nr_name + b->bdg_namelen + 1; in netmap_get_bdg_na()
457 * This block contains all the ephemeral-specific logic. in netmap_get_bdg_na()
460 if (hdr->nr_reqtype != NETMAP_REQ_REGISTER) { in netmap_get_bdg_na()
466 error = b->bdg_ops.vp_create(hdr, NULL, nmd, &vpna); in netmap_get_bdg_na()
472 /* shortcut - we can skip get_hw_na(), in netmap_get_bdg_na()
480 switch (hdr->nr_reqtype) { in netmap_get_bdg_na()
496 error = hw->nm_bdg_attach(nr_name, hw, b); in netmap_get_bdg_na()
498 error = b->bdg_ops.bwrap_attach(nr_name, hw); in netmap_get_bdg_na()
502 vpna = hw->na_vp; in netmap_get_bdg_na()
503 hostna = hw->na_hostvp; in netmap_get_bdg_na()
504 if (hdr->nr_reqtype == NETMAP_REQ_VALE_ATTACH) { in netmap_get_bdg_na()
507 (struct nmreq_vale_attach *)(uintptr_t)hdr->nr_body; in netmap_get_bdg_na()
508 if (areq->reg.nr_mode != NR_REG_NIC_SW) { in netmap_get_bdg_na()
515 vpna->bdg_port = cand; in netmap_get_bdg_na()
518 b->bdg_ports[cand] = vpna; in netmap_get_bdg_na()
519 vpna->na_bdg = b; in netmap_get_bdg_na()
520 b->bdg_active_ports++; in netmap_get_bdg_na()
523 b->bdg_ports[cand2] = hostna; in netmap_get_bdg_na()
524 hostna->bdg_port = cand2; in netmap_get_bdg_na()
525 hostna->na_bdg = b; in netmap_get_bdg_na()
526 b->bdg_active_ports++; in netmap_get_bdg_na()
529 nm_prdis("if %s refs %d", ifname, vpna->up.na_refcount); in netmap_get_bdg_na()
531 *na = &vpna->up; in netmap_get_bdg_na()
547 (struct nmreq_vale_attach *)(uintptr_t)hdr->nr_body; in netmap_bdg_attach()
556 b = nm_find_bridge(hdr->nr_name, 0 /* don't create */, NULL); in netmap_bdg_attach()
562 if (req->reg.nr_mem_id) { in netmap_bdg_attach()
563 nmd = netmap_mem_find(req->reg.nr_mem_id); in netmap_bdg_attach()
592 if (na->nm_bdg_ctl) { in netmap_bdg_attach()
596 error = na->nm_bdg_ctl(hdr, na); in netmap_bdg_attach()
599 nm_prdis("registered %s to netmap-mode", na->name); in netmap_bdg_attach()
602 req->port_index = vpna->bdg_port; in netmap_bdg_attach()
624 return na->nm_register == netmap_bwrap_reg; in nm_is_bwrap()
643 struct nmreq_vale_detach *nmreq_det = (void *)(uintptr_t)hdr->nr_body; in netmap_bdg_detach_locked()
650 b = nm_find_bridge(hdr->nr_name, 0 /* don't create */, NULL); in netmap_bdg_detach_locked()
665 ((struct netmap_bwrap_adapter *)na)->na_polling_state) { in netmap_bdg_detach_locked()
672 if (na->na_vp != vpna) { in netmap_bdg_detach_locked()
679 nmreq_det->port_index = vpna->bdg_port; in netmap_bdg_detach_locked()
681 if (na->nm_bdg_ctl) { in netmap_bdg_detach_locked()
685 error = na->nm_bdg_ctl(hdr, na); in netmap_bdg_detach_locked()
727 qfirst = nbk->qfirst; in netmap_bwrap_polling()
728 qlast = nbk->qlast; in netmap_bwrap_polling()
729 bna = nbk->bps->bna; in netmap_bwrap_polling()
730 kring0 = NMR(bna->hwna, NR_RX); in netmap_bwrap_polling()
734 kring->nm_notify(kring, 0); in netmap_bwrap_polling()
744 bps->kthreads = nm_os_malloc(sizeof(struct nm_bdg_kthread) * bps->ncpus); in nm_bdg_create_kthreads()
745 if (bps->kthreads == NULL) in nm_bdg_create_kthreads()
750 for (i = 0; i < bps->ncpus; i++) { in nm_bdg_create_kthreads()
751 struct nm_bdg_kthread *t = bps->kthreads + i; in nm_bdg_create_kthreads()
752 int all = (bps->ncpus == 1 && in nm_bdg_create_kthreads()
753 bps->mode == NETMAP_POLLING_MODE_SINGLE_CPU); in nm_bdg_create_kthreads()
754 int affinity = bps->cpu_from + i; in nm_bdg_create_kthreads()
756 t->bps = bps; in nm_bdg_create_kthreads()
757 t->qfirst = all ? bps->qfirst /* must be 0 */: affinity; in nm_bdg_create_kthreads()
758 t->qlast = all ? bps->qlast : t->qfirst + 1; in nm_bdg_create_kthreads()
760 nm_prinf("kthread %d a:%u qf:%u ql:%u", i, affinity, t->qfirst, in nm_bdg_create_kthreads()
761 t->qlast); in nm_bdg_create_kthreads()
765 t->nmk = nm_os_kctx_create(&kcfg, NULL); in nm_bdg_create_kthreads()
766 if (t->nmk == NULL) { in nm_bdg_create_kthreads()
769 nm_os_kctx_worker_setaff(t->nmk, affinity); in nm_bdg_create_kthreads()
775 struct nm_bdg_kthread *t = bps->kthreads + i; in nm_bdg_create_kthreads()
776 nm_os_kctx_destroy(t->nmk); in nm_bdg_create_kthreads()
778 nm_os_free(bps->kthreads); in nm_bdg_create_kthreads()
792 bps->stopped = false; in nm_bdg_polling_start_kthreads()
794 for (i = 0; i < bps->ncpus; i++) { in nm_bdg_polling_start_kthreads()
795 struct nm_bdg_kthread *t = bps->kthreads + i; in nm_bdg_polling_start_kthreads()
796 error = nm_os_kctx_worker_start(t->nmk); in nm_bdg_polling_start_kthreads()
806 struct nm_bdg_kthread *t = bps->kthreads + i; in nm_bdg_polling_start_kthreads()
807 nm_os_kctx_worker_stop(t->nmk); in nm_bdg_polling_start_kthreads()
809 bps->stopped = true; in nm_bdg_polling_start_kthreads()
821 for (i = 0; i < bps->ncpus; i++) { in nm_bdg_polling_stop_delete_kthreads()
822 struct nm_bdg_kthread *t = bps->kthreads + i; in nm_bdg_polling_stop_delete_kthreads()
823 nm_os_kctx_worker_stop(t->nmk); in nm_bdg_polling_stop_delete_kthreads()
824 nm_os_kctx_destroy(t->nmk); in nm_bdg_polling_stop_delete_kthreads()
826 bps->stopped = true; in nm_bdg_polling_stop_delete_kthreads()
835 uint32_t i = req->nr_first_cpu_id; in get_polling_cfg()
836 uint32_t req_cpus = req->nr_num_polling_cpus; in get_polling_cfg()
848 if (req->nr_mode == NETMAP_POLLING_MODE_MULTI_CPU) { in get_polling_cfg()
854 nm_prerr("Rings %u-%u not in range (have %d rings)", in get_polling_cfg()
862 } else if (req->nr_mode == NETMAP_POLLING_MODE_SINGLE_CPU) { in get_polling_cfg()
878 bps->mode = req->nr_mode; in get_polling_cfg()
879 bps->qfirst = qfirst; in get_polling_cfg()
880 bps->qlast = qlast; in get_polling_cfg()
881 bps->cpu_from = core_from; in get_polling_cfg()
882 bps->ncpus = req_cpus; in get_polling_cfg()
884 req->nr_mode == NETMAP_POLLING_MODE_MULTI_CPU ? in get_polling_cfg()
898 if (bna->na_polling_state) { in nm_bdg_ctl_polling_start()
906 bps->configured = false; in nm_bdg_ctl_polling_start()
907 bps->stopped = true; in nm_bdg_ctl_polling_start()
919 bps->configured = true; in nm_bdg_ctl_polling_start()
920 bna->na_polling_state = bps; in nm_bdg_ctl_polling_start()
921 bps->bna = bna; in nm_bdg_ctl_polling_start()
924 nma_intr_enable(bna->hwna, 0); in nm_bdg_ctl_polling_start()
929 nm_os_free(bps->kthreads); in nm_bdg_ctl_polling_start()
931 bna->na_polling_state = NULL; in nm_bdg_ctl_polling_start()
932 nma_intr_enable(bna->hwna, 1); in nm_bdg_ctl_polling_start()
943 if (!bna->na_polling_state) { in nm_bdg_ctl_polling_stop()
947 bps = bna->na_polling_state; in nm_bdg_ctl_polling_stop()
948 nm_bdg_polling_stop_delete_kthreads(bna->na_polling_state); in nm_bdg_ctl_polling_stop()
949 bps->configured = false; in nm_bdg_ctl_polling_stop()
951 bna->na_polling_state = NULL; in nm_bdg_ctl_polling_stop()
952 /* re-enable interrupts */ in nm_bdg_ctl_polling_stop()
953 nma_intr_enable(bna->hwna, 1); in nm_bdg_ctl_polling_stop()
961 (struct nmreq_vale_polling *)(uintptr_t)hdr->nr_body; in nm_bdg_polling()
970 } else if (hdr->nr_reqtype == NETMAP_BDG_POLLING_ON) { in nm_bdg_polling()
1017 bzero(b->ht, sizeof(struct nm_hash_ent) * NM_BDG_HASH); in netmap_bdg_regops()
1018 b->bdg_ops = b->bdg_saved_ops; in netmap_bdg_regops()
1019 b->private_data = b->ht; in netmap_bdg_regops()
1022 b->private_data = private_data; in netmap_bdg_regops()
1023 #define nm_bdg_override(m) if (bdg_ops->m) b->bdg_ops.m = bdg_ops->m in netmap_bdg_regops()
1047 b = nm_find_bridge(nr->nifr_name, 0, NULL); in netmap_bdg_config()
1055 if (b->bdg_ops.config != NULL) in netmap_bdg_config()
1056 error = b->bdg_ops.config(nr); in netmap_bdg_config()
1072 if (vpna->na_bdg) in netmap_vp_reg()
1073 BDG_WLOCK(vpna->na_bdg); in netmap_vp_reg()
1076 if (na->active_fds == 0) in netmap_vp_reg()
1077 na->na_flags |= NAF_NETMAP_ON; in netmap_vp_reg()
1079 * toggle IFCAP_NETMAP in na->ifp (2014-03-16) in netmap_vp_reg()
1082 if (na->active_fds == 0) in netmap_vp_reg()
1083 na->na_flags &= ~NAF_NETMAP_ON; in netmap_vp_reg()
1086 if (vpna->na_bdg) in netmap_vp_reg()
1087 BDG_WUNLOCK(vpna->na_bdg); in netmap_vp_reg()
1098 struct netmap_adapter *na = kring->na; in netmap_vp_rxsync_locked()
1099 struct netmap_ring *ring = kring->ring; in netmap_vp_rxsync_locked()
1100 u_int nm_i, lim = kring->nkr_num_slots - 1; in netmap_vp_rxsync_locked()
1101 u_int head = kring->rhead; in netmap_vp_rxsync_locked()
1114 nm_i = kring->nr_hwcur; in netmap_vp_rxsync_locked()
1118 struct netmap_slot *slot = &ring->slot[nm_i]; in netmap_vp_rxsync_locked()
1121 if (addr == NETMAP_BUF_BASE(kring->na)) { /* bad buf */ in netmap_vp_rxsync_locked()
1123 slot->buf_idx); in netmap_vp_rxsync_locked()
1125 slot->flags &= ~NS_BUF_CHANGED; in netmap_vp_rxsync_locked()
1128 kring->nr_hwcur = head; in netmap_vp_rxsync_locked()
1148 mtx_lock(&kring->q_lock); in netmap_vp_rxsync()
1150 mtx_unlock(&kring->q_lock); in netmap_vp_rxsync()
1158 return ops->bwrap_attach(nr_name, hwna); in netmap_bwrap_attach()
1163 * This is used to connect a non-VALE-port netmap_adapter (hwna) to a
1175 * - callbacks coming from the netmap module are intercepted by
1178 * - callbacks coming from outside of the netmap module only know
1180 * handlers, where only the hwna->nm_notify callback is called.
1181 * What the bwrap does is to overwrite the hwna->nm_notify callback
1183 * XXX This assumes that the hwna->nm_notify callback was the
1185 * Any additional action performed by hwna->nm_notify will not be
1197 struct netmap_adapter *hwna = bna->hwna; in netmap_bwrap_dtor()
1198 struct nm_bridge *b = bna->up.na_bdg, in netmap_bwrap_dtor()
1199 *bh = bna->host.na_bdg; in netmap_bwrap_dtor()
1201 if (bna->host.up.nm_mem) in netmap_bwrap_dtor()
1202 netmap_mem_put(bna->host.up.nm_mem); in netmap_bwrap_dtor()
1205 netmap_bdg_detach_common(b, bna->up.bdg_port, in netmap_bwrap_dtor()
1206 (bh ? bna->host.bdg_port : -1)); in netmap_bwrap_dtor()
1210 na->ifp = NULL; in netmap_bwrap_dtor()
1211 bna->host.up.ifp = NULL; in netmap_bwrap_dtor()
1212 hwna->na_vp = bna->saved_na_vp; in netmap_bwrap_dtor()
1213 hwna->na_hostvp = NULL; in netmap_bwrap_dtor()
1214 hwna->na_private = NULL; in netmap_bwrap_dtor()
1215 hwna->na_flags &= ~NAF_BUSY; in netmap_bwrap_dtor()
1243 struct netmap_adapter *na = kring->na; in netmap_bwrap_intr_notify()
1244 struct netmap_bwrap_adapter *bna = na->na_private; in netmap_bwrap_intr_notify()
1246 struct netmap_vp_adapter *vpna = &bna->up; in netmap_bwrap_intr_notify()
1247 u_int ring_nr = kring->ring_id; in netmap_bwrap_intr_notify()
1252 nm_prinf("%s %s 0x%x", na->name, kring->name, flags); in netmap_bwrap_intr_notify()
1254 bkring = vpna->up.tx_rings[ring_nr]; in netmap_bwrap_intr_notify()
1262 nm_prinf("%s head %d cur %d tail %d", na->name, in netmap_bwrap_intr_notify()
1263 kring->rhead, kring->rcur, kring->rtail); in netmap_bwrap_intr_notify()
1268 error = kring->nm_sync(kring, 0); in netmap_bwrap_intr_notify()
1271 if (kring->nr_hwcur == kring->nr_hwtail) { in netmap_bwrap_intr_notify()
1274 kring->name); in netmap_bwrap_intr_notify()
1278 /* new packets are kring->rcur to kring->nr_hwtail, and the bkring in netmap_bwrap_intr_notify()
1279 * had hwcur == bkring->rhead. So advance bkring->rhead to kring->nr_hwtail in netmap_bwrap_intr_notify()
1282 bkring->rhead = bkring->rcur = kring->nr_hwtail; in netmap_bwrap_intr_notify()
1284 bkring->nm_sync(bkring, flags); in netmap_bwrap_intr_notify()
1287 kring->rhead = kring->rcur = kring->rtail = kring->nr_hwtail; in netmap_bwrap_intr_notify()
1289 error = kring->nm_sync(kring, 0); in netmap_bwrap_intr_notify()
1293 if (kring->rcur != kring->nr_hwtail) { in netmap_bwrap_intr_notify()
1309 struct netmap_adapter *hwna = bna->hwna; in netmap_bwrap_reg()
1310 struct netmap_vp_adapter *hostna = &bna->host; in netmap_bwrap_reg()
1312 enum txrx t; in netmap_bwrap_reg()
1314 nm_prdis("%s %s", na->name, onoff ? "on" : "off"); in netmap_bwrap_reg()
1322 hwna->na_lut = na->na_lut; in netmap_bwrap_reg()
1324 if (hostna->na_bdg) { in netmap_bwrap_reg()
1329 hostna->up.na_lut = na->na_lut; in netmap_bwrap_reg()
1337 NMR(hwna, nm_txrx_swap(t))[i]->nr_pending_mode = in netmap_bwrap_reg()
1338 NMR(na, t)[i]->nr_pending_mode; in netmap_bwrap_reg()
1343 error = hwna->nm_register(hwna, onoff); in netmap_bwrap_reg()
1351 NMR(na, t)[i]->nr_mode = kring->nr_mode; in netmap_bwrap_reg()
1357 if (hostna->na_bdg) in netmap_bwrap_reg()
1358 netmap_vp_reg(&hostna->up, onoff); in netmap_bwrap_reg()
1363 for (i = 0; i < hwna->num_rx_rings; i++) { in netmap_bwrap_reg()
1364 hwna->rx_rings[i]->save_notify = hwna->rx_rings[i]->nm_notify; in netmap_bwrap_reg()
1365 hwna->rx_rings[i]->nm_notify = bna->nm_intr_notify; in netmap_bwrap_reg()
1367 i = hwna->num_rx_rings; /* for safety */ in netmap_bwrap_reg()
1370 hwna->rx_rings[i]->save_notify = in netmap_bwrap_reg()
1371 hwna->rx_rings[i]->nm_notify; in netmap_bwrap_reg()
1372 if (hostna->na_bdg) { in netmap_bwrap_reg()
1374 hwna->rx_rings[i]->nm_notify = in netmap_bwrap_reg()
1376 na->tx_rings[i]->nm_sync = na->nm_txsync; in netmap_bwrap_reg()
1379 if (na->active_fds == 0) in netmap_bwrap_reg()
1380 na->na_flags |= NAF_NETMAP_ON; in netmap_bwrap_reg()
1384 if (na->active_fds == 0) in netmap_bwrap_reg()
1385 na->na_flags &= ~NAF_NETMAP_ON; in netmap_bwrap_reg()
1389 hwna->rx_rings[i]->nm_notify = in netmap_bwrap_reg()
1390 hwna->rx_rings[i]->save_notify; in netmap_bwrap_reg()
1391 hwna->rx_rings[i]->save_notify = NULL; in netmap_bwrap_reg()
1393 hwna->na_lut.lut = NULL; in netmap_bwrap_reg()
1394 hwna->na_lut.plut = NULL; in netmap_bwrap_reg()
1395 hwna->na_lut.objtotal = 0; in netmap_bwrap_reg()
1396 hwna->na_lut.objsize = 0; in netmap_bwrap_reg()
1414 struct netmap_adapter *hwna = bna->hwna; in netmap_bwrap_config()
1418 error = netmap_mem_get_lut(hwna->nm_mem, &bna->host.up.na_lut); in netmap_bwrap_config()
1425 error = netmap_mem_get_lut(hwna->nm_mem, &hwna->na_lut); in netmap_bwrap_config()
1430 info->num_tx_rings = hwna->num_rx_rings; in netmap_bwrap_config()
1431 info->num_tx_descs = hwna->num_rx_desc; in netmap_bwrap_config()
1432 info->num_rx_rings = hwna->num_tx_rings; in netmap_bwrap_config()
1433 info->num_rx_descs = hwna->num_tx_desc; in netmap_bwrap_config()
1434 info->rx_buf_maxsize = hwna->rx_buf_maxsize; in netmap_bwrap_config()
1436 if (na->na_flags & NAF_HOST_RINGS) { in netmap_bwrap_config()
1437 struct netmap_adapter *hostna = &bna->host.up; in netmap_bwrap_config()
1438 enum txrx t; in netmap_bwrap_config()
1441 if (na->na_flags & NAF_HOST_ALL) { in netmap_bwrap_config()
1442 hostna->num_tx_rings = nma_get_nrings(hwna, NR_RX); in netmap_bwrap_config()
1443 hostna->num_rx_rings = nma_get_nrings(hwna, NR_TX); in netmap_bwrap_config()
1445 nm_bound_var(&hostna->num_tx_rings, 1, 1, in netmap_bwrap_config()
1447 nm_bound_var(&hostna->num_rx_rings, 1, 1, in netmap_bwrap_config()
1451 enum txrx r = nm_txrx_swap(t); in netmap_bwrap_config()
1469 struct netmap_adapter *na = kring->na; in netmap_bwrap_bufcfg()
1472 struct netmap_adapter *hwna = bna->hwna; in netmap_bwrap_bufcfg()
1474 enum txrx r; in netmap_bwrap_bufcfg()
1480 r = nm_txrx_swap(kring->tx); in netmap_bwrap_bufcfg()
1481 hwkring = NMR(hwna, r)[kring->ring_id]; in netmap_bwrap_bufcfg()
1486 hwkring->offset_mask = kring->offset_mask; in netmap_bwrap_bufcfg()
1487 hwkring->offset_max = kring->offset_max; in netmap_bwrap_bufcfg()
1488 hwkring->offset_gap = kring->offset_gap; in netmap_bwrap_bufcfg()
1490 error = hwkring->nm_bufcfg(hwkring, target); in netmap_bwrap_bufcfg()
1494 kring->hwbuf_len = hwkring->hwbuf_len; in netmap_bwrap_bufcfg()
1495 kring->buf_align = hwkring->buf_align; in netmap_bwrap_bufcfg()
1506 struct netmap_adapter *hwna = bna->hwna; in netmap_bwrap_krings_create_common()
1507 struct netmap_adapter *hostna = &bna->host.up; in netmap_bwrap_krings_create_common()
1509 enum txrx t; in netmap_bwrap_krings_create_common()
1512 error = hwna->nm_krings_create(hwna); in netmap_bwrap_krings_create_common()
1520 NMR(hwna, t)[i]->users++; in netmap_bwrap_krings_create_common()
1523 NMR(na, t)[i]->nr_kflags |= NKR_NEEDRING; in netmap_bwrap_krings_create_common()
1533 /* cross-link the netmap rings in netmap_bwrap_krings_create_common()
1538 enum txrx r = nm_txrx_swap(t); /* swap NR_TX <-> NR_RX */ in netmap_bwrap_krings_create_common()
1540 NMR(na, t)[i]->nkr_num_slots = NMR(hwna, r)[i]->nkr_num_slots; in netmap_bwrap_krings_create_common()
1541 NMR(na, t)[i]->ring = NMR(hwna, r)[i]->ring; in netmap_bwrap_krings_create_common()
1545 if (na->na_flags & NAF_HOST_RINGS) { in netmap_bwrap_krings_create_common()
1550 hostna->tx_rings = &na->tx_rings[na->num_tx_rings]; in netmap_bwrap_krings_create_common()
1551 hostna->rx_rings = &na->rx_rings[na->num_rx_rings]; in netmap_bwrap_krings_create_common()
1554 NMR(hostna, t)[i]->na = hostna; in netmap_bwrap_krings_create_common()
1564 NMR(hwna, t)[i]->users--; in netmap_bwrap_krings_create_common()
1565 NMR(na, t)[i]->users--; in netmap_bwrap_krings_create_common()
1568 hwna->nm_krings_delete(hwna); in netmap_bwrap_krings_create_common()
1578 struct netmap_adapter *hwna = bna->hwna; in netmap_bwrap_krings_delete_common()
1579 enum txrx t; in netmap_bwrap_krings_delete_common()
1582 nm_prdis("%s", na->name); in netmap_bwrap_krings_delete_common()
1587 NMR(hwna, t)[i]->users--; in netmap_bwrap_krings_delete_common()
1588 NMR(na, t)[i]->users--; in netmap_bwrap_krings_delete_common()
1594 hwna->nm_krings_delete(hwna); in netmap_bwrap_krings_delete_common()
1598 /* notify method for the bridge-->hwna direction */
1602 struct netmap_adapter *na = kring->na; in netmap_bwrap_notify()
1603 struct netmap_bwrap_adapter *bna = na->na_private; in netmap_bwrap_notify()
1604 struct netmap_adapter *hwna = bna->hwna; in netmap_bwrap_notify()
1605 u_int ring_n = kring->ring_id; in netmap_bwrap_notify()
1606 u_int lim = kring->nkr_num_slots - 1; in netmap_bwrap_notify()
1611 (kring ? kring->name : "NULL!"), in netmap_bwrap_notify()
1612 (na ? na->name : "NULL!"), in netmap_bwrap_notify()
1613 (hwna ? hwna->name : "NULL!")); in netmap_bwrap_notify()
1614 hw_kring = hwna->tx_rings[ring_n]; in netmap_bwrap_notify()
1623 na->name, ring_n, in netmap_bwrap_notify()
1624 kring->nr_hwcur, kring->nr_hwtail, kring->nkr_hwlease, in netmap_bwrap_notify()
1625 kring->rhead, kring->rcur, kring->rtail, in netmap_bwrap_notify()
1626 hw_kring->nr_hwcur, hw_kring->nr_hwtail, hw_kring->rtail); in netmap_bwrap_notify()
1630 hw_kring->rhead = hw_kring->rcur = kring->nr_hwtail; in netmap_bwrap_notify()
1631 error = hw_kring->nm_sync(hw_kring, flags); in netmap_bwrap_notify()
1637 kring->rhead = kring->rcur = nm_next(hw_kring->nr_hwtail, lim); /* skip past reserved slot */ in netmap_bwrap_notify()
1642 na->name, ring_n, in netmap_bwrap_notify()
1643 kring->nr_hwcur, kring->nr_hwtail, kring->nkr_hwlease, in netmap_bwrap_notify()
1644 kring->rhead, kring->rcur, kring->rtail, in netmap_bwrap_notify()
1645 hw_kring->nr_hwcur, hw_kring->nr_hwtail, hw_kring->rtail); in netmap_bwrap_notify()
1654 * Called on bridge-attach and detach, as an effect of valectl -[ahd].
1668 if (hdr->nr_reqtype == NETMAP_REQ_VALE_ATTACH) { in netmap_bwrap_bdg_ctl()
1670 (struct nmreq_vale_attach *)(uintptr_t)hdr->nr_body; in netmap_bwrap_bdg_ctl()
1671 if (req->reg.nr_ringid != 0 || in netmap_bwrap_bdg_ctl()
1672 (req->reg.nr_mode != NR_REG_ALL_NIC && in netmap_bwrap_bdg_ctl()
1673 req->reg.nr_mode != NR_REG_NIC_SW)) { in netmap_bwrap_bdg_ctl()
1681 if (bna->na_kpriv) { in netmap_bwrap_bdg_ctl()
1688 npriv->np_ifp = na->ifp; /* let the priv destructor release the ref */ in netmap_bwrap_bdg_ctl()
1692 netmap_mem_restore(bna->hwna); in netmap_bwrap_bdg_ctl()
1695 bna->na_kpriv = npriv; in netmap_bwrap_bdg_ctl()
1696 na->na_flags |= NAF_BUSY; in netmap_bwrap_bdg_ctl()
1698 if (na->active_fds == 0) /* not registered */ in netmap_bwrap_bdg_ctl()
1700 netmap_priv_delete(bna->na_kpriv); in netmap_bwrap_bdg_ctl()
1701 bna->na_kpriv = NULL; in netmap_bwrap_bdg_ctl()
1702 na->na_flags &= ~NAF_BUSY; in netmap_bwrap_bdg_ctl()
1703 netmap_mem_restore(bna->hwna); in netmap_bwrap_bdg_ctl()
1717 enum txrx t; in netmap_bwrap_attach_common()
1721 nm_prerr("NIC %s busy, cannot attach to bridge", hwna->name); in netmap_bwrap_attach_common()
1727 na->ifp = hwna->ifp; in netmap_bwrap_attach_common()
1728 if_ref(na->ifp); in netmap_bwrap_attach_common()
1729 na->na_private = bna; in netmap_bwrap_attach_common()
1731 * swapped. The real cross-linking will be done during register, in netmap_bwrap_attach_common()
1735 enum txrx r = nm_txrx_swap(t); /* swap NR_TX <-> NR_RX */ in netmap_bwrap_attach_common()
1739 na->nm_dtor = netmap_bwrap_dtor; in netmap_bwrap_attach_common()
1740 na->nm_config = netmap_bwrap_config; in netmap_bwrap_attach_common()
1741 na->nm_bufcfg = netmap_bwrap_bufcfg; in netmap_bwrap_attach_common()
1742 na->nm_bdg_ctl = netmap_bwrap_bdg_ctl; in netmap_bwrap_attach_common()
1743 na->pdev = hwna->pdev; in netmap_bwrap_attach_common()
1744 na->nm_mem = netmap_mem_get(hwna->nm_mem); in netmap_bwrap_attach_common()
1745 na->virt_hdr_len = hwna->virt_hdr_len; in netmap_bwrap_attach_common()
1746 na->rx_buf_maxsize = hwna->rx_buf_maxsize; in netmap_bwrap_attach_common()
1748 bna->hwna = hwna; in netmap_bwrap_attach_common()
1750 hwna->na_private = bna; /* weak reference */ in netmap_bwrap_attach_common()
1751 bna->saved_na_vp = hwna->na_vp; in netmap_bwrap_attach_common()
1752 hwna->na_vp = &bna->up; in netmap_bwrap_attach_common()
1753 bna->up.up.na_vp = &(bna->up); in netmap_bwrap_attach_common()
1755 if (hwna->na_flags & NAF_HOST_RINGS) { in netmap_bwrap_attach_common()
1756 if (hwna->na_flags & NAF_SW_ONLY) in netmap_bwrap_attach_common()
1757 na->na_flags |= NAF_SW_ONLY; in netmap_bwrap_attach_common()
1758 na->na_flags |= NAF_HOST_RINGS; in netmap_bwrap_attach_common()
1759 hostna = &bna->host.up; in netmap_bwrap_attach_common()
1761 snprintf(hostna->name, sizeof(hostna->name), "%s^", na->name); in netmap_bwrap_attach_common()
1762 hostna->ifp = hwna->ifp; in netmap_bwrap_attach_common()
1763 // hostna->nm_txsync = netmap_bwrap_host_txsync; in netmap_bwrap_attach_common()
1764 // hostna->nm_rxsync = netmap_bwrap_host_rxsync; in netmap_bwrap_attach_common()
1765 hostna->nm_mem = netmap_mem_get(na->nm_mem); in netmap_bwrap_attach_common()
1766 hostna->na_private = bna; in netmap_bwrap_attach_common()
1767 hostna->na_vp = &bna->up; in netmap_bwrap_attach_common()
1768 na->na_hostvp = hwna->na_hostvp = in netmap_bwrap_attach_common()
1769 hostna->na_hostvp = &bna->host; in netmap_bwrap_attach_common()
1770 hostna->na_flags = NAF_BUSY; /* prevent NIOCREGIF */ in netmap_bwrap_attach_common()
1771 hostna->rx_buf_maxsize = hwna->rx_buf_maxsize; in netmap_bwrap_attach_common()
1774 if (hwna->na_flags & NAF_MOREFRAG) in netmap_bwrap_attach_common()
1775 na->na_flags |= NAF_MOREFRAG; in netmap_bwrap_attach_common()
1777 nm_prdis("%s<->%s txr %d txd %d rxr %d rxd %d", in netmap_bwrap_attach_common()
1778 na->name, if_name(ifp), in netmap_bwrap_attach_common()
1779 na->num_tx_rings, na->num_tx_desc, in netmap_bwrap_attach_common()
1780 na->num_rx_rings, na->num_rx_desc); in netmap_bwrap_attach_common()
1786 hwna->na_flags |= NAF_BUSY; in netmap_bwrap_attach_common()
1790 hwna->na_vp = hwna->na_hostvp = NULL; in netmap_bwrap_attach_common()