- * [dpdk-dev] [PATCH 01/15] ixgbe: migrate flow director filter operations (add/delete/update) to new API
  2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
@ 2015-01-29  5:29 ` Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 02/15] ethdev: extend flow type and flexible payload type definition for flow director Jingjing Wu
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Jingjing Wu @ 2015-01-29  5:29 UTC (permalink / raw)
  To: dev
This patch changes the add/delete/update operations to be implemented through
filter_ctrl API and RTE_ETH_FILTER_ADD/RTE_ETH_FILTER_DELETE/RTE_ETH_FILTER_UPDATE ops.
It also removes the callback functions:
 - ixgbe_eth_dev_ops.fdir_add_signature_filter
 - ixgbe_eth_dev_ops.fdir_update_signature_filter
 - ixgbe_eth_dev_ops.fdir_remove_signature_filter
 - ixgbe_eth_dev_ops.fdir_add_perfect_filter
 - ixgbe_eth_dev_ops.fdir_update_perfect_filter
 - ixgbe_eth_dev_ops.fdir_remove_perfect_filter
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c |   9 +-
 lib/librte_pmd_ixgbe/ixgbe_ethdev.h |  23 +-
 lib/librte_pmd_ixgbe/ixgbe_fdir.c   | 927 ++++++++++++++++++------------------
 3 files changed, 477 insertions(+), 482 deletions(-)
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index b341dd0..c3a76e6 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -360,13 +360,7 @@ static struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.set_vf_vlan_filter   = ixgbe_set_pool_vlan_filter,
 	.set_queue_rate_limit = ixgbe_set_queue_rate_limit,
 	.set_vf_rate_limit    = ixgbe_set_vf_rate_limit,
-	.fdir_add_signature_filter    = ixgbe_fdir_add_signature_filter,
-	.fdir_update_signature_filter = ixgbe_fdir_update_signature_filter,
-	.fdir_remove_signature_filter = ixgbe_fdir_remove_signature_filter,
 	.fdir_infos_get               = ixgbe_fdir_info_get,
-	.fdir_add_perfect_filter      = ixgbe_fdir_add_perfect_filter,
-	.fdir_update_perfect_filter   = ixgbe_fdir_update_perfect_filter,
-	.fdir_remove_perfect_filter   = ixgbe_fdir_remove_perfect_filter,
 	.fdir_set_masks               = ixgbe_fdir_set_masks,
 	.reta_update          = ixgbe_dev_rss_reta_update,
 	.reta_query           = ixgbe_dev_rss_reta_query,
@@ -4213,6 +4207,9 @@ ixgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
 	case RTE_ETH_FILTER_ETHERTYPE:
 		ret = ixgbe_ethertype_filter_handle(dev, filter_op, arg);
 		break;
+	case RTE_ETH_FILTER_FDIR:
+		ret = ixgbe_fdir_ctrl_func(dev, filter_op, arg);
+		break;
 	default:
 		PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
 							filter_type);
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
index 1383194..d92e54a 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
@@ -309,29 +309,9 @@ int ixgbe_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
  */
 int ixgbe_fdir_configure(struct rte_eth_dev *dev);
 
-int ixgbe_fdir_add_signature_filter(struct rte_eth_dev *dev,
-		struct rte_fdir_filter *fdir_filter, uint8_t queue);
-
-int ixgbe_fdir_update_signature_filter(struct rte_eth_dev *dev,
-		struct rte_fdir_filter *fdir_filter, uint8_t queue);
-
-int ixgbe_fdir_remove_signature_filter(struct rte_eth_dev *dev,
-		struct rte_fdir_filter *fdir_filter);
-
 void ixgbe_fdir_info_get(struct rte_eth_dev *dev,
 		struct rte_eth_fdir *fdir);
 
-int ixgbe_fdir_add_perfect_filter(struct rte_eth_dev *dev,
-		struct rte_fdir_filter *fdir_filter, uint16_t soft_id,
-		uint8_t queue, uint8_t drop);
-
-int ixgbe_fdir_update_perfect_filter(struct rte_eth_dev *dev,
-		struct rte_fdir_filter *fdir_filter,uint16_t soft_id,
-		uint8_t queue, uint8_t drop);
-
-int ixgbe_fdir_remove_perfect_filter(struct rte_eth_dev *dev,
-		struct rte_fdir_filter *fdir_filter, uint16_t soft_id);
-
 int ixgbe_fdir_set_masks(struct rte_eth_dev *dev,
 		struct rte_fdir_masks *fdir_masks);
 
@@ -355,4 +335,7 @@ void ixgbe_pf_mbx_process(struct rte_eth_dev *eth_dev);
 int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev);
 
 uint32_t ixgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val);
+
+int ixgbe_fdir_ctrl_func(struct rte_eth_dev *dev,
+			enum rte_filter_op filter_op, void *arg);
 #endif /* _IXGBE_ETHDEV_H_ */
diff --git a/lib/librte_pmd_ixgbe/ixgbe_fdir.c b/lib/librte_pmd_ixgbe/ixgbe_fdir.c
index cfcb515..e682d14 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_fdir.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_fdir.c
@@ -62,7 +62,28 @@
 #define SIG_BUCKET_64KB_HASH_MASK       0x1FFF  /* 13 bits */
 #define SIG_BUCKET_128KB_HASH_MASK      0x3FFF  /* 14 bits */
 #define SIG_BUCKET_256KB_HASH_MASK      0x7FFF  /* 15 bits */
-
+#define IXGBE_FDIRCMD_CMD_INTERVAL_US   10
+
+static int fdir_erase_filter_82599(struct ixgbe_hw *hw, uint32_t fdirhash);
+static int ixgbe_fdir_filter_to_atr_input(
+		const struct rte_eth_fdir_filter *fdir_filter,
+		union ixgbe_atr_input *input);
+static uint32_t ixgbe_atr_compute_hash_82599(union ixgbe_atr_input *atr_input,
+				 uint32_t key);
+static uint32_t atr_compute_sig_hash_82599(union ixgbe_atr_input *input,
+		enum rte_fdir_pballoc_type pballoc);
+static uint32_t atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,
+		enum rte_fdir_pballoc_type pballoc);
+static int fdir_write_perfect_filter_82599(struct ixgbe_hw *hw,
+			union ixgbe_atr_input *input, uint8_t queue,
+			uint32_t fdircmd, uint32_t fdirhash);
+static int fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
+		union ixgbe_atr_input *input, u8 queue, uint32_t fdircmd,
+		uint32_t fdirhash);
+static int ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev,
+			      const struct rte_eth_fdir_filter *fdir_filter,
+			      bool del,
+			      bool update);
 /**
  * This function is based on ixgbe_fdir_enable_82599() in ixgbe/ixgbe_82599.c.
  * It adds extra configuration of fdirctrl that is common for all filter types.
@@ -214,6 +235,215 @@ ixgbe_fdir_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
+/**
+ * Reverse the bits in FDIR registers that store 2 x 16 bit masks.
+ *
+ *  @hi_dword: Bits 31:16 mask to be bit swapped.
+ *  @lo_dword: Bits 15:0  mask to be bit swapped.
+ *
+ *  Flow director uses several registers to store 2 x 16 bit masks with the
+ *  bits reversed such as FDIRTCPM, FDIRUDPM and FDIRIP6M. The LS bit of the
+ *  mask affects the MS bit/byte of the target. This function reverses the
+ *  bits in these masks.
+ *  **/
+static uint32_t
+reverse_fdir_bitmasks(uint16_t hi_dword, uint16_t lo_dword)
+{
+	u32 mask = hi_dword << 16;
+	mask |= lo_dword;
+	mask = ((mask & 0x55555555) << 1) | ((mask & 0xAAAAAAAA) >> 1);
+	mask = ((mask & 0x33333333) << 2) | ((mask & 0xCCCCCCCC) >> 2);
+	mask = ((mask & 0x0F0F0F0F) << 4) | ((mask & 0xF0F0F0F0) >> 4);
+	return ((mask & 0x00FF00FF) << 8) | ((mask & 0xFF00FF00) >> 8);
+}
+
+/*
+ * This macro exists in ixgbe/ixgbe_82599.c, however in that file it reverses
+ * the bytes, and then reverses them again. So here it does nothing.
+ */
+#define IXGBE_WRITE_REG_BE32 IXGBE_WRITE_REG
+
+/*
+ * This is based on ixgbe_fdir_set_input_mask_82599() in ixgbe/ixgbe_82599.c,
+ * but makes use of the rte_fdir_masks structure to see which bits to set.
+ */
+static int
+fdir_set_input_mask_82599(struct ixgbe_hw *hw,
+		struct rte_fdir_masks *input_mask)
+{
+	/* mask VM pool since it is currently not supported */
+	u32 fdirm = IXGBE_FDIRM_POOL;
+	u32 fdirtcpm;  /* TCP source and destination port masks. */
+	u32 fdiripv6m; /* IPv6 source and destination masks. */
+
+	PMD_INIT_FUNC_TRACE();
+
+	/*
+	 * Program the relevant mask registers.  If src/dst_port or src/dst_addr
+	 * are zero, then assume a full mask for that field. Also assume that
+	 * a VLAN of 0 is unspecified, so mask that out as well.  L4type
+	 * cannot be masked out in this implementation.
+	 */
+	if (input_mask->only_ip_flow) {
+		/* use the L4 protocol mask for raw IPv4/IPv6 traffic */
+		fdirm |= IXGBE_FDIRM_L4P;
+		if (input_mask->dst_port_mask || input_mask->src_port_mask) {
+			PMD_INIT_LOG(ERR, " Error on src/dst port mask");
+			return -EINVAL;
+		}
+	}
+
+	if (!input_mask->comp_ipv6_dst)
+		/* mask DIPV6 */
+		fdirm |= IXGBE_FDIRM_DIPv6;
+
+	if (!input_mask->vlan_id)
+		/* mask VLAN ID*/
+		fdirm |= IXGBE_FDIRM_VLANID;
+
+	if (!input_mask->vlan_prio)
+		/* mask VLAN priority */
+		fdirm |= IXGBE_FDIRM_VLANP;
+
+	if (!input_mask->flexbytes)
+		/* Mask Flex Bytes */
+		fdirm |= IXGBE_FDIRM_FLEX;
+
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRM, fdirm);
+
+	/* store the TCP/UDP port masks, bit reversed from port layout */
+	fdirtcpm = reverse_fdir_bitmasks(input_mask->dst_port_mask,
+					 input_mask->src_port_mask);
+
+	/* write both the same so that UDP and TCP use the same mask */
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRTCPM, ~fdirtcpm);
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRUDPM, ~fdirtcpm);
+
+	if (!input_mask->set_ipv6_mask) {
+		/* Store source and destination IPv4 masks (big-endian) */
+		IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIP4M,
+				IXGBE_NTOHL(~input_mask->src_ipv4_mask));
+		IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRDIP4M,
+				IXGBE_NTOHL(~input_mask->dst_ipv4_mask));
+	} else {
+		/* Store source and destination IPv6 masks (bit reversed) */
+		fdiripv6m = reverse_fdir_bitmasks(input_mask->dst_ipv6_mask,
+						  input_mask->src_ipv6_mask);
+
+		IXGBE_WRITE_REG(hw, IXGBE_FDIRIP6M, ~fdiripv6m);
+	}
+
+	return IXGBE_SUCCESS;
+}
+
+int
+ixgbe_fdir_set_masks(struct rte_eth_dev *dev, struct rte_fdir_masks *fdir_masks)
+{
+	struct ixgbe_hw *hw;
+	int err;
+
+	PMD_INIT_FUNC_TRACE();
+
+	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	if (hw->mac.type != ixgbe_mac_82599EB &&
+		hw->mac.type != ixgbe_mac_X540 &&
+		hw->mac.type != ixgbe_mac_X550 &&
+		hw->mac.type != ixgbe_mac_X550EM_x)
+		return -ENOSYS;
+
+	err = ixgbe_reinit_fdir_tables_82599(hw);
+	if (err) {
+		PMD_INIT_LOG(ERR, "reinit of fdir tables failed");
+		return -EIO;
+	}
+
+	return fdir_set_input_mask_82599(hw, fdir_masks);
+}
+
+/*
+ * Convert DPDK rte_eth_fdir_filter struct to ixgbe_atr_input union that is used
+ * by the IXGBE driver code.
+ */
+static int
+ixgbe_fdir_filter_to_atr_input(const struct rte_eth_fdir_filter *fdir_filter,
+		union ixgbe_atr_input *input)
+{
+	input->formatted.vlan_id = fdir_filter->input.flow_ext.vlan_tci;
+	input->formatted.flex_bytes = (uint16_t)(
+		(fdir_filter->input.flow_ext.flexbytes[1] << 8 & 0xFF00) |
+		(fdir_filter->input.flow_ext.flexbytes[0] & 0xFF));
+
+	switch (fdir_filter->input.flow_type) {
+	case RTE_ETH_FLOW_TYPE_UDPV4:
+		input->formatted.flow_type = IXGBE_ATR_FLOW_TYPE_UDPV4;
+		break;
+	case RTE_ETH_FLOW_TYPE_TCPV4:
+		input->formatted.flow_type = IXGBE_ATR_FLOW_TYPE_TCPV4;
+		break;
+	case RTE_ETH_FLOW_TYPE_SCTPV4:
+		input->formatted.flow_type = IXGBE_ATR_FLOW_TYPE_SCTPV4;
+		break;
+	case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
+		input->formatted.flow_type = IXGBE_ATR_FLOW_TYPE_IPV4;
+		break;
+	case RTE_ETH_FLOW_TYPE_UDPV6:
+		input->formatted.flow_type = IXGBE_ATR_FLOW_TYPE_UDPV6;
+		break;
+	case RTE_ETH_FLOW_TYPE_TCPV6:
+		input->formatted.flow_type = IXGBE_ATR_FLOW_TYPE_TCPV6;
+		break;
+	case RTE_ETH_FLOW_TYPE_SCTPV6:
+		input->formatted.flow_type = IXGBE_ATR_FLOW_TYPE_SCTPV6;
+		break;
+	case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
+		input->formatted.flow_type = IXGBE_ATR_FLOW_TYPE_IPV6;
+		break;
+	default:
+		PMD_DRV_LOG(ERR, " Error on flow_type input");
+		return -EINVAL;
+	}
+
+	switch (fdir_filter->input.flow_type) {
+	case RTE_ETH_FLOW_TYPE_UDPV4:
+	case RTE_ETH_FLOW_TYPE_TCPV4:
+		input->formatted.src_port =
+			fdir_filter->input.flow.udp4_flow.src_port;
+		input->formatted.dst_port =
+			fdir_filter->input.flow.udp4_flow.dst_port;
+	/*for SCTP flow type, port and verify_tag are meaningless in ixgbe.*/
+	case RTE_ETH_FLOW_TYPE_SCTPV4:
+	case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
+		input->formatted.src_ip[0] =
+			fdir_filter->input.flow.ip4_flow.src_ip;
+		input->formatted.dst_ip[0] =
+			fdir_filter->input.flow.ip4_flow.dst_ip;
+		break;
+
+	case RTE_ETH_FLOW_TYPE_UDPV6:
+	case RTE_ETH_FLOW_TYPE_TCPV6:
+		input->formatted.src_port =
+			fdir_filter->input.flow.udp6_flow.src_port;
+		input->formatted.dst_port =
+			fdir_filter->input.flow.udp6_flow.dst_port;
+	/*for SCTP flow type, port and verify_tag are meaningless in ixgbe.*/
+	case RTE_ETH_FLOW_TYPE_SCTPV6:
+	case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
+		rte_memcpy(input->formatted.src_ip,
+			   fdir_filter->input.flow.ipv6_flow.src_ip,
+			   sizeof(input->formatted.src_ip));
+		rte_memcpy(input->formatted.dst_ip,
+			   fdir_filter->input.flow.ipv6_flow.dst_ip,
+			   sizeof(input->formatted.dst_ip));
+		break;
+	default:
+		PMD_DRV_LOG(ERR, " Error on flow_type input");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 /*
  * The below function is taken from the FreeBSD IXGBE drivers release
  * 2.3.8. The only change is not to mask hash_result with IXGBE_ATR_HASH_MASK
@@ -230,9 +460,9 @@ ixgbe_fdir_configure(struct rte_eth_dev *dev)
  *  @stream: input bitstream to compute the hash on
  *  @key: 32-bit hash key
  **/
-static u32
+static uint32_t
 ixgbe_atr_compute_hash_82599(union ixgbe_atr_input *atr_input,
-				 u32 key)
+				 uint32_t key)
 {
 	/*
 	 * The algorithm is as follows:
@@ -315,6 +545,43 @@ ixgbe_atr_compute_hash_82599(union ixgbe_atr_input *atr_input,
 	return hash_result;
 }
 
+static uint32_t
+atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,
+		enum rte_fdir_pballoc_type pballoc)
+{
+	if (pballoc == RTE_FDIR_PBALLOC_256K)
+		return ixgbe_atr_compute_hash_82599(input,
+				IXGBE_ATR_BUCKET_HASH_KEY) &
+				PERFECT_BUCKET_256KB_HASH_MASK;
+	else if (pballoc == RTE_FDIR_PBALLOC_128K)
+		return ixgbe_atr_compute_hash_82599(input,
+				IXGBE_ATR_BUCKET_HASH_KEY) &
+				PERFECT_BUCKET_128KB_HASH_MASK;
+	else
+		return ixgbe_atr_compute_hash_82599(input,
+				IXGBE_ATR_BUCKET_HASH_KEY) &
+				PERFECT_BUCKET_64KB_HASH_MASK;
+}
+
+/**
+ * ixgbe_fdir_check_cmd_complete - poll to check whether FDIRCMD is complete
+ * @hw: pointer to hardware structure
+ */
+static inline int
+ixgbe_fdir_check_cmd_complete(struct ixgbe_hw *hw, uint32_t *fdircmd)
+{
+	int i;
+
+	for (i = 0; i < IXGBE_FDIRCMD_CMD_POLL; i++) {
+		*fdircmd = IXGBE_READ_REG(hw, IXGBE_FDIRCMD);
+		if (!(*fdircmd & IXGBE_FDIRCMD_CMD_MASK))
+			return 0;
+		rte_delay_us(IXGBE_FDIRCMD_CMD_INTERVAL_US);
+	}
+
+	return -ETIMEDOUT;
+}
+
 /*
  * Calculate the hash value needed for signature-match filters. In the FreeBSD
  * driver, this is done by the optimised function
@@ -346,6 +613,63 @@ atr_compute_sig_hash_82599(union ixgbe_atr_input *input,
 	return (sig_hash << IXGBE_FDIRHASH_SIG_SW_INDEX_SHIFT) | bucket_hash;
 }
 
+/*
+ * This is based on ixgbe_fdir_write_perfect_filter_82599() in
+ * ixgbe/ixgbe_82599.c, with the ability to set extra flags in FDIRCMD register
+ * added, and IPv6 support also added. The hash value is also pre-calculated
+ * as the pballoc value is needed to do it.
+ */
+static int
+fdir_write_perfect_filter_82599(struct ixgbe_hw *hw,
+			union ixgbe_atr_input *input, uint8_t queue,
+			uint32_t fdircmd, uint32_t fdirhash)
+{
+	uint32_t fdirport, fdirvlan;
+	int err = 0;
+
+	/* record the IPv4 address (big-endian) */
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRIPSA, input->formatted.src_ip[0]);
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRIPDA, input->formatted.dst_ip[0]);
+
+	/* record source and destination port (little-endian)*/
+	fdirport = IXGBE_NTOHS(input->formatted.dst_port);
+	fdirport <<= IXGBE_FDIRPORT_DESTINATION_SHIFT;
+	fdirport |= IXGBE_NTOHS(input->formatted.src_port);
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRPORT, fdirport);
+
+	/* record vlan (little-endian) and flex_bytes(big-endian) */
+	fdirvlan = input->formatted.flex_bytes;
+	fdirvlan <<= IXGBE_FDIRVLAN_FLEX_SHIFT;
+	fdirvlan |= IXGBE_NTOHS(input->formatted.vlan_id);
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRVLAN, fdirvlan);
+
+	/* configure FDIRHASH register */
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, fdirhash);
+
+	/*
+	 * flush all previous writes to make certain registers are
+	 * programmed prior to issuing the command
+	 */
+	IXGBE_WRITE_FLUSH(hw);
+
+	/* configure FDIRCMD register */
+	fdircmd |= IXGBE_FDIRCMD_CMD_ADD_FLOW |
+		  IXGBE_FDIRCMD_LAST | IXGBE_FDIRCMD_QUEUE_EN;
+	fdircmd |= input->formatted.flow_type << IXGBE_FDIRCMD_FLOW_TYPE_SHIFT;
+	fdircmd |= (uint32_t)queue << IXGBE_FDIRCMD_RX_QUEUE_SHIFT;
+	fdircmd |= (uint32_t)input->formatted.vm_pool << IXGBE_FDIRCMD_VT_POOL_SHIFT;
+
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, fdircmd);
+
+	PMD_DRV_LOG(DEBUG, "Rx Queue=%x hash=%x", queue, fdirhash);
+
+	err = ixgbe_fdir_check_cmd_complete(hw, &fdircmd);
+	if (err < 0)
+		PMD_DRV_LOG(ERR, "Timeout writing flow director filter.");
+
+	return err;
+}
+
 /**
  * This function is based on ixgbe_atr_add_signature_filter_82599() in
  * ixgbe/ixgbe_82599.c, but uses a pre-calculated hash value. It also supports
@@ -361,12 +685,12 @@ atr_compute_sig_hash_82599(union ixgbe_atr_input *input,
  *  @fdircmd: any extra flags to set in fdircmd register
  *  @fdirhash: pre-calculated hash value for the filter
  **/
-static void
+static int
 fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
-		union ixgbe_atr_input *input, u8 queue, u32 fdircmd,
-		u32 fdirhash)
+		union ixgbe_atr_input *input, u8 queue, uint32_t fdircmd,
+		uint32_t fdirhash)
 {
-	u64  fdirhashcmd;
+	int err = 0;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -374,164 +698,43 @@ fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
 	fdircmd |= IXGBE_FDIRCMD_CMD_ADD_FLOW |
 	          IXGBE_FDIRCMD_LAST | IXGBE_FDIRCMD_QUEUE_EN;
 	fdircmd |= input->formatted.flow_type << IXGBE_FDIRCMD_FLOW_TYPE_SHIFT;
-	fdircmd |= (u32)queue << IXGBE_FDIRCMD_RX_QUEUE_SHIFT;
+	fdircmd |= (uint32_t)queue << IXGBE_FDIRCMD_RX_QUEUE_SHIFT;
 
-	/*
-	 * The lower 32-bits of fdirhashcmd is for FDIRHASH, the upper 32-bits
-	 * is for FDIRCMD.  Then do a 64-bit register write from FDIRHASH.
-	 */
-	fdirhashcmd = (u64)fdircmd << 32;
-	fdirhashcmd |= fdirhash;
-	IXGBE_WRITE_REG64(hw, IXGBE_FDIRHASH, fdirhashcmd);
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, fdirhash);
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, fdircmd);
+
+	PMD_DRV_LOG(DEBUG, "Rx Queue=%x hash=%x", queue, fdirhash);
 
-	PMD_INIT_LOG(DEBUG, "Tx Queue=%x hash=%x", queue, (u32)fdirhashcmd);
+	err = ixgbe_fdir_check_cmd_complete(hw, &fdircmd);
+	if (err < 0)
+		PMD_DRV_LOG(ERR, "Timeout writing flow director filter.");
+
+	return err;
 }
 
 /*
- * Convert DPDK rte_fdir_filter struct to ixgbe_atr_input union that is used
- * by the IXGBE driver code.
+ * This is based on ixgbe_fdir_erase_perfect_filter_82599() in
+ * ixgbe/ixgbe_82599.c. It is modified to take in the hash as a parameter so
+ * that it can be used for removing signature and perfect filters.
  */
 static int
-fdir_filter_to_atr_input(struct rte_fdir_filter *fdir_filter,
-		union ixgbe_atr_input *input)
+fdir_erase_filter_82599(struct ixgbe_hw *hw, uint32_t fdirhash)
 {
-	if ((fdir_filter->l4type == RTE_FDIR_L4TYPE_SCTP ||
-			fdir_filter->l4type == RTE_FDIR_L4TYPE_NONE) &&
-			(fdir_filter->port_src || fdir_filter->port_dst)) {
-		PMD_INIT_LOG(ERR, "Invalid fdir_filter");
-		return -EINVAL;
-	}
+	uint32_t fdircmd = 0;
+	int err = 0;
 
-	memset(input, 0, sizeof(*input));
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, fdirhash);
 
-	input->formatted.vlan_id = fdir_filter->vlan_id;
-	input->formatted.src_port = fdir_filter->port_src;
-	input->formatted.dst_port = fdir_filter->port_dst;
-	input->formatted.flex_bytes = fdir_filter->flex_bytes;
-
-	switch (fdir_filter->l4type) {
-	case RTE_FDIR_L4TYPE_TCP:
-		input->formatted.flow_type = IXGBE_ATR_FLOW_TYPE_TCPV4;
-		break;
-	case RTE_FDIR_L4TYPE_UDP:
-		input->formatted.flow_type = IXGBE_ATR_FLOW_TYPE_UDPV4;
-		break;
-	case RTE_FDIR_L4TYPE_SCTP:
-		input->formatted.flow_type = IXGBE_ATR_FLOW_TYPE_SCTPV4;
-		break;
-	case RTE_FDIR_L4TYPE_NONE:
-		input->formatted.flow_type = IXGBE_ATR_FLOW_TYPE_IPV4;
-		break;
-	default:
-		PMD_INIT_LOG(ERR, " Error on l4type input");
-		return -EINVAL;
-	}
-
-	if (fdir_filter->iptype == RTE_FDIR_IPTYPE_IPV6) {
-		input->formatted.flow_type |= IXGBE_ATR_L4TYPE_IPV6_MASK;
-
-		input->formatted.src_ip[0] = fdir_filter->ip_src.ipv6_addr[0];
-		input->formatted.src_ip[1] = fdir_filter->ip_src.ipv6_addr[1];
-		input->formatted.src_ip[2] = fdir_filter->ip_src.ipv6_addr[2];
-		input->formatted.src_ip[3] = fdir_filter->ip_src.ipv6_addr[3];
-
-		input->formatted.dst_ip[0] = fdir_filter->ip_dst.ipv6_addr[0];
-		input->formatted.dst_ip[1] = fdir_filter->ip_dst.ipv6_addr[1];
-		input->formatted.dst_ip[2] = fdir_filter->ip_dst.ipv6_addr[2];
-		input->formatted.dst_ip[3] = fdir_filter->ip_dst.ipv6_addr[3];
-
-	} else {
-		input->formatted.src_ip[0] = fdir_filter->ip_src.ipv4_addr;
-		input->formatted.dst_ip[0] = fdir_filter->ip_dst.ipv4_addr;
-	}
-
-	return 0;
-}
-
-/*
- * Adds or updates a signature filter.
- *
- * dev: ethernet device to add filter to
- * fdir_filter: filter details
- * queue: queue index to direct traffic to
- * update: 0 to add a new filter, otherwise update existing.
- */
-static int
-fdir_add_update_signature_filter(struct rte_eth_dev *dev,
-		struct rte_fdir_filter *fdir_filter, uint8_t queue, int update)
-{
-	struct ixgbe_hw *hw= IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	uint32_t fdircmd_flags = (update) ? IXGBE_FDIRCMD_FILTER_UPDATE : 0;
-	uint32_t fdirhash;
-	union ixgbe_atr_input input;
-	int err;
-
-	if (hw->mac.type != ixgbe_mac_82599EB &&
-		hw->mac.type != ixgbe_mac_X540 &&
-		hw->mac.type != ixgbe_mac_X550 &&
-		hw->mac.type != ixgbe_mac_X550EM_x)
-		return -ENOSYS;
-
-	err = fdir_filter_to_atr_input(fdir_filter, &input);
-	if (err)
-		return err;
-
-	fdirhash = atr_compute_sig_hash_82599(&input,
-			dev->data->dev_conf.fdir_conf.pballoc);
-	fdir_add_signature_filter_82599(hw, &input, queue, fdircmd_flags,
-			fdirhash);
-	return 0;
-}
-
-int
-ixgbe_fdir_add_signature_filter(struct rte_eth_dev *dev,
-		struct rte_fdir_filter *fdir_filter, uint8_t queue)
-{
-	PMD_INIT_FUNC_TRACE();
-	return fdir_add_update_signature_filter(dev, fdir_filter, queue, 0);
-}
-
-int
-ixgbe_fdir_update_signature_filter(struct rte_eth_dev *dev,
-		struct rte_fdir_filter *fdir_filter, uint8_t queue)
-{
-	PMD_INIT_FUNC_TRACE();
-	return fdir_add_update_signature_filter(dev, fdir_filter, queue, 1);
-}
-
-/*
- * This is based on ixgbe_fdir_erase_perfect_filter_82599() in
- * ixgbe/ixgbe_82599.c. It is modified to take in the hash as a parameter so
- * that it can be used for removing signature and perfect filters.
- */
-static s32
-fdir_erase_filter_82599(struct ixgbe_hw *hw,
-	__rte_unused union ixgbe_atr_input *input, uint32_t fdirhash)
-{
-	u32 fdircmd = 0;
-	u32 retry_count;
-	s32 err = 0;
-
-	IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, fdirhash);
-
-	/* flush hash to HW */
-	IXGBE_WRITE_FLUSH(hw);
+	/* flush hash to HW */
+	IXGBE_WRITE_FLUSH(hw);
 
 	/* Query if filter is present */
 	IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, IXGBE_FDIRCMD_CMD_QUERY_REM_FILT);
 
-	for (retry_count = 10; retry_count; retry_count--) {
-		/* allow 10us for query to process */
-		usec_delay(10);
-		/* verify query completed successfully */
-		fdircmd = IXGBE_READ_REG(hw, IXGBE_FDIRCMD);
-		if (!(fdircmd & IXGBE_FDIRCMD_CMD_MASK))
-			break;
-	}
-
-	if (!retry_count) {
-		PMD_INIT_LOG(ERR, "Timeout querying for flow director filter");
-		err = -EIO;
+	err = ixgbe_fdir_check_cmd_complete(hw, &fdircmd);
+	if (err < 0) {
+		PMD_INIT_LOG(ERR, "Timeout querying for flow director filter.");
+		return err;
 	}
 
 	/* if filter exists in hardware then remove it */
@@ -541,331 +744,97 @@ fdir_erase_filter_82599(struct ixgbe_hw *hw,
 		IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
 				IXGBE_FDIRCMD_CMD_REMOVE_FLOW);
 	}
-
+	err = ixgbe_fdir_check_cmd_complete(hw, &fdircmd);
+	if (err < 0)
+		PMD_INIT_LOG(ERR, "Timeout erasing flow director filter.");
 	return err;
-}
-
-int
-ixgbe_fdir_remove_signature_filter(struct rte_eth_dev *dev,
-		struct rte_fdir_filter *fdir_filter)
-{
-	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	union ixgbe_atr_input input;
-	int err;
 
-	PMD_INIT_FUNC_TRACE();
-
-	if (hw->mac.type != ixgbe_mac_82599EB &&
-		hw->mac.type != ixgbe_mac_X540 &&
-		hw->mac.type != ixgbe_mac_X550 &&
-		hw->mac.type != ixgbe_mac_X550EM_x)
-		return -ENOSYS;
-
-	err = fdir_filter_to_atr_input(fdir_filter, &input);
-	if (err)
-		return err;
-
-	return fdir_erase_filter_82599(hw, &input,
-			atr_compute_sig_hash_82599(&input,
-			dev->data->dev_conf.fdir_conf.pballoc));
-}
-
-/**
- * Reverse the bits in FDIR registers that store 2 x 16 bit masks.
- *
- *  @hi_dword: Bits 31:16 mask to be bit swapped.
- *  @lo_dword: Bits 15:0  mask to be bit swapped.
- *
- *  Flow director uses several registers to store 2 x 16 bit masks with the
- *  bits reversed such as FDIRTCPM, FDIRUDPM and FDIRIP6M. The LS bit of the
- *  mask affects the MS bit/byte of the target. This function reverses the
- *  bits in these masks.
- *  **/
-static uint32_t
-reverse_fdir_bitmasks(uint16_t hi_dword, uint16_t lo_dword)
-{
-	u32 mask = hi_dword << 16;
-	mask |= lo_dword;
-	mask = ((mask & 0x55555555) << 1) | ((mask & 0xAAAAAAAA) >> 1);
-	mask = ((mask & 0x33333333) << 2) | ((mask & 0xCCCCCCCC) >> 2);
-	mask = ((mask & 0x0F0F0F0F) << 4) | ((mask & 0xF0F0F0F0) >> 4);
-	return ((mask & 0x00FF00FF) << 8) | ((mask & 0xFF00FF00) >> 8);
 }
 
 /*
- * This macro exists in ixgbe/ixgbe_82599.c, however in that file it reverses
- * the bytes, and then reverses them again. So here it does nothing.
- */
-#define IXGBE_WRITE_REG_BE32 IXGBE_WRITE_REG
-
-/*
- * This is based on ixgbe_fdir_set_input_mask_82599() in ixgbe/ixgbe_82599.c,
- * but makes use of the rte_fdir_masks structure to see which bits to set.
+ * ixgbe_add_del_fdir_filter - add or remove a flow diretor filter.
+ * @dev: pointer to the structure rte_eth_dev
+ * @fdir_filter: fdir filter entry
+ * @del: 1 - delete, 0 - add
+ * @update: 1 - update
  */
 static int
-fdir_set_input_mask_82599(struct ixgbe_hw *hw,
-		struct rte_fdir_masks *input_mask)
-{
-	/* mask VM pool since it is currently not supported */
-	u32 fdirm = IXGBE_FDIRM_POOL;
-	u32 fdirtcpm;  /* TCP source and destination port masks. */
-	u32 fdiripv6m; /* IPv6 source and destination masks. */
-
-	PMD_INIT_FUNC_TRACE();
-
-	/*
-	 * Program the relevant mask registers.  If src/dst_port or src/dst_addr
-	 * are zero, then assume a full mask for that field. Also assume that
-	 * a VLAN of 0 is unspecified, so mask that out as well.  L4type
-	 * cannot be masked out in this implementation.
-	 */
-	if (input_mask->only_ip_flow) {
-		/* use the L4 protocol mask for raw IPv4/IPv6 traffic */
-		fdirm |= IXGBE_FDIRM_L4P;
-		if (input_mask->dst_port_mask || input_mask->src_port_mask) {
-			PMD_INIT_LOG(ERR, " Error on src/dst port mask");
-			return -EINVAL;
-		}
-	}
-
-	if (!input_mask->comp_ipv6_dst)
-		/* mask DIPV6 */
-		fdirm |= IXGBE_FDIRM_DIPv6;
-
-	if (!input_mask->vlan_id)
-		/* mask VLAN ID*/
-		fdirm |= IXGBE_FDIRM_VLANID;
-
-	if (!input_mask->vlan_prio)
-		/* mask VLAN priority */
-		fdirm |= IXGBE_FDIRM_VLANP;
-
-	if (!input_mask->flexbytes)
-		/* Mask Flex Bytes */
-		fdirm |= IXGBE_FDIRM_FLEX;
-
-	IXGBE_WRITE_REG(hw, IXGBE_FDIRM, fdirm);
-
-	/* store the TCP/UDP port masks, bit reversed from port layout */
-	fdirtcpm = reverse_fdir_bitmasks(input_mask->dst_port_mask,
-	                                 input_mask->src_port_mask);
-
-	/* write both the same so that UDP and TCP use the same mask */
-	IXGBE_WRITE_REG(hw, IXGBE_FDIRTCPM, ~fdirtcpm);
-	IXGBE_WRITE_REG(hw, IXGBE_FDIRUDPM, ~fdirtcpm);
-
-	if (!input_mask->set_ipv6_mask) {
-		/* Store source and destination IPv4 masks (big-endian) */
-		IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIP4M,
-				IXGBE_NTOHL(~input_mask->src_ipv4_mask));
-		IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRDIP4M,
-				IXGBE_NTOHL(~input_mask->dst_ipv4_mask));
-	}
-	else {
-		/* Store source and destination IPv6 masks (bit reversed) */
-		fdiripv6m = reverse_fdir_bitmasks(input_mask->dst_ipv6_mask,
-		                                  input_mask->src_ipv6_mask);
-
-		IXGBE_WRITE_REG(hw, IXGBE_FDIRIP6M, ~fdiripv6m);
-	}
-
-	return IXGBE_SUCCESS;
-}
-
-int
-ixgbe_fdir_set_masks(struct rte_eth_dev *dev, struct rte_fdir_masks *fdir_masks)
-{
-	struct ixgbe_hw *hw;
-	int err;
-
-	PMD_INIT_FUNC_TRACE();
-
-	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-
-	if (hw->mac.type != ixgbe_mac_82599EB &&
-		hw->mac.type != ixgbe_mac_X540 &&
-		hw->mac.type != ixgbe_mac_X550 &&
-		hw->mac.type != ixgbe_mac_X550EM_x)
-		return -ENOSYS;
-
-	err = ixgbe_reinit_fdir_tables_82599(hw);
-	if (err) {
-		PMD_INIT_LOG(ERR, "reinit of fdir tables failed");
-		return -EIO;
-	}
-
-	return fdir_set_input_mask_82599(hw, fdir_masks);
-}
-
-static uint32_t
-atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,
-		enum rte_fdir_pballoc_type pballoc)
-{
-	if (pballoc == RTE_FDIR_PBALLOC_256K)
-		return ixgbe_atr_compute_hash_82599(input,
-				IXGBE_ATR_BUCKET_HASH_KEY) &
-				PERFECT_BUCKET_256KB_HASH_MASK;
-	else if (pballoc == RTE_FDIR_PBALLOC_128K)
-		return ixgbe_atr_compute_hash_82599(input,
-				IXGBE_ATR_BUCKET_HASH_KEY) &
-				PERFECT_BUCKET_128KB_HASH_MASK;
-	else
-		return ixgbe_atr_compute_hash_82599(input,
-				IXGBE_ATR_BUCKET_HASH_KEY) &
-				PERFECT_BUCKET_64KB_HASH_MASK;
-}
-
-/*
- * This is based on ixgbe_fdir_write_perfect_filter_82599() in
- * ixgbe/ixgbe_82599.c, with the ability to set extra flags in FDIRCMD register
- * added, and IPv6 support also added. The hash value is also pre-calculated
- * as the pballoc value is needed to do it.
- */
-static void
-fdir_write_perfect_filter_82599(struct ixgbe_hw *hw, union ixgbe_atr_input *input,
-		uint16_t soft_id, uint8_t queue, uint32_t fdircmd,
-		uint32_t fdirhash)
-{
-	u32 fdirport, fdirvlan;
-
-	/* record the source address (big-endian) */
-	if (input->formatted.flow_type & IXGBE_ATR_L4TYPE_IPV6_MASK) {
-		IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIPv6(0), input->formatted.src_ip[0]);
-		IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIPv6(1), input->formatted.src_ip[1]);
-		IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIPv6(2), input->formatted.src_ip[2]);
-		IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRIPSA, input->formatted.src_ip[3]);
-	}
-	else {
-		IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRIPSA, input->formatted.src_ip[0]);
-	}
-
-	/* record the first 32 bits of the destination address (big-endian) */
-	IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRIPDA, input->formatted.dst_ip[0]);
-
-	/* record source and destination port (little-endian)*/
-	fdirport = IXGBE_NTOHS(input->formatted.dst_port);
-	fdirport <<= IXGBE_FDIRPORT_DESTINATION_SHIFT;
-	fdirport |= IXGBE_NTOHS(input->formatted.src_port);
-	IXGBE_WRITE_REG(hw, IXGBE_FDIRPORT, fdirport);
-
-	/* record vlan (little-endian) and flex_bytes(big-endian) */
-	fdirvlan = input->formatted.flex_bytes;
-	fdirvlan <<= IXGBE_FDIRVLAN_FLEX_SHIFT;
-	fdirvlan |= IXGBE_NTOHS(input->formatted.vlan_id);
-	IXGBE_WRITE_REG(hw, IXGBE_FDIRVLAN, fdirvlan);
-
-	/* configure FDIRHASH register */
-	fdirhash |= soft_id << IXGBE_FDIRHASH_SIG_SW_INDEX_SHIFT;
-	IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, fdirhash);
-
-	/*
-	 * flush all previous writes to make certain registers are
-	 * programmed prior to issuing the command
-	 */
-	IXGBE_WRITE_FLUSH(hw);
-
-	/* configure FDIRCMD register */
-	fdircmd |= IXGBE_FDIRCMD_CMD_ADD_FLOW |
-		  IXGBE_FDIRCMD_LAST | IXGBE_FDIRCMD_QUEUE_EN;
-	fdircmd |= input->formatted.flow_type << IXGBE_FDIRCMD_FLOW_TYPE_SHIFT;
-	fdircmd |= (u32)queue << IXGBE_FDIRCMD_RX_QUEUE_SHIFT;
-	fdircmd |= (u32)input->formatted.vm_pool << IXGBE_FDIRCMD_VT_POOL_SHIFT;
-
-	IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, fdircmd);
-}
-
-/*
- * Adds or updates a perfect filter.
- *
- * dev: ethernet device to add filter to
- * fdir_filter: filter details
- * soft_id: software index for the filters
- * queue: queue index to direct traffic to
- * drop: non-zero if packets should be sent to the drop queue
- * update: 0 to add a new filter, otherwise update existing.
- */
-static int
-fdir_add_update_perfect_filter(struct rte_eth_dev *dev,
-		struct rte_fdir_filter *fdir_filter, uint16_t soft_id,
-		uint8_t queue, int drop, int update)
+ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev,
+			      const struct rte_eth_fdir_filter *fdir_filter,
+			      bool del,
+			      bool update)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	uint32_t fdircmd_flags = (update) ? IXGBE_FDIRCMD_FILTER_UPDATE : 0;
+	uint32_t fdircmd_flags;
 	uint32_t fdirhash;
 	union ixgbe_atr_input input;
+	uint8_t queue;
+	bool is_perfect = FALSE;
 	int err;
 
-	if (hw->mac.type != ixgbe_mac_82599EB &&
-		hw->mac.type != ixgbe_mac_X540 &&
-		hw->mac.type != ixgbe_mac_X550 &&
-		hw->mac.type != ixgbe_mac_X550EM_x)
-		return -ENOSYS;
-
-	err = fdir_filter_to_atr_input(fdir_filter, &input);
-	if (err)
-		return err;
-
-	if (drop) {
-		queue = dev->data->dev_conf.fdir_conf.drop_queue;
-		fdircmd_flags |= IXGBE_FDIRCMD_DROP;
-	}
-
-	fdirhash = atr_compute_perfect_hash_82599(&input,
-			dev->data->dev_conf.fdir_conf.pballoc);
+	if (dev->data->dev_conf.fdir_conf.mode == RTE_FDIR_MODE_NONE)
+		return -ENOTSUP;
 
-	fdir_write_perfect_filter_82599(hw, &input, soft_id, queue,
-			fdircmd_flags, fdirhash);
-	return 0;
-}
+	if (dev->data->dev_conf.fdir_conf.mode == RTE_FDIR_MODE_PERFECT)
+		is_perfect = TRUE;
 
-int
-ixgbe_fdir_add_perfect_filter(struct rte_eth_dev *dev,
-		struct rte_fdir_filter *fdir_filter, uint16_t soft_id,
-		uint8_t queue, uint8_t drop)
-{
-	PMD_INIT_FUNC_TRACE();
-	return fdir_add_update_perfect_filter(dev, fdir_filter, soft_id, queue,
-			drop, 0);
-}
-
-int
-ixgbe_fdir_update_perfect_filter(struct rte_eth_dev *dev,
-		struct rte_fdir_filter *fdir_filter, uint16_t soft_id,
-		uint8_t queue, uint8_t drop)
-{
-	PMD_INIT_FUNC_TRACE();
-	return fdir_add_update_perfect_filter(dev, fdir_filter, soft_id, queue,
-			drop, 1);
-}
-
-int
-ixgbe_fdir_remove_perfect_filter(struct rte_eth_dev *dev,
-		struct rte_fdir_filter *fdir_filter,
-		uint16_t soft_id)
-{
-	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	union ixgbe_atr_input input;
-	uint32_t fdirhash;
-	int err;
-
-	PMD_INIT_FUNC_TRACE();
+	memset(&input, 0, sizeof(input));
 
-	if (hw->mac.type != ixgbe_mac_82599EB &&
-		hw->mac.type != ixgbe_mac_X540 &&
-		hw->mac.type != ixgbe_mac_X550 &&
-		hw->mac.type != ixgbe_mac_X550EM_x)
-		return -ENOSYS;
-
-	err = fdir_filter_to_atr_input(fdir_filter, &input);
+	err = ixgbe_fdir_filter_to_atr_input(fdir_filter, &input);
 	if (err)
 		return err;
 
-	/* configure FDIRHASH register */
-	fdirhash = atr_compute_perfect_hash_82599(&input,
-			dev->data->dev_conf.fdir_conf.pballoc);
-	fdirhash |= soft_id << IXGBE_FDIRHASH_SIG_SW_INDEX_SHIFT;
+	if (is_perfect) {
+		if (input.formatted.flow_type & IXGBE_ATR_L4TYPE_IPV6_MASK) {
+			PMD_DRV_LOG(ERR, "IPv6 is not supported in"
+					 " perfect mode!");
+			return -ENOTSUP;
+		}
+		fdirhash = atr_compute_perfect_hash_82599(&input,
+				dev->data->dev_conf.fdir_conf.pballoc);
+		fdirhash |= fdir_filter->soft_id <<
+				IXGBE_FDIRHASH_SIG_SW_INDEX_SHIFT;
+	} else
+		fdirhash = atr_compute_sig_hash_82599(&input,
+				dev->data->dev_conf.fdir_conf.pballoc);
+
+	if (del) {
+		err = fdir_erase_filter_82599(hw, fdirhash);
+		if (err < 0)
+			PMD_DRV_LOG(ERR, "Fail to delete FDIR filter!");
+		else
+			PMD_DRV_LOG(DEBUG, "Success to delete FDIR filter!");
+		return err;
+	}
+	/* add or update an fdir filter*/
+	fdircmd_flags = (update) ? IXGBE_FDIRCMD_FILTER_UPDATE : 0;
+	if (fdir_filter->action.behavior == RTE_ETH_FDIR_REJECT) {
+		if (is_perfect) {
+			queue = dev->data->dev_conf.fdir_conf.drop_queue;
+			fdircmd_flags |= IXGBE_FDIRCMD_DROP;
+		} else {
+			PMD_DRV_LOG(ERR, "Drop option is not supported in"
+				" signature mode.");
+			return -EINVAL;
+		}
+	} else if (fdir_filter->action.rx_queue < IXGBE_MAX_RX_QUEUE_NUM)
+		queue = (uint8_t)fdir_filter->action.rx_queue;
+	else
+		return -EINVAL;
+
+	if (is_perfect) {
+		err = fdir_write_perfect_filter_82599(hw, &input, queue,
+				fdircmd_flags, fdirhash);
+	} else {
+		err = fdir_add_signature_filter_82599(hw, &input, queue,
+				fdircmd_flags, fdirhash);
+	}
+	if (err < 0)
+		PMD_DRV_LOG(ERR, "Fail to add FDIR filter!");
+	else
+		PMD_DRV_LOG(DEBUG, "Success to add FDIR filter");
 
-	return fdir_erase_filter_82599(hw, &input, fdirhash);
+	return err;
 }
 
 void
@@ -917,3 +886,49 @@ ixgbe_fdir_info_get(struct rte_eth_dev *dev, struct rte_eth_fdir *fdir)
 	fdir->f_remove = info->f_remove;
 	fdir->f_add = info->f_add;
 }
+
+/*
+ * ixgbe_fdir_ctrl_func - deal with all operations on flow director.
+ * @dev: pointer to the structure rte_eth_dev
+ * @filter_op:operation will be taken
+ * @arg: a pointer to specific structure corresponding to the filter_op
+ */
+int
+ixgbe_fdir_ctrl_func(struct rte_eth_dev *dev,
+			enum rte_filter_op filter_op, void *arg)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	int ret = 0;
+
+	if (hw->mac.type != ixgbe_mac_82599EB &&
+		hw->mac.type != ixgbe_mac_X540 &&
+		hw->mac.type != ixgbe_mac_X550 &&
+		hw->mac.type != ixgbe_mac_X550EM_x)
+		return -ENOTSUP;
+
+	if (filter_op == RTE_ETH_FILTER_NOP)
+		return 0;
+
+	if (arg == NULL && filter_op != RTE_ETH_FILTER_FLUSH)
+		return -EINVAL;
+
+	switch (filter_op) {
+	case RTE_ETH_FILTER_ADD:
+		ret = ixgbe_add_del_fdir_filter(dev,
+			(struct rte_eth_fdir_filter *)arg, FALSE, FALSE);
+		break;
+	case RTE_ETH_FILTER_UPDATE:
+		ret = ixgbe_add_del_fdir_filter(dev,
+			(struct rte_eth_fdir_filter *)arg, FALSE, TRUE);
+		break;
+	case RTE_ETH_FILTER_DELETE:
+		ret = ixgbe_add_del_fdir_filter(dev,
+			(struct rte_eth_fdir_filter *)arg, TRUE, FALSE);
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "unknown operation %u", filter_op);
+		ret = -EINVAL;
+		break;
+	}
+	return ret;
+}
-- 
1.9.3
^ permalink raw reply	[flat|nested] 18+ messages in thread
- * [dpdk-dev] [PATCH 02/15] ethdev: extend flow type and flexible payload type definition for flow director
  2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 01/15] ixgbe: migrate flow director filter operations (add/delete/update) " Jingjing Wu
@ 2015-01-29  5:29 ` Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 03/15] ixgbe: implement the flexpayload configuration of flow director filter Jingjing Wu
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Jingjing Wu @ 2015-01-29  5:29 UTC (permalink / raw)
  To: dev
