예제 #1
0
/* remove the monitor mkring from the list of monitors of kring.
 * If this is the last monitor, restore the original callbacks
 */
static void
netmap_monitor_del(struct netmap_kring *mkring, struct netmap_kring *kring)
{
	/* sinchronize with concurrently running nm_sync()s */
	nm_kr_stop(kring, NM_KR_LOCKED);
	kring->n_monitors--;
	if (mkring->mon_pos != kring->n_monitors) {
		kring->monitors[mkring->mon_pos] = kring->monitors[kring->n_monitors];
		kring->monitors[mkring->mon_pos]->mon_pos = mkring->mon_pos;
	}
	kring->monitors[kring->n_monitors] = NULL;
	if (kring->n_monitors == 0) {
		/* this was the last monitor, restore callbacks  and delete monitor array */
		D("%s: restoring sync on %s: %p", mkring->name, kring->name, kring->mon_sync);
		kring->nm_sync = kring->mon_sync;
		kring->mon_sync = NULL;
		if (kring->tx == NR_RX) {
			D("%s: restoring notify on %s: %p", 
					mkring->name, kring->name, kring->mon_notify);
			kring->nm_notify = kring->mon_notify;
			kring->mon_notify = NULL;
		}
		nm_monitor_dealloc(kring);
	}
	nm_kr_start(kring);
}
예제 #2
0
/* remove the monitor mkring from the list of monitors of kring.
 * If this is the last monitor, restore the original callbacks
 */
static void
netmap_monitor_del(struct netmap_kring *mkring, struct netmap_kring *kring)
{
	struct netmap_zmon_list *mz = &mkring->zmon_list[kring->tx];
	int zmon = nm_is_zmon(mkring->na);


	if (zmon && mz->prev != NULL)
		kring = mz->prev;

	/* sinchronize with concurrently running nm_sync()s */
	nm_kr_stop(kring, NM_KR_LOCKED);

	if (zmon) {
		/* remove the monitor from the list */
		if (mz->prev != NULL)
			mz->prev->zmon_list[kring->tx].next = mz->next;
		else
			kring->zmon_list[kring->tx].next = mz->next;
		if (mz->next != NULL) {
			mz->next->zmon_list[kring->tx].prev = mz->prev;
		} else {
			kring->zmon_list[kring->tx].prev = mz->prev;
		}
	} else {
		/* this is a copy monitor */
		uint32_t mon_pos = mkring->mon_pos[kring->tx];
		kring->n_monitors--;
		if (mon_pos != kring->n_monitors) {
			kring->monitors[mon_pos] =
				kring->monitors[kring->n_monitors];
			kring->monitors[mon_pos]->mon_pos[kring->tx] = mon_pos;
		}
		kring->monitors[kring->n_monitors] = NULL;
		if (kring->n_monitors == 0) {
			nm_monitor_dealloc(kring);
		}
	}

	if (nm_monitor_none(kring)) {
		/* this was the last monitor, restore the callbacks */
		ND("%s: restoring sync on %s: %p", mkring->name, kring->name,
				kring->mon_sync);
		kring->nm_sync = kring->mon_sync;
		kring->mon_sync = NULL;
		if (kring->tx == NR_RX) {
			ND("%s: restoring notify on %s: %p",
					mkring->name, kring->name, kring->mon_notify);
			kring->nm_notify = kring->mon_notify;
			kring->mon_notify = NULL;
		}
	}

	nm_kr_start(kring);
}