[dpdk-dev] [PATCH v2 02/14] ethdev: move MAC filter type to i40e driver

Andrew Rybchenko arybchenko at solarflare.com
Thu Oct 22 11:42:25 CEST 2020


net/i40e driver is the only user of the enum rte_mac_filter_type.
Move the define to the driver and use i40e_ prefix instead of rte_.

Signed-off-by: Andrew Rybchenko <arybchenko at solarflare.com>
---
 drivers/net/i40e/i40e_ethdev.c   | 58 ++++++++++++++++----------------
 drivers/net/i40e/i40e_ethdev.h   | 15 +++++++--
 drivers/net/i40e/i40e_pf.c       |  2 +-
 drivers/net/i40e/rte_pmd_i40e.c  | 30 ++++++++---------
 lib/librte_ethdev/rte_eth_ctrl.h | 11 ------
 5 files changed, 58 insertions(+), 58 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 217a7bbbd8..e298d7aee6 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -4329,9 +4329,9 @@ i40e_macaddr_add(struct rte_eth_dev *dev,
 
 	rte_memcpy(&mac_filter.mac_addr, mac_addr, RTE_ETHER_ADDR_LEN);
 	if (rxmode->offloads & DEV_RX_OFFLOAD_VLAN_FILTER)
-		mac_filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
+		mac_filter.filter_type = I40E_MACVLAN_PERFECT_MATCH;
 	else
-		mac_filter.filter_type = RTE_MAC_PERFECT_MATCH;
+		mac_filter.filter_type = I40E_MAC_PERFECT_MATCH;
 
 	if (pool == 0)
 		vsi = pf->main_vsi;
@@ -5537,7 +5537,7 @@ i40e_update_default_filter_setting(struct i40e_vsi *vsi)
 		mac = &f->mac_info.mac_addr;
 		rte_memcpy(&mac->addr_bytes, hw->mac.perm_addr,
 				ETH_ADDR_LEN);
-		f->mac_info.filter_type = RTE_MACVLAN_PERFECT_MATCH;
+		f->mac_info.filter_type = I40E_MACVLAN_PERFECT_MATCH;
 		TAILQ_INSERT_TAIL(&vsi->mac_list, f, next);
 		vsi->mac_num++;
 
@@ -5545,7 +5545,7 @@ i40e_update_default_filter_setting(struct i40e_vsi *vsi)
 	}
 	rte_memcpy(&filter.mac_addr,
 		(struct rte_ether_addr *)(hw->mac.perm_addr), ETH_ADDR_LEN);
-	filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
+	filter.filter_type = I40E_MACVLAN_PERFECT_MATCH;
 	return i40e_vsi_add_mac(vsi, &filter);
 }
 