This patch adds RTE_ETH_FLOW_TYPE_RAW and RTE_ETH_RAW_PAYLOAD to support the
flexible payload is started from the beginning of the packet.
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 lib/librte_ether/rte_eth_ctrl.h | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index 5d9c387..74403b7 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -183,6 +183,7 @@ struct rte_eth_tunnel_filter_conf {
  */
 enum rte_eth_flow_type {
 	RTE_ETH_FLOW_TYPE_NONE = 0,
+	RTE_ETH_FLOW_TYPE_RAW,
 	RTE_ETH_FLOW_TYPE_UDPV4,
 	RTE_ETH_FLOW_TYPE_TCPV4,
 	RTE_ETH_FLOW_TYPE_SCTPV4,
@@ -347,6 +348,7 @@ struct rte_eth_fdir_filter {
  */
 enum rte_eth_payload_type {
 	RTE_ETH_PAYLOAD_UNKNOWN = 0,
+	RTE_ETH_RAW_PAYLOAD,
 	RTE_ETH_L2_PAYLOAD,
 	RTE_ETH_L3_PAYLOAD,
 	RTE_ETH_L4_PAYLOAD,
-- 
1.9.3
^ permalink raw reply	[flat|nested] 18+ messages in thread
- * [dpdk-dev] [PATCH 03/15] ixgbe: implement the flexpayload configuration of flow director filter
  2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 01/15] ixgbe: migrate flow director filter operations (add/delete/update) " Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 02/15] ethdev: extend flow type and flexible payload type definition for flow director Jingjing Wu
@ 2015-01-29  5:29 ` Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 04/15] app/test: remove the flexbytes_offset setting in test_link_bonding Jingjing Wu
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Jingjing Wu @ 2015-01-29  5:29 UTC (permalink / raw)
  To: dev
This patch implement the flexpayload configuration of flow director filter.
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 lib/librte_pmd_ixgbe/ixgbe_ethdev.h |   1 +
 lib/librte_pmd_ixgbe/ixgbe_fdir.c   | 114 +++++++++++++++++++++++++++++++++---
 2 files changed, 108 insertions(+), 7 deletions(-)
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
index d92e54a..bea28c5 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
@@ -102,6 +102,7 @@
  * Information about the fdir mode.
  */
 struct ixgbe_hw_fdir_info {
+	uint8_t     flex_bytes_offset;
 	uint16_t    collision;
 	uint16_t    free;
 	uint16_t    maxhash;
diff --git a/lib/librte_pmd_ixgbe/ixgbe_fdir.c b/lib/librte_pmd_ixgbe/ixgbe_fdir.c
index e682d14..ccc9ad3 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_fdir.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_fdir.c
@@ -62,9 +62,15 @@
 #define SIG_BUCKET_64KB_HASH_MASK       0x1FFF  /* 13 bits */
 #define SIG_BUCKET_128KB_HASH_MASK      0x3FFF  /* 14 bits */
 #define SIG_BUCKET_256KB_HASH_MASK      0x7FFF  /* 15 bits */
+#define IXGBE_DEFAULT_FLEXBYTES_OFFSET  12 /* default flexbytes offset in bytes */
+#define IXGBE_MAX_FLX_SOURCE_OFF        62
+#define IXGBE_FDIRCTRL_FLEX_MASK        (0x1F << IXGBE_FDIRCTRL_FLEX_SHIFT)
 #define IXGBE_FDIRCMD_CMD_INTERVAL_US   10
 
+static int ixgbe_set_fdir_flex_conf(struct rte_eth_dev *dev,
+		const struct rte_eth_fdir_flex_conf *conf);
 static int fdir_erase_filter_82599(struct ixgbe_hw *hw, uint32_t fdirhash);
+static int fdir_enable_82599(struct ixgbe_hw *hw, uint32_t fdirctrl);
 static int ixgbe_fdir_filter_to_atr_input(
 		const struct rte_eth_fdir_filter *fdir_filter,
 		union ixgbe_atr_input *input);
@@ -92,7 +98,8 @@ static int ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev,
  *  @hw: pointer to hardware structure
  *  @fdirctrl: value to write to flow director control register
  **/
-static void fdir_enable_82599(struct ixgbe_hw *hw, u32 fdirctrl)
+static int
+fdir_enable_82599(struct ixgbe_hw *hw, uint32_t fdirctrl)
 {
 	int i;
 
@@ -132,16 +139,20 @@ static void fdir_enable_82599(struct ixgbe_hw *hw, u32 fdirctrl)
 		msec_delay(1);
 	}
 
-	if (i >= IXGBE_FDIR_INIT_DONE_POLL)
-		PMD_INIT_LOG(WARNING, "Flow Director poll time exceeded!");
+	if (i >= IXGBE_FDIR_INIT_DONE_POLL) {
+		PMD_INIT_LOG(ERR, "Flow Director poll time exceeded"
+			"during enabling!");
+		return -ETIMEDOUT;
+	}
+	return 0;
 }
 
 /*
  * Set appropriate bits in fdirctrl for: variable reporting levels, moving
  * flexbytes matching field, and drop queue (only for perfect matching mode).
  */
-static int
-configure_fdir_flags(struct rte_fdir_conf *conf, uint32_t *fdirctrl)
+static inline int
+configure_fdir_flags(const struct rte_fdir_conf *conf, uint32_t *fdirctrl)
 {
 	*fdirctrl = 0;
 
@@ -183,13 +194,88 @@ configure_fdir_flags(struct rte_fdir_conf *conf, uint32_t *fdirctrl)
 		return -EINVAL;
 	};
 
-	*fdirctrl |= (conf->flexbytes_offset << IXGBE_FDIRCTRL_FLEX_SHIFT);
+	*fdirctrl |= (IXGBE_DEFAULT_FLEXBYTES_OFFSET / sizeof(uint16_t)) <<
+		     IXGBE_FDIRCTRL_FLEX_SHIFT;
 
 	if (conf->mode == RTE_FDIR_MODE_PERFECT) {
 		*fdirctrl |= IXGBE_FDIRCTRL_PERFECT_MATCH;
 		*fdirctrl |= (conf->drop_queue << IXGBE_FDIRCTRL_DROP_Q_SHIFT);
 	}
+	/*
+	 * Continue setup of fdirctrl register bits:
+	 *  Set the maximum length per hash bucket to 0xA filters
+	 *  Send interrupt when 64 filters are left
+	 */
+	*fdirctrl |= (0xA << IXGBE_FDIRCTRL_MAX_LENGTH_SHIFT) |
+		    (4 << IXGBE_FDIRCTRL_FULL_THRESH_SHIFT);
+
+	return 0;
+}
+
+/*
+ * ixgbe_check_fdir_flex_conf -check if the flex payload and mask configuration
+ * arguments are valid
+ */
+static int
+ixgbe_set_fdir_flex_conf(struct rte_eth_dev *dev,
+		const struct rte_eth_fdir_flex_conf *conf)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ixgbe_hw_fdir_info *info =
+			IXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data->dev_private);
+	const struct rte_eth_flex_payload_cfg *flex_cfg;
+	const struct rte_eth_fdir_flex_mask *flex_mask;
+	uint32_t fdirctrl, fdirm;
+	uint16_t flexbytes = 0;
+	uint16_t i;
+
+	fdirctrl = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL);
+	fdirm = IXGBE_READ_REG(hw, IXGBE_FDIRM);
+
+	if (conf == NULL) {
+		PMD_DRV_LOG(INFO, "NULL pointer.");
+		return -EINVAL;
+	}
 
+	for (i = 0; i < conf->nb_payloads; i++) {
+		flex_cfg = &conf->flex_set[i];
+		if (flex_cfg->type != RTE_ETH_RAW_PAYLOAD) {
+			PMD_DRV_LOG(ERR, "unsupported payload type.");
+			return -EINVAL;
+		}
+		if (((flex_cfg->src_offset[0] & 0x1) == 0) &&
+		    (flex_cfg->src_offset[1] == flex_cfg->src_offset[0] + 1) &&
+		    (flex_cfg->src_offset[0] <= IXGBE_MAX_FLX_SOURCE_OFF)) {
+			fdirctrl &= ~IXGBE_FDIRCTRL_FLEX_MASK;
+			fdirctrl |= (flex_cfg->src_offset[0] / sizeof(uint16_t)) <<
+					IXGBE_FDIRCTRL_FLEX_SHIFT;
+		} else {
+			PMD_DRV_LOG(ERR, "invalid flexbytes arguments.");
+			return -EINVAL;
+		}
+	}
+
+	for (i = 0; i < conf->nb_flexmasks; i++) {
+		flex_mask = &conf->flex_mask[i];
+		if (flex_mask->flow_type != RTE_ETH_FLOW_TYPE_RAW) {
+			PMD_DRV_LOG(ERR, "unsupported flow type.");
+			return -EINVAL;
+		}
+		flexbytes = (uint16_t)(((flex_mask->mask[0] << 8) & 0xFF00) |
+					((flex_mask->mask[1]) & 0xFF));
+		if (flexbytes == UINT16_MAX)
+			fdirm &= ~IXGBE_FDIRM_FLEX;
+		else if (flexbytes != 0) {
+			/* IXGBE_FDIRM_FLEX is set by default when set mask */
+			PMD_DRV_LOG(ERR, " invalid flexbytes mask arguments.");
+			return -EINVAL;
+		}
+	}
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRCTRL, fdirctrl);
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRM, fdirm);
+	info->flex_bytes_offset = (uint8_t)((fdirctrl &
+					    IXGBE_FDIRCTRL_FLEX_MASK) >>
+					    IXGBE_FDIRCTRL_FLEX_SHIFT);
 	return 0;
 }
 
@@ -231,7 +317,19 @@ ixgbe_fdir_configure(struct rte_eth_dev *dev)
 	for (i = 1; i < 8; i++)
 		IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), 0);
 
-	fdir_enable_82599(hw, fdirctrl);
+
+	err = ixgbe_set_fdir_flex_conf(dev,
+		&dev->data->dev_conf.fdir_conf.flex_conf);
+	if (err < 0) {
+		PMD_INIT_LOG(ERR, " Error on setting FD flexible arguments.");
+		return err;
+	}
+
+	err = fdir_enable_82599(hw, fdirctrl);
+	if (err < 0) {
+		PMD_INIT_LOG(ERR, " Error on enabling FD.");
+		return err;
+	}
 	return 0;
 }
 
@@ -336,6 +434,8 @@ fdir_set_input_mask_82599(struct ixgbe_hw *hw,
 	return IXGBE_SUCCESS;
 }
 
+
+
 int
 ixgbe_fdir_set_masks(struct rte_eth_dev *dev, struct rte_fdir_masks *fdir_masks)
 {
-- 
1.9.3
^ permalink raw reply	[flat|nested] 18+ messages in thread
- * [dpdk-dev] [PATCH 04/15] app/test: remove the flexbytes_offset setting in test_link_bonding
  2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
                   ` (2 preceding siblings ...)
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 03/15] ixgbe: implement the flexpayload configuration of flow director filter Jingjing Wu
@ 2015-01-29  5:29 ` Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 05/15] testpmd: remove the flexbytes_offset setting Jingjing Wu
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Jingjing Wu @ 2015-01-29  5:29 UTC (permalink / raw)
  To: dev
This patch removes the flexbytes_offset setting, because the flexible payload
setting is done by flex_conf instead of flexbytes_offset.
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test/test_link_bonding.c | 1 -
 1 file changed, 1 deletion(-)
diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c
index 4523de6..630c047 100644
--- a/app/test/test_link_bonding.c
+++ b/app/test/test_link_bonding.c
@@ -182,7 +182,6 @@ struct rte_fdir_conf fdir_conf = {
 	.mode = RTE_FDIR_MODE_NONE,
 	.pballoc = RTE_FDIR_PBALLOC_64K,
 	.status = RTE_FDIR_REPORT_STATUS,
-	.flexbytes_offset = 0x6,
 	.drop_queue = 127,
 };
 
-- 
1.9.3
^ permalink raw reply	[flat|nested] 18+ messages in thread
- * [dpdk-dev] [PATCH 05/15] testpmd: remove the flexbytes_offset setting
  2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
                   ` (3 preceding siblings ...)
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 04/15] app/test: remove the flexbytes_offset setting in test_link_bonding Jingjing Wu
@ 2015-01-29  5:29 ` Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 06/15] ethdev: remove flexbytes_offset from rte_fdir_conf Jingjing Wu
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Jingjing Wu @ 2015-01-29  5:29 UTC (permalink / raw)
  To: dev
This patch removes the flexbytes_offset setting, because the flexible payload
setting is done by flex_conf instead of flexbytes_offset.
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/parameters.c | 16 ----------------
 app/test-pmd/testpmd.c    |  1 -
 2 files changed, 17 deletions(-)
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index adf3203..db124db 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -145,10 +145,6 @@ usage(char* progname)
 	       "(N: none  or match (default) or always).\n");
 	printf("  --pkt-filter-size=N: set Flow Director mode "
 	       "(N: 64K (default mode) or 128K or 256K).\n");
-	printf("  --pkt-filter-flexbytes-offset=N: set flexbytes-offset. "
-	       "The offset is defined in word units counted from the "
-	       "first byte of the destination Ethernet MAC address. "
-	       "0 <= N <= 32.\n");
 	printf("  --pkt-filter-drop-queue=N: set drop-queue. "
 	       "In perfect mode, when you add a rule with queue = -1 "
 	       "the packet will be enqueued into the rx drop-queue. "
@@ -523,7 +519,6 @@ launch_args_parse(int argc, char** argv)
 		{ "pkt-filter-mode",            1, 0, 0 },
 		{ "pkt-filter-report-hash",     1, 0, 0 },
 		{ "pkt-filter-size",            1, 0, 0 },
-		{ "pkt-filter-flexbytes-offset",1, 0, 0 },
 		{ "pkt-filter-drop-queue",      1, 0, 0 },
 		{ "crc-strip",                  0, 0, 0 },
 		{ "enable-rx-cksum",            0, 0, 0 },
@@ -747,17 +742,6 @@ launch_args_parse(int argc, char** argv)
 						 optarg);
 			}
 			if (!strcmp(lgopts[opt_idx].name,
-				    "pkt-filter-flexbytes-offset")) {
-				n = atoi(optarg);
-				if ( n >= 0 && n <= (int) 32)
-					fdir_conf.flexbytes_offset =
-						(uint8_t) n;
-				else
-					rte_exit(EXIT_FAILURE,
-						 "flexbytes %d invalid - must"
-						 "be  >= 0 && <= 32\n", n);
-			}
-			if (!strcmp(lgopts[opt_idx].name,
 				    "pkt-filter-drop-queue")) {
 				n = atoi(optarg);
 				if (n >= 0)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 773b8af..2773c10 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -298,7 +298,6 @@ struct rte_fdir_conf fdir_conf = {
 	.mode = RTE_FDIR_MODE_NONE,
 	.pballoc = RTE_FDIR_PBALLOC_64K,
 	.status = RTE_FDIR_REPORT_STATUS,
-	.flexbytes_offset = 0x6,
 	.drop_queue = 127,
 };
 
-- 
1.9.3
^ permalink raw reply	[flat|nested] 18+ messages in thread
- * [dpdk-dev] [PATCH 06/15] ethdev: remove flexbytes_offset from rte_fdir_conf
  2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
                   ` (4 preceding siblings ...)
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 05/15] testpmd: remove the flexbytes_offset setting Jingjing Wu
@ 2015-01-29  5:29 ` Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 07/15] ethdev: structures definition for flow director masks Jingjing Wu
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Jingjing Wu @ 2015-01-29  5:29 UTC (permalink / raw)
  To: dev
This patch removes the flexbytes_offset from rte_fdir_conf, because
the flexible payload setting is done by flex_conf instead of flexbytes_offset.
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 lib/librte_ether/rte_ethdev.h | 2 --
 1 file changed, 2 deletions(-)
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 1200c1c..cbe05b1 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -718,8 +718,6 @@ struct rte_fdir_conf {
 	enum rte_fdir_mode mode; /**< Flow Director mode. */
 	enum rte_fdir_pballoc_type pballoc; /**< Space for FDIR filters. */
 	enum rte_fdir_status_mode status;  /**< How to report FDIR hash. */
-	/** Offset of flexbytes field in RX packets (in 16-bit word units). */
-	uint8_t flexbytes_offset;
 	/** RX queue of packets matching a "drop" filter in perfect mode. */
 	uint8_t drop_queue;
 	struct rte_eth_fdir_flex_conf flex_conf;
-- 
1.9.3
^ permalink raw reply	[flat|nested] 18+ messages in thread
- * [dpdk-dev] [PATCH 07/15] ethdev: structures definition for flow director masks
  2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
                   ` (5 preceding siblings ...)
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 06/15] ethdev: remove flexbytes_offset from rte_fdir_conf Jingjing Wu
@ 2015-01-29  5:29 ` Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 08/15] ixgbe: implement the mask configuration of flow director filter Jingjing Wu
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Jingjing Wu @ 2015-01-29  5:29 UTC (permalink / raw)
  To: dev
This patch defines structure rte_eth_fdir_masks.
It extends rte_fdir_conf and rte_eth_fdir_info to contain mask's configuration.
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 lib/librte_ether/rte_eth_ctrl.h | 13 +++++++++++++
 lib/librte_ether/rte_ethdev.h   |  1 +
 2 files changed, 14 insertions(+)
diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index 74403b7..a5db310 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -344,6 +344,18 @@ struct rte_eth_fdir_filter {
 };
 
 /**
+ *  A structure used to configure FDIR masks that are used by the device
+ *  to match the various fields of RX packet headers.
+ */
+struct rte_eth_fdir_masks {
+	uint16_t vlan_tci_mask;
+	struct rte_eth_ipv4_flow   ipv4_mask;
+	struct rte_eth_ipv6_flow   ipv6_mask;
+	uint16_t src_port_mask;
+	uint16_t dst_port_mask;
+};
+
+/**
  * Payload type
  */
 enum rte_eth_payload_type {
@@ -409,6 +421,7 @@ enum rte_fdir_mode {
  */
 struct rte_eth_fdir_info {
 	enum rte_fdir_mode mode;     /**< Flow director mode */
+	struct rte_eth_fdir_masks mask;
 	struct rte_eth_fdir_flex_conf flex_conf;
 	/**< Flex payload configuration information */
 	uint32_t guarant_spc;          /**< Guaranteed spaces.*/
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index cbe05b1..6c8ad08 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -720,6 +720,7 @@ struct rte_fdir_conf {
 	enum rte_fdir_status_mode status;  /**< How to report FDIR hash. */
 	/** RX queue of packets matching a "drop" filter in perfect mode. */
 	uint8_t drop_queue;
+	struct rte_eth_fdir_masks mask;
 	struct rte_eth_fdir_flex_conf flex_conf;
 	/**< Flex payload configuration. */
 };
-- 
1.9.3
^ permalink raw reply	[flat|nested] 18+ messages in thread
- * [dpdk-dev] [PATCH 08/15] ixgbe: implement the mask configuration of flow director filter
  2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
                   ` (6 preceding siblings ...)
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 07/15] ethdev: structures definition for flow director masks Jingjing Wu
@ 2015-01-29  5:29 ` Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 09/15] ixgbe: implement the get info and statistic operations of flow director Jingjing Wu
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Jingjing Wu @ 2015-01-29  5:29 UTC (permalink / raw)
  To: dev
This patch implement the mask configuration of flow director filter,
by using the mask defined in rte_fdir_conf instead of callback function
fdir_set_masks.
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c |   1 -
 lib/librte_pmd_ixgbe/ixgbe_ethdev.h |  16 +-
 lib/librte_pmd_ixgbe/ixgbe_fdir.c   | 282 +++++++++++++++++++-----------------
 3 files changed, 165 insertions(+), 134 deletions(-)
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index c3a76e6..8bc7009 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -361,7 +361,6 @@ static struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.set_queue_rate_limit = ixgbe_set_queue_rate_limit,
 	.set_vf_rate_limit    = ixgbe_set_vf_rate_limit,
 	.fdir_infos_get               = ixgbe_fdir_info_get,
-	.fdir_set_masks               = ixgbe_fdir_set_masks,
 	.reta_update          = ixgbe_dev_rss_reta_update,
 	.reta_query           = ixgbe_dev_rss_reta_query,
 #ifdef RTE_NIC_BYPASS
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
index bea28c5..7961167 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
@@ -101,7 +101,20 @@
 /*
  * Information about the fdir mode.
  */
+
+struct ixgbe_hw_fdir_mask {
+	uint16_t vlan_tci_mask;
+	uint32_t src_ipv4_mask;
+	uint32_t dst_ipv4_mask;
+	uint16_t src_ipv6_mask;
+	uint16_t dst_ipv6_mask;
+	uint16_t src_port_mask;
+	uint16_t dst_port_mask;
+	uint16_t flex_bytes_mask;
+};
+
 struct ixgbe_hw_fdir_info {
+	struct ixgbe_hw_fdir_mask mask;
 	uint8_t     flex_bytes_offset;
 	uint16_t    collision;
 	uint16_t    free;
@@ -313,9 +326,6 @@ int ixgbe_fdir_configure(struct rte_eth_dev *dev);
 void ixgbe_fdir_info_get(struct rte_eth_dev *dev,
 		struct rte_eth_fdir *fdir);
 
-int ixgbe_fdir_set_masks(struct rte_eth_dev *dev,
-		struct rte_fdir_masks *fdir_masks);
-
 void ixgbe_configure_dcb(struct rte_eth_dev *dev);
 
 /*
diff --git a/lib/librte_pmd_ixgbe/ixgbe_fdir.c b/lib/librte_pmd_ixgbe/ixgbe_fdir.c
index ccc9ad3..16b0ba8 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_fdir.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_fdir.c
@@ -63,13 +63,53 @@
 #define SIG_BUCKET_128KB_HASH_MASK      0x3FFF  /* 14 bits */
 #define SIG_BUCKET_256KB_HASH_MASK      0x7FFF  /* 15 bits */
 #define IXGBE_DEFAULT_FLEXBYTES_OFFSET  12 /* default flexbytes offset in bytes */
+#define IXGBE_FDIR_MAX_FLEX_LEN         2 /* len in bytes of flexbytes */
 #define IXGBE_MAX_FLX_SOURCE_OFF        62
 #define IXGBE_FDIRCTRL_FLEX_MASK        (0x1F << IXGBE_FDIRCTRL_FLEX_SHIFT)
 #define IXGBE_FDIRCMD_CMD_INTERVAL_US   10
 
+#define IXGBE_FDIR_FLOW_TYPES ( \
+	(1 << RTE_ETH_FLOW_TYPE_UDPV4) | \
+	(1 << RTE_ETH_FLOW_TYPE_TCPV4) | \
+	(1 << RTE_ETH_FLOW_TYPE_SCTPV4) | \
+	(1 << RTE_ETH_FLOW_TYPE_IPV4_OTHER) | \
+	(1 << RTE_ETH_FLOW_TYPE_UDPV6) | \
+	(1 << RTE_ETH_FLOW_TYPE_TCPV6) | \
+	(1 << RTE_ETH_FLOW_TYPE_SCTPV6) | \
+	(1 << RTE_ETH_FLOW_TYPE_IPV6_OTHER))
+
+#define IPV6_ADDR_TO_MASK(ipaddr, ipv6m) do { \
+	uint8_t ipv6_addr[16]; \
+	uint8_t i; \
+	rte_memcpy(ipv6_addr, (ipaddr), sizeof(ipv6_addr));\
+	(ipv6m) = 0; \
+	for (i = 0; i < sizeof(ipv6_addr); i++) { \
+		if (ipv6_addr[i] == UINT8_MAX) \
+			(ipv6m) |= 1 << i; \
+		else if (ipv6_addr[i] != 0) { \
+			PMD_DRV_LOG(ERR, " invalid IPv6 address mask."); \
+			return -EINVAL; \
+		} \
+	} \
+} while (0)
+
+#define IPV6_MASK_TO_ADDR(ipv6m, ipaddr) do { \
+	uint8_t ipv6_addr[16]; \
+	uint8_t i; \
+	for (i = 0; i < sizeof(ipv6_addr); i++) { \
+		if ((ipv6m) & (1 << i)) \
+			ipv6_addr[i] = UINT8_MAX; \
+		else \
+			ipv6_addr[i] = 0; \
+	} \
+	rte_memcpy((ipaddr), ipv6_addr, sizeof(ipv6_addr));\
+} while (0)
+
+static int fdir_erase_filter_82599(struct ixgbe_hw *hw, uint32_t fdirhash);
+static int fdir_set_input_mask_82599(struct rte_eth_dev *dev,
+		const struct rte_eth_fdir_masks *input_mask);
 static int ixgbe_set_fdir_flex_conf(struct rte_eth_dev *dev,
 		const struct rte_eth_fdir_flex_conf *conf);
-static int fdir_erase_filter_82599(struct ixgbe_hw *hw, uint32_t fdirhash);
 static int fdir_enable_82599(struct ixgbe_hw *hw, uint32_t fdirctrl);
 static int ixgbe_fdir_filter_to_atr_input(
 		const struct rte_eth_fdir_filter *fdir_filter,
@@ -212,6 +252,111 @@ configure_fdir_flags(const struct rte_fdir_conf *conf, uint32_t *fdirctrl)
 	return 0;
 }
 
+/**
+ * Reverse the bits in FDIR registers that store 2 x 16 bit masks.
+ *
+ *  @hi_dword: Bits 31:16 mask to be bit swapped.
+ *  @lo_dword: Bits 15:0  mask to be bit swapped.
+ *
+ *  Flow director uses several registers to store 2 x 16 bit masks with the
+ *  bits reversed such as FDIRTCPM, FDIRUDPM. The LS bit of the
+ *  mask affects the MS bit/byte of the target. This function reverses the
+ *  bits in these masks.
+ *  **/
+static inline uint32_t
+reverse_fdir_bitmasks(uint16_t hi_dword, uint16_t lo_dword)
+{
+	uint32_t mask = hi_dword << 16;
+	mask |= lo_dword;
+	mask = ((mask & 0x55555555) << 1) | ((mask & 0xAAAAAAAA) >> 1);
+	mask = ((mask & 0x33333333) << 2) | ((mask & 0xCCCCCCCC) >> 2);
+	mask = ((mask & 0x0F0F0F0F) << 4) | ((mask & 0xF0F0F0F0) >> 4);
+	return ((mask & 0x00FF00FF) << 8) | ((mask & 0xFF00FF00) >> 8);
+}
+
+/*
+ * This is based on ixgbe_fdir_set_input_mask_82599() in ixgbe/ixgbe_82599.c,
+ * but makes use of the rte_fdir_masks structure to see which bits to set.
+ */
+static int
+fdir_set_input_mask_82599(struct rte_eth_dev *dev,
+		const struct rte_eth_fdir_masks *input_mask)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ixgbe_hw_fdir_info *info =
+			IXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data->dev_private);
+	/*
+	 * mask VM pool and DIPv6 since there are currently not supported
+	 * mask FLEX byte, it will be set in flex_conf
+	 */
+	uint32_t fdirm = IXGBE_FDIRM_POOL | IXGBE_FDIRM_DIPv6 | IXGBE_FDIRM_FLEX;
+	uint32_t fdirtcpm;  /* TCP source and destination port masks. */
+	uint32_t fdiripv6m; /* IPv6 source and destination masks. */
+	uint16_t dst_ipv6m = 0;
+	uint16_t src_ipv6m = 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	/*
+	 * Program the relevant mask registers.  If src/dst_port or src/dst_addr
+	 * are zero, then assume a full mask for that field. Also assume that
+	 * a VLAN of 0 is unspecified, so mask that out as well.  L4type
+	 * cannot be masked out in this implementation.
+	 */
+	if (input_mask->dst_port_mask == 0 && input_mask->src_port_mask == 0)
+		/* use the L4 protocol mask for raw IPv4/IPv6 traffic */
+		fdirm |= IXGBE_FDIRM_L4P;
+
+	if (input_mask->vlan_tci_mask == 0x0FFF)
+		/* mask VLAN Priority */
+		fdirm |= IXGBE_FDIRM_VLANP;
+	else if (input_mask->vlan_tci_mask == 0xE000)
+		/* mask VLAN ID */
+		fdirm |= IXGBE_FDIRM_VLANID;
+	else if (input_mask->vlan_tci_mask == 0)
+		/* mask VLAN ID and Priority */
+		fdirm |= IXGBE_FDIRM_VLANID | IXGBE_FDIRM_VLANP;
+	else if (input_mask->vlan_tci_mask != 0xEFFF) {
+		PMD_INIT_LOG(ERR, "invalid vlan_tci_mask");
+		return -EINVAL;
+	}
+	info->mask.vlan_tci_mask = input_mask->vlan_tci_mask;
+
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRM, fdirm);
+
+	/* store the TCP/UDP port masks, bit reversed from port layout */
+	fdirtcpm = reverse_fdir_bitmasks(input_mask->dst_port_mask,
+					 input_mask->src_port_mask);
+
+	/* write both the same so that UDP and TCP use the same mask */
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRTCPM, ~fdirtcpm);
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRUDPM, ~fdirtcpm);
+	info->mask.src_port_mask = input_mask->src_port_mask;
+	info->mask.dst_port_mask = input_mask->dst_port_mask;
+
+	/* Store source and destination IPv4 masks (big-endian) */
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRSIP4M, ~(input_mask->ipv4_mask.src_ip));
+	IXGBE_WRITE_REG(hw, IXGBE_FDIRDIP4M, ~(input_mask->ipv4_mask.dst_ip));
+	info->mask.src_ipv4_mask = input_mask->ipv4_mask.src_ip;
+	info->mask.dst_ipv4_mask = input_mask->ipv4_mask.dst_ip;
+
+	if (dev->data->dev_conf.fdir_conf.mode == RTE_FDIR_MODE_SIGNATURE) {
+		/*
+		 * IPv6 mask is only meaningful in signature mode
+		 * Store source and destination IPv6 masks (bit reversed)
+		 */
+		IPV6_ADDR_TO_MASK(input_mask->ipv6_mask.src_ip, src_ipv6m);
+		IPV6_ADDR_TO_MASK(input_mask->ipv6_mask.dst_ip, dst_ipv6m);
+		fdiripv6m = (dst_ipv6m << 16) | src_ipv6m;
+
+		IXGBE_WRITE_REG(hw, IXGBE_FDIRIP6M, ~fdiripv6m);
+		info->mask.src_ipv6_mask = src_ipv6m;
+		info->mask.dst_ipv6_mask = dst_ipv6m;
+	}
+
+	return IXGBE_SUCCESS;
+}
+
 /*
  * ixgbe_check_fdir_flex_conf -check if the flex payload and mask configuration
  * arguments are valid
@@ -273,6 +418,7 @@ ixgbe_set_fdir_flex_conf(struct rte_eth_dev *dev,
 	}
 	IXGBE_WRITE_REG(hw, IXGBE_FDIRCTRL, fdirctrl);
 	IXGBE_WRITE_REG(hw, IXGBE_FDIRM, fdirm);
+	info->mask.flex_bytes_mask = flexbytes ? UINT16_MAX : 0;
 	info->flex_bytes_offset = (uint8_t)((fdirctrl &
 					    IXGBE_FDIRCTRL_FLEX_MASK) >>
 					    IXGBE_FDIRCTRL_FLEX_SHIFT);
@@ -317,7 +463,11 @@ ixgbe_fdir_configure(struct rte_eth_dev *dev)
 	for (i = 1; i < 8; i++)
 		IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), 0);
 
-
+	err = fdir_set_input_mask_82599(dev, &dev->data->dev_conf.fdir_conf.mask);
+	if (err < 0) {
+		PMD_INIT_LOG(ERR, " Error on setting FD mask");
+		return err;
+	}
 	err = ixgbe_set_fdir_flex_conf(dev,
 		&dev->data->dev_conf.fdir_conf.flex_conf);
 	if (err < 0) {
@@ -333,134 +483,6 @@ ixgbe_fdir_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
-/**
- * Reverse the bits in FDIR registers that store 2 x 16 bit masks.
- *
- *  @hi_dword: Bits 31:16 mask to be bit swapped.
- *  @lo_dword: Bits 15:0  mask to be bit swapped.
- *
- *  Flow director uses several registers to store 2 x 16 bit masks with the
- *  bits reversed such as FDIRTCPM, FDIRUDPM and FDIRIP6M. The LS bit of the
- *  mask affects the MS bit/byte of the target. This function reverses the
- *  bits in these masks.
- *  **/
-static uint32_t
-reverse_fdir_bitmasks(uint16_t hi_dword, uint16_t lo_dword)
-{
-	u32 mask = hi_dword << 16;
-	mask |= lo_dword;
-	mask = ((mask & 0x55555555) << 1) | ((mask & 0xAAAAAAAA) >> 1);
-	mask = ((mask & 0x33333333) << 2) | ((mask & 0xCCCCCCCC) >> 2);
-	mask = ((mask & 0x0F0F0F0F) << 4) | ((mask & 0xF0F0F0F0) >> 4);
-	return ((mask & 0x00FF00FF) << 8) | ((mask & 0xFF00FF00) >> 8);
-}
-
-/*
- * This macro exists in ixgbe/ixgbe_82599.c, however in that file it reverses
- * the bytes, and then reverses them again. So here it does nothing.
- */
-#define IXGBE_WRITE_REG_BE32 IXGBE_WRITE_REG
-
-/*
- * This is based on ixgbe_fdir_set_input_mask_82599() in ixgbe/ixgbe_82599.c,
- * but makes use of the rte_fdir_masks structure to see which bits to set.
- */
-static int
-fdir_set_input_mask_82599(struct ixgbe_hw *hw,
-		struct rte_fdir_masks *input_mask)
-{
-	/* mask VM pool since it is currently not supported */
-	u32 fdirm = IXGBE_FDIRM_POOL;
-	u32 fdirtcpm;  /* TCP source and destination port masks. */
-	u32 fdiripv6m; /* IPv6 source and destination masks. */
-
-	PMD_INIT_FUNC_TRACE();
-
-	/*
-	 * Program the relevant mask registers.  If src/dst_port or src/dst_addr
-	 * are zero, then assume a full mask for that field. Also assume that
-	 * a VLAN of 0 is unspecified, so mask that out as well.  L4type
-	 * cannot be masked out in this implementation.
-	 */
-	if (input_mask->only_ip_flow) {
-		/* use the L4 protocol mask for raw IPv4/IPv6 traffic */
-		fdirm |= IXGBE_FDIRM_L4P;
-		if (input_mask->dst_port_mask || input_mask->src_port_mask) {
-			PMD_INIT_LOG(ERR, " Error on src/dst port mask");
-			return -EINVAL;
-		}
-	}
-
-	if (!input_mask->comp_ipv6_dst)
-		/* mask DIPV6 */
-		fdirm |= IXGBE_FDIRM_DIPv6;
-
-	if (!input_mask->vlan_id)
-		/* mask VLAN ID*/
-		fdirm |= IXGBE_FDIRM_VLANID;
-
-	if (!input_mask->vlan_prio)
-		/* mask VLAN priority */
-		fdirm |= IXGBE_FDIRM_VLANP;
-
-	if (!input_mask->flexbytes)
-		/* Mask Flex Bytes */
-		fdirm |= IXGBE_FDIRM_FLEX;
-
-	IXGBE_WRITE_REG(hw, IXGBE_FDIRM, fdirm);
-
-	/* store the TCP/UDP port masks, bit reversed from port layout */
-	fdirtcpm = reverse_fdir_bitmasks(input_mask->dst_port_mask,
-					 input_mask->src_port_mask);
-
-	/* write both the same so that UDP and TCP use the same mask */
-	IXGBE_WRITE_REG(hw, IXGBE_FDIRTCPM, ~fdirtcpm);
-	IXGBE_WRITE_REG(hw, IXGBE_FDIRUDPM, ~fdirtcpm);
-
-	if (!input_mask->set_ipv6_mask) {
-		/* Store source and destination IPv4 masks (big-endian) */
-		IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIP4M,
-				IXGBE_NTOHL(~input_mask->src_ipv4_mask));
-		IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRDIP4M,
-				IXGBE_NTOHL(~input_mask->dst_ipv4_mask));
-	} else {
-		/* Store source and destination IPv6 masks (bit reversed) */
-		fdiripv6m = reverse_fdir_bitmasks(input_mask->dst_ipv6_mask,
-						  input_mask->src_ipv6_mask);
-
-		IXGBE_WRITE_REG(hw, IXGBE_FDIRIP6M, ~fdiripv6m);
-	}
-
-	return IXGBE_SUCCESS;
-}
-
-
-
-int
-ixgbe_fdir_set_masks(struct rte_eth_dev *dev, struct rte_fdir_masks *fdir_masks)
-{
-	struct ixgbe_hw *hw;
-	int err;
-
-	PMD_INIT_FUNC_TRACE();
-
-	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-
-	if (hw->mac.type != ixgbe_mac_82599EB &&
-		hw->mac.type != ixgbe_mac_X540 &&
-		hw->mac.type != ixgbe_mac_X550 &&
-		hw->mac.type != ixgbe_mac_X550EM_x)
-		return -ENOSYS;
-
-	err = ixgbe_reinit_fdir_tables_82599(hw);
-	if (err) {
-		PMD_INIT_LOG(ERR, "reinit of fdir tables failed");
-		return -EIO;
-	}
-
-	return fdir_set_input_mask_82599(hw, fdir_masks);
-}
-
 /*
  * Convert DPDK rte_eth_fdir_filter struct to ixgbe_atr_input union that is used
  * by the IXGBE driver code.
-- 
1.9.3
^ permalink raw reply	[flat|nested] 18+ messages in thread
- * [dpdk-dev] [PATCH 09/15] ixgbe: implement the get info and statistic operations of flow director
  2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
                   ` (7 preceding siblings ...)
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 08/15] ixgbe: implement the mask configuration of flow director filter Jingjing Wu
@ 2015-01-29  5:29 ` Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 10/15] ixgbe: implement the flush operation " Jingjing Wu
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Jingjing Wu @ 2015-01-29  5:29 UTC (permalink / raw)
  To: dev
This patch changes the get info operation to be implemented through
filter_ctrl API and RTE_ETH_FILTER_INFO/RTE_ETH_FILTER_STATS ops.
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c |  1 -
 lib/librte_pmd_ixgbe/ixgbe_ethdev.h |  3 --
 lib/librte_pmd_ixgbe/ixgbe_fdir.c   | 94 ++++++++++++++++++++++++++++++-------
 3 files changed, 78 insertions(+), 20 deletions(-)
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index 8bc7009..a2cdef7 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -360,7 +360,6 @@ static struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.set_vf_vlan_filter   = ixgbe_set_pool_vlan_filter,
 	.set_queue_rate_limit = ixgbe_set_queue_rate_limit,
 	.set_vf_rate_limit    = ixgbe_set_vf_rate_limit,
-	.fdir_infos_get               = ixgbe_fdir_info_get,
 	.reta_update          = ixgbe_dev_rss_reta_update,
 	.reta_query           = ixgbe_dev_rss_reta_query,
 #ifdef RTE_NIC_BYPASS
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
index 7961167..e985199 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
@@ -323,9 +323,6 @@ int ixgbe_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
  */
 int ixgbe_fdir_configure(struct rte_eth_dev *dev);
 
-void ixgbe_fdir_info_get(struct rte_eth_dev *dev,
-		struct rte_eth_fdir *fdir);
-
 void ixgbe_configure_dcb(struct rte_eth_dev *dev);
 
 /*
diff --git a/lib/librte_pmd_ixgbe/ixgbe_fdir.c b/lib/librte_pmd_ixgbe/ixgbe_fdir.c
index 16b0ba8..40ab342 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_fdir.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_fdir.c
@@ -130,6 +130,11 @@ static int ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev,
 			      const struct rte_eth_fdir_filter *fdir_filter,
 			      bool del,
 			      bool update);
+static void ixgbe_fdir_info_get(struct rte_eth_dev *dev,
+			struct rte_eth_fdir_info *fdir_info);
+static void ixgbe_fdir_stats_get(struct rte_eth_dev *dev,
+			struct rte_eth_fdir_stats *fdir_stats);
+
 /**
  * This function is based on ixgbe_fdir_enable_82599() in ixgbe/ixgbe_82599.c.
  * It adds extra configuration of fdirctrl that is common for all filter types.
@@ -959,19 +964,61 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev,
 	return err;
 }
 
-void
-ixgbe_fdir_info_get(struct rte_eth_dev *dev, struct rte_eth_fdir *fdir)
+#define FDIRENTRIES_NUM_SHIFT 10
+static void
+ixgbe_fdir_info_get(struct rte_eth_dev *dev, struct rte_eth_fdir_info *fdir_info)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 	struct ixgbe_hw_fdir_info *info =
 			IXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data->dev_private);
-	uint32_t reg;
+	uint32_t fdirctrl, max_num;
+	uint8_t offset;
 
-	if (hw->mac.type != ixgbe_mac_82599EB &&
-		hw->mac.type != ixgbe_mac_X540 &&
-		hw->mac.type != ixgbe_mac_X550 &&
-		hw->mac.type != ixgbe_mac_X550EM_x)
-		return;
+	fdirctrl = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL);
+	offset = ((fdirctrl & IXGBE_FDIRCTRL_FLEX_MASK) >>
+			IXGBE_FDIRCTRL_FLEX_SHIFT) * sizeof(uint16_t);
+
+	fdir_info->mode = dev->data->dev_conf.fdir_conf.mode;
+	max_num = (1 << (FDIRENTRIES_NUM_SHIFT +
+			(fdirctrl & FDIRCTRL_PBALLOC_MASK)));
+	if (fdir_info->mode == RTE_FDIR_MODE_PERFECT)
+		fdir_info->guarant_spc = max_num;
+	else if (fdir_info->mode == RTE_FDIR_MODE_SIGNATURE)
+		fdir_info->guarant_spc = max_num * 4;
+
+	fdir_info->mask.vlan_tci_mask = info->mask.vlan_tci_mask;
+	fdir_info->mask.ipv4_mask.src_ip = info->mask.src_ipv4_mask;
+	fdir_info->mask.ipv4_mask.dst_ip = info->mask.dst_ipv4_mask;
+	IPV6_MASK_TO_ADDR(info->mask.src_ipv6_mask,
+			fdir_info->mask.ipv6_mask.src_ip);
+	IPV6_MASK_TO_ADDR(info->mask.dst_ipv6_mask,
+			fdir_info->mask.ipv6_mask.dst_ip);
+	fdir_info->mask.src_port_mask = info->mask.src_port_mask;
+	fdir_info->mask.dst_port_mask = info->mask.dst_port_mask;
+	fdir_info->max_flexpayload = IXGBE_FDIR_MAX_FLEX_LEN;
+	fdir_info->flow_types_mask[0] = IXGBE_FDIR_FLOW_TYPES;
+	fdir_info->flex_payload_unit = sizeof(uint16_t);
+	fdir_info->max_flex_payload_segment_num = 1;
+	fdir_info->flex_payload_limit = 62;
+	fdir_info->flex_conf.nb_payloads = 1;
+	fdir_info->flex_conf.flex_set[0].type = RTE_ETH_RAW_PAYLOAD;
+	fdir_info->flex_conf.flex_set[0].src_offset[0] = offset;
+	fdir_info->flex_conf.flex_set[0].src_offset[1] = offset + 1;
+	fdir_info->flex_conf.nb_flexmasks = 1;
+	fdir_info->flex_conf.flex_mask[0].flow_type = RTE_ETH_FLOW_TYPE_RAW;
+	fdir_info->flex_conf.flex_mask[0].mask[0] =
+			(uint8_t)(info->mask.flex_bytes_mask & 0x00FF);
+	fdir_info->flex_conf.flex_mask[0].mask[1] =
+			(uint8_t)((info->mask.flex_bytes_mask & 0xFF00) >> 8);
+}
+
+static void
+ixgbe_fdir_stats_get(struct rte_eth_dev *dev, struct rte_eth_fdir_stats *fdir_stats)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ixgbe_hw_fdir_info *info =
+			IXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data->dev_private);
+	uint32_t reg, max_num;
 
 	/* Get the information from registers */
 	reg = IXGBE_READ_REG(hw, IXGBE_FDIRFREE);
@@ -999,14 +1046,23 @@ ixgbe_fdir_info_get(struct rte_eth_dev *dev, struct rte_eth_fdir *fdir)
 		IXGBE_FDIRFSTAT_FADD_SHIFT;
 
 	/*  Copy the new information in the fdir parameter */
-	fdir->collision = info->collision;
-	fdir->free = info->free;
-	fdir->maxhash = info->maxhash;
-	fdir->maxlen = info->maxlen;
-	fdir->remove = info->remove;
-	fdir->add = info->add;
-	fdir->f_remove = info->f_remove;
-	fdir->f_add = info->f_add;
+	fdir_stats->collision = info->collision;
+	fdir_stats->free = info->free;
+	fdir_stats->maxhash = info->maxhash;
+	fdir_stats->maxlen = info->maxlen;
+	fdir_stats->remove = info->remove;
+	fdir_stats->add = info->add;
+	fdir_stats->f_remove = info->f_remove;
+	fdir_stats->f_add = info->f_add;
+
+	reg = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL);
+	max_num = (1 << (FDIRENTRIES_NUM_SHIFT +
+			(reg & FDIRCTRL_PBALLOC_MASK)));
+	if (dev->data->dev_conf.fdir_conf.mode == RTE_FDIR_MODE_PERFECT)
+			fdir_stats->guarant_cnt = max_num - fdir_stats->free;
+	else if (dev->data->dev_conf.fdir_conf.mode == RTE_FDIR_MODE_SIGNATURE)
+		fdir_stats->guarant_cnt = max_num * 4 - fdir_stats->free;
+
 }
 
 /*
@@ -1047,6 +1103,12 @@ ixgbe_fdir_ctrl_func(struct rte_eth_dev *dev,
 		ret = ixgbe_add_del_fdir_filter(dev,
 			(struct rte_eth_fdir_filter *)arg, TRUE, FALSE);
 		break;
+	case RTE_ETH_FILTER_INFO:
+		ixgbe_fdir_info_get(dev, (struct rte_eth_fdir_info *)arg);
+		break;
+	case RTE_ETH_FILTER_STATS:
+		ixgbe_fdir_stats_get(dev, (struct rte_eth_fdir_stats *)arg);
+		break;
 	default:
 		PMD_DRV_LOG(ERR, "unknown operation %u", filter_op);
 		ret = -EINVAL;
-- 
1.9.3
^ permalink raw reply	[flat|nested] 18+ messages in thread
- * [dpdk-dev] [PATCH 10/15] ixgbe: implement the flush operation of flow director
  2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
                   ` (8 preceding siblings ...)
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 09/15] ixgbe: implement the get info and statistic operations of flow director Jingjing Wu
@ 2015-01-29  5:29 ` Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 11/15] testpmd: add and update commands for " Jingjing Wu
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Jingjing Wu @ 2015-01-29  5:29 UTC (permalink / raw)
  To: dev
This patch implement RTE_ETH_FILTER_FLUSH operation to delete all
flow director filters in ixgbe driver.
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 lib/librte_pmd_ixgbe/ixgbe_fdir.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
diff --git a/lib/librte_pmd_ixgbe/ixgbe_fdir.c b/lib/librte_pmd_ixgbe/ixgbe_fdir.c
index 40ab342..4f843bb 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_fdir.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_fdir.c
@@ -130,6 +130,7 @@ static int ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev,
 			      const struct rte_eth_fdir_filter *fdir_filter,
 			      bool del,
 			      bool update);
+static int ixgbe_fdir_flush(struct rte_eth_dev *dev);
 static void ixgbe_fdir_info_get(struct rte_eth_dev *dev,
 			struct rte_eth_fdir_info *fdir_info);
 static void ixgbe_fdir_stats_get(struct rte_eth_dev *dev,
@@ -964,6 +965,28 @@ ixgbe_add_del_fdir_filter(struct rte_eth_dev *dev,
 	return err;
 }
 
+static int
+ixgbe_fdir_flush(struct rte_eth_dev *dev)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ixgbe_hw_fdir_info *info =
+			IXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data->dev_private);
+	int ret;
+
+	ret = ixgbe_reinit_fdir_tables_82599(hw);
+	if (ret < 0) {
+		PMD_INIT_LOG(ERR, "Failed to re-initialize FD table.");
+		return ret;
+	}
+
+	info->f_add = 0;
+	info->f_remove = 0;
+	info->add = 0;
+	info->remove = 0;
+
+	return ret;
+}
+
 #define FDIRENTRIES_NUM_SHIFT 10
 static void
 ixgbe_fdir_info_get(struct rte_eth_dev *dev, struct rte_eth_fdir_info *fdir_info)
@@ -1103,6 +1126,9 @@ ixgbe_fdir_ctrl_func(struct rte_eth_dev *dev,
 		ret = ixgbe_add_del_fdir_filter(dev,
 			(struct rte_eth_fdir_filter *)arg, TRUE, FALSE);
 		break;
+	case RTE_ETH_FILTER_FLUSH:
+		ret = ixgbe_fdir_flush(dev);
+		break;
 	case RTE_ETH_FILTER_INFO:
 		ixgbe_fdir_info_get(dev, (struct rte_eth_fdir_info *)arg);
 		break;
-- 
1.9.3
^ permalink raw reply	[flat|nested] 18+ messages in thread
- * [dpdk-dev] [PATCH 11/15] testpmd: add and update commands for flow director
  2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
                   ` (9 preceding siblings ...)
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 10/15] ixgbe: implement the flush operation " Jingjing Wu
@ 2015-01-29  5:29 ` Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 12/15] testpmd: update function to show flow director information Jingjing Wu
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Jingjing Wu @ 2015-01-29  5:29 UTC (permalink / raw)
  To: dev
Add new command to set flow director's mask:
  - flow_director_mask
Update arguments of commands:
  - flow_director_filter
  - flow_director_flex_mask
  - flow_director_flex_payload
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline.c | 182 ++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 164 insertions(+), 18 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4beb404..3671d25 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -701,25 +701,26 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"get_flex_filter (port_id) index (idx)\n"
 			"    get info of a flex filter.\n\n"
 
-			"flow_director_filter (port_id) (add|del)"
+			"flow_director_filter (port_id) (add|del|update)"
 			" flow (ip4|ip4-frag|ip6|ip6-frag)"
 			" src (src_ip_address) dst (dst_ip_address)"
-			" flexbytes (flexbytes_value)"
+			" vlan (vlan_value) flexbytes (flexbytes_value)"
 			" (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
 			"    Add/Del an IP type flow director filter.\n\n"
 
-			"flow_director_filter (port_id) (add|del)"
+			"flow_director_filter (port_id) (add|del|update)"
 			" flow (udp4|tcp4|udp6|tcp6)"
 			" src (src_ip_address) (src_port)"
 			" dst (dst_ip_address) (dst_port)"
-			" flexbytes (flexbytes_value)"
+			" vlan (vlan_value) flexbytes (flexbytes_value)"
 			" (drop|fwd) queue (queue_id) fd_id (fd_id_value)\n"
 			"    Add/Del an UDP/TCP type flow director filter.\n\n"
 
-			"flow_director_filter (port_id) (add|del)"
+			"flow_director_filter (port_id) (add|del|update)"
 			" flow (sctp4|sctp6)"
-			" src (src_ip_address) dst (dst_ip_address)"
-			" tag (verification_tag)"
+			" src (src_ip_address) (src_port)"
+			" dst (dst_ip_address) (dst_port)"
+			" tag (verification_tag) vlan (vlan_value)"
 			" flexbytes (flexbytes_value) (drop|fwd)"
 			" queue (queue_id) fd_id (fd_id_value)\n"
 			"    Add/Del a SCTP type flow director filter.\n\n"
@@ -727,13 +728,18 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"flush_flow_director (port_id)\n"
 			"    Flush all flow director entries of a device.\n\n"
 
+			"flow_director_mask (port_id) vlan (vlan_value)"
+			" src_mask (ipv4_src) (ipv6_src) (src_port)"
+			" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
+			"    Set flow director mask.\n\n"
+
 			"flow_director_flex_mask (port_id)"
-			" flow (ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
+			" flow (raw|ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all)"
 			" (mask)\n"
 			"    Configure mask of flex payload.\n\n"
 
 			"flow_director_flex_payload (port_id)"
-			" (l2|l3|l4) (config)\n"
+			" (raw|l2|l3|l4) (config)\n"
 			"    Configure flex payload selection.\n\n"
 		);
 	}
@@ -8084,6 +8090,8 @@ struct cmd_flow_director_result {
 	uint16_t port_dst;
 	cmdline_fixed_string_t verify_tag;
 	uint32_t verify_tag_value;
+	cmdline_fixed_string_t vlan;
+	uint16_t vlan_value;
 	cmdline_fixed_string_t flexbytes;
 	cmdline_fixed_string_t flexbytes_value;
 	cmdline_fixed_string_t drop;
@@ -8139,6 +8147,7 @@ str2flowtype(char *string)
 		char str[32];
 		enum rte_eth_flow_type type;
 	} flowtype_str[] = {
+		{"raw", RTE_ETH_FLOW_TYPE_RAW},
 		{"ip4", RTE_ETH_FLOW_TYPE_IPV4_OTHER},
 		{"ip4-frag", RTE_ETH_FLOW_TYPE_FRAG_IPV4},
 		{"udp4", RTE_ETH_FLOW_TYPE_UDPV4},
@@ -8209,6 +8218,7 @@ cmd_flow_director_filter_parsed(void *parsed_result,
 	entry.input.flow_type = str2flowtype(res->flow_type);
 	switch (entry.input.flow_type) {
 	case RTE_ETH_FLOW_TYPE_IPV4_OTHER:
+	case RTE_ETH_FLOW_TYPE_FRAG_IPV4:
 	case RTE_ETH_FLOW_TYPE_UDPV4:
 	case RTE_ETH_FLOW_TYPE_TCPV4:
 		IPV4_ADDR_TO_UINT(res->ip_dst,
@@ -8231,6 +8241,7 @@ cmd_flow_director_filter_parsed(void *parsed_result,
 				rte_cpu_to_be_32(res->verify_tag_value);
 		break;
 	case RTE_ETH_FLOW_TYPE_IPV6_OTHER:
+	case RTE_ETH_FLOW_TYPE_FRAG_IPV6:
 	case RTE_ETH_FLOW_TYPE_UDPV6:
 	case RTE_ETH_FLOW_TYPE_TCPV6:
 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
@@ -8260,6 +8271,8 @@ cmd_flow_director_filter_parsed(void *parsed_result,
 		   flexbytes,
 		   RTE_ETH_FDIR_MAX_FLEXLEN);
 
+	entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
+
 	entry.action.flex_off = 0;  /*use 0 by default */
 	if (!strcmp(res->drop, "drop"))
 		entry.action.behavior = RTE_ETH_FDIR_REJECT;
@@ -8272,9 +8285,12 @@ cmd_flow_director_filter_parsed(void *parsed_result,
 	if (!strcmp(res->ops, "add"))
 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
 					     RTE_ETH_FILTER_ADD, &entry);
-	else
+	else if (!strcmp(res->ops, "del"))
 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
 					     RTE_ETH_FILTER_DELETE, &entry);
+	else
+		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
+					     RTE_ETH_FILTER_UPDATE, &entry);
 	if (ret < 0)
 		printf("flow director programming error: (%s)\n",
 			strerror(-ret));
@@ -8288,7 +8304,7 @@ cmdline_parse_token_num_t cmd_flow_director_port_id =
 			      port_id, UINT8);
 cmdline_parse_token_string_t cmd_flow_director_ops =
 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
-				 ops, "add#del");
+				 ops, "add#del#update");
 cmdline_parse_token_string_t cmd_flow_director_flow =
 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
 				 flow, "flow");
@@ -8321,6 +8337,12 @@ cmdline_parse_token_string_t cmd_flow_director_verify_tag =
 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
 			      verify_tag_value, UINT32);
+cmdline_parse_token_string_t cmd_flow_director_vlan =
+	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
+				 vlan, "vlan");
+cmdline_parse_token_num_t cmd_flow_director_vlan_value =
+	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
+			      vlan_value, UINT16);
 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
 				 flexbytes, "flexbytes");
@@ -8357,6 +8379,8 @@ cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
 		(void *)&cmd_flow_director_ip_src,
 		(void *)&cmd_flow_director_dst,
 		(void *)&cmd_flow_director_ip_dst,
+		(void *)&cmd_flow_director_vlan,
+		(void *)&cmd_flow_director_vlan_value,
 		(void *)&cmd_flow_director_flexbytes,
 		(void *)&cmd_flow_director_flexbytes_value,
 		(void *)&cmd_flow_director_drop,
@@ -8384,6 +8408,8 @@ cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
 		(void *)&cmd_flow_director_dst,
 		(void *)&cmd_flow_director_ip_dst,
 		(void *)&cmd_flow_director_port_dst,
+		(void *)&cmd_flow_director_vlan,
+		(void *)&cmd_flow_director_vlan_value,
 		(void *)&cmd_flow_director_flexbytes,
 		(void *)&cmd_flow_director_flexbytes_value,
 		(void *)&cmd_flow_director_drop,
@@ -8407,10 +8433,14 @@ cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
 		(void *)&cmd_flow_director_flow_type,
 		(void *)&cmd_flow_director_src,
 		(void *)&cmd_flow_director_ip_src,
+		(void *)&cmd_flow_director_port_dst,
 		(void *)&cmd_flow_director_dst,
 		(void *)&cmd_flow_director_ip_dst,
+		(void *)&cmd_flow_director_port_dst,
 		(void *)&cmd_flow_director_verify_tag,
 		(void *)&cmd_flow_director_verify_tag_value,
+		(void *)&cmd_flow_director_vlan,
+		(void *)&cmd_flow_director_vlan_value,
 		(void *)&cmd_flow_director_flexbytes,
 		(void *)&cmd_flow_director_flexbytes_value,
 		(void *)&cmd_flow_director_drop,
@@ -8467,6 +8497,112 @@ cmdline_parse_inst_t cmd_flush_flow_director = {
 	},
 };
 
+/* *** deal with flow director mask *** */
+struct cmd_flow_director_mask_result {
+	cmdline_fixed_string_t flow_director_mask;
+	uint8_t port_id;
+	cmdline_fixed_string_t vlan;
+	uint16_t vlan_value;
+	cmdline_fixed_string_t src_mask;
+	cmdline_ipaddr_t ipv4_src;
+	cmdline_ipaddr_t ipv6_src;
+	uint16_t port_src;
+	cmdline_fixed_string_t dst_mask;
+	cmdline_ipaddr_t ipv4_dst;
+	cmdline_ipaddr_t ipv6_dst;
+	uint16_t port_dst;
+};
+
+static void
+cmd_flow_director_mask_parsed(void *parsed_result,
+			  __attribute__((unused)) struct cmdline *cl,
+			  __attribute__((unused)) void *data)
+{
+	struct cmd_flow_director_mask_result *res = parsed_result;
+	struct rte_eth_fdir_masks *mask;
+	struct rte_port *port;
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	port = &ports[res->port_id];
+	/** Check if the port is not started **/
+	if (port->port_status != RTE_PORT_STOPPED) {
+		printf("Please stop port %d first\n", res->port_id);
+		return;
+	}
+	mask = &port->dev_conf.fdir_conf.mask;
+
+	mask->vlan_tci_mask = res->vlan_value;
+	IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
+	IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
+	IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
+	IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
+	mask->src_port_mask = res->port_src;
+	mask->dst_port_mask = res->port_dst;
+
+	cmd_reconfig_device_queue(res->port_id, 1, 1);
+}
+
+cmdline_parse_token_string_t cmd_flow_director_mask =
+	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
+				 flow_director_mask, "flow_director_mask");
+cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
+			      port_id, UINT8);
+cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
+	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
+				 vlan, "vlan");
+cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
+	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
+			      vlan_value, UINT16);
+cmdline_parse_token_string_t cmd_flow_director_mask_src =
+	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
+				 src_mask, "src_mask");
+cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
+	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
+				 ipv4_src);
+cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
+	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
+				 ipv6_src);
+cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
+	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
+			      port_src, UINT16);
+cmdline_parse_token_string_t cmd_flow_director_mask_dst =
+	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
+				 dst_mask, "dst_mask");
+cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
+	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
+				 ipv4_dst);
+cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
+	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
+				 ipv6_dst);
+cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
+	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
+			      port_dst, UINT16);
+cmdline_parse_inst_t cmd_set_flow_director_mask = {
+	.f = cmd_flow_director_mask_parsed,
+	.data = NULL,
+	.help_str = "set flow director's mask on NIC",
+	.tokens = {
+		(void *)&cmd_flow_director_mask,
+		(void *)&cmd_flow_director_mask_port_id,
+		(void *)&cmd_flow_director_mask_vlan,
+		(void *)&cmd_flow_director_mask_vlan_value,
+		(void *)&cmd_flow_director_mask_src,
+		(void *)&cmd_flow_director_mask_ipv4_src,
+		(void *)&cmd_flow_director_mask_ipv6_src,
+		(void *)&cmd_flow_director_mask_port_src,
+		(void *)&cmd_flow_director_mask_dst,
+		(void *)&cmd_flow_director_mask_ipv4_dst,
+		(void *)&cmd_flow_director_mask_ipv6_dst,
+		(void *)&cmd_flow_director_mask_port_dst,
+		NULL,
+	},
+};
+
 /* *** deal with flow director mask on flexible payload *** */
 struct cmd_flow_director_flex_mask_result {
 	cmdline_fixed_string_t flow_director_flexmask;
@@ -8482,6 +8618,7 @@ cmd_flow_director_flex_mask_parsed(void *parsed_result,
 			  __attribute__((unused)) void *data)
 {
 	struct cmd_flow_director_flex_mask_result *res = parsed_result;
+	struct rte_eth_fdir_info fdir_info;
 	struct rte_eth_fdir_flex_mask flex_mask;
 	struct rte_port *port;
 	enum rte_eth_flow_type i;
@@ -8507,14 +8644,20 @@ cmd_flow_director_flex_mask_parsed(void *parsed_result,
 		printf("error: Cannot parse mask input.\n");
 		return;
 	}
+
 	if (!strcmp(res->flow_type, "all")) {
-		for (i = RTE_ETH_FLOW_TYPE_UDPV4;
+		memset(&fdir_info, 0, sizeof(fdir_info));
+		rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
+				       RTE_ETH_FILTER_INFO, &fdir_info);
+		for (i = RTE_ETH_FLOW_TYPE_RAW;
 		     i <= RTE_ETH_FLOW_TYPE_FRAG_IPV6;
 		     i++) {
-			flex_mask.flow_type = i;
-			fdir_set_flex_mask(res->port_id, &flex_mask);
+			if (fdir_info.flow_types_mask[0] & (1 << i)) {
+				flex_mask.flow_type = i;
+				fdir_set_flex_mask(res->port_id, &flex_mask);
+			}
 		}
-		cmd_reconfig_device_queue(res->port_id, 1, 0);
+		cmd_reconfig_device_queue(res->port_id, 1, 1);
 		return;
 	}
 	flex_mask.flow_type = str2flowtype(res->flow_type);
@@ -8535,7 +8678,7 @@ cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
 				 flow_type,
-				"ip4#ip4-frag#tcp4#udp4#sctp4#"
+				"raw#ip4#ip4-frag#tcp4#udp4#sctp4#"
 				"ip6#ip6-frag#tcp6#udp6#sctp6#all");
 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
@@ -8625,7 +8768,9 @@ cmd_flow_director_flxpld_parsed(void *parsed_result,
 
 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
 
-	if (!strcmp(res->payload_layer, "l2"))
+	if (!strcmp(res->payload_layer, "raw"))
+		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
+	else if (!strcmp(res->payload_layer, "l2"))
 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
 	else if (!strcmp(res->payload_layer, "l3"))
 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
@@ -8652,7 +8797,7 @@ cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
 			      port_id, UINT8);
 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
-				 payload_layer, "l2#l3#l4");
+				 payload_layer, "raw#l2#l3#l4");
 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
 				 payload_cfg, NULL);
@@ -8805,6 +8950,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
 	(cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
 	(cmdline_parse_inst_t *)&cmd_flush_flow_director,
+	(cmdline_parse_inst_t *)&cmd_set_flow_director_mask,
 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
 	NULL,
-- 
1.9.3
^ permalink raw reply	[flat|nested] 18+ messages in thread
- * [dpdk-dev] [PATCH 12/15] testpmd: update function to show flow director information
  2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
                   ` (10 preceding siblings ...)
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 11/15] testpmd: add and update commands for " Jingjing Wu
@ 2015-01-29  5:29 ` Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 13/15] testpmd: set the default value of flow director's mask Jingjing Wu
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Jingjing Wu @ 2015-01-29  5:29 UTC (permalink / raw)
  To: dev
update the function to print information includes:
 - capability
 - mask
 - flex configuration
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/config.c | 77 ++++++++++++++++++++++++++++++---------------------
 1 file changed, 45 insertions(+), 32 deletions(-)
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index c40f819..4db9b9a 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -98,6 +98,7 @@
 
 static const char *flowtype_str[RTE_ETH_FLOW_TYPE_MAX] = {
 	NULL,
+	"raw",
 	"udp4",
 	"tcp4",
 	"sctp4",
@@ -1822,14 +1823,34 @@ fdir_remove_signature_filter(portid_t port_id,
 }
 
 static inline void
-print_fdir_flex_payload(struct rte_eth_fdir_flex_conf *flex_conf)
+print_fdir_mask(struct rte_eth_fdir_masks *mask)
+{
+	printf("\n    vlan_tci: 0x%04x, src_ipv4: 0x%08x, dst_ipv4: 0x%08x,"
+		      " src_port: 0x%04x, dst_port: 0x%04x",
+		mask->vlan_tci_mask, mask->ipv4_mask.src_ip,
+		mask->ipv4_mask.dst_ip,
+		mask->src_port_mask, mask->dst_port_mask);
+
+	printf("\n    src_ipv6: 0x%08x,0x%08x,0x%08x,0x%08x,"
+		     " dst_ipv6: 0x%08x,0x%08x,0x%08x,0x%08x",
+		mask->ipv6_mask.src_ip[0], mask->ipv6_mask.src_ip[1],
+		mask->ipv6_mask.src_ip[2], mask->ipv6_mask.src_ip[3],
+		mask->ipv6_mask.dst_ip[0], mask->ipv6_mask.dst_ip[1],
+		mask->ipv6_mask.dst_ip[2], mask->ipv6_mask.dst_ip[3]);
+	printf("\n");
+}
+
+static inline void
+print_fdir_flex_payload(struct rte_eth_fdir_flex_conf *flex_conf, uint32_t num)
 {
 	struct rte_eth_flex_payload_cfg *cfg;
-	int i, j;
+	uint32_t i, j;
 
 	for (i = 0; i < flex_conf->nb_payloads; i++) {
 		cfg = &flex_conf->flex_set[i];
-		if (cfg->type == RTE_ETH_L2_PAYLOAD)
+		if (cfg->type == RTE_ETH_RAW_PAYLOAD)
+			printf("\n    RAW:  ");
+		else if (cfg->type == RTE_ETH_L2_PAYLOAD)
 			printf("\n    L2_PAYLOAD:  ");
 		else if (cfg->type == RTE_ETH_L3_PAYLOAD)
 			printf("\n    L3_PAYLOAD:  ");
@@ -1837,22 +1858,22 @@ print_fdir_flex_payload(struct rte_eth_fdir_flex_conf *flex_conf)
 			printf("\n    L4_PAYLOAD:  ");
 		else
 			printf("\n    UNKNOWN PAYLOAD(%u):  ", cfg->type);
-		for (j = 0; j < RTE_ETH_FDIR_MAX_FLEXLEN; j++)
+		for (j = 0; j < num; j++)
 			printf("  %-5u", cfg->src_offset[j]);
 	}
 	printf("\n");
 }
 
 static inline void
-print_fdir_flex_mask(struct rte_eth_fdir_flex_conf *flex_conf)
+print_fdir_flex_mask(struct rte_eth_fdir_flex_conf *flex_conf, uint32_t num)
 {
 	struct rte_eth_fdir_flex_mask *mask;
-	int i, j;
+	uint32_t i, j;
 
 	for (i = 0; i < flex_conf->nb_flexmasks; i++) {
 		mask = &flex_conf->flex_mask[i];
 		printf("\n    %s:\t", flowtype_str[mask->flow_type]);
-		for (j = 0; j < RTE_ETH_FDIR_MAX_FLEXLEN; j++)
+		for (j = 0; j < num; j++)
 			printf(" %02x", mask->mask[j]);
 	}
 	printf("\n");
@@ -1885,26 +1906,8 @@ fdir_get_infos(portid_t port_id)
 		return;
 	ret = rte_eth_dev_filter_supported(port_id, RTE_ETH_FILTER_FDIR);
 	if (ret < 0) {
-		/* use the old fdir APIs to get info */
-		struct rte_eth_fdir fdir;
-		memset(&fdir, 0, sizeof(fdir));
-		ret = rte_eth_dev_fdir_get_infos(port_id, &fdir);
-		if (ret < 0) {
-			printf("\n getting fdir info fails on port %-2d\n",
-				port_id);
-			return;
-		}
-		printf("\n  %s FDIR infos for port %-2d     %s\n",
-			fdir_stats_border, port_id, fdir_stats_border);
-		printf("  collision: %-10"PRIu64"  free:     %"PRIu64"\n"
-		       "  maxhash:   %-10"PRIu64"  maxlen:   %"PRIu64"\n"
-		       "  add:	     %-10"PRIu64"  remove:   %"PRIu64"\n"
-		       "  f_add:     %-10"PRIu64"  f_remove: %"PRIu64"\n",
-		       (uint64_t)(fdir.collision), (uint64_t)(fdir.free),
-		       (uint64_t)(fdir.maxhash), (uint64_t)(fdir.maxlen),
-		       fdir.add, fdir.remove, fdir.f_add, fdir.f_remove);
-		printf("  %s############################%s\n",
-		       fdir_stats_border, fdir_stats_border);
+		printf("\n FDIR is not supported on port %-2d\n",
+			port_id);
 		return;
 	}
 
@@ -1933,18 +1936,28 @@ fdir_get_infos(portid_t port_id)
 		fdir_info.flex_payload_unit,
 		fdir_info.max_flex_payload_segment_num,
 		fdir_info.flex_bitmask_unit, fdir_info.max_flex_bitmask_num);
+	printf("  MASK: ");
+	print_fdir_mask(&fdir_info.mask);
 	if (fdir_info.flex_conf.nb_payloads > 0) {
 		printf("  FLEX PAYLOAD SRC OFFSET:");
-		print_fdir_flex_payload(&fdir_info.flex_conf);
+		print_fdir_flex_payload(&fdir_info.flex_conf, fdir_info.max_flexpayload);
 	}
 	if (fdir_info.flex_conf.nb_flexmasks > 0) {
 		printf("  FLEX MASK CFG:");
-		print_fdir_flex_mask(&fdir_info.flex_conf);
+		print_fdir_flex_mask(&fdir_info.flex_conf, fdir_info.max_flexpayload);
 	}
-	printf("  guarant_count: %-10"PRIu32"  best_count:    %-10"PRIu32"\n",
+	printf("  guarant_count: %-10"PRIu32"  best_count:    %"PRIu32"\n",
 	       fdir_stat.guarant_cnt, fdir_stat.best_cnt);
-	printf("  guarant_space: %-10"PRIu32"  best_space:    %-10"PRIu32"\n",
-	       fdir_info.guarant_spc, fdir_info.guarant_spc);
+	printf("  guarant_space: %-10"PRIu32"  best_space:    %"PRIu32"\n",
+	       fdir_info.guarant_spc, fdir_info.best_spc);
+	printf("  collision:     %-10"PRIu32"  free:          %"PRIu32"\n"
+	       "  maxhash:       %-10"PRIu32"  maxlen:        %"PRIu32"\n"
+	       "  add:	         %-10"PRIu64"  remove:        %"PRIu64"\n"
+	       "  f_add:         %-10"PRIu64"  f_remove:      %"PRIu64"\n",
+	       fdir_stat.collision, fdir_stat.free,
+	       fdir_stat.maxhash, fdir_stat.maxlen,
+	       fdir_stat.add, fdir_stat.remove,
+	       fdir_stat.f_add, fdir_stat.f_remove);
 	printf("  %s############################%s\n",
 	       fdir_stats_border, fdir_stats_border);
 }
-- 
1.9.3
^ permalink raw reply	[flat|nested] 18+ messages in thread
- * [dpdk-dev] [PATCH 13/15] testpmd: set the default value of flow director's mask
  2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
                   ` (11 preceding siblings ...)
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 12/15] testpmd: update function to show flow director information Jingjing Wu
@ 2015-01-29  5:29 ` Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 14/15] testpmd: remove old commands for flow director Jingjing Wu
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: Jingjing Wu @ 2015-01-29  5:29 UTC (permalink / raw)
  To: dev
this patch sets the default value of flow director's mask.
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/testpmd.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 2773c10..8b41fe5 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -298,6 +298,19 @@ struct rte_fdir_conf fdir_conf = {
 	.mode = RTE_FDIR_MODE_NONE,
 	.pballoc = RTE_FDIR_PBALLOC_64K,
 	.status = RTE_FDIR_REPORT_STATUS,
+	.mask = {
+		.vlan_tci_mask = 0x0,
+		.ipv4_mask     = {
+			.src_ip = 0xFFFFFFFF,
+			.dst_ip = 0xFFFFFFFF,
+		},
+		.ipv6_mask     = {
+			.src_ip = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},
+			.dst_ip = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},
+		},
+		.src_port_mask = 0xFFFF,
+		.dst_port_mask = 0xFFFF,
+	},
 	.drop_queue = 127,
 };
 
-- 
1.9.3
^ permalink raw reply	[flat|nested] 18+ messages in thread
- * [dpdk-dev] [PATCH 14/15] testpmd: remove old commands for flow director
  2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
                   ` (12 preceding siblings ...)
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 13/15] testpmd: set the default value of flow director's mask Jingjing Wu
@ 2015-01-29  5:29 ` Jingjing Wu
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 15/15] doc: commands changed in testpmd_funcs.rst " Jingjing Wu
  2015-02-11  8:09 ` [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Zhang, Helin
  15 siblings, 0 replies; 18+ messages in thread
From: Jingjing Wu @ 2015-01-29  5:29 UTC (permalink / raw)
  To: dev
Following commands of flow director filter are removed:
  - add_signature_filter
  - upd_signature_filter
  - rm_signature_filter
  - add_perfect_filter
  - upd_perfect_filter
  - rm_perfect_filter
  - set_masks_filter
  - set_ipv6_masks_filter
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline.c | 573 +------------------------------------------------
 app/test-pmd/config.c  | 124 -----------
 app/test-pmd/testpmd.h |  16 --
 3 files changed, 1 insertion(+), 712 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 3671d25..fb7eff5 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -115,7 +115,6 @@ static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
 		"information.\n"
 		"    help config     : Configuration information.\n"
 		"    help ports      : Configuring ports.\n"
-		"    help flowdir    : Flow Director filter help.\n"
 		"    help registers  : Reading and setting port registers.\n"
 		"    help filters    : Filters configuration help.\n"
 		"    help all        : All of the above sections.\n\n"
@@ -490,71 +489,6 @@ static void cmd_help_long_parsed(void *parsed_result,
 		);
 	}
 
