FreeBSD/sys/dev/ixl/ixlvc.c
/*
** Scan the Filter Table looking for vlans that need
** to be removed, then create the data to hand to the AQ
** for handling.
*/
Scan the Filter Table looking for vlans that need
to be removed, then create the data to hand to the AQ
for handling.
Scan the Filter Table looking for vlans that need to be removed then create the data to hand to the AQ for handling .
void
ixlv_del_vlans(struct ixlv_sc *sc)
{
	device_t	dev = sc->dev;
	struct i40e_virtchnl_vlan_filter_list *v;
	struct ixlv_vlan_filter *f, *ftmp;
	int len, i = 0, cnt = 0;
	SLIST_FOREACH(f, sc->vlan_filters, next) {
		if (f->flags & IXL_FILTER_DEL)
			cnt++;
	}
	if (!cnt) {  
		ixl_vc_process_resp(&sc->vc_mgr, IXLV_FLAG_AQ_DEL_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 | M_ZERO);
	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_DEL) {
                        bcopy(&f->vlan, &v->vlan_id[i], sizeof(u16));
                        i++;
                        SLIST_REMOVE(sc->vlan_filters, f, ixlv_vlan_filter, next);
                        free(f, M_DEVBUF);
                }
                if (i == cnt)
                        break;
	}
	ixlv_send_pf_msg(sc, I40E_VIRTCHNL_OP_DEL_VLAN, (u8 *)v, len);
	free(v, M_DEVBUF);
}
void ixlv_del_vlans ( struct ixlv_sc * sc ) { device_t dev = sc -> dev ; struct i40e_virtchnl_vlan_filter_list * v ; struct ixlv_vlan_filter * f , * ftmp ; int len , i = 0 , cnt = 0 ; SLIST_FOREACH ( f , sc -> vlan_filters , next ) { if ( f -> flags & IXL_FILTER_DEL ) cnt ++ ; } if ( ! cnt ) { ixl_vc_process_resp ( & sc -> vc_mgr , IXLV_FLAG_AQ_DEL_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 | M_ZERO ) ; 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_DEL ) { bcopy ( & f -> vlan , & v -> vlan_id [ i ] , sizeof ( u16 ) ) ; i ++ ; SLIST_REMOVE ( sc -> vlan_filters , f , ixlv_vlan_filter , next ) ; free ( f , M_DEVBUF ) ; } if ( i == cnt ) break ; } ixlv_send_pf_msg ( sc , I40E_VIRTCHNL_OP_DEL_VLAN , ( u8 * ) v , len ) ; free ( v , M_DEVBUF ) ; }
Scan the Filter Table looking for vlans that need
to be removed, then create the data to hand to the AQ
for handling.
Scan the Filter Table looking for vlans that need to be removed then create the data to hand to the AQ for handling .
/* Get count of VLAN filters to delete */ /* no work... */ /* Scan the filter array */ /* add stats? */