@@ -6011,7 +6011,7 @@ i40e_vsi_setup(struct i40e_pf *pf,
 
 	/* MAC/VLAN configuration */
 	rte_memcpy(&filter.mac_addr, &broadcast, RTE_ETHER_ADDR_LEN);
-	filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
+	filter.filter_type = I40E_MACVLAN_PERFECT_MATCH;
 
 	ret = i40e_vsi_add_mac(vsi, &filter);
 	if (ret != I40E_SUCCESS) {
@@ -6039,15 +6039,15 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on)
 	struct i40e_mac_filter *f;
 	void *temp;
 	struct i40e_mac_filter_info *mac_filter;
-	enum rte_mac_filter_type desired_filter;
+	enum i40e_mac_filter_type desired_filter;
 	int ret = I40E_SUCCESS;
 
 	if (on) {
 		/* Filter to match MAC and VLAN */
-		desired_filter = RTE_MACVLAN_PERFECT_MATCH;
+		desired_filter = I40E_MACVLAN_PERFECT_MATCH;
 	} else {
 		/* Filter to match only MAC */
-		desired_filter = RTE_MAC_PERFECT_MATCH;
+		desired_filter = I40E_MAC_PERFECT_MATCH;
 	}
 
 	num = vsi->mac_num;
@@ -6990,18 +6990,18 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi,
 				rte_cpu_to_le_16(filter[num + i].vlan_id);
 
 			switch (filter[num + i].filter_type) {
-			case RTE_MAC_PERFECT_MATCH:
+			case I40E_MAC_PERFECT_MATCH:
 				flags = I40E_AQC_MACVLAN_ADD_PERFECT_MATCH |
 					I40E_AQC_MACVLAN_ADD_IGNORE_VLAN;
 				break;
-			case RTE_MACVLAN_PERFECT_MATCH:
+			case I40E_MACVLAN_PERFECT_MATCH:
 				flags = I40E_AQC_MACVLAN_ADD_PERFECT_MATCH;
 				break;
-			case RTE_MAC_HASH_MATCH:
+			case I40E_MAC_HASH_MATCH:
 				flags = I40E_AQC_MACVLAN_ADD_HASH_MATCH |
 					I40E_AQC_MACVLAN_ADD_IGNORE_VLAN;
 				break;
-			case RTE_MACVLAN_HASH_MATCH:
+			case I40E_MACVLAN_HASH_MATCH:
 				flags = I40E_AQC_MACVLAN_ADD_HASH_MATCH;
 				break;
 			default:
@@ -7065,18 +7065,18 @@ i40e_remove_macvlan_filters(struct i40e_vsi *vsi,
 				rte_cpu_to_le_16(filter[num + i].vlan_id);
 
 			switch (filter[num + i].filter_type) {
-			case RTE_MAC_PERFECT_MATCH:
+			case I40E_MAC_PERFECT_MATCH:
 				flags = I40E_AQC_MACVLAN_DEL_PERFECT_MATCH |
 					I40E_AQC_MACVLAN_DEL_IGNORE_VLAN;
 				break;
-			case RTE_MACVLAN_PERFECT_MATCH:
+			case I40E_MACVLAN_PERFECT_MATCH:
 				flags = I40E_AQC_MACVLAN_DEL_PERFECT_MATCH;
 				break;
-			case RTE_MAC_HASH_MATCH:
+			case I40E_MAC_HASH_MATCH:
 				flags = I40E_AQC_MACVLAN_DEL_HASH_MATCH |
 					I40E_AQC_MACVLAN_DEL_IGNORE_VLAN;
 				break;
-			case RTE_MACVLAN_HASH_MATCH:
+			case I40E_MACVLAN_HASH_MATCH:
 				flags = I40E_AQC_MACVLAN_DEL_HASH_MATCH;
 				break;
 			default:
@@ -7421,8 +7421,8 @@ i40e_vsi_add_mac(struct i40e_vsi *vsi, struct i40e_mac_filter_info *mac_filter)
 	f = i40e_find_mac_filter(vsi, &mac_filter->mac_addr);
 	if (f != NULL)
 		return I40E_SUCCESS;
-	if ((mac_filter->filter_type == RTE_MACVLAN_PERFECT_MATCH) ||
-		(mac_filter->filter_type == RTE_MACVLAN_HASH_MATCH)) {
+	if (mac_filter->filter_type == I40E_MACVLAN_PERFECT_MATCH ||
+		mac_filter->filter_type == I40E_MACVLAN_HASH_MATCH) {
 
 		/**
 		 * If vlan_num is 0, that's the first time to add mac,
@@ -7433,8 +7433,8 @@ i40e_vsi_add_mac(struct i40e_vsi *vsi, struct i40e_mac_filter_info *mac_filter)
 			vsi->vlan_num = 1;
 		}
 		vlan_num = vsi->vlan_num;
-	} else if ((mac_filter->filter_type == RTE_MAC_PERFECT_MATCH) ||
-			(mac_filter->filter_type == RTE_MAC_HASH_MATCH))
+	} else if (mac_filter->filter_type == I40E_MAC_PERFECT_MATCH ||
+			mac_filter->filter_type == I40E_MAC_HASH_MATCH)
 		vlan_num = 1;
 
 	mv_f = rte_zmalloc("macvlan_data", vlan_num * sizeof(*mv_f), 0);
@@ -7449,8 +7449,8 @@ i40e_vsi_add_mac(struct i40e_vsi *vsi, struct i40e_mac_filter_info *mac_filter)
 				ETH_ADDR_LEN);
 	}
 
-	if (mac_filter->filter_type == RTE_MACVLAN_PERFECT_MATCH ||
-		mac_filter->filter_type == RTE_MACVLAN_HASH_MATCH) {
+	if (mac_filter->filter_type == I40E_MACVLAN_PERFECT_MATCH ||
+		mac_filter->filter_type == I40E_MACVLAN_HASH_MATCH) {
 		ret = i40e_find_all_vlan_for_mac(vsi, mv_f, vlan_num,
 					&mac_filter->mac_addr);
 		if (ret != I40E_SUCCESS)
@@ -7487,7 +7487,7 @@ i40e_vsi_delete_mac(struct i40e_vsi *vsi, struct rte_ether_addr *addr)
 	struct i40e_mac_filter *f;
 	struct i40e_macvlan_filter *mv_f;
 	int i, vlan_num;
-	enum rte_mac_filter_type filter_type;
+	enum i40e_mac_filter_type filter_type;
 	int ret = I40E_SUCCESS;
 
 	/* Can't find it, return an error */
@@ -7497,14 +7497,14 @@ i40e_vsi_delete_mac(struct i40e_vsi *vsi, struct rte_ether_addr *addr)
 
 	vlan_num = vsi->vlan_num;
 	filter_type = f->mac_info.filter_type;
-	if (filter_type == RTE_MACVLAN_PERFECT_MATCH ||
-		filter_type == RTE_MACVLAN_HASH_MATCH) {
+	if (filter_type == I40E_MACVLAN_PERFECT_MATCH ||
+		filter_type == I40E_MACVLAN_HASH_MATCH) {
 		if (vlan_num == 0) {
 			PMD_DRV_LOG(ERR, "VLAN number shouldn't be 0");
 			return I40E_ERR_PARAM;
 		}
-	} else if (filter_type == RTE_MAC_PERFECT_MATCH ||
-			filter_type == RTE_MAC_HASH_MATCH)
+	} else if (filter_type == I40E_MAC_PERFECT_MATCH ||
+			filter_type == I40E_MAC_HASH_MATCH)
 		vlan_num = 1;
 
 	mv_f = rte_zmalloc("macvlan_data", vlan_num * sizeof(*mv_f), 0);
@@ -7518,8 +7518,8 @@ i40e_vsi_delete_mac(struct i40e_vsi *vsi, struct rte_ether_addr *addr)
 		rte_memcpy(&mv_f[i].macaddr, &f->mac_info.mac_addr,
 				ETH_ADDR_LEN);
 	}
-	if (filter_type == RTE_MACVLAN_PERFECT_MATCH ||
-			filter_type == RTE_MACVLAN_HASH_MATCH) {
+	if (filter_type == I40E_MACVLAN_PERFECT_MATCH ||
+			filter_type == I40E_MACVLAN_HASH_MATCH) {
 		ret = i40e_find_all_vlan_for_mac(vsi, mv_f, vlan_num, addr);
 		if (ret != I40E_SUCCESS)
 			goto DONE;
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 1466998aa1..458219c784 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -288,11 +288,22 @@ struct rte_flow {
 struct i40e_adapter;
 struct rte_pci_driver;
 
+/**
+ * MAC filter type
+ */
+enum i40e_mac_filter_type {
+	I40E_MAC_PERFECT_MATCH = 1, /**< exact match of MAC addr. */
+	I40E_MACVLAN_PERFECT_MATCH, /**< exact match of MAC addr and VLAN ID. */
+	I40E_MAC_HASH_MATCH, /**< hash match of MAC addr. */
+	/** hash match of MAC addr and exact match of VLAN ID. */
+	I40E_MACVLAN_HASH_MATCH,
+};
+
 /**
  * MAC filter structure
  */
 struct i40e_mac_filter_info {
-	enum rte_mac_filter_type filter_type;
+	enum i40e_mac_filter_type filter_type;
 	struct rte_ether_addr mac_addr;
 };
 
@@ -347,7 +358,7 @@ struct i40e_veb {
 /* i40e MACVLAN filter structure */
 struct i40e_macvlan_filter {
 	struct rte_ether_addr macaddr;
-	enum rte_mac_filter_type filter_type;
+	enum i40e_mac_filter_type filter_type;
 	uint16_t vlan_id;
 };
 
diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index 03c2070c3f..65d649b627 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -844,7 +844,7 @@ i40e_pf_host_process_cmd_add_ether_address(struct i40e_pf_vf *vf,
 	for (i = 0; i < addr_list->num_elements; i++) {
 		mac = (struct rte_ether_addr *)(addr_list->list[i].addr);
 		rte_memcpy(&filter.mac_addr, mac, RTE_ETHER_ADDR_LEN);
-		filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
+		filter.filter_type = I40E_MACVLAN_PERFECT_MATCH;
 		if (rte_is_zero_ether_addr(mac) ||
 		    i40e_vsi_add_mac(vf->vsi, &filter)) {
 			ret = I40E_ERR_INVALID_MAC_ADDR;
diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index 17938e7d30..790d042002 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -211,7 +211,7 @@ i40e_vsi_rm_mac_filter(struct i40e_vsi *vsi)
 	struct i40e_mac_filter *f;
 	struct i40e_macvlan_filter *mv_f;
 	int i, vlan_num;
-	enum rte_mac_filter_type filter_type;
+	enum i40e_mac_filter_type filter_type;
 	int ret = I40E_SUCCESS;
 	void *temp;
 
@@ -219,14 +219,14 @@ i40e_vsi_rm_mac_filter(struct i40e_vsi *vsi)
 	TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) {
 		vlan_num = vsi->vlan_num;
 		filter_type = f->mac_info.filter_type;
-		if (filter_type == RTE_MACVLAN_PERFECT_MATCH ||
-		    filter_type == RTE_MACVLAN_HASH_MATCH) {
+		if (filter_type == I40E_MACVLAN_PERFECT_MATCH ||
+		    filter_type == I40E_MACVLAN_HASH_MATCH) {
 			if (vlan_num == 0) {
 				PMD_DRV_LOG(ERR, "VLAN number shouldn't be 0");
 				return I40E_ERR_PARAM;
 			}
-		} else if (filter_type == RTE_MAC_PERFECT_MATCH ||
-			   filter_type == RTE_MAC_HASH_MATCH)
+		} else if (filter_type == I40E_MAC_PERFECT_MATCH ||
+			   filter_type == I40E_MAC_HASH_MATCH)
 			vlan_num = 1;
 
 		mv_f = rte_zmalloc("macvlan_data", vlan_num * sizeof(*mv_f), 0);
@@ -241,8 +241,8 @@ i40e_vsi_rm_mac_filter(struct i40e_vsi *vsi)
 					 &f->mac_info.mac_addr,
 					 ETH_ADDR_LEN);
 		}
-		if (filter_type == RTE_MACVLAN_PERFECT_MATCH ||
-		    filter_type == RTE_MACVLAN_HASH_MATCH) {
+		if (filter_type == I40E_MACVLAN_PERFECT_MATCH ||
+		    filter_type == I40E_MACVLAN_HASH_MATCH) {
 			ret = i40e_find_all_vlan_for_mac(vsi, mv_f, vlan_num,
 							 &f->mac_info.mac_addr);
 			if (ret != I40E_SUCCESS) {
@@ -275,8 +275,8 @@ i40e_vsi_restore_mac_filter(struct i40e_vsi *vsi)
 
 	/* restore all the MACs */
 	TAILQ_FOREACH_SAFE(f, &vsi->mac_list, next, temp) {
-		if ((f->mac_info.filter_type == RTE_MACVLAN_PERFECT_MATCH) ||
-		    (f->mac_info.filter_type == RTE_MACVLAN_HASH_MATCH)) {
+		if (f->mac_info.filter_type == I40E_MACVLAN_PERFECT_MATCH ||
+		    f->mac_info.filter_type == I40E_MACVLAN_HASH_MATCH) {
 			/**
 			 * If vlan_num is 0, that's the first time to add mac,
 			 * set mask for vlan_id 0.
@@ -286,8 +286,8 @@ i40e_vsi_restore_mac_filter(struct i40e_vsi *vsi)
 				vsi->vlan_num = 1;
 			}
 			vlan_num = vsi->vlan_num;
-		} else if ((f->mac_info.filter_type == RTE_MAC_PERFECT_MATCH) ||
-			   (f->mac_info.filter_type == RTE_MAC_HASH_MATCH))
+		} else if (f->mac_info.filter_type == I40E_MAC_PERFECT_MATCH ||
+			   f->mac_info.filter_type == I40E_MAC_HASH_MATCH)
 			vlan_num = 1;
 
 		mv_f = rte_zmalloc("macvlan_data", vlan_num * sizeof(*mv_f), 0);
@@ -303,8 +303,8 @@ i40e_vsi_restore_mac_filter(struct i40e_vsi *vsi)
 					 ETH_ADDR_LEN);
 		}
 
-		if (f->mac_info.filter_type == RTE_MACVLAN_PERFECT_MATCH ||
-		    f->mac_info.filter_type == RTE_MACVLAN_HASH_MATCH) {
+		if (f->mac_info.filter_type == I40E_MACVLAN_PERFECT_MATCH ||
+		    f->mac_info.filter_type == I40E_MACVLAN_HASH_MATCH) {
 			ret = i40e_find_all_vlan_for_mac(vsi, mv_f, vlan_num,
 							 &f->mac_info.mac_addr);
 			if (ret != I40E_SUCCESS) {
@@ -768,7 +768,7 @@ int rte_pmd_i40e_set_vf_broadcast(uint16_t port, uint16_t vf_id,
 
 	if (on) {
 		rte_memcpy(&filter.mac_addr, &broadcast, RTE_ETHER_ADDR_LEN);
-		filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
+		filter.filter_type = I40E_MACVLAN_PERFECT_MATCH;
 		ret = i40e_vsi_add_mac(vsi, &filter);
 	} else {
 		ret = i40e_vsi_delete_mac(vsi, &broadcast);
@@ -2388,7 +2388,7 @@ rte_pmd_i40e_add_vf_mac_addr(uint16_t port, uint16_t vf_id,
 		return -EINVAL;
 	}
 
-	mac_filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
+	mac_filter.filter_type = I40E_MACVLAN_PERFECT_MATCH;
 	rte_ether_addr_copy(mac_addr, &mac_filter.mac_addr);
 	ret = i40e_vsi_add_mac(vsi, &mac_filter);
 	if (ret != I40E_SUCCESS) {
diff --git a/lib/librte_ethdev/rte_eth_ctrl.h b/lib/librte_ethdev/rte_eth_ctrl.h
index bbb94eccce..a3d49e0913 100644
--- a/lib/librte_ethdev/rte_eth_ctrl.h
+++ b/lib/librte_ethdev/rte_eth_ctrl.h
@@ -56,17 +56,6 @@ enum rte_filter_op {
 	RTE_ETH_FILTER_OP_MAX
 };
 
-/**
- * MAC filter type
- */
-enum rte_mac_filter_type {
-	RTE_MAC_PERFECT_MATCH = 1, /**< exact match of MAC addr. */
-	RTE_MACVLAN_PERFECT_MATCH, /**< exact match of MAC addr and VLAN ID. */
-	RTE_MAC_HASH_MATCH, /**< hash match of MAC addr. */
-	/** hash match of MAC addr and exact match of VLAN ID. */
-	RTE_MACVLAN_HASH_MATCH,
-};
-
 /**
  * Define all structures for Ethertype Filter type.
  */
-- 
2.17.1



More information about the dev mailing list