-
-	if (show_all || !strcmp(res->section, "flowdir")) {
-
-		cmdline_printf(
-			cl,
-			"\n"
-			"Flow director mode:\n"
-			"-------------------\n\n"
-
-			"add_signature_filter (port_id) (ip|udp|tcp|sctp)"
-			" src (src_ip_address) (src_port)"
-			" dst (dst_ip_address) (dst_port)"
-			" flexbytes (flexbytes_values) vlan (vlan_id)"
-			" queue (queue_id)\n"
-			"    Add a signature filter.\n\n"
-
-			"upd_signature_filter (port_id) (ip|udp|tcp|sctp)"
-			" src (src_ip_address) (src_port)"
-			" dst (dst_ip_address) (dst_port)"
-			" flexbytes (flexbytes_values) vlan (vlan_id)"
-			" queue (queue_id)\n"
-			"    Update a signature filter.\n\n"
-
-			"rm_signature_filter (port_id) (ip|udp|tcp|sctp)"
-			" src (src_ip_address) (src_port)"
-			" dst (dst_ip_address) (dst_port)"
-			" flexbytes (flexbytes_values) vlan (vlan_id)\n"
-			"    Remove a signature filter.\n\n"
-
-			"add_perfect_filter (port_id) (ip|udp|tcp|sctp)"
-			" src (src_ip_address) (src_port)"
-			" dst (dst_ip_address) (dst_port)"
-			" flexbytes (flexbytes_values) vlan (vlan_id)"
-			" queue (queue_id) soft (soft_id)\n"
-			"    Add a perfect filter.\n\n"
-
-			"upd_perfect_filter (port_id) (ip|udp|tcp|sctp)"
-			" src (src_ip_address) (src_port)"
-			" dst (dst_ip_address) (dst_port)"
-			" flexbytes (flexbytes_values) vlan (vlan_id)"
-			" queue (queue_id)\n"
-			"    Update a perfect filter.\n\n"
-
-			"rm_perfect_filter (port_id) (ip|udp|tcp|sctp)"
-			" src (src_ip_address) (src_port)"
-			" dst (dst_ip_address) (dst_port)"
-			" flexbytes (flexbytes_values) vlan (vlan_id)"
-			" soft (soft_id)\n"
-			"    Remove a perfect filter.\n\n"
-
-			"set_masks_filter (port_id) only_ip_flow (0|1)"
-			" src_mask (ip_src_mask) (src_port_mask)"
-			" dst_mask (ip_dst_mask) (dst_port_mask)"
-			" flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)\n"
-			"    Set IPv4 filter masks.\n\n"
-
-			"set_ipv6_masks_filter (port_id) only_ip_flow (0|1)"
-			" src_mask (ip_src_mask) (src_port_mask)"
-			" dst_mask (ip_dst_mask) (dst_port_mask)"
-			" flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)"
-			" compare_dst (0|1)\n"
-			"    Set IPv6 filter masks.\n\n"
-		);
-	}
-
 	if (show_all || !strcmp(res->section, "ports")) {
 
 		cmdline_printf(
@@ -750,7 +684,7 @@ cmdline_parse_token_string_t cmd_help_long_help =
 
 cmdline_parse_token_string_t cmd_help_long_section =
 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
-			"all#control#display#config#flowdir#"
+			"all#control#display#config#"
 			"ports#registers#filters");
 
 cmdline_parse_inst_t cmd_help_long = {
@@ -4361,503 +4295,6 @@ cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
 	},
 };
 
