Lines 308-334
Link Here
|
308 |
MODULE_DEPEND(vtnet, netmap, 1, 1, 1); |
308 |
MODULE_DEPEND(vtnet, netmap, 1, 1, 1); |
309 |
#endif /* DEV_NETMAP */ |
309 |
#endif /* DEV_NETMAP */ |
310 |
|
310 |
|
|
|
311 |
static struct sx mlu; |
312 |
SX_SYSINIT(vtnet_mlu, &mlu, "vtnet mod load/unload"); |
313 |
|
311 |
static int |
314 |
static int |
312 |
vtnet_modevent(module_t mod, int type, void *unused) |
315 |
vtnet_modevent(module_t mod, int type, void *unused) |
313 |
{ |
316 |
{ |
314 |
int error; |
317 |
int error = 0; |
|
|
318 |
static int loaded = 0; |
315 |
|
319 |
|
316 |
error = 0; |
|
|
317 |
|
318 |
switch (type) { |
320 |
switch (type) { |
319 |
case MOD_LOAD: |
321 |
case MOD_LOAD: |
320 |
vtnet_tx_header_zone = uma_zcreate("vtnet_tx_hdr", |
322 |
sx_xlock(&mlu); |
321 |
sizeof(struct vtnet_tx_header), |
323 |
if (loaded++ == 0) |
322 |
NULL, NULL, NULL, NULL, 0, 0); |
324 |
vtnet_tx_header_zone = uma_zcreate("vtnet_tx_hdr", |
|
|
325 |
sizeof(struct vtnet_tx_header), |
326 |
NULL, NULL, NULL, NULL, 0, 0); |
327 |
sx_xunlock(&mlu); |
323 |
break; |
328 |
break; |
324 |
case MOD_QUIESCE: |
329 |
case MOD_QUIESCE: |
325 |
case MOD_UNLOAD: |
330 |
case MOD_UNLOAD: |
326 |
if (uma_zone_get_cur(vtnet_tx_header_zone) > 0) |
331 |
sx_xlock(&mlu); |
327 |
error = EBUSY; |
332 |
if (--loaded == 0) { |
328 |
else if (type == MOD_UNLOAD) { |
333 |
if (uma_zone_get_cur(vtnet_tx_header_zone) > 0) |
329 |
uma_zdestroy(vtnet_tx_header_zone); |
334 |
error = EBUSY; |
330 |
vtnet_tx_header_zone = NULL; |
335 |
else if (type == MOD_UNLOAD) { |
|
|
336 |
uma_zdestroy(vtnet_tx_header_zone); |
337 |
vtnet_tx_header_zone = NULL; |
338 |
} |
331 |
} |
339 |
} |
|
|
340 |
sx_xunlock(&mlu); |
332 |
break; |
341 |
break; |
333 |
case MOD_SHUTDOWN: |
342 |
case MOD_SHUTDOWN: |
334 |
break; |
343 |
break; |