* [dpdk-dev] [PATCH] net/i40e: add support for packet template to flow director
@ 2017-10-19 9:00 Kirill Rybalchenko
2017-10-23 22:11 ` Ferruh Yigit
2017-10-24 14:08 ` [dpdk-dev] [PATCH v2] " Kirill Rybalchenko
0 siblings, 2 replies; 5+ messages in thread
From: Kirill Rybalchenko @ 2017-10-19 9:00 UTC (permalink / raw)
To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu
For complex packets use raw flow type with pre-constructed packet buffer
instead of creating a packet internally in PMD.
Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
drivers/net/i40e/i40e_ethdev.h | 9 +++++
drivers/net/i40e/i40e_fdir.c | 56 ++++++++++++++++++++++++-----
drivers/net/i40e/rte_pmd_i40e.c | 28 +++++++++++++++
drivers/net/i40e/rte_pmd_i40e.h | 58 +++++++++++++++++++++++++++++++
drivers/net/i40e/rte_pmd_i40e_version.map | 1 +
5 files changed, 144 insertions(+), 8 deletions(-)
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 2f1905e..cd67453 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -485,6 +485,13 @@ struct i40e_gtp_ipv6_flow {
struct rte_eth_ipv6_flow ip6;
};
+/* A structure used to define the input for raw type flow */
+struct i40e_raw_flow {
+ uint16_t pctype;
+ void *packet;
+ uint32_t length;
+};
+
/*
* A union contains the inputs for all types of flow
* items in flows need to be in big endian
@@ -502,6 +509,7 @@ union i40e_fdir_flow {
struct i40e_gtp_flow gtp_flow;
struct i40e_gtp_ipv4_flow gtp_ipv4_flow;
struct i40e_gtp_ipv6_flow gtp_ipv6_flow;
+ struct i40e_raw_flow raw_flow;
};
enum i40e_fdir_ip_type {
@@ -519,6 +527,7 @@ struct i40e_fdir_flow_ext {
bool inner_ip; /* If there is inner ip */
enum i40e_fdir_ip_type iip_type; /* ip type for inner ip */
bool customized_pctype; /* If customized pctype is used */
+ bool pkt_template; /* If raw packet template is used */
};
/* A structure used to define the input for a flow director filter entry */
diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index 491c643..395c9ac 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -49,6 +49,7 @@
#include <rte_udp.h>
#include <rte_tcp.h>
#include <rte_sctp.h>
+#include <rte_hash_crc.h>
#include "i40e_logs.h"
#include "base/i40e_type.h"
@@ -1113,6 +1114,13 @@ i40e_flow_fdir_construct_pkt(struct i40e_pf *pf,
uint8_t pctype = fdir_input->pctype;
struct i40e_customized_pctype *cus_pctype;
+ /* raw pcket template - just copy contents of the raw packet */
+ if (fdir_input->flow_ext.pkt_template) {
+ memcpy(raw_pkt, fdir_input->flow.raw_flow.packet,
+ fdir_input->flow.raw_flow.length);
+ return 0;
+ }
+
/* fill the ethernet and IP head */
len = i40e_flow_fdir_fill_eth_ip_head(pf, fdir_input, raw_pkt,
!!fdir_input->flow_ext.vlan_tci);
@@ -1370,6 +1378,13 @@ i40e_fdir_filter_convert(const struct i40e_fdir_filter_conf *input,
struct i40e_fdir_filter *filter)
{
rte_memcpy(&filter->fdir, input, sizeof(struct i40e_fdir_filter_conf));
+ if (input->input.flow_ext.pkt_template) {
+ filter->fdir.input.flow.raw_flow.packet = NULL;
+ filter->fdir.input.flow.raw_flow.length =
+ rte_hash_crc(input->input.flow.raw_flow.packet,
+ input->input.flow.raw_flow.length,
+ input->input.flow.raw_flow.pctype);
+ }
return 0;
}
@@ -1380,7 +1395,13 @@ i40e_sw_fdir_filter_lookup(struct i40e_fdir_info *fdir_info,
{
int ret;
- ret = rte_hash_lookup(fdir_info->hash_table, (const void *)input);
+ if (input->flow_ext.pkt_template)
+ ret = rte_hash_lookup_with_hash(fdir_info->hash_table,
+ (const void *)input,
+ input->flow.raw_flow.length);
+ else
+ ret = rte_hash_lookup(fdir_info->hash_table,
+ (const void *)input);
if (ret < 0)
return NULL;
@@ -1394,8 +1415,13 @@ i40e_sw_fdir_filter_insert(struct i40e_pf *pf, struct i40e_fdir_filter *filter)
struct i40e_fdir_info *fdir_info = &pf->fdir;
int ret;
- ret = rte_hash_add_key(fdir_info->hash_table,
- &filter->fdir.input);
+ if (filter->fdir.input.flow_ext.pkt_template)
+ ret = rte_hash_add_key_with_hash(fdir_info->hash_table,
+ &filter->fdir.input,
+ filter->fdir.input.flow.raw_flow.length);
+ else
+ ret = rte_hash_add_key(fdir_info->hash_table,
+ &filter->fdir.input);
if (ret < 0) {
PMD_DRV_LOG(ERR,
"Failed to insert fdir filter to hash table %d!",
@@ -1417,7 +1443,12 @@ i40e_sw_fdir_filter_del(struct i40e_pf *pf, struct i40e_fdir_input *input)
struct i40e_fdir_filter *filter;
int ret;
- ret = rte_hash_del_key(fdir_info->hash_table, input);
+ if (input->flow_ext.pkt_template)
+ ret = rte_hash_del_key_with_hash(fdir_info->hash_table,
+ input,
+ input->flow.raw_flow.length);
+ else
+ ret = rte_hash_del_key(fdir_info->hash_table, input);
if (ret < 0) {
PMD_DRV_LOG(ERR,
"Failed to delete fdir filter to hash table %d!",
@@ -1529,6 +1560,17 @@ i40e_flow_add_del_fdir_filter(struct rte_eth_dev *dev,
PMD_DRV_LOG(ERR, "Invalid VF ID");
return -EINVAL;
}
+ if (filter->input.flow_ext.pkt_template) {
+ if (filter->input.flow.raw_flow.length > I40E_FDIR_PKT_LEN ||
+ !filter->input.flow.raw_flow.packet) {
+ PMD_DRV_LOG(ERR, "Invalid raw packet template"
+ " flow filter parameters!");
+ return -EINVAL;
+ }
+ pctype = filter->input.flow.raw_flow.pctype;
+ } else {
+ pctype = filter->input.pctype;
+ }
/* Check if there is the filter in SW list */
memset(&check_filter, 0, sizeof(check_filter));
@@ -1557,10 +1599,8 @@ i40e_flow_add_del_fdir_filter(struct rte_eth_dev *dev,
if (hw->mac.type == I40E_MAC_X722) {
/* get translated pctype value in fd pctype register */
pctype = (enum i40e_filter_pctype)i40e_read_rx_ctl(
- hw, I40E_GLQF_FD_PCTYPES(
- (int)filter->input.pctype));
- } else
- pctype = filter->input.pctype;
+ hw, I40E_GLQF_FD_PCTYPES((int)pctype));
+ }
ret = i40e_flow_fdir_filter_programming(pf, pctype, filter, add);
if (ret < 0) {
diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index 4881ea0..8357537 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -2954,3 +2954,31 @@ int rte_pmd_i40e_rss_queue_region_conf(uint16_t port_id,
return ret;
}
+
+int rte_pmd_i40e_flow_add_del_packet_template(
+ uint16_t port,
+ const struct rte_pmd_i40e_pkt_template_conf *conf,
+ uint8_t add)
+{
+ struct rte_eth_dev *dev = &rte_eth_devices[port];
+ struct i40e_fdir_filter_conf filter_conf;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+ if (!is_i40e_supported(dev))
+ return -ENOTSUP;
+
+ memset(&filter_conf, 0, sizeof(filter_conf));
+ filter_conf.soft_id = conf->soft_id;
+ filter_conf.input.flow.raw_flow.pctype = conf->input.pctype;
+ filter_conf.input.flow.raw_flow.packet = conf->input.packet;
+ filter_conf.input.flow.raw_flow.length = conf->input.length;
+ filter_conf.input.flow_ext.pkt_template = true;
+
+ filter_conf.action.rx_queue = conf->action.rx_queue;
+ filter_conf.action.behavior = conf->action.behavior;
+ filter_conf.action.report_status = conf->action.report_status;
+ filter_conf.action.flex_off = conf->action.flex_off;
+
+ return i40e_flow_add_del_fdir_filter(dev, &filter_conf, add);
+}
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 467b415..fd744af 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -250,6 +250,64 @@ struct rte_pmd_i40e_queue_regions {
region[RTE_PMD_I40E_REGION_MAX_NUM];
};
+/* Behavior will be taken if raw packet template is matched. */
+enum rte_pmd_i40e_pkt_template_behavior {
+ RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT = 0,
+ RTE_PMD_I40E_PKT_TEMPLATE_REJECT,
+ RTE_PMD_I40E_PKT_TEMPLATE_PASSTHRU,
+};
+
+/* Flow director report status
+ * It defines what will be reported if raw packet template is matched.
+ */
+enum rte_pmd_i40e_pkt_template_status {
+ RTE_PMD_I40E_PKT_TEMPLATE_NO_REPORT_STATUS = 0,
+ RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID,
+ RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID_FLEX_4,
+ RTE_PMD_I40E_PKT_TEMPLATE_REPORT_FLEX_8,
+};
+
+/* A structure used to define an action when raw packet template is matched. */
+struct rte_pmd_i40e_pkt_template_action {
+ uint16_t rx_queue;
+ enum rte_pmd_i40e_pkt_template_behavior behavior;
+ enum rte_pmd_i40e_pkt_template_status report_status;
+ uint8_t flex_off;
+};
+
+/* A structure used to define the input for raw packet template. */
+struct rte_pmd_i40e_pkt_template_input {
+ uint16_t pctype; /* pctype used for raw packet template. */
+ void *packet; /* Buffer conatining raw packet template. */
+ uint32_t length; /* Length of buffer with raw packet template. */
+};
+
+struct rte_pmd_i40e_pkt_template_conf {
+ struct rte_pmd_i40e_pkt_template_input input;
+ struct rte_pmd_i40e_pkt_template_action action;
+ uint32_t soft_id;
+};
+
+/**
+ * Add/remove raw packet template filter to Flow Director.
+ *
+ * @param port
+ * The port identifier of the Ethernet device.
+ * @param conf
+ * Specifies configuration parameters of raw packet template filter.
+ * @param add
+ * Speicifes an action to be taken - add or remove raw packet template filter.
+ * @return
+ * - (0) if successful.
+ * - (-ENODEV) if *port* invalid.
+ * - (-EINVAL) if *conf* invalid.
+ * - (-ENOTSUP) not supported by firmware.
+ */
+int rte_pmd_i40e_flow_add_del_packet_template(
+ uint16_t port,
+ const struct rte_pmd_i40e_pkt_template_conf *conf,
+ uint8_t add);
+
/**
* Notify VF when PF link status changes.
*
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index 1d34f6c..5117ec6 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -55,5 +55,6 @@ DPDK_17.11 {
rte_pmd_i40e_flow_type_mapping_reset;
rte_pmd_i40e_query_vfid_by_mac;
rte_pmd_i40e_rss_queue_region_conf;
+ rte_pmd_i40e_flow_add_del_packet_template;
} DPDK_17.08;
--
2.5.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH] net/i40e: add support for packet template to flow director
2017-10-19 9:00 [dpdk-dev] [PATCH] net/i40e: add support for packet template to flow director Kirill Rybalchenko
@ 2017-10-23 22:11 ` Ferruh Yigit
2017-10-24 14:08 ` [dpdk-dev] [PATCH v2] " Kirill Rybalchenko
1 sibling, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2017-10-23 22:11 UTC (permalink / raw)
To: Kirill Rybalchenko, dev; +Cc: andrey.chilikin, beilei.xing, jingjing.wu
On 10/19/2017 2:00 AM, Kirill Rybalchenko wrote:
> For complex packets use raw flow type with pre-constructed packet buffer
> instead of creating a packet internally in PMD.
>
> Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
<...>
> diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
> index 467b415..fd744af 100644
> --- a/drivers/net/i40e/rte_pmd_i40e.h
> +++ b/drivers/net/i40e/rte_pmd_i40e.h
> @@ -250,6 +250,64 @@ struct rte_pmd_i40e_queue_regions {
> region[RTE_PMD_I40E_REGION_MAX_NUM];
> };
>
> +/* Behavior will be taken if raw packet template is matched. */
> +enum rte_pmd_i40e_pkt_template_behavior {
> + RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT = 0,
Assignment is not required, it is zero by default.
> + RTE_PMD_I40E_PKT_TEMPLATE_REJECT,
> + RTE_PMD_I40E_PKT_TEMPLATE_PASSTHRU,
> +};
> +
> +/* Flow director report status
> + * It defines what will be reported if raw packet template is matched.
> + */
> +enum rte_pmd_i40e_pkt_template_status {
> + RTE_PMD_I40E_PKT_TEMPLATE_NO_REPORT_STATUS = 0,
> + RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID,
> + RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID_FLEX_4,
> + RTE_PMD_I40E_PKT_TEMPLATE_REPORT_FLEX_8,
> +};
> +
> +/* A structure used to define an action when raw packet template is matched. */
> +struct rte_pmd_i40e_pkt_template_action {
> + uint16_t rx_queue;
> + enum rte_pmd_i40e_pkt_template_behavior behavior;
> + enum rte_pmd_i40e_pkt_template_status report_status;
> + uint8_t flex_off;
> +};
> +
> +/* A structure used to define the input for raw packet template. */
> +struct rte_pmd_i40e_pkt_template_input {
> + uint16_t pctype; /* pctype used for raw packet template. */
> + void *packet; /* Buffer conatining raw packet template. */
> + uint32_t length; /* Length of buffer with raw packet template. */
> +};
> +
> +struct rte_pmd_i40e_pkt_template_conf {
> + struct rte_pmd_i40e_pkt_template_input input;
> + struct rte_pmd_i40e_pkt_template_action action;
> + uint32_t soft_id;
> +};
These are in public header now. Can you please document structs and elements of
them via doxygen style comments?
Thanks,
ferruh
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH v2] net/i40e: add support for packet template to flow director
2017-10-19 9:00 [dpdk-dev] [PATCH] net/i40e: add support for packet template to flow director Kirill Rybalchenko
2017-10-23 22:11 ` Ferruh Yigit
@ 2017-10-24 14:08 ` Kirill Rybalchenko
2017-10-24 18:02 ` Ferruh Yigit
1 sibling, 1 reply; 5+ messages in thread
From: Kirill Rybalchenko @ 2017-10-24 14:08 UTC (permalink / raw)
To: dev; +Cc: kirill.rybalchenko, andrey.chilikin, beilei.xing, jingjing.wu
For complex packets use raw flow type with pre-constructed packet buffer
instead of creating a packet internally in PMD.
v2:
Fix documentation according to doxygen style comments.
Fix compilation warnings for clang target.
Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
---
drivers/net/i40e/i40e_ethdev.h | 9 ++++
drivers/net/i40e/i40e_fdir.c | 56 +++++++++++++++++---
drivers/net/i40e/rte_pmd_i40e.c | 30 +++++++++++
drivers/net/i40e/rte_pmd_i40e.h | 87 +++++++++++++++++++++++++++++++
drivers/net/i40e/rte_pmd_i40e_version.map | 1 +
5 files changed, 175 insertions(+), 8 deletions(-)
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 2f1905e..cd67453 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -485,6 +485,13 @@ struct i40e_gtp_ipv6_flow {
struct rte_eth_ipv6_flow ip6;
};
+/* A structure used to define the input for raw type flow */
+struct i40e_raw_flow {
+ uint16_t pctype;
+ void *packet;
+ uint32_t length;
+};
+
/*
* A union contains the inputs for all types of flow
* items in flows need to be in big endian
@@ -502,6 +509,7 @@ union i40e_fdir_flow {
struct i40e_gtp_flow gtp_flow;
struct i40e_gtp_ipv4_flow gtp_ipv4_flow;
struct i40e_gtp_ipv6_flow gtp_ipv6_flow;
+ struct i40e_raw_flow raw_flow;
};
enum i40e_fdir_ip_type {
@@ -519,6 +527,7 @@ struct i40e_fdir_flow_ext {
bool inner_ip; /* If there is inner ip */
enum i40e_fdir_ip_type iip_type; /* ip type for inner ip */
bool customized_pctype; /* If customized pctype is used */
+ bool pkt_template; /* If raw packet template is used */
};
/* A structure used to define the input for a flow director filter entry */
diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index 491c643..395c9ac 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -49,6 +49,7 @@
#include <rte_udp.h>
#include <rte_tcp.h>
#include <rte_sctp.h>
+#include <rte_hash_crc.h>
#include "i40e_logs.h"
#include "base/i40e_type.h"
@@ -1113,6 +1114,13 @@ i40e_flow_fdir_construct_pkt(struct i40e_pf *pf,
uint8_t pctype = fdir_input->pctype;
struct i40e_customized_pctype *cus_pctype;
+ /* raw pcket template - just copy contents of the raw packet */
+ if (fdir_input->flow_ext.pkt_template) {
+ memcpy(raw_pkt, fdir_input->flow.raw_flow.packet,
+ fdir_input->flow.raw_flow.length);
+ return 0;
+ }
+
/* fill the ethernet and IP head */
len = i40e_flow_fdir_fill_eth_ip_head(pf, fdir_input, raw_pkt,
!!fdir_input->flow_ext.vlan_tci);
@@ -1370,6 +1378,13 @@ i40e_fdir_filter_convert(const struct i40e_fdir_filter_conf *input,
struct i40e_fdir_filter *filter)
{
rte_memcpy(&filter->fdir, input, sizeof(struct i40e_fdir_filter_conf));
+ if (input->input.flow_ext.pkt_template) {
+ filter->fdir.input.flow.raw_flow.packet = NULL;
+ filter->fdir.input.flow.raw_flow.length =
+ rte_hash_crc(input->input.flow.raw_flow.packet,
+ input->input.flow.raw_flow.length,
+ input->input.flow.raw_flow.pctype);
+ }
return 0;
}
@@ -1380,7 +1395,13 @@ i40e_sw_fdir_filter_lookup(struct i40e_fdir_info *fdir_info,
{
int ret;
- ret = rte_hash_lookup(fdir_info->hash_table, (const void *)input);
+ if (input->flow_ext.pkt_template)
+ ret = rte_hash_lookup_with_hash(fdir_info->hash_table,
+ (const void *)input,
+ input->flow.raw_flow.length);
+ else
+ ret = rte_hash_lookup(fdir_info->hash_table,
+ (const void *)input);
if (ret < 0)
return NULL;
@@ -1394,8 +1415,13 @@ i40e_sw_fdir_filter_insert(struct i40e_pf *pf, struct i40e_fdir_filter *filter)
struct i40e_fdir_info *fdir_info = &pf->fdir;
int ret;
- ret = rte_hash_add_key(fdir_info->hash_table,
- &filter->fdir.input);
+ if (filter->fdir.input.flow_ext.pkt_template)
+ ret = rte_hash_add_key_with_hash(fdir_info->hash_table,
+ &filter->fdir.input,
+ filter->fdir.input.flow.raw_flow.length);
+ else
+ ret = rte_hash_add_key(fdir_info->hash_table,
+ &filter->fdir.input);
if (ret < 0) {
PMD_DRV_LOG(ERR,
"Failed to insert fdir filter to hash table %d!",
@@ -1417,7 +1443,12 @@ i40e_sw_fdir_filter_del(struct i40e_pf *pf, struct i40e_fdir_input *input)
struct i40e_fdir_filter *filter;
int ret;
- ret = rte_hash_del_key(fdir_info->hash_table, input);
+ if (input->flow_ext.pkt_template)
+ ret = rte_hash_del_key_with_hash(fdir_info->hash_table,
+ input,
+ input->flow.raw_flow.length);
+ else
+ ret = rte_hash_del_key(fdir_info->hash_table, input);
if (ret < 0) {
PMD_DRV_LOG(ERR,
"Failed to delete fdir filter to hash table %d!",
@@ -1529,6 +1560,17 @@ i40e_flow_add_del_fdir_filter(struct rte_eth_dev *dev,
PMD_DRV_LOG(ERR, "Invalid VF ID");
return -EINVAL;
}
+ if (filter->input.flow_ext.pkt_template) {
+ if (filter->input.flow.raw_flow.length > I40E_FDIR_PKT_LEN ||
+ !filter->input.flow.raw_flow.packet) {
+ PMD_DRV_LOG(ERR, "Invalid raw packet template"
+ " flow filter parameters!");
+ return -EINVAL;
+ }
+ pctype = filter->input.flow.raw_flow.pctype;
+ } else {
+ pctype = filter->input.pctype;
+ }
/* Check if there is the filter in SW list */
memset(&check_filter, 0, sizeof(check_filter));
@@ -1557,10 +1599,8 @@ i40e_flow_add_del_fdir_filter(struct rte_eth_dev *dev,
if (hw->mac.type == I40E_MAC_X722) {
/* get translated pctype value in fd pctype register */
pctype = (enum i40e_filter_pctype)i40e_read_rx_ctl(
- hw, I40E_GLQF_FD_PCTYPES(
- (int)filter->input.pctype));
- } else
- pctype = filter->input.pctype;
+ hw, I40E_GLQF_FD_PCTYPES((int)pctype));
+ }
ret = i40e_flow_fdir_filter_programming(pf, pctype, filter, add);
if (ret < 0) {
diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index 4881ea0..a4c6761 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -2954,3 +2954,33 @@ int rte_pmd_i40e_rss_queue_region_conf(uint16_t port_id,
return ret;
}
+
+int rte_pmd_i40e_flow_add_del_packet_template(
+ uint16_t port,
+ const struct rte_pmd_i40e_pkt_template_conf *conf,
+ uint8_t add)
+{
+ struct rte_eth_dev *dev = &rte_eth_devices[port];
+ struct i40e_fdir_filter_conf filter_conf;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+ if (!is_i40e_supported(dev))
+ return -ENOTSUP;
+
+ memset(&filter_conf, 0, sizeof(filter_conf));
+ filter_conf.soft_id = conf->soft_id;
+ filter_conf.input.flow.raw_flow.pctype = conf->input.pctype;
+ filter_conf.input.flow.raw_flow.packet = conf->input.packet;
+ filter_conf.input.flow.raw_flow.length = conf->input.length;
+ filter_conf.input.flow_ext.pkt_template = true;
+
+ filter_conf.action.rx_queue = conf->action.rx_queue;
+ filter_conf.action.behavior =
+ (enum i40e_fdir_behavior)conf->action.behavior;
+ filter_conf.action.report_status =
+ (enum i40e_fdir_status)conf->action.report_status;
+ filter_conf.action.flex_off = conf->action.flex_off;
+
+ return i40e_flow_add_del_fdir_filter(dev, &filter_conf, add);
+}
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 467b415..01c68ff 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -251,6 +251,93 @@ struct rte_pmd_i40e_queue_regions {
};
/**
+ * Behavior will be taken if raw packet template is matched.
+ */
+enum rte_pmd_i40e_pkt_template_behavior {
+ RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT,
+ RTE_PMD_I40E_PKT_TEMPLATE_REJECT,
+ RTE_PMD_I40E_PKT_TEMPLATE_PASSTHRU,
+};
+
+/**
+ * Flow director report status
+ * It defines what will be reported if raw packet template is matched.
+ */
+enum rte_pmd_i40e_pkt_template_status {
+ /** report nothing */
+ RTE_PMD_I40E_PKT_TEMPLATE_NO_REPORT_STATUS = 0,
+ /** only report FD ID */
+ RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID,
+ /** report FD ID and 4 flex bytes */
+ RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID_FLEX_4,
+ /** report 8 flex bytes */
+ RTE_PMD_I40E_PKT_TEMPLATE_REPORT_FLEX_8,
+};
+
+/**
+ * A structure used to define an action when raw packet template is matched.
+ */
+struct rte_pmd_i40e_pkt_template_action {
+ /** queue assigned to if raw packet template match */
+ uint16_t rx_queue;
+ /** behavior will be taken */
+ enum rte_pmd_i40e_pkt_template_behavior behavior;
+ /** status report option */
+ enum rte_pmd_i40e_pkt_template_status report_status;
+ /**
+ * If report_status is RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID_FLEX_4 or
+ * RTE_PMD_I40E_PKT_TEMPLATE_REPORT_FLEX_8, flex_off specifies
+ * where the reported flex bytes start from in flexible payload.
+ */
+ uint8_t flex_off;
+};
+
+/**
+ * A structure used to define the input for raw packet template.
+ */
+struct rte_pmd_i40e_pkt_template_input {
+ /** the pctype used for raw packet template */
+ uint16_t pctype;
+ /** the buffer conatining raw packet template */
+ void *packet;
+ /** the length of buffer with raw packet template */
+ uint32_t length;
+};
+
+/**
+ * A structure used to define the configuration parameters
+ * for raw packet template.
+ */
+struct rte_pmd_i40e_pkt_template_conf {
+ /** the input for raw packet template. */
+ struct rte_pmd_i40e_pkt_template_input input;
+ /** the action to be taken when raw packet template is matched */
+ struct rte_pmd_i40e_pkt_template_action action;
+ /** ID, an unique software index for the raw packet template filter */
+ uint32_t soft_id;
+};
+
+/**
+ * Add or remove raw packet template filter to Flow Director.
+ *
+ * @param port
+ * The port identifier of the Ethernet device.
+ * @param conf
+ * Specifies configuration parameters of raw packet template filter.
+ * @param add
+ * Speicifes an action to be taken - add or remove raw packet template filter.
+ * @return
+ * - (0) if successful.
+ * - (-ENODEV) if *port* invalid.
+ * - (-EINVAL) if *conf* invalid.
+ * - (-ENOTSUP) not supported by firmware.
+ */
+int rte_pmd_i40e_flow_add_del_packet_template(
+ uint16_t port,
+ const struct rte_pmd_i40e_pkt_template_conf *conf,
+ uint8_t add);
+
+/**
* Notify VF when PF link status changes.
*
* @param port
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index 1d34f6c..5117ec6 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -55,5 +55,6 @@ DPDK_17.11 {
rte_pmd_i40e_flow_type_mapping_reset;
rte_pmd_i40e_query_vfid_by_mac;
rte_pmd_i40e_rss_queue_region_conf;
+ rte_pmd_i40e_flow_add_del_packet_template;
} DPDK_17.08;
--
2.5.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH v2] net/i40e: add support for packet template to flow director
2017-10-24 14:08 ` [dpdk-dev] [PATCH v2] " Kirill Rybalchenko
@ 2017-10-24 18:02 ` Ferruh Yigit
2017-10-24 18:07 ` Ferruh Yigit
0 siblings, 1 reply; 5+ messages in thread
From: Ferruh Yigit @ 2017-10-24 18:02 UTC (permalink / raw)
To: Kirill Rybalchenko, dev; +Cc: andrey.chilikin, beilei.xing, jingjing.wu
On 10/24/2017 7:08 AM, Kirill Rybalchenko wrote:
> For complex packets use raw flow type with pre-constructed packet buffer
> instead of creating a packet internally in PMD.
>
> v2:
>
> Fix documentation according to doxygen style comments.
> Fix compilation warnings for clang target.
>
> Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH v2] net/i40e: add support for packet template to flow director
2017-10-24 18:02 ` Ferruh Yigit
@ 2017-10-24 18:07 ` Ferruh Yigit
0 siblings, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2017-10-24 18:07 UTC (permalink / raw)
To: Kirill Rybalchenko, dev; +Cc: andrey.chilikin, beilei.xing, jingjing.wu
On 10/24/2017 11:02 AM, Ferruh Yigit wrote:
> On 10/24/2017 7:08 AM, Kirill Rybalchenko wrote:
>> For complex packets use raw flow type with pre-constructed packet buffer
>> instead of creating a packet internally in PMD.
>>
>> v2:
>>
>> Fix documentation according to doxygen style comments.
>> Fix compilation warnings for clang target.
>>
>> Signed-off-by: Kirill Rybalchenko <kirill.rybalchenko@intel.com>
>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
Applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-10-24 18:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-19 9:00 [dpdk-dev] [PATCH] net/i40e: add support for packet template to flow director Kirill Rybalchenko
2017-10-23 22:11 ` Ferruh Yigit
2017-10-24 14:08 ` [dpdk-dev] [PATCH v2] " Kirill Rybalchenko
2017-10-24 18:02 ` Ferruh Yigit
2017-10-24 18:07 ` Ferruh Yigit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).