-/* *** ADD/REMOVE A PKT FILTER *** */
-struct cmd_pkt_filter_result {
-	cmdline_fixed_string_t pkt_filter;
-	uint8_t  port_id;
-	cmdline_fixed_string_t protocol;
-	cmdline_fixed_string_t src;
-	cmdline_ipaddr_t ip_src;
-	uint16_t port_src;
-	cmdline_fixed_string_t dst;
-	cmdline_ipaddr_t ip_dst;
-	uint16_t port_dst;
-	cmdline_fixed_string_t flexbytes;
-	uint16_t flexbytes_value;
-	cmdline_fixed_string_t vlan;
-	uint16_t  vlan_id;
-	cmdline_fixed_string_t queue;
-	int8_t  queue_id;
-	cmdline_fixed_string_t soft;
-	uint8_t  soft_id;
-};
-
-static void
-cmd_pkt_filter_parsed(void *parsed_result,
-			  __attribute__((unused)) struct cmdline *cl,
-			  __attribute__((unused)) void *data)
-{
-	struct rte_fdir_filter fdir_filter;
-	struct cmd_pkt_filter_result *res = parsed_result;
-
-	memset(&fdir_filter, 0, sizeof(struct rte_fdir_filter));
-
-	if (res->ip_src.family == AF_INET)
-		fdir_filter.ip_src.ipv4_addr = res->ip_src.addr.ipv4.s_addr;
-	else
-		memcpy(&(fdir_filter.ip_src.ipv6_addr),
-		       &(res->ip_src.addr.ipv6),
-		       sizeof(struct in6_addr));
-
-	if (res->ip_dst.family == AF_INET)
-		fdir_filter.ip_dst.ipv4_addr = res->ip_dst.addr.ipv4.s_addr;
-	else
-		memcpy(&(fdir_filter.ip_dst.ipv6_addr),
-		       &(res->ip_dst.addr.ipv6),
-		       sizeof(struct in6_addr));
-
-	fdir_filter.port_dst = rte_cpu_to_be_16(res->port_dst);
-	fdir_filter.port_src = rte_cpu_to_be_16(res->port_src);
-
-	if (!strcmp(res->protocol, "udp"))
-		fdir_filter.l4type = RTE_FDIR_L4TYPE_UDP;
-	else if (!strcmp(res->protocol, "tcp"))
-		fdir_filter.l4type = RTE_FDIR_L4TYPE_TCP;
-	else if (!strcmp(res->protocol, "sctp"))
-		fdir_filter.l4type = RTE_FDIR_L4TYPE_SCTP;
-	else /* default only IP */
-		fdir_filter.l4type = RTE_FDIR_L4TYPE_NONE;
-
-	if (res->ip_dst.family == AF_INET6)
-		fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV6;
-	else
-		fdir_filter.iptype = RTE_FDIR_IPTYPE_IPV4;
-
-	fdir_filter.vlan_id    = rte_cpu_to_be_16(res->vlan_id);
-	fdir_filter.flex_bytes = rte_cpu_to_be_16(res->flexbytes_value);
-
-	if (!strcmp(res->pkt_filter, "add_signature_filter"))
-		fdir_add_signature_filter(res->port_id, res->queue_id,
-					  &fdir_filter);
-	else if (!strcmp(res->pkt_filter, "upd_signature_filter"))
-		fdir_update_signature_filter(res->port_id, res->queue_id,
-					     &fdir_filter);
-	else if (!strcmp(res->pkt_filter, "rm_signature_filter"))
-		fdir_remove_signature_filter(res->port_id, &fdir_filter);
-	else if (!strcmp(res->pkt_filter, "add_perfect_filter"))
-		fdir_add_perfect_filter(res->port_id, res->soft_id,
-					res->queue_id,
-					(uint8_t) (res->queue_id < 0),
-					&fdir_filter);
-	else if (!strcmp(res->pkt_filter, "upd_perfect_filter"))
-		fdir_update_perfect_filter(res->port_id, res->soft_id,
-					   res->queue_id,
-					   (uint8_t) (res->queue_id < 0),
-					   &fdir_filter);
-	else if (!strcmp(res->pkt_filter, "rm_perfect_filter"))
-		fdir_remove_perfect_filter(res->port_id, res->soft_id,
-					   &fdir_filter);
-
-}
-
-
-cmdline_parse_token_num_t cmd_pkt_filter_port_id =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
-			      port_id, UINT8);
-cmdline_parse_token_string_t cmd_pkt_filter_protocol =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
-				 protocol, "ip#tcp#udp#sctp");
-cmdline_parse_token_string_t cmd_pkt_filter_src =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
-				 src, "src");
-cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_src =
-	TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
-				 ip_src);
-cmdline_parse_token_num_t cmd_pkt_filter_port_src =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
-			      port_src, UINT16);
-cmdline_parse_token_string_t cmd_pkt_filter_dst =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
-				 dst, "dst");
-cmdline_parse_token_ipaddr_t cmd_pkt_filter_ip_dst =
-	TOKEN_IPADDR_INITIALIZER(struct cmd_pkt_filter_result,
-				 ip_dst);
-cmdline_parse_token_num_t cmd_pkt_filter_port_dst =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
-			      port_dst, UINT16);
-cmdline_parse_token_string_t cmd_pkt_filter_flexbytes =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
-				 flexbytes, "flexbytes");
-cmdline_parse_token_num_t cmd_pkt_filter_flexbytes_value =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
-			      flexbytes_value, UINT16);
-cmdline_parse_token_string_t cmd_pkt_filter_vlan =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
-				 vlan, "vlan");
-cmdline_parse_token_num_t cmd_pkt_filter_vlan_id =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
-			      vlan_id, UINT16);
-cmdline_parse_token_string_t cmd_pkt_filter_queue =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
-				 queue, "queue");
-cmdline_parse_token_num_t cmd_pkt_filter_queue_id =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
-			      queue_id, INT8);
-cmdline_parse_token_string_t cmd_pkt_filter_soft =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
-				 soft, "soft");
-cmdline_parse_token_num_t cmd_pkt_filter_soft_id =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_result,
-			      soft_id, UINT16);
-
-
-cmdline_parse_token_string_t cmd_pkt_filter_add_signature_filter =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
-				 pkt_filter, "add_signature_filter");
-cmdline_parse_inst_t cmd_add_signature_filter = {
-	.f = cmd_pkt_filter_parsed,
-	.data = NULL,
-	.help_str = "add a signature filter",
-	.tokens = {
-		(void *)&cmd_pkt_filter_add_signature_filter,
-		(void *)&cmd_pkt_filter_port_id,
-		(void *)&cmd_pkt_filter_protocol,
-		(void *)&cmd_pkt_filter_src,
-		(void *)&cmd_pkt_filter_ip_src,
-		(void *)&cmd_pkt_filter_port_src,
-		(void *)&cmd_pkt_filter_dst,
-		(void *)&cmd_pkt_filter_ip_dst,
-		(void *)&cmd_pkt_filter_port_dst,
-		(void *)&cmd_pkt_filter_flexbytes,
-		(void *)&cmd_pkt_filter_flexbytes_value,
-		(void *)&cmd_pkt_filter_vlan,
-		(void *)&cmd_pkt_filter_vlan_id,
-		(void *)&cmd_pkt_filter_queue,
-		(void *)&cmd_pkt_filter_queue_id,
-		NULL,
-	},
-};
-
-
-cmdline_parse_token_string_t cmd_pkt_filter_upd_signature_filter =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
-				 pkt_filter, "upd_signature_filter");
-cmdline_parse_inst_t cmd_upd_signature_filter = {
-	.f = cmd_pkt_filter_parsed,
-	.data = NULL,
-	.help_str = "update a signature filter",
-	.tokens = {
-		(void *)&cmd_pkt_filter_upd_signature_filter,
-		(void *)&cmd_pkt_filter_port_id,
-		(void *)&cmd_pkt_filter_protocol,
-		(void *)&cmd_pkt_filter_src,
-		(void *)&cmd_pkt_filter_ip_src,
-		(void *)&cmd_pkt_filter_port_src,
-		(void *)&cmd_pkt_filter_dst,
-		(void *)&cmd_pkt_filter_ip_dst,
-		(void *)&cmd_pkt_filter_port_dst,
-		(void *)&cmd_pkt_filter_flexbytes,
-		(void *)&cmd_pkt_filter_flexbytes_value,
-		(void *)&cmd_pkt_filter_vlan,
-		(void *)&cmd_pkt_filter_vlan_id,
-		(void *)&cmd_pkt_filter_queue,
-		(void *)&cmd_pkt_filter_queue_id,
-		NULL,
-	},
-};
-
-
-cmdline_parse_token_string_t cmd_pkt_filter_rm_signature_filter =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
-				 pkt_filter, "rm_signature_filter");
-cmdline_parse_inst_t cmd_rm_signature_filter = {
-	.f = cmd_pkt_filter_parsed,
-	.data = NULL,
-	.help_str = "remove a signature filter",
-	.tokens = {
-		(void *)&cmd_pkt_filter_rm_signature_filter,
-		(void *)&cmd_pkt_filter_port_id,
-		(void *)&cmd_pkt_filter_protocol,
-		(void *)&cmd_pkt_filter_src,
-		(void *)&cmd_pkt_filter_ip_src,
-		(void *)&cmd_pkt_filter_port_src,
-		(void *)&cmd_pkt_filter_dst,
-		(void *)&cmd_pkt_filter_ip_dst,
-		(void *)&cmd_pkt_filter_port_dst,
-		(void *)&cmd_pkt_filter_flexbytes,
-		(void *)&cmd_pkt_filter_flexbytes_value,
-		(void *)&cmd_pkt_filter_vlan,
-		(void *)&cmd_pkt_filter_vlan_id,
-		NULL
-		},
-};
-
-
-cmdline_parse_token_string_t cmd_pkt_filter_add_perfect_filter =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
-				 pkt_filter, "add_perfect_filter");
-cmdline_parse_inst_t cmd_add_perfect_filter = {
-	.f = cmd_pkt_filter_parsed,
-	.data = NULL,
-	.help_str = "add a perfect filter",
-	.tokens = {
-		(void *)&cmd_pkt_filter_add_perfect_filter,
-		(void *)&cmd_pkt_filter_port_id,
-		(void *)&cmd_pkt_filter_protocol,
-		(void *)&cmd_pkt_filter_src,
-		(void *)&cmd_pkt_filter_ip_src,
-		(void *)&cmd_pkt_filter_port_src,
-		(void *)&cmd_pkt_filter_dst,
-		(void *)&cmd_pkt_filter_ip_dst,
-		(void *)&cmd_pkt_filter_port_dst,
-		(void *)&cmd_pkt_filter_flexbytes,
-		(void *)&cmd_pkt_filter_flexbytes_value,
-		(void *)&cmd_pkt_filter_vlan,
-		(void *)&cmd_pkt_filter_vlan_id,
-		(void *)&cmd_pkt_filter_queue,
-		(void *)&cmd_pkt_filter_queue_id,
-		(void *)&cmd_pkt_filter_soft,
-		(void *)&cmd_pkt_filter_soft_id,
-		NULL,
-	},
-};
-
-
-cmdline_parse_token_string_t cmd_pkt_filter_upd_perfect_filter =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
-				 pkt_filter, "upd_perfect_filter");
-cmdline_parse_inst_t cmd_upd_perfect_filter = {
-	.f = cmd_pkt_filter_parsed,
-	.data = NULL,
-	.help_str = "update a perfect filter",
-	.tokens = {
-		(void *)&cmd_pkt_filter_upd_perfect_filter,
-		(void *)&cmd_pkt_filter_port_id,
-		(void *)&cmd_pkt_filter_protocol,
-		(void *)&cmd_pkt_filter_src,
-		(void *)&cmd_pkt_filter_ip_src,
-		(void *)&cmd_pkt_filter_port_src,
-		(void *)&cmd_pkt_filter_dst,
-		(void *)&cmd_pkt_filter_ip_dst,
-		(void *)&cmd_pkt_filter_port_dst,
-		(void *)&cmd_pkt_filter_flexbytes,
-		(void *)&cmd_pkt_filter_flexbytes_value,
-		(void *)&cmd_pkt_filter_vlan,
-		(void *)&cmd_pkt_filter_vlan_id,
-		(void *)&cmd_pkt_filter_queue,
-		(void *)&cmd_pkt_filter_queue_id,
-		(void *)&cmd_pkt_filter_soft,
-		(void *)&cmd_pkt_filter_soft_id,
-		NULL,
-	},
-};
-
-
-cmdline_parse_token_string_t cmd_pkt_filter_rm_perfect_filter =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_result,
-				 pkt_filter, "rm_perfect_filter");
-cmdline_parse_inst_t cmd_rm_perfect_filter = {
-	.f = cmd_pkt_filter_parsed,
-	.data = NULL,
-	.help_str = "remove a perfect filter",
-	.tokens = {
-		(void *)&cmd_pkt_filter_rm_perfect_filter,
-		(void *)&cmd_pkt_filter_port_id,
-		(void *)&cmd_pkt_filter_protocol,
-		(void *)&cmd_pkt_filter_src,
-		(void *)&cmd_pkt_filter_ip_src,
-		(void *)&cmd_pkt_filter_port_src,
-		(void *)&cmd_pkt_filter_dst,
-		(void *)&cmd_pkt_filter_ip_dst,
-		(void *)&cmd_pkt_filter_port_dst,
-		(void *)&cmd_pkt_filter_flexbytes,
-		(void *)&cmd_pkt_filter_flexbytes_value,
-		(void *)&cmd_pkt_filter_vlan,
-		(void *)&cmd_pkt_filter_vlan_id,
-		(void *)&cmd_pkt_filter_soft,
-		(void *)&cmd_pkt_filter_soft_id,
-		NULL,
-	},
-};
-
-/* *** SETUP MASKS FILTER *** */
-struct cmd_pkt_filter_masks_result {
-	cmdline_fixed_string_t filter_mask;
-	uint8_t  port_id;
-	cmdline_fixed_string_t src_mask;
-	uint32_t ip_src_mask;
-	uint16_t ipv6_src_mask;
-	uint16_t port_src_mask;
-	cmdline_fixed_string_t dst_mask;
-	uint32_t ip_dst_mask;
-	uint16_t ipv6_dst_mask;
-	uint16_t port_dst_mask;
-	cmdline_fixed_string_t flexbytes;
-	uint8_t flexbytes_value;
-	cmdline_fixed_string_t vlan_id;
-	uint8_t  vlan_id_value;
-	cmdline_fixed_string_t vlan_prio;
-	uint8_t  vlan_prio_value;
-	cmdline_fixed_string_t only_ip_flow;
-	uint8_t  only_ip_flow_value;
-	cmdline_fixed_string_t comp_ipv6_dst;
-	uint8_t  comp_ipv6_dst_value;
-};
-
-static void
-cmd_pkt_filter_masks_parsed(void *parsed_result,
-			  __attribute__((unused)) struct cmdline *cl,
-			  __attribute__((unused)) void *data)
-{
-	struct rte_fdir_masks fdir_masks;
-	struct cmd_pkt_filter_masks_result *res = parsed_result;
-
-	memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
-
-	fdir_masks.only_ip_flow  = res->only_ip_flow_value;
-	fdir_masks.vlan_id       = res->vlan_id_value;
-	fdir_masks.vlan_prio     = res->vlan_prio_value;
-	fdir_masks.dst_ipv4_mask = res->ip_dst_mask;
-	fdir_masks.src_ipv4_mask = res->ip_src_mask;
-	fdir_masks.src_port_mask = res->port_src_mask;
-	fdir_masks.dst_port_mask = res->port_dst_mask;
-	fdir_masks.flexbytes     = res->flexbytes_value;
-
-	fdir_set_masks(res->port_id, &fdir_masks);
-}
-
-cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
-				 filter_mask, "set_masks_filter");
-cmdline_parse_token_num_t cmd_pkt_filter_masks_port_id =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
-			      port_id, UINT8);
-cmdline_parse_token_string_t cmd_pkt_filter_masks_only_ip_flow =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
-				 only_ip_flow, "only_ip_flow");
-cmdline_parse_token_num_t cmd_pkt_filter_masks_only_ip_flow_value =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
-			      only_ip_flow_value, UINT8);
-cmdline_parse_token_string_t cmd_pkt_filter_masks_src_mask =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
-				 src_mask, "src_mask");
-cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_src_mask =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
-			      ip_src_mask, UINT32);
-cmdline_parse_token_num_t cmd_pkt_filter_masks_port_src_mask =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
-			      port_src_mask, UINT16);
-cmdline_parse_token_string_t cmd_pkt_filter_masks_dst_mask =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
-				 dst_mask, "dst_mask");
-cmdline_parse_token_num_t cmd_pkt_filter_masks_ip_dst_mask =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
-			      ip_dst_mask, UINT32);
-cmdline_parse_token_num_t cmd_pkt_filter_masks_port_dst_mask =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
-			      port_dst_mask, UINT16);
-cmdline_parse_token_string_t cmd_pkt_filter_masks_flexbytes =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
-				 flexbytes, "flexbytes");
-cmdline_parse_token_num_t cmd_pkt_filter_masks_flexbytes_value =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
-			      flexbytes_value, UINT8);
-cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_id =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
-				 vlan_id, "vlan_id");
-cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_id_value =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
-			      vlan_id_value, UINT8);
-cmdline_parse_token_string_t cmd_pkt_filter_masks_vlan_prio =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
-				 vlan_prio, "vlan_prio");
-cmdline_parse_token_num_t cmd_pkt_filter_masks_vlan_prio_value =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
-			      vlan_prio_value, UINT8);
-
-cmdline_parse_inst_t cmd_set_masks_filter = {
-	.f = cmd_pkt_filter_masks_parsed,
-	.data = NULL,
-	.help_str = "setup masks filter",
-	.tokens = {
-		(void *)&cmd_pkt_filter_masks_filter_mask,
-		(void *)&cmd_pkt_filter_masks_port_id,
-		(void *)&cmd_pkt_filter_masks_only_ip_flow,
-		(void *)&cmd_pkt_filter_masks_only_ip_flow_value,
-		(void *)&cmd_pkt_filter_masks_src_mask,
-		(void *)&cmd_pkt_filter_masks_ip_src_mask,
-		(void *)&cmd_pkt_filter_masks_port_src_mask,
-		(void *)&cmd_pkt_filter_masks_dst_mask,
-		(void *)&cmd_pkt_filter_masks_ip_dst_mask,
-		(void *)&cmd_pkt_filter_masks_port_dst_mask,
-		(void *)&cmd_pkt_filter_masks_flexbytes,
-		(void *)&cmd_pkt_filter_masks_flexbytes_value,
-		(void *)&cmd_pkt_filter_masks_vlan_id,
-		(void *)&cmd_pkt_filter_masks_vlan_id_value,
-		(void *)&cmd_pkt_filter_masks_vlan_prio,
-		(void *)&cmd_pkt_filter_masks_vlan_prio_value,
-		NULL,
-	},
-};
-
-static void
-cmd_pkt_filter_masks_ipv6_parsed(void *parsed_result,
-			  __attribute__((unused)) struct cmdline *cl,
-			  __attribute__((unused)) void *data)
-{
-	struct rte_fdir_masks fdir_masks;
-	struct cmd_pkt_filter_masks_result *res = parsed_result;
-
-	memset(&fdir_masks, 0, sizeof(struct rte_fdir_masks));
-
-	fdir_masks.set_ipv6_mask = 1;
-	fdir_masks.only_ip_flow  = res->only_ip_flow_value;
-	fdir_masks.vlan_id       = res->vlan_id_value;
-	fdir_masks.vlan_prio     = res->vlan_prio_value;
-	fdir_masks.dst_ipv6_mask = res->ipv6_dst_mask;
-	fdir_masks.src_ipv6_mask = res->ipv6_src_mask;
-	fdir_masks.src_port_mask = res->port_src_mask;
-	fdir_masks.dst_port_mask = res->port_dst_mask;
-	fdir_masks.flexbytes     = res->flexbytes_value;
-	fdir_masks.comp_ipv6_dst = res->comp_ipv6_dst_value;
-
-	fdir_set_masks(res->port_id, &fdir_masks);
-}
-
-cmdline_parse_token_string_t cmd_pkt_filter_masks_filter_mask_ipv6 =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
-				 filter_mask, "set_ipv6_masks_filter");
-cmdline_parse_token_num_t cmd_pkt_filter_masks_src_mask_ipv6_value =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
-			      ipv6_src_mask, UINT16);
-cmdline_parse_token_num_t cmd_pkt_filter_masks_dst_mask_ipv6_value =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
-			      ipv6_dst_mask, UINT16);
-
-cmdline_parse_token_string_t cmd_pkt_filter_masks_comp_ipv6_dst =
-	TOKEN_STRING_INITIALIZER(struct cmd_pkt_filter_masks_result,
-				 comp_ipv6_dst, "compare_dst");
-cmdline_parse_token_num_t cmd_pkt_filter_masks_comp_ipv6_dst_value =
-	TOKEN_NUM_INITIALIZER(struct cmd_pkt_filter_masks_result,
-			      comp_ipv6_dst_value, UINT8);
-
-cmdline_parse_inst_t cmd_set_ipv6_masks_filter = {
-	.f = cmd_pkt_filter_masks_ipv6_parsed,
-	.data = NULL,
-	.help_str = "setup ipv6 masks filter",
-	.tokens = {
-		(void *)&cmd_pkt_filter_masks_filter_mask_ipv6,
-		(void *)&cmd_pkt_filter_masks_port_id,
-		(void *)&cmd_pkt_filter_masks_only_ip_flow,
-		(void *)&cmd_pkt_filter_masks_only_ip_flow_value,
-		(void *)&cmd_pkt_filter_masks_src_mask,
-		(void *)&cmd_pkt_filter_masks_src_mask_ipv6_value,
-		(void *)&cmd_pkt_filter_masks_port_src_mask,
-		(void *)&cmd_pkt_filter_masks_dst_mask,
-		(void *)&cmd_pkt_filter_masks_dst_mask_ipv6_value,
-		(void *)&cmd_pkt_filter_masks_port_dst_mask,
-		(void *)&cmd_pkt_filter_masks_flexbytes,
-		(void *)&cmd_pkt_filter_masks_flexbytes_value,
-		(void *)&cmd_pkt_filter_masks_vlan_id,
-		(void *)&cmd_pkt_filter_masks_vlan_id_value,
-		(void *)&cmd_pkt_filter_masks_vlan_prio,
-		(void *)&cmd_pkt_filter_masks_vlan_prio_value,
-		(void *)&cmd_pkt_filter_masks_comp_ipv6_dst,
-		(void *)&cmd_pkt_filter_masks_comp_ipv6_dst_value,
-		NULL,
-	},
-};
-
 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
 struct cmd_link_flow_ctrl_set_result {
 	cmdline_fixed_string_t set;
@@ -8888,14 +8325,6 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
-	(cmdline_parse_inst_t *)&cmd_add_signature_filter,
-	(cmdline_parse_inst_t *)&cmd_upd_signature_filter,
-	(cmdline_parse_inst_t *)&cmd_rm_signature_filter,
-	(cmdline_parse_inst_t *)&cmd_add_perfect_filter,
-	(cmdline_parse_inst_t *)&cmd_upd_perfect_filter,
-	(cmdline_parse_inst_t *)&cmd_rm_perfect_filter,
-	(cmdline_parse_inst_t *)&cmd_set_masks_filter,
-	(cmdline_parse_inst_t *)&cmd_set_ipv6_masks_filter,
 	(cmdline_parse_inst_t *)&cmd_stop,
 	(cmdline_parse_inst_t *)&cmd_mac_addr,
 	(cmdline_parse_inst_t *)&cmd_set_qmap,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 4db9b9a..2046a8e 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1768,60 +1768,6 @@ set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value)
 	}
 }
 
