FreeBSD/sys/dev/netmap/netmap_vale.c
/*
 * Allocate the forwarding tables for the rings attached to the bridge ports.
 */
Allocate the forwarding tables for the rings attached to the bridge ports.
Allocate the forwarding tables for the rings attached to the bridge ports .
static int
nm_alloc_bdgfwd(struct netmap_adapter *na)
{
	int nrings, l, i, num_dstq;
	struct netmap_kring *kring;
	NMG_LOCK_ASSERT();
	num_dstq = NM_BDG_MAXPORTS * NM_BDG_MAXRINGS + 1;
	l = sizeof(struct nm_bdg_fwd) * NM_BDG_BATCH_MAX;
	l += sizeof(struct nm_bdg_q) * num_dstq;
	l += sizeof(uint16_t) * NM_BDG_BATCH_MAX;
	nrings = netmap_real_rings(na, NR_TX);
	kring = na->tx_rings;
	for (i = 0; i < nrings; i++) {
		struct nm_bdg_fwd *ft;
		struct nm_bdg_q *dstq;
		int j;
		ft = malloc(l, M_DEVBUF, M_NOWAIT | M_ZERO);
		if (!ft) {
			nm_free_bdgfwd(na);
			return ENOMEM;
		}
		dstq = (struct nm_bdg_q *)(ft + NM_BDG_BATCH_MAX);
		for (j = 0; j < num_dstq; j++) {
			dstq[j].bq_head = dstq[j].bq_tail = NM_FT_NULL;
			dstq[j].bq_len = 0;
		}
		kring[i].nkr_ft = ft;
	}
	return 0;
}
static int nm_alloc_bdgfwd ( struct netmap_adapter * na ) { int nrings , l , i , num_dstq ; struct netmap_kring * kring ; NMG_LOCK_ASSERT ( ) ; num_dstq = NM_BDG_MAXPORTS * NM_BDG_MAXRINGS + 1 ; l = sizeof ( struct nm_bdg_fwd ) * NM_BDG_BATCH_MAX ; l += sizeof ( struct nm_bdg_q ) * num_dstq ; l += sizeof ( uint16_t ) * NM_BDG_BATCH_MAX ; nrings = netmap_real_rings ( na , NR_TX ) ; kring = na -> tx_rings ; for ( i = 0 ; i < nrings ; i ++ ) { struct nm_bdg_fwd * ft ; struct nm_bdg_q * dstq ; int j ; ft = malloc ( l , M_DEVBUF , M_NOWAIT | M_ZERO ) ; if ( ! ft ) { nm_free_bdgfwd ( na ) ; return ENOMEM ; } dstq = ( struct nm_bdg_q * ) ( ft + NM_BDG_BATCH_MAX ) ; for ( j = 0 ; j < num_dstq ; j ++ ) { dstq [ j ] . bq_head = dstq [ j ] . bq_tail = NM_FT_NULL ; dstq [ j ] . bq_len = 0 ; } kring [ i ] . nkr_ft = ft ; } return 0 ; }
Allocate the forwarding tables for the rings attached to the bridge ports.
Allocate the forwarding tables for the rings attached to the bridge ports .
/* all port:rings + broadcast */