src/dpdk/drivers/net/hinic/hinic_pmd_ethdev.c
static int hinic_vlan_filter_set(struct rte_eth_dev *dev,
				uint16_t vlan_id, int enable)
{
	struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
	int err = 0;
	u16 func_id;

	if (vlan_id > RTE_ETHER_MAX_VLAN_ID)
		return -EINVAL;

	func_id = hinic_global_func_id(nic_dev->hwdev);

	if (enable) {
		/* If vlanid is already set, just return */
		if (hinic_find_vlan_filter(nic_dev, vlan_id)) {
			PMD_DRV_LOG(INFO, "Vlan %u has been added, device: %s",
				  vlan_id, nic_dev->proc_dev_name);
			return 0;
		}

		err = hinic_add_remove_vlan(nic_dev->hwdev, vlan_id,
					    func_id, TRUE);
	} else {
		/* If vlanid can't be found, just return */
		if (!hinic_find_vlan_filter(nic_dev, vlan_id)) {
			PMD_DRV_LOG(INFO, "Vlan %u is not in the vlan filter list, device: %s",
				  vlan_id, nic_dev->proc_dev_name);
			return 0;
		}

		err = hinic_add_remove_vlan(nic_dev->hwdev, vlan_id,
					    func_id, FALSE);
	}

	if (err) {
		PMD_DRV_LOG(ERR, "%s vlan failed, func_id: %d, vlan_id: %d, err: %d",
		      enable ? "Add" : "Remove", func_id, vlan_id, err);
		return err;
	}

	hinic_store_vlan_filter(nic_dev, vlan_id, enable);

	PMD_DRV_LOG(INFO, "%s vlan %u succeed, device: %s",
		  enable ? "Add" : "Remove", vlan_id, nic_dev->proc_dev_name);
	return 0;
}
/**
 * DPDK callback to set vlan filter.
 *
 * @param dev
 *   Pointer to Ethernet device structure.
 * @param vlan_id
 *   vlan id is used to filter vlan packets
 * @param enable
 *   enable disable or enable vlan filter function
 */
DPDK callback to set vlan filter.
@param dev
Pointer to Ethernet device structure.
@param vlan_id
vlan id is used to filter vlan packets
@param enable
enable disable or enable vlan filter function
DPDK callback to set vlan filter . @param dev Pointer to Ethernet device structure . @param vlan_id vlan id is used to filter vlan packets @param enable enable disable or enable vlan filter function
static int hinic_vlan_filter_set(struct rte_eth_dev *dev,
				uint16_t vlan_id, int enable)
{
	struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
	int err = 0;
	u16 func_id;
	if (vlan_id > RTE_ETHER_MAX_VLAN_ID)
		return -EINVAL;
	func_id = hinic_global_func_id(nic_dev->hwdev);
	if (enable) {
		if (hinic_find_vlan_filter(nic_dev, vlan_id)) {
			PMD_DRV_LOG(INFO, "Vlan %u has been added, device: %s",
				  vlan_id, nic_dev->proc_dev_name);
			return 0;
		}
		err = hinic_add_remove_vlan(nic_dev->hwdev, vlan_id,
					    func_id, TRUE);
	} else {
		if (!hinic_find_vlan_filter(nic_dev, vlan_id)) {
			PMD_DRV_LOG(INFO, "Vlan %u is not in the vlan filter list, device: %s",
				  vlan_id, nic_dev->proc_dev_name);
			return 0;
		}
		err = hinic_add_remove_vlan(nic_dev->hwdev, vlan_id,
					    func_id, FALSE);
	}
	if (err) {
		PMD_DRV_LOG(ERR, "%s vlan failed, func_id: %d, vlan_id: %d, err: %d",
		      enable ? "Add" : "Remove", func_id, vlan_id, err);
		return err;
	}
	hinic_store_vlan_filter(nic_dev, vlan_id, enable);
	PMD_DRV_LOG(INFO, "%s vlan %u succeed, device: %s",
		  enable ? "Add" : "Remove", vlan_id, nic_dev->proc_dev_name);
	return 0;
}
static int hinic_vlan_filter_set ( struct rte_eth_dev * dev , uint16_t vlan_id , int enable ) { struct hinic_nic_dev * nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV ( dev ) ; int err = 0 ; u16 func_id ; if ( vlan_id > RTE_ETHER_MAX_VLAN_ID ) return - EINVAL ; func_id = hinic_global_func_id ( nic_dev -> hwdev ) ; if ( enable ) { if ( hinic_find_vlan_filter ( nic_dev , vlan_id ) ) { PMD_DRV_LOG ( INFO , " " , vlan_id , nic_dev -> proc_dev_name ) ; return 0 ; } err = hinic_add_remove_vlan ( nic_dev -> hwdev , vlan_id , func_id , TRUE ) ; } else { if ( ! hinic_find_vlan_filter ( nic_dev , vlan_id ) ) { PMD_DRV_LOG ( INFO , " " , vlan_id , nic_dev -> proc_dev_name ) ; return 0 ; } err = hinic_add_remove_vlan ( nic_dev -> hwdev , vlan_id , func_id , FALSE ) ; } if ( err ) { PMD_DRV_LOG ( ERR , " " , enable ? " " : " " , func_id , vlan_id , err ) ; return err ; } hinic_store_vlan_filter ( nic_dev , vlan_id , enable ) ; PMD_DRV_LOG ( INFO , " " , enable ? " " : " " , vlan_id , nic_dev -> proc_dev_name ) ; return 0 ; }
DPDK callback to set vlan filter.
DPDK callback to set vlan filter .
/* If vlanid is already set, just return */ /* If vlanid can't be found, just return */