-void
-fdir_add_signature_filter(portid_t port_id, uint8_t queue_id,
-			  struct rte_fdir_filter *fdir_filter)
-{
-	int diag;
-
-	if (port_id_is_invalid(port_id))
-		return;
-
-	diag = rte_eth_dev_fdir_add_signature_filter(port_id, fdir_filter,
-						     queue_id);
-	if (diag == 0)
-		return;
-
-	printf("rte_eth_dev_fdir_add_signature_filter for port_id=%d failed "
-	       "diag=%d\n", port_id, diag);
-}
-
-void
-fdir_update_signature_filter(portid_t port_id, uint8_t queue_id,
-			     struct rte_fdir_filter *fdir_filter)
-{
-	int diag;
-
-	if (port_id_is_invalid(port_id))
-		return;
-
-	diag = rte_eth_dev_fdir_update_signature_filter(port_id, fdir_filter,
-							queue_id);
-	if (diag == 0)
-		return;
-
-	printf("rte_eth_dev_fdir_update_signature_filter for port_id=%d failed "
-	       "diag=%d\n", port_id, diag);
-}
-
-void
-fdir_remove_signature_filter(portid_t port_id,
-			     struct rte_fdir_filter *fdir_filter)
-{
-	int diag;
-
-	if (port_id_is_invalid(port_id))
-		return;
-
-	diag = rte_eth_dev_fdir_remove_signature_filter(port_id, fdir_filter);
-	if (diag == 0)
-		return;
-
-	printf("rte_eth_dev_fdir_add_signature_filter for port_id=%d failed "
-	       "diag=%d\n", port_id, diag);
-
-}
-
 static inline void
 print_fdir_mask(struct rte_eth_fdir_masks *mask)
 {
@@ -1963,76 +1909,6 @@ fdir_get_infos(portid_t port_id)
 }
 
 void
