src/dpdk/drivers/net/hns3/hns3_flow.c
static int
hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
		  struct rte_flow_error *error)
{
	struct hns3_process_private *process_list = dev->process_private;
	struct hns3_adapter *hns = dev->data->dev_private;
	struct hns3_fdir_rule_ele *fdir_rule_ptr;
	struct hns3_rss_conf_ele *rss_filter_ptr;
	struct hns3_flow_mem *flow_node;
	enum rte_filter_type filter_type;
	struct hns3_fdir_rule fdir_rule;
	int ret;

	if (flow == NULL)
		return rte_flow_error_set(error, EINVAL,
					  RTE_FLOW_ERROR_TYPE_HANDLE,
					  flow, "Flow is NULL");

	filter_type = flow->filter_type;
	switch (filter_type) {
	case RTE_ETH_FILTER_FDIR:
		fdir_rule_ptr = (struct hns3_fdir_rule_ele *)flow->rule;
		memcpy(&fdir_rule, &fdir_rule_ptr->fdir_conf,
			   sizeof(struct hns3_fdir_rule));

		ret = hns3_fdir_filter_program(hns, &fdir_rule, true);
		if (ret)
			return rte_flow_error_set(error, EIO,
						  RTE_FLOW_ERROR_TYPE_HANDLE,
						  flow,
						  "Destroy FDIR fail.Try again");
		if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER)
			hns3_counter_release(dev, fdir_rule.act_cnt.id);
		TAILQ_REMOVE(&process_list->fdir_list, fdir_rule_ptr, entries);
		rte_free(fdir_rule_ptr);
		fdir_rule_ptr = NULL;
		break;
	case RTE_ETH_FILTER_HASH:
		rss_filter_ptr = (struct hns3_rss_conf_ele *)flow->rule;
		ret = hns3_config_rss_filter(dev, &rss_filter_ptr->filter_info,
					     false);
		if (ret)
			return rte_flow_error_set(error, EIO,
						  RTE_FLOW_ERROR_TYPE_HANDLE,
						  flow,
						  "Destroy RSS fail.Try again");
		TAILQ_REMOVE(&process_list->filter_rss_list, rss_filter_ptr,
			     entries);
		rte_free(rss_filter_ptr);
		rss_filter_ptr = NULL;
		break;
	default:
		return rte_flow_error_set(error, EINVAL,
					  RTE_FLOW_ERROR_TYPE_HANDLE, flow,
					  "Unsupported filter type");
	}

	TAILQ_FOREACH(flow_node, &process_list->flow_list, entries) {
		if (flow_node->flow == flow) {
			TAILQ_REMOVE(&process_list->flow_list, flow_node,
				     entries);
			rte_free(flow_node);
			flow_node = NULL;
			break;
		}
	}
	rte_free(flow);
	flow = NULL;

	return 0;
}
/* Destroy a flow rule on hns3. */
Destroy a flow rule on hns3.
Destroy a flow rule on hns3 .
static int
hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
		  struct rte_flow_error *error)
{
	struct hns3_process_private *process_list = dev->process_private;
	struct hns3_adapter *hns = dev->data->dev_private;
	struct hns3_fdir_rule_ele *fdir_rule_ptr;
	struct hns3_rss_conf_ele *rss_filter_ptr;
	struct hns3_flow_mem *flow_node;
	enum rte_filter_type filter_type;
	struct hns3_fdir_rule fdir_rule;
	int ret;
	if (flow == NULL)
		return rte_flow_error_set(error, EINVAL,
					  RTE_FLOW_ERROR_TYPE_HANDLE,
					  flow, "Flow is NULL");
	filter_type = flow->filter_type;
	switch (filter_type) {
	case RTE_ETH_FILTER_FDIR:
		fdir_rule_ptr = (struct hns3_fdir_rule_ele *)flow->rule;
		memcpy(&fdir_rule, &fdir_rule_ptr->fdir_conf,
			   sizeof(struct hns3_fdir_rule));
		ret = hns3_fdir_filter_program(hns, &fdir_rule, true);
		if (ret)
			return rte_flow_error_set(error, EIO,
						  RTE_FLOW_ERROR_TYPE_HANDLE,
						  flow,
						  "Destroy FDIR fail.Try again");
		if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER)
			hns3_counter_release(dev, fdir_rule.act_cnt.id);
		TAILQ_REMOVE(&process_list->fdir_list, fdir_rule_ptr, entries);
		rte_free(fdir_rule_ptr);
		fdir_rule_ptr = NULL;
		break;
	case RTE_ETH_FILTER_HASH:
		rss_filter_ptr = (struct hns3_rss_conf_ele *)flow->rule;
		ret = hns3_config_rss_filter(dev, &rss_filter_ptr->filter_info,
					     false);
		if (ret)
			return rte_flow_error_set(error, EIO,
						  RTE_FLOW_ERROR_TYPE_HANDLE,
						  flow,
						  "Destroy RSS fail.Try again");
		TAILQ_REMOVE(&process_list->filter_rss_list, rss_filter_ptr,
			     entries);
		rte_free(rss_filter_ptr);
		rss_filter_ptr = NULL;
		break;
	default:
		return rte_flow_error_set(error, EINVAL,
					  RTE_FLOW_ERROR_TYPE_HANDLE, flow,
					  "Unsupported filter type");
	}
	TAILQ_FOREACH(flow_node, &process_list->flow_list, entries) {
		if (flow_node->flow == flow) {
			TAILQ_REMOVE(&process_list->flow_list, flow_node,
				     entries);
			rte_free(flow_node);
			flow_node = NULL;
			break;
		}
	}
	rte_free(flow);
	flow = NULL;
	return 0;
}
static int hns3_flow_destroy ( struct rte_eth_dev * dev , struct rte_flow * flow , struct rte_flow_error * error ) { struct hns3_process_private * process_list = dev -> process_private ; struct hns3_adapter * hns = dev -> data -> dev_private ; struct hns3_fdir_rule_ele * fdir_rule_ptr ; struct hns3_rss_conf_ele * rss_filter_ptr ; struct hns3_flow_mem * flow_node ; enum rte_filter_type filter_type ; struct hns3_fdir_rule fdir_rule ; int ret ; if ( flow == NULL ) return rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_HANDLE , flow , " " ) ; filter_type = flow -> filter_type ; switch ( filter_type ) { case RTE_ETH_FILTER_FDIR : fdir_rule_ptr = ( struct hns3_fdir_rule_ele * ) flow -> rule ; memcpy ( & fdir_rule , & fdir_rule_ptr -> fdir_conf , sizeof ( struct hns3_fdir_rule ) ) ; ret = hns3_fdir_filter_program ( hns , & fdir_rule , true ) ; if ( ret ) return rte_flow_error_set ( error , EIO , RTE_FLOW_ERROR_TYPE_HANDLE , flow , " " ) ; if ( fdir_rule . flags & HNS3_RULE_FLAG_COUNTER ) hns3_counter_release ( dev , fdir_rule . act_cnt . id ) ; TAILQ_REMOVE ( & process_list -> fdir_list , fdir_rule_ptr , entries ) ; rte_free ( fdir_rule_ptr ) ; fdir_rule_ptr = NULL ; break ; case RTE_ETH_FILTER_HASH : rss_filter_ptr = ( struct hns3_rss_conf_ele * ) flow -> rule ; ret = hns3_config_rss_filter ( dev , & rss_filter_ptr -> filter_info , false ) ; if ( ret ) return rte_flow_error_set ( error , EIO , RTE_FLOW_ERROR_TYPE_HANDLE , flow , " " ) ; TAILQ_REMOVE ( & process_list -> filter_rss_list , rss_filter_ptr , entries ) ; rte_free ( rss_filter_ptr ) ; rss_filter_ptr = NULL ; break ; default : return rte_flow_error_set ( error , EINVAL , RTE_FLOW_ERROR_TYPE_HANDLE , flow , " " ) ; } TAILQ_FOREACH ( flow_node , & process_list -> flow_list , entries ) { if ( flow_node -> flow == flow ) { TAILQ_REMOVE ( & process_list -> flow_list , flow_node , entries ) ; rte_free ( flow_node ) ; flow_node = NULL ; break ; } } rte_free ( flow ) ; flow = NULL ; return 0 ; }
Destroy a flow rule on hns3.
Destroy a flow rule on hns3 .