> -----Original Message----- > From: Xing, Beilei > Sent: Friday, September 29, 2017 7:30 PM > To: Sean Harte <sea...@gmail.com> > Cc: Wu, Jingjing <jingjing...@intel.com>; Chilikin, Andrey > <andrey.chili...@intel.com>; dev@dpdk.org > Subject: RE: [dpdk-dev] [PATCH v6 6/8] net/i40e: add FDIR support for GTP-C > and GTP-U > > > > > -----Original Message----- > > From: Sean Harte [mailto:sea...@gmail.com] > > Sent: Friday, September 29, 2017 6:10 PM > > To: Xing, Beilei <beilei.x...@intel.com> > > Cc: Wu, Jingjing <jingjing...@intel.com>; Chilikin, Andrey > > <andrey.chili...@intel.com>; dev@dpdk.org > > Subject: Re: [dpdk-dev] [PATCH v6 6/8] net/i40e: add FDIR support for > > GTP-C and GTP-U > > > > On 29 September 2017 at 10:33, Xing, Beilei <beilei.x...@intel.com> > wrote: > > > > > > > > >> -----Original Message----- > > >> From: Sean Harte [mailto:sea...@gmail.com] > > >> Sent: Friday, September 29, 2017 4:15 PM > > >> To: Xing, Beilei <beilei.x...@intel.com> > > >> Cc: Wu, Jingjing <jingjing...@intel.com>; Chilikin, Andrey > > >> <andrey.chili...@intel.com>; dev@dpdk.org > > >> Subject: Re: [dpdk-dev] [PATCH v6 6/8] net/i40e: add FDIR support > > >> for GTP-C and GTP-U > > >> > > >> On 29 September 2017 at 06:19, Beilei Xing <beilei.x...@intel.com> > wrote: > > >> > This patch adds FDIR support for GTP-C and GTP-U. The input set > > >> > of GTP-C and GTP-U is TEID. > > >> > > > >> > Signed-off-by: Beilei Xing <beilei.x...@intel.com> > > >> > --- > > >> > drivers/net/i40e/i40e_ethdev.h | 30 +++++ > > >> > drivers/net/i40e/i40e_fdir.c | 200 > ++++++++++++++++++++++--------- > > >> > drivers/net/i40e/i40e_flow.c | 263 > > >> +++++++++++++++++++++++++++++++++++------ > > >> > 3 files changed, 396 insertions(+), 97 deletions(-) > > >> > > >> <snip> > > >> > > >> > @@ -1173,10 +1196,69 @@ i40e_flow_fdir_construct_pkt(struct > > >> > i40e_pf > > >> *pf, > > >> > > rte_cpu_to_be_16(ETHER_TYPE_ARP)) > > >> > payload += sizeof(struct arp_hdr); > > >> > set_idx = I40E_FLXPLD_L2_IDX; > > >> > - break; > > >> > - default: > > >> > - PMD_DRV_LOG(ERR, "unknown pctype %u.", > fdir_input- > > >pctype); > > >> > - return -EINVAL; > > >> > + } else if (fdir_input->flow_ext.customized_pctype) { > > >> > + /* If customized pctype is used */ > > >> > + cus_pctype = > > >> > + i40e_flow_fdir_find_customized_pctype(pf, > > pctype); > > >> > + if (cus_pctype->index == I40E_CUSTOMIZED_GTPC > || > > >> > + cus_pctype->index == > I40E_CUSTOMIZED_GTPU_IPV4 || > > >> > + cus_pctype->index == > I40E_CUSTOMIZED_GTPU_IPV6 || > > >> > + cus_pctype->index == > I40E_CUSTOMIZED_GTPU) { > > >> > + udp = (struct udp_hdr *)(raw_pkt + len); > > >> > + udp->dgram_len = > > >> > + > > >> > + rte_cpu_to_be_16(I40E_FDIR_UDP_DEFAULT_LEN); > > >> > + > > >> > + gtp = (struct rte_flow_item_gtp *) > > >> > + ((unsigned char *)udp + > sizeof(struct udp_hdr)); > > >> > + gtp->v_pt_rsv_flags = 0x30; > > >> > > >> 0x30 isn't valid for GTP-C, the sequence number must be present in > > >> GTP-C so it will be 0x32 or more. Is this byte actually matched > > >> against by the device using the GTP pctypes? > > > > > > We construct packets and send the packet to HW to create flow > > > director rule for GTP-C and GTP-U. Actually I didn’t get error info > > > with 0x30. And in my test, GTP-C packets can hit GTP-C pctype rule. > > > Will try > > 0x32 later. > > > > > >> > > >> > + gtp->msg_len = > > >> > + > rte_cpu_to_be_16(I40E_FDIR_GTP_DEFAULT_LEN); > > >> > + gtp->teid = > fdir_input->flow.gtp_flow.teid; > > >> > + gtp->msg_type = 0x1; > > >> > > >> Why use this value? > > > > > > Just for constructing a GTP packet to create a fdir rule for one > > > pctype, can > > use other values except 0xFF. > > > > > >> > > >> > + > > >> > + if (cus_pctype->index == > I40E_CUSTOMIZED_GTPC) > > >> > + udp->dst_port = > > >> > + rte_cpu_to_be_16(2123); > > >> > > >> This will only match half of GTP-C messages. GTP-C messages have a > > >> UDP port destination of 2123, or a UDP source port of 2123. To > > >> match all GTP-C packets you need to look at both. > > > > > > Yes. But the GTP profile for i40e didn't support response message. > > > > That's not clear to a user of the rte_flow API > > Rte_flow is a generic API, I think it should allow users to create rule for > response message. > But i40e PMD does not the support response message, if user want to create > a rule for i40e like below: > Flow create 0 ingress pattern eth / ipv4 / udp src is 2123 / gtpc / end / > actions queue index 4 / end It will fail. But maybe other PMD can support it. > > > > > > > > >> > > >> > + else > > >> > + udp->dst_port = > > >> > + rte_cpu_to_be_16(2152); > > >> > + > > >> > + if (cus_pctype->index == > I40E_CUSTOMIZED_GTPU_IPV4) { > > >> > + gtp->msg_type = 0xFF; > > >> > + gtp_ipv4 = (struct ipv4_hdr *) > > >> > + ((unsigned char *)gtp > + > > >> > + sizeof(struct > > >> > + rte_flow_item_gtp)); > > >> > > >> This is only valid if v_pt_rsv_flags is 0x30. GTP-U packets are > > >> allowed to have a sequence number, which adds an extra 4 bytes to > > >> the > > GTP header. > > > > > > For the GTP profile, there're 4 pctypes for GTP packets: GTPC, GTPU, > > GTPIPV4, and GTPIPV6. > > > HW parse which pctype the GTP packets belonge to. > > > We construct packet to create a fdir rule for one pctype, after > > > that, all packets whose pctype matches the rule's pctype will hit the > > > rule. > > > > My point is that you can only assume the inner IP header starts at an > > offset of sizeof(struct rte_flow_item_gtp) if v_pt_rsv_flags is > > exactly 0x30. If you match only those packets then some GTP-U packets > will not be matched. > > That should be clear to a user of the rte_flow API. > > > > No matter if GTP-U packets has a sequence number, once message-type is > 0xFF, the pctype of the packet parsed by i40e HW will be GTPIPV4 or > GTPIPV6. > So If I create a flow rule for GTP-U packets with v_pt_rsv_flags 0x30 and > message_type is 0xFF, it means I create a rule for pctype GTPIPV4 or > GTPIPV6. > Then GTP-U packets with v_pt_rsv_flags 0x32 can hit the rule because its > pctype is also GTPIPV4 or GTPIPV6. > It's just i40e HW's behavior, doesn't mean it's effective for other NICs. > Hope I explain it clearly:) >
The key point is : for i40e HW, different packet types can use the same pctype. > > > > > >> > > >> > + gtp_ipv4->version_ihl = > > >> > + > I40E_FDIR_IP_DEFAULT_VERSION_IHL; > > >> > + gtp_ipv4->next_proto_id = > IPPROTO_IP; > > >> > + gtp_ipv4->total_length = > > >> > + rte_cpu_to_be_16( > > >> > + > I40E_FDIR_INNER_IP_DEFAULT_LEN); > > >> > + payload = (unsigned char > *)gtp_ipv4 + > > >> > + sizeof(struct > ipv4_hdr); > > >> > + } else if (cus_pctype->index == > > >> > + > I40E_CUSTOMIZED_GTPU_IPV6) { > > >> > + gtp->msg_type = 0xFF; > > >> > + gtp_ipv6 = (struct ipv6_hdr *) > > >> > + ((unsigned char *)gtp > + > > >> > + sizeof(struct > > >> > + rte_flow_item_gtp)); > > >> > > >> This is only valid if v_pt_rsv_flags is 0x30. GTP-U packets are > > >> allowed to have a sequence number, which adds an extra 4 bytes to > > >> the > > GTP header. > > > > > > Same with above. > > > > > >> > > >> > + gtp_ipv6->vtc_flow = > > >> > + rte_cpu_to_be_32( > > >> > + > I40E_FDIR_IPv6_DEFAULT_VTC_FLOW | > > >> > + (0 << > I40E_FDIR_IPv6_TC_OFFSET)); > > >> > + gtp_ipv6->proto = > IPPROTO_NONE; > > >> > + gtp_ipv6->payload_len = > > >> > + rte_cpu_to_be_16( > > >> > + > I40E_FDIR_INNER_IPv6_DEFAULT_LEN); > > >> > + gtp_ipv6->hop_limits = > > >> > + > I40E_FDIR_IPv6_DEFAULT_HOP_LIMITS; > > >> > + payload = (unsigned char > *)gtp_ipv6 + > > >> > + sizeof(struct > ipv6_hdr); > > >> > + } else > > >> > + payload = (unsigned char *)gtp > + > > >> > + sizeof(struct > rte_flow_item_gtp); > > >> > + } > > >> > + } else { > > >> > + PMD_DRV_LOG(ERR, "unknown pctype %u.", > > >> > + fdir_input->pctype); > > >> > + return -1; > > >> > } > > >> > > > >> > /* fill the flexbytes to payload */ > > >> > > >> <snip>