-fdir_add_perfect_filter(portid_t port_id, uint16_t soft_id, uint8_t queue_id,
-			uint8_t drop, struct rte_fdir_filter *fdir_filter)
-{
-	int diag;
-
-	if (port_id_is_invalid(port_id))
-		return;
-
-	diag = rte_eth_dev_fdir_add_perfect_filter(port_id, fdir_filter,
-						   soft_id, queue_id, drop);
-	if (diag == 0)
-		return;
-
-	printf("rte_eth_dev_fdir_add_perfect_filter for port_id=%d failed "
-	       "diag=%d\n", port_id, diag);
-}
-
-void
-fdir_update_perfect_filter(portid_t port_id, uint16_t soft_id, uint8_t queue_id,
-			   uint8_t drop, struct rte_fdir_filter *fdir_filter)
-{
-	int diag;
-
-	if (port_id_is_invalid(port_id))
-		return;
-
-	diag = rte_eth_dev_fdir_update_perfect_filter(port_id, fdir_filter,
-						      soft_id, queue_id, drop);
-	if (diag == 0)
-		return;
-
-	printf("rte_eth_dev_fdir_update_perfect_filter for port_id=%d failed "
-	       "diag=%d\n", port_id, diag);
-}
-
-void
-fdir_remove_perfect_filter(portid_t port_id, uint16_t soft_id,
-			   struct rte_fdir_filter *fdir_filter)
-{
-	int diag;
-
-	if (port_id_is_invalid(port_id))
-		return;
-
-	diag = rte_eth_dev_fdir_remove_perfect_filter(port_id, fdir_filter,
-						      soft_id);
-	if (diag == 0)
-		return;
-
-	printf("rte_eth_dev_fdir_update_perfect_filter for port_id=%d failed "
-	       "diag=%d\n", port_id, diag);
-}
-
-void
-fdir_set_masks(portid_t port_id, struct rte_fdir_masks *fdir_masks)
-{
-	int diag;
-
-	if (port_id_is_invalid(port_id))
-		return;
-
-	diag = rte_eth_dev_fdir_set_masks(port_id, fdir_masks);
-	if (diag == 0)
-		return;
-
-	printf("rte_eth_dev_set_masks_filter for port_id=%d failed "
-	       "diag=%d\n", port_id, diag);
-}
-
-void
 fdir_set_flex_mask(portid_t port_id, struct rte_eth_fdir_flex_mask *cfg)
 {
 	struct rte_port *port;
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 8f5e6c7..25756e2 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -518,23 +518,7 @@ void close_port(portid_t pid);
 int all_ports_stopped(void);
 int port_is_started(portid_t port_id);
 void pmd_test_exit(void);
-
-void fdir_add_signature_filter(portid_t port_id, uint8_t queue_id,
-			       struct rte_fdir_filter *fdir_filter);
-void fdir_update_signature_filter(portid_t port_id, uint8_t queue_id,
-				  struct rte_fdir_filter *fdir_filter);
-void fdir_remove_signature_filter(portid_t port_id,
-				  struct rte_fdir_filter *fdir_filter);
 void fdir_get_infos(portid_t port_id);
-void fdir_add_perfect_filter(portid_t port_id, uint16_t soft_id,
-			     uint8_t queue_id, uint8_t drop,
-			     struct rte_fdir_filter *fdir_filter);
-void fdir_update_perfect_filter(portid_t port_id, uint16_t soft_id,
-				uint8_t queue_id, uint8_t drop,
-				struct rte_fdir_filter *fdir_filter);
-void fdir_remove_perfect_filter(portid_t port_id, uint16_t soft_id,
-				struct rte_fdir_filter *fdir_filter);
-void fdir_set_masks(portid_t port_id, struct rte_fdir_masks *fdir_masks);
 void fdir_set_flex_mask(portid_t port_id,
 			   struct rte_eth_fdir_flex_mask *cfg);
 void fdir_set_flex_payload(portid_t port_id,
-- 
1.9.3
^ permalink raw reply	[flat|nested] 18+ messages in thread
- * [dpdk-dev] [PATCH 15/15] doc: commands changed in testpmd_funcs.rst for flow director
  2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
                   ` (13 preceding siblings ...)
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 14/15] testpmd: remove old commands for flow director Jingjing Wu
@ 2015-01-29  5:29 ` Jingjing Wu
  2015-02-11  8:09 ` [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Zhang, Helin
  15 siblings, 0 replies; 18+ messages in thread
From: Jingjing Wu @ 2015-01-29  5:29 UTC (permalink / raw)
  To: dev
Following commands of flow director filter are removed:
  - add_signature_filter
  - upd_signature_filter
  - rm_signature_filter
  - add_perfect_filter
  - upd_perfect_filter
  - rm_perfect_filter
  - set_masks_filter
  - set_ipv6_masks_filter
New command is added to set flow director's mask:
  - flow_director_mask
Update arguments of commands:
  - flow_director_filter
  - flow_director_flex_mask
  - flow_director_flex_payload
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 287 ++++++++++------------------
 1 file changed, 100 insertions(+), 187 deletions(-)
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 218835a..70fe9ea 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -71,7 +71,6 @@ These are divided into sections and can be accessed using help, help section or
         help display    : Displaying port, stats and config information.
         help config     : Configuration information.
         help ports      : Configuring ports.
-        help flowdir    : Flow Director filter help.
         help registers  : Reading and setting port registers.
         help filters    : Filters configuration help.
         help all        : All of the above sections.
@@ -971,192 +970,6 @@ Where the threshold type can be:
 *   txrst: Set the transmit RS bit threshold of TX rings, 0 <= value <= txd.
     These threshold options are also available from the command-line.
 
-Flow Director Functions
------------------------
-
-The Flow Director works in receive mode to identify specific flows or sets of flows and route them to specific queues.
-
-Two types of filtering are supported which are referred to as Perfect Match and Signature filters:
-
-*   Perfect match filters.
-    The hardware checks a match between the masked fields of the received packets and the programmed filters.
-
-*   Signature filters.
-    The hardware checks a match between a hash-based signature of the masked fields of the received packet.
-
-The Flow Director filters can match the following fields in a packet:
-
-*   Source IP and destination IP addresses.
-
-*   Source port and destination port numbers (for UDP and TCP packets).
-
-*   IPv4/IPv6 and UDP/ TCP/SCTP protocol match.
-
-*   VLAN header.
-
-*   Flexible 2-byte tuple match anywhere in the first 64 bytes of the packet.
-
-The Flow Director can also mask out parts of all of these fields so that filters are only applied to certain fields
-or parts of the fields.
-For example it is possible to mask out sub-nets of IP addresses or to ignore VLAN headers.
-
-In the following sections, several common parameters are used in the Flow Director filters.
-These are explained below:
-
-*   src: A pair of source address values. The source IP, in IPv4 or IPv6 format, and the source port:
-
-    src 192.168.0.1 1024
-
-    src 2001:DB8:85A3:0:0:8A2E:370:7000 1024
-
-*   dst: A pair of destination address values. The destination IP, in IPv4 or IPv6 format, and the destination port.
-
-*   flexbytes: A 2-byte tuple to be matched within the first 64 bytes of a packet.
-
-The offset where the match occurs is set by the --pkt-filter-flexbytes-offset command-line parameter
-and is counted from the first byte of the destination Ethernet MAC address.
-The default offset is 0xC bytes, which is the "Type" word in the MAC header.
-Typically, the flexbyte value is set to 0x0800 to match the IPv4 MAC type or 0x86DD to match IPv6.
-These values change when a VLAN tag is added.
-
-*   vlan: The VLAN header to match in the packet.
-
-*   queue: The index of the RX queue to route matched packets to.
-
-*   soft: The 16-bit value in the MBUF flow director ID field for RX packets matching the filter.
-
-add_signature_filter
-~~~~~~~~~~~~~~~~~~~~
-
-Add a signature filter:
-
-# Command is displayed on several lines for clarity.
-
-add_signature_filter (port_id) (ip|udp|tcp|sctp)
-
-    src (src_ip_address) (src_port)
-
-    dst (dst_ip_address) (dst_port)
-
-    flexbytes (flexbytes_values)
-
-    vlan (vlan_id) queue (queue_id)
-
-upd_signature_filter
-~~~~~~~~~~~~~~~~~~~~
-
-Update a signature filter:
-
-# Command is displayed on several lines for clarity.
-
-upd_signature_filter (port_id) (ip|udp|tcp|sctp)
-
-    src (src_ip_address) (src_port)
-
-    dst (dst_ip_address) (dst_port)
-
-    flexbytes (flexbytes_values)
-
-    vlan (vlan_id) queue (queue_id)
-
-rm_signature_filter
-~~~~~~~~~~~~~~~~~~~
-
-Remove a signature filter:
-
-# Command is displayed on several lines for clarity.
-
-rm_signature_filter (port_id) (ip|udp|tcp|sctp)
-
-    src (src_ip_address) (src_port)
-
-    dst (dst_ip_address) (dst_port)
-
-    flexbytes (flexbytes_values)
-
-    vlan (vlan_id)
-
-add_perfect_filter
-~~~~~~~~~~~~~~~~~~
-
-Add a perfect filter:
-
-# Command is displayed on several lines for clarity.
-
-add_perfect_filter (port_id) (ip|udp|tcp|sctp)
-
-    src (src_ip_address) (src_port)
-
-    dst (dst_ip_address) (dst_port)
-
-    flexbytes (flexbytes_values)
-
-    vlan (vlan_id) queue (queue_id) soft (soft_id)
-
-upd_perfect_filter
-~~~~~~~~~~~~~~~~~~
-
-Update a perfect filter:
-
-# Command is displayed on several lines for clarity.
-
-upd_perfect_filter (port_id) (ip|udp|tcp|sctp)
-
-    src (src_ip_address) (src_port)
-
-    dst (dst_ip_address) (dst_port)
-
-    flexbytes (flexbytes_values)
-
-    vlan (vlan_id) queue (queue_id)
-
-rm_perfect_filter
-~~~~~~~~~~~~~~~~~
-
-Remove a perfect filter:
-
-rm_perfect_filter (port_id) (ip|udp|tcp|sctp)
-
-    src (src_ip_address) (src_port)
-
-    dst (dst_ip_address) (dst_port)
-
-    flexbytes (flexbytes_values)
-
-    vlan (vlan_id) soft (soft_id)
-
-set_masks_filter
-~~~~~~~~~~~~~~~~
-
-Set IPv4 filter masks:
-
-# Command is displayed on several lines for clarity.
-
-set_masks_filter (port_id) only_ip_flow (0|1)
-
-    src_mask (ip_src_mask) (src_port_mask)
-
-    dst_mask (ip_dst_mask) (dst_port_mask)
-
-    flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)
-
-set_ipv6_masks_filter
-~~~~~~~~~~~~~~~~~~~~~
-
-Set IPv6 filter masks:
-
-# Command is displayed on several lines for clarity.
-
-set_ipv6_masks_filter (port_id) only_ip_flow (0|1)
-
-    src_mask (ip_src_mask) (src_port_mask)
-
-    dst_mask (ip_dst_mask) (dst_port_mask)
-
-    flexbytes (0|1) vlan_id (0|1) vlan_prio (0|1)
-
-    compare_dst (0|1)
-
 Link Bonding Functions
 ----------------------
 
@@ -1663,3 +1476,103 @@ Example:
     0000000000000000000000000000000000000000000000000000000000
 
         priority: 3   queue: 3
+
+flow_director_filter
+~~~~~~~~~~~~~~~~~~~~
+
+The Flow Director works in receive mode to identify specific flows or sets of flows and route them to specific queues.
+
+Two types of filtering are supported which are referred to as Perfect Match and Signature filters, the match mode
+is set by the --pkt-filter-mode command-line parameter:
+
+*   Perfect match filters.
+    The hardware checks a match between the masked fields of the received packets and the programmed filters.
+
+*   Signature filters.
+    The hardware checks a match between a hash-based signature of the masked fields of the received packet.
+
+The Flow Director filters can match the different fields for different type of packet: flow type, specific input set
+per flow type and the flexible payload. The Flow Director can also mask out parts of all of these fields so that filters
+are only applied to certain fields or parts of the fields.
+
+Different NICs may have different capabilities, command show port fdir (port_id) can be used to acquire the information.
+
+# Commands to add flow director filters of different flow types.
+
+flow_director_filter (port_id) (add|del|update) flow (ip4|ip4-frag|ip6|ip6-frag)
+src (src_ip_address) dst (dst_ip_address) vlan (vlan_value) flexbytes (flexbytes_value)
+(drop|fwd) queue (queue_id) fd_id (fd_id_value)
+
+flow_director_filter (port_id) (add|del|update) flow (udp4|tcp4|udp6|tcp6)
+src (src_ip_address) (src_port) dst (dst_ip_address) (dst_port) vlan (vlan_value)
+flexbytes (flexbytes_value) (drop|fwd) queue (queue_id) fd_id (fd_id_value)
+
+flow_director_filter (port_id) (add|del|update) flow (sctp4|sctp6)
+src (src_ip_address) (src_port) dst (dst_ip_address) (dst_port) tag (verification_tag)
+vlan (vlan_value) flexbytes (flexbytes_value) (drop|fwd) queue (queue_id) fd_id (fd_id_value)
+
+For example, to add an udp flow type filter:
+
+.. code-block:: console
+
+    testpmd> flow_director_filter 0 add flow udp4 src 2.2.2.3 32 dst 2.2.2.5 33 vlan 0x1 flexbytes (0x88,0x48) fwd queue 1 fd_id 1
+
+For example, add an ip4 flow type filter:
+
+.. code-block:: console
+
+    testpmd> flow_director_filter 0 add flow ip4 src 2.2.2.3 dst 2.2.2.5 vlan 0x1 flexbytes (0x88,0x48) fwd queue 1 fd_id 1
+
+flush_flow_director
+~~~~~~~~~~~~~~~~~~~
+
+flush all flow director filters on a device:
+
+flush_flow_director (port_id)
+
+Example, to flush all flow director filter on port 0:
+
+.. code-block:: console
+
+   testpmd> flush_flow_director 0
+
+flow_director_mask
+~~~~~~~~~~~~~~~~~~
+
+set flow director's masks on match input set
+
+flow_director_mask (port_id) vlan (vlan_value) src_mask (ipv4_src) (ipv6_src) (src_port) dst_mask (ipv4_dst) (ipv6_dst) (dst_port)
+
+Example, to set flow director mask on port 0:
+
+.. code-block:: console
+
+   testpmd> flow_director_mask 0 vlan 0xefff src_mask 255.255.255.255 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 0xFFFF dst_mask 255.255.255.255 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 0xFFFF
+
+
+flow_director_flex_mask
+~~~~~~~~~~~~~~~~~~~~~~~
+
+set masks of flow director's flexible payload based on certain flow type:
+
+flow_director_flex_mask (port_id) flow (raw|ip4|ip4-frag|tcp4|udp4|sctp4|ip6|ip6-frag|tcp6|udp6|sctp6|all) (mask)
+
+Example, to set flow director's udpv4 flex mask on port 0:
+
+.. code-block:: console
+
+   testpmd> flow_director_flex_mask 0 flow all (0xff,0xff,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
+
+
+flow_director_flex_payload
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Configure flexible payload selection.
+
+flow_director_flex_payload (port_id) (raw|l2|l3|l4) (config)
+
+For example, to select the first 16 bytes from the offset 4 (bytes) of packet’s payload as flexible payload.
+
+.. code-block:: console
+
+   testpmd> flow_director_flex_payload 0 l4 (4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19)
-- 
1.9.3
^ permalink raw reply	[flat|nested] 18+ messages in thread
- * Re: [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API
  2015-01-29  5:29 [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Jingjing Wu
                   ` (14 preceding siblings ...)
  2015-01-29  5:29 ` [dpdk-dev] [PATCH 15/15] doc: commands changed in testpmd_funcs.rst " Jingjing Wu
@ 2015-02-11  8:09 ` Zhang, Helin
  2015-02-22  1:04   ` Thomas Monjalon
  15 siblings, 1 reply; 18+ messages in thread
From: Zhang, Helin @ 2015-02-11  8:09 UTC (permalink / raw)
  To: Wu, Jingjing, dev
> -----Original Message-----
> From: Wu, Jingjing
> Sent: Thursday, January 29, 2015 1:29 PM
> To: dev@dpdk.org
> Cc: Wu, Jingjing; Zhang, Helin; Liu, Jijiang; Mcnamara, John; Cao, Min; Xu,
> HuilongX
> Subject: [PATCH 00/15] migrate flow director in ixgbe driver to new API
> 
> The patch set uses new filter_ctrl API to replace old flow director filter APIs.
> It uses new functions and structure to replace old ones in ixgbe driver, updates
> commands to replace old ones in testpmd, and removes the old APIs
> 
> Jingjing Wu (15):
>   ixgbe: migrate flow director filter operations (add/delete/update) to
>     new API
>   ethdev: extend flow type and flexible payload type definition for flow
>     director
>   ixgbe: implement the flexpayload configuration of flow director filter
>   app/test: remove the flexbytes_offset setting in test_link_bonding
>   testpmd: remove the flexbytes_offset setting
>   ethdev: remove flexbytes_offset from rte_fdir_conf
>   ethdev: structures definition for flow director masks
>   ixgbe: implement the mask configuration of flow director filter
>   ixgbe: implement the get info and statistic operations of flow
>     director
>   ixgbe: implement the flush operation of flow director
>   testpmd: add and update commands for flow director
>   testpmd: update function to show flow director information
>   testpmd: set the default value of flow director's mask
>   testpmd: remove old commands for flow director
>   doc: commands changed in testpmd_funcs.rst for flow director
> 
>  app/test-pmd/cmdline.c                      |  755 ++++-------------
>  app/test-pmd/config.c                       |  197 +----
>  app/test-pmd/parameters.c                   |   16 -
>  app/test-pmd/testpmd.c                      |   14 +-
>  app/test-pmd/testpmd.h                      |   16 -
>  app/test/test_link_bonding.c                |    1 -
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  287 +++----
>  lib/librte_ether/rte_eth_ctrl.h             |   15 +
>  lib/librte_ether/rte_ethdev.h               |    3 +-
>  lib/librte_pmd_ixgbe/ixgbe_ethdev.c         |   11 +-
>  lib/librte_pmd_ixgbe/ixgbe_ethdev.h         |   43 +-
>  lib/librte_pmd_ixgbe/ixgbe_fdir.c           | 1169
> ++++++++++++++++-----------
>  12 files changed, 1054 insertions(+), 1473 deletions(-)
> 
> --
> 1.9.3
Acked-by: Helin Zhang <helin.zhang@intel.com>
Note that there is dependency on "[PATCH v2 0/7] unified flow types and RSS offload types".
That unified flow types and rss offload types should be merged first, and then rework is needed.
^ permalink raw reply	[flat|nested] 18+ messages in thread
- * Re: [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API
  2015-02-11  8:09 ` [dpdk-dev] [PATCH 00/15] migrate flow director in ixgbe driver to new API Zhang, Helin
@ 2015-02-22  1:04   ` Thomas Monjalon
  0 siblings, 0 replies; 18+ messages in thread
From: Thomas Monjalon @ 2015-02-22  1:04 UTC (permalink / raw)
  To: Wu, Jingjing; +Cc: dev
> > The patch set uses new filter_ctrl API to replace old flow director filter APIs.
> > It uses new functions and structure to replace old ones in ixgbe driver, updates
> > commands to replace old ones in testpmd, and removes the old APIs
> > 
> > Jingjing Wu (15):
> >   ixgbe: migrate flow director filter operations (add/delete/update) to
> >     new API
> >   ethdev: extend flow type and flexible payload type definition for flow
> >     director
> >   ixgbe: implement the flexpayload configuration of flow director filter
> >   app/test: remove the flexbytes_offset setting in test_link_bonding
> >   testpmd: remove the flexbytes_offset setting
> >   ethdev: remove flexbytes_offset from rte_fdir_conf
> >   ethdev: structures definition for flow director masks
> >   ixgbe: implement the mask configuration of flow director filter
> >   ixgbe: implement the get info and statistic operations of flow
> >     director
> >   ixgbe: implement the flush operation of flow director
> >   testpmd: add and update commands for flow director
> >   testpmd: update function to show flow director information
> >   testpmd: set the default value of flow director's mask
> >   testpmd: remove old commands for flow director
> >   doc: commands changed in testpmd_funcs.rst for flow director
> 
> Acked-by: Helin Zhang <helin.zhang@intel.com>
Applied, thanks.
Some patches were merged (example: doc update with matching code update).
Now we wait for enic to be converted to the new flow director API,
in order to remove the old API.
^ permalink raw reply	[flat|nested] 18+ messages in thread