Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/netmap/netmap_vale.c
Show First 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | |||||
SYSBEGIN(vars_vale); | SYSBEGIN(vars_vale); | ||||
SYSCTL_DECL(_dev_netmap); | SYSCTL_DECL(_dev_netmap); | ||||
SYSCTL_INT(_dev_netmap, OID_AUTO, bridge_batch, CTLFLAG_RW, &bridge_batch, 0, | SYSCTL_INT(_dev_netmap, OID_AUTO, bridge_batch, CTLFLAG_RW, &bridge_batch, 0, | ||||
"Max batch size to be used in the bridge"); | "Max batch size to be used in the bridge"); | ||||
SYSCTL_UINT(_dev_netmap, OID_AUTO, max_bridges, CTLFLAG_RDTUN, &vale_max_bridges, 0, | SYSCTL_UINT(_dev_netmap, OID_AUTO, max_bridges, CTLFLAG_RDTUN, &vale_max_bridges, 0, | ||||
"Max number of vale bridges"); | "Max number of vale bridges"); | ||||
SYSEND; | SYSEND; | ||||
static int netmap_vale_vp_create(struct nmreq_header *hdr, struct ifnet *, | static int netmap_vale_vp_create(struct nmreq_header *hdr, if_t, | ||||
struct netmap_mem_d *nmd, struct netmap_vp_adapter **); | struct netmap_mem_d *nmd, struct netmap_vp_adapter **); | ||||
static int netmap_vale_vp_bdg_attach(const char *, struct netmap_adapter *, | static int netmap_vale_vp_bdg_attach(const char *, struct netmap_adapter *, | ||||
struct nm_bridge *); | struct nm_bridge *); | ||||
static int netmap_vale_bwrap_attach(const char *, struct netmap_adapter *); | static int netmap_vale_bwrap_attach(const char *, struct netmap_adapter *); | ||||
/* | /* | ||||
* For each output interface, nm_vale_q is used to construct a list. | * For each output interface, nm_vale_q is used to construct a list. | ||||
* bq_len is the number of output buffers (we can have coalescing | * bq_len is the number of output buffers (we can have coalescing | ||||
▲ Show 20 Lines • Show All 268 Lines • ▼ Show 20 Lines | netmap_vale_vp_dtor(struct netmap_adapter *na) | ||||
if (b) { | if (b) { | ||||
netmap_bdg_detach_common(b, vpna->bdg_port, -1); | netmap_bdg_detach_common(b, vpna->bdg_port, -1); | ||||
} | } | ||||
if (na->ifp != NULL && !nm_iszombie(na)) { | if (na->ifp != NULL && !nm_iszombie(na)) { | ||||
NM_DETACH_NA(na->ifp); | NM_DETACH_NA(na->ifp); | ||||
if (vpna->autodelete) { | if (vpna->autodelete) { | ||||
nm_prdis("releasing %s", na->ifp->if_xname); | nm_prdis("releasing %s", if_name(na->ifp)); | ||||
zlei: Must be wrongly changed by tools ;)
| |||||
NMG_UNLOCK(); | NMG_UNLOCK(); | ||||
nm_os_vi_detach(na->ifp); | nm_os_vi_detach(na->ifp); | ||||
NMG_LOCK(); | NMG_LOCK(); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 711 Lines • ▼ Show 20 Lines | done: | ||||
return 0; | return 0; | ||||
} | } | ||||
/* create a netmap_vp_adapter that describes a VALE port. | /* create a netmap_vp_adapter that describes a VALE port. | ||||
* Only persistent VALE ports have a non-null ifp. | * Only persistent VALE ports have a non-null ifp. | ||||
*/ | */ | ||||
static int | static int | ||||
netmap_vale_vp_create(struct nmreq_header *hdr, struct ifnet *ifp, | netmap_vale_vp_create(struct nmreq_header *hdr, if_t ifp, | ||||
struct netmap_mem_d *nmd, struct netmap_vp_adapter **ret) | struct netmap_mem_d *nmd, struct netmap_vp_adapter **ret) | ||||
{ | { | ||||
struct nmreq_register *req = (struct nmreq_register *)(uintptr_t)hdr->nr_body; | struct nmreq_register *req = (struct nmreq_register *)(uintptr_t)hdr->nr_body; | ||||
struct netmap_vp_adapter *vpna; | struct netmap_vp_adapter *vpna; | ||||
struct netmap_adapter *na; | struct netmap_adapter *na; | ||||
int error = 0; | int error = 0; | ||||
u_int npipes = 0; | u_int npipes = 0; | ||||
u_int extrabufs = 0; | u_int extrabufs = 0; | ||||
▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | nm_vi_create(struct nmreq_header *hdr) | ||||
req->nr_mem_id = regreq.nr_mem_id; | req->nr_mem_id = regreq.nr_mem_id; | ||||
return error; | return error; | ||||
} | } | ||||
/* remove a persistent VALE port from the system */ | /* remove a persistent VALE port from the system */ | ||||
int | int | ||||
nm_vi_destroy(const char *name) | nm_vi_destroy(const char *name) | ||||
{ | { | ||||
struct ifnet *ifp; | if_t ifp; | ||||
struct netmap_vp_adapter *vpna; | struct netmap_vp_adapter *vpna; | ||||
int error; | int error; | ||||
ifp = ifunit_ref(name); | ifp = ifunit_ref(name); | ||||
if (!ifp) | if (!ifp) | ||||
return ENXIO; | return ENXIO; | ||||
NMG_LOCK(); | NMG_LOCK(); | ||||
/* make sure this is actually a VALE port */ | /* make sure this is actually a VALE port */ | ||||
Show All 15 Lines | if (NETMAP_OWNED_BY_ANY(&vpna->up) || | ||||
vpna->up.na_refcount > 1 /* any ref besides the one in nm_vi_create()? */) { | vpna->up.na_refcount > 1 /* any ref besides the one in nm_vi_create()? */) { | ||||
error = EBUSY; | error = EBUSY; | ||||
goto err; | goto err; | ||||
} | } | ||||
NMG_UNLOCK(); | NMG_UNLOCK(); | ||||
if (netmap_verbose) | if (netmap_verbose) | ||||
nm_prinf("destroying a persistent vale interface %s", ifp->if_xname); | nm_prinf("destroying a persistent vale interface %s", if_name(ifp)); | ||||
Done Inline Actions@vmaffione zlei: @vmaffione
Is this intended, `if_getdname()` or `if_name()` ? | |||||
Done Inline ActionsYes, if_name is correct. vmaffione: Yes, `if_name` is correct. | |||||
/* Linux requires all the references are released | /* Linux requires all the references are released | ||||
* before unregister | * before unregister | ||||
*/ | */ | ||||
netmap_detach(ifp); | netmap_detach(ifp); | ||||
if_rele(ifp); | if_rele(ifp); | ||||
nm_os_vi_detach(ifp); | nm_os_vi_detach(ifp); | ||||
return 0; | return 0; | ||||
Show All 18 Lines | |||||
/* | /* | ||||
* Create a virtual interface registered to the system. | * Create a virtual interface registered to the system. | ||||
* The interface will be attached to a bridge later. | * The interface will be attached to a bridge later. | ||||
*/ | */ | ||||
int | int | ||||
netmap_vi_create(struct nmreq_header *hdr, int autodelete) | netmap_vi_create(struct nmreq_header *hdr, int autodelete) | ||||
{ | { | ||||
struct nmreq_register *req = (struct nmreq_register *)(uintptr_t)hdr->nr_body; | struct nmreq_register *req = (struct nmreq_register *)(uintptr_t)hdr->nr_body; | ||||
struct ifnet *ifp; | if_t ifp; | ||||
struct netmap_vp_adapter *vpna; | struct netmap_vp_adapter *vpna; | ||||
struct netmap_mem_d *nmd = NULL; | struct netmap_mem_d *nmd = NULL; | ||||
int error; | int error; | ||||
if (hdr->nr_reqtype != NETMAP_REQ_REGISTER) { | if (hdr->nr_reqtype != NETMAP_REQ_REGISTER) { | ||||
return EINVAL; | return EINVAL; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | netmap_vi_create(struct nmreq_header *hdr, int autodelete) | ||||
error = nm_update_info(req, &vpna->up); | error = nm_update_info(req, &vpna->up); | ||||
if (error) { | if (error) { | ||||
goto err_2; | goto err_2; | ||||
} | } | ||||
nm_prdis("returning nr_mem_id %d", req->nr_mem_id); | nm_prdis("returning nr_mem_id %d", req->nr_mem_id); | ||||
if (nmd) | if (nmd) | ||||
netmap_mem_put(nmd); | netmap_mem_put(nmd); | ||||
NMG_UNLOCK(); | NMG_UNLOCK(); | ||||
nm_prdis("created %s", ifp->if_xname); | nm_prdis("created %s", if_name(ifp)); | ||||
return 0; | return 0; | ||||
err_2: | err_2: | ||||
netmap_detach(ifp); | netmap_detach(ifp); | ||||
err_1: | err_1: | ||||
if (nmd) | if (nmd) | ||||
netmap_mem_put(nmd); | netmap_mem_put(nmd); | ||||
NMG_UNLOCK(); | NMG_UNLOCK(); | ||||
nm_os_vi_detach(ifp); | nm_os_vi_detach(ifp); | ||||
return error; | return error; | ||||
} | } | ||||
#endif /* WITH_VALE */ | #endif /* WITH_VALE */ |
Must be wrongly changed by tools ;)