From patchwork Wed Mar 2 11:30:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingjing Wu X-Patchwork-Id: 10983 X-Patchwork-Delegate: bruce.richardson@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id B3B63AD85; Wed, 2 Mar 2016 12:30:42 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 4095AAD98 for ; Wed, 2 Mar 2016 12:30:41 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP; 02 Mar 2016 03:30:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,528,1449561600"; d="scan'208";a="662448025" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 02 Mar 2016 03:30:39 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id u22BUbbS029200; Wed, 2 Mar 2016 19:30:37 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id u22BUZMB031810; Wed, 2 Mar 2016 19:30:37 +0800 Received: (from wujingji@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id u22BUZ5C031806; Wed, 2 Mar 2016 19:30:35 +0800 From: Jingjing Wu To: bruce.richardson@intel.com Date: Wed, 2 Mar 2016 19:30:06 +0800 Message-Id: <1456918207-31696-12-git-send-email-jingjing.wu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1456918207-31696-1-git-send-email-jingjing.wu@intel.com> References: <1453789575-6297-1-git-send-email-jingjing.wu@intel.com> <1456918207-31696-1-git-send-email-jingjing.wu@intel.com> Cc: dev@dpdk.org Subject: [dpdk-dev] [PATCH v2 11/12] i40e: extend flow director to filter by vlan id X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch extended flow director to select vlan id as filter's input set and program the filter rule with vlan id. Signed-off-by: Jingjing Wu --- doc/guides/rel_notes/release_16_04.rst | 2 ++ drivers/net/i40e/i40e_ethdev.c | 11 ++++++++ drivers/net/i40e/i40e_fdir.c | 49 ++++++++++++++++++++++++++-------- 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/doc/guides/rel_notes/release_16_04.rst b/doc/guides/rel_notes/release_16_04.rst index 1d784d3..8c7b3e1 100644 --- a/doc/guides/rel_notes/release_16_04.rst +++ b/doc/guides/rel_notes/release_16_04.rst @@ -74,6 +74,8 @@ This section should contain new features added in this release. Sample format: * **szedata2: Add functions for setting link up/down.** +* **Added Flow director enhancements on Intel X710/XL710.** + Resolved Issues --------------- diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 6401768..a829e8b 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -6626,58 +6626,69 @@ i40e_get_valid_input_set(enum i40e_filter_pctype pctype, */ static const uint64_t valid_fdir_inset_table[] = { [I40E_FILTER_PCTYPE_FRAG_IPV4] = + I40E_INSET_VLAN_OUTER | I40E_INSET_VLAN_INNER | I40E_INSET_TUNNEL_ID | I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST | I40E_INSET_IPV4_TOS | I40E_INSET_IPV4_PROTO | I40E_INSET_IPV4_TTL, [I40E_FILTER_PCTYPE_NONF_IPV4_UDP] = + I40E_INSET_VLAN_OUTER | I40E_INSET_VLAN_INNER | I40E_INSET_TUNNEL_ID | I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST | I40E_INSET_IPV4_TOS | I40E_INSET_IPV4_TTL | I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT, [I40E_FILTER_PCTYPE_NONF_IPV4_TCP] = + I40E_INSET_VLAN_OUTER | I40E_INSET_VLAN_INNER | I40E_INSET_TUNNEL_ID | I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST | I40E_INSET_IPV4_TOS | I40E_INSET_IPV4_TTL | I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT, [I40E_FILTER_PCTYPE_NONF_IPV4_SCTP] = + I40E_INSET_VLAN_OUTER | I40E_INSET_VLAN_INNER | I40E_INSET_TUNNEL_ID | I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST | I40E_INSET_IPV4_TOS | I40E_INSET_IPV4_TTL | I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT | I40E_INSET_SCTP_VT, [I40E_FILTER_PCTYPE_NONF_IPV4_OTHER] = + I40E_INSET_VLAN_OUTER | I40E_INSET_VLAN_INNER | I40E_INSET_TUNNEL_ID | I40E_INSET_IPV4_SRC | I40E_INSET_IPV4_DST | I40E_INSET_IPV4_TOS | I40E_INSET_IPV4_PROTO | I40E_INSET_IPV4_TTL, [I40E_FILTER_PCTYPE_FRAG_IPV6] = + I40E_INSET_VLAN_OUTER | I40E_INSET_VLAN_INNER | I40E_INSET_TUNNEL_ID | I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST | I40E_INSET_IPV6_TC | I40E_INSET_IPV6_NEXT_HDR | I40E_INSET_IPV6_HOP_LIMIT, [I40E_FILTER_PCTYPE_NONF_IPV6_UDP] = + I40E_INSET_VLAN_OUTER | I40E_INSET_VLAN_INNER | I40E_INSET_TUNNEL_ID | I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST | I40E_INSET_IPV6_TC | I40E_INSET_IPV6_HOP_LIMIT | I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT, [I40E_FILTER_PCTYPE_NONF_IPV6_TCP] = + I40E_INSET_VLAN_OUTER | I40E_INSET_VLAN_INNER | I40E_INSET_TUNNEL_ID | I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST | I40E_INSET_IPV6_TC | I40E_INSET_IPV6_HOP_LIMIT | I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT, [I40E_FILTER_PCTYPE_NONF_IPV6_SCTP] = + I40E_INSET_VLAN_OUTER | I40E_INSET_VLAN_INNER | I40E_INSET_TUNNEL_ID | I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST | I40E_INSET_IPV6_TC | I40E_INSET_IPV6_HOP_LIMIT | I40E_INSET_SRC_PORT | I40E_INSET_DST_PORT | I40E_INSET_SCTP_VT, [I40E_FILTER_PCTYPE_NONF_IPV6_OTHER] = + I40E_INSET_VLAN_OUTER | I40E_INSET_VLAN_INNER | I40E_INSET_TUNNEL_ID | I40E_INSET_IPV6_SRC | I40E_INSET_IPV6_DST | I40E_INSET_IPV6_TC | I40E_INSET_IPV6_NEXT_HDR | I40E_INSET_IPV6_HOP_LIMIT, [I40E_FILTER_PCTYPE_L2_PAYLOAD] = + I40E_INSET_VLAN_OUTER | I40E_INSET_VLAN_INNER | I40E_INSET_TUNNEL_ID | I40E_INSET_LAST_ETHER_TYPE, }; diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c index 48ec63b..33be634 100644 --- a/drivers/net/i40e/i40e_fdir.c +++ b/drivers/net/i40e/i40e_fdir.c @@ -686,34 +686,50 @@ i40e_fdir_configure(struct rte_eth_dev *dev) return ret; } -static inline void +static inline int i40e_fdir_fill_ether_head(const struct rte_eth_fdir_input *fdir_input, - unsigned char *pkt) + unsigned char *pkt, bool vlan) { - struct ether_hdr *ether = (struct ether_hdr *)pkt; + static uint8_t vlan_frame[] = {0x81, 0, 0, 0}; + uint16_t *ether_type; + uint8_t len = 2 * sizeof(struct ether_addr); + + pkt += 2 * sizeof(struct ether_addr); + if (vlan && fdir_input->flow_ext.vlan_tci) { + rte_memcpy(pkt, vlan_frame, sizeof(vlan_frame)); + rte_memcpy(pkt + sizeof(uint16_t), + &fdir_input->flow_ext.vlan_tci, + sizeof(uint16_t)); + pkt += sizeof(vlan_frame); + len += sizeof(vlan_frame); + } + ether_type = (uint16_t *)pkt; + switch (fdir_input->flow_type) { case RTE_ETH_FLOW_L2_PAYLOAD: - ether->ether_type = fdir_input->flow.l2_flow.ether_type; + *ether_type = fdir_input->flow.l2_flow.ether_type; break; case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: case RTE_ETH_FLOW_NONFRAG_IPV4_UDP: case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: case RTE_ETH_FLOW_FRAG_IPV4: - ether->ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4); + *ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4); break; case RTE_ETH_FLOW_NONFRAG_IPV6_TCP: case RTE_ETH_FLOW_NONFRAG_IPV6_UDP: case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: case RTE_ETH_FLOW_FRAG_IPV6: - ether->ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv6); + *ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv6); break; default: PMD_DRV_LOG(ERR, "unknown flow type %u.", fdir_input->flow_type); - break; + return -1; } + len += sizeof(uint16_t); + return len; } static inline void @@ -813,6 +829,8 @@ i40e_fdir_construct_pkt(struct i40e_pf *pf, struct sctp_hdr *sctp; uint8_t size, dst = 0; uint8_t i, pit_idx, set_idx = I40E_FLXPLD_L4_IDX; /* use l4 by default*/ + int len; + static uint8_t vlan_frame[] = {0x81, 0, 0, 0}; static uint8_t gre4_frame[] = {0x08, 0, 0x45, 0, 0, 0x3A, 0, 0, 0, 0, 0x40, 0x2F, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x20, 0, 0x08, 0, @@ -832,6 +850,14 @@ i40e_fdir_construct_pkt(struct i40e_pf *pf, 0, 0, 0, 0}; /*Mac + IP + NVGRE hdr*/ inner_pkt += 2 * sizeof(struct ether_addr); + if (fdir_input->flow_ext.vlan_tci) { + rte_memcpy(inner_pkt, vlan_frame, sizeof(vlan_frame)); + rte_memcpy(inner_pkt + sizeof(uint16_t), + &fdir_input->flow_ext.vlan_tci, + sizeof(uint16_t)); + inner_pkt += sizeof(vlan_frame); + } + /* fill the tunnel header if required */ switch (fdir_input->flow.tunnel_flow.tunnel_type) { case RTE_FDIR_TUNNEL_TYPE_GRE: @@ -861,7 +887,7 @@ i40e_fdir_construct_pkt(struct i40e_pf *pf, &fdir_input->flow.tunnel_flow.tunnel_id, I40E_TUNNEL_KEY_LEN); /* fill the ethernet and IP head of inner frame */ - i40e_fdir_fill_ether_head(fdir_input, inner_pkt); + i40e_fdir_fill_ether_head(fdir_input, inner_pkt, FALSE); inner_pkt += sizeof(struct ether_hdr); break; case RTE_FDIR_TUNNEL_TYPE_NVGRE: @@ -871,13 +897,13 @@ i40e_fdir_construct_pkt(struct i40e_pf *pf, &fdir_input->flow.tunnel_flow.tunnel_id, I40E_TUNNEL_KEY_LEN); /* fill the Ether header of inner frame */ - i40e_fdir_fill_ether_head(fdir_input, inner_pkt); + i40e_fdir_fill_ether_head(fdir_input, inner_pkt, FALSE); inner_pkt += sizeof(struct ether_hdr); break; default: /* fill the Ether header of single frame */ - i40e_fdir_fill_ether_head(fdir_input, raw_pkt); - inner_pkt = raw_pkt + sizeof(struct ether_hdr); + len = i40e_fdir_fill_ether_head(fdir_input, raw_pkt, TRUE); + inner_pkt = raw_pkt + len; break; } @@ -1122,6 +1148,7 @@ i40e_add_del_fdir_filter(struct rte_eth_dev *dev, PMD_DRV_LOG(ERR, "construct packet for fdir fails."); return ret; } + pctype = i40e_flowtype_to_pctype(filter->input.flow_type); ret = i40e_fdir_filter_programming(pf, pctype, filter, add); if (ret < 0) {