Example #1
0
int
efrm_create_vf_resource_manager(struct efrm_resource_manager **rm_out)
{
	int rc;
	int nic_index;

	EFRM_ASSERT(rm_out);

	efrm_vf_manager = kzalloc(sizeof(*efrm_vf_manager), GFP_KERNEL);
	if (efrm_vf_manager == NULL)
		return -ENOMEM;

	for (nic_index = 0; nic_index < EFHW_MAX_NR_DEVS; ++nic_index)
		INIT_LIST_HEAD(&efrm_vf_manager->nic[nic_index].free_list);

	rc = efrm_resource_manager_ctor(&efrm_vf_manager->rm,
					efrm_vf_rm_dtor, "VF",
					EFRM_RESOURCE_VF);
	if (rc < 0)
		goto fail1;

	*rm_out = &efrm_vf_manager->rm;
	return 0;

fail1:
	EFRM_DO_DEBUG(memset(efrm_vf_manager, 0, sizeof(*efrm_vf_manager)));
	kfree(efrm_vf_manager);
	return rc;
}
Example #2
0
void efrm_filter_resource_free(struct filter_resource *frs)
{
	struct efhw_nic *nic = frs->rs.rs_client->nic;
	int id;

	EFRM_RESOURCE_ASSERT_VALID(&frs->rs, 1);

	EFRM_TRACE("%s: " EFRM_RESOURCE_FMT, __func__,
		   EFRM_RESOURCE_PRI_ARG(frs->rs.rs_handle));

	efhw_nic_ipfilter_clear(nic, frs->filter_idx);
	frs->filter_idx = -1;
	efrm_vi_resource_release(frs->pt);

	/* Free this filter. */
	id = EFRM_RESOURCE_INSTANCE(frs->rs.rs_handle);
	EFRM_VERIFY_EQ(kfifo_put(efrm_filter_manager->free_ids,
				 (unsigned char *)&id, sizeof(id)),
		       sizeof(id));

	efrm_client_put(frs->rs.rs_client);
	EFRM_DO_DEBUG(memset(frs, 0, sizeof(*frs)));
	kfree(frs);
}