FreeBSD/sys/dev/ixl/ixlvc.c
/*
** Scan the Filter List looking for vlans that need
** to be added, then create the data to hand to the AQ
** for handling.
*/
Scan the Filter List looking for vlans that need
to be added, then create the data to hand to the AQ
for handling.
Scan the Filter List looking for vlans that need to be added then create the data to hand to the AQ for handling .
void
ixlv_add_vlans(struct ixlv_sc *sc)
{
	struct i40e_virtchnl_vlan_filter_list	*v;
	struct ixlv_vlan_filter *f, *ftmp;
	device_t	dev = sc->dev;
	int		len, i = 0, cnt = 0;
	SLIST_FOREACH(f, sc->vlan_filters, next) {
		if (f->flags & IXL_FILTER_ADD)
			cnt++;
	}
	if (!cnt) {  
		ixl_vc_process_resp(&sc->vc_mgr, IXLV_FLAG_AQ_ADD_VLAN_FILTER,
		    I40E_SUCCESS);
		return;
	}
	len = sizeof(struct i40e_virtchnl_vlan_filter_list) +
	      (cnt * sizeof(u16));
	if (len > IXL_AQ_BUF_SZ) {
		device_printf(dev, "%s: Exceeded Max AQ Buf size\n",
			__func__);
		ixl_vc_schedule_retry(&sc->vc_mgr);
		return;
	}
	v = malloc(len, M_DEVBUF, M_NOWAIT);
	if (!v) {
		device_printf(dev, "%s: unable to allocate memory\n",
			__func__);
		ixl_vc_schedule_retry(&sc->vc_mgr);
		return;
	}
	v->vsi_id = sc->vsi_res->vsi_id;
	v->num_elements = cnt;
	SLIST_FOREACH_SAFE(f, sc->vlan_filters, next, ftmp) {
                if (f->flags & IXL_FILTER_ADD) {
                        bcopy(&f->vlan, &v->vlan_id[i], sizeof(u16));
			f->flags = IXL_FILTER_USED;
                        i++;
                }
                if (i == cnt)
                        break;
	}
	ixlv_send_pf_msg(sc, I40E_VIRTCHNL_OP_ADD_VLAN, (u8 *)v, len);
	free(v, M_DEVBUF);
}
void ixlv_add_vlans ( struct ixlv_sc * sc ) { struct i40e_virtchnl_vlan_filter_list * v ; struct ixlv_vlan_filter * f , * ftmp ; device_t dev = sc -> dev ; int len , i = 0 , cnt = 0 ; SLIST_FOREACH ( f , sc -> vlan_filters , next ) { if ( f -> flags & IXL_FILTER_ADD ) cnt ++ ; } if ( ! cnt ) { ixl_vc_process_resp ( & sc -> vc_mgr , IXLV_FLAG_AQ_ADD_VLAN_FILTER , I40E_SUCCESS ) ; return ; } len = sizeof ( struct i40e_virtchnl_vlan_filter_list ) + ( cnt * sizeof ( u16 ) ) ; if ( len > IXL_AQ_BUF_SZ ) { device_printf ( dev , " \n " , __func__ ) ; ixl_vc_schedule_retry ( & sc -> vc_mgr ) ; return ; } v = malloc ( len , M_DEVBUF , M_NOWAIT ) ; if ( ! v ) { device_printf ( dev , " \n " , __func__ ) ; ixl_vc_schedule_retry ( & sc -> vc_mgr ) ; return ; } v -> vsi_id = sc -> vsi_res -> vsi_id ; v -> num_elements = cnt ; SLIST_FOREACH_SAFE ( f , sc -> vlan_filters , next , ftmp ) { if ( f -> flags & IXL_FILTER_ADD ) { bcopy ( & f -> vlan , & v -> vlan_id [ i ] , sizeof ( u16 ) ) ; f -> flags = IXL_FILTER_USED ; i ++ ; } if ( i == cnt ) break ; } ixlv_send_pf_msg ( sc , I40E_VIRTCHNL_OP_ADD_VLAN , ( u8 * ) v , len ) ; free ( v , M_DEVBUF ) ; }
Scan the Filter List looking for vlans that need
to be added, then create the data to hand to the AQ
for handling.
Scan the Filter List looking for vlans that need to be added then create the data to hand to the AQ for handling .
/* Get count of VLAN filters to add */ /* no work... */ /* Scan the filter array */ /* add stats? */