> -----Original Message----- > From: Nélio Laranjeiro <nelio.laranje...@6wind.com> > Sent: Friday, April 13, 2018 4:38 PM > To: Xueming(Steven) Li <xuemi...@mellanox.com> > Cc: Shahaf Shuler <shah...@mellanox.com>; dev@dpdk.org > Subject: Re: [PATCH v2 04/15] net/mlx5: support Rx tunnel type > identification > > On Thu, Apr 12, 2018 at 02:27:45PM +0000, Xueming(Steven) Li wrote: > > > -----Original Message----- > > > From: Nélio Laranjeiro <nelio.laranje...@6wind.com> > > > Sent: Thursday, April 12, 2018 5:51 PM > > > To: Xueming(Steven) Li <xuemi...@mellanox.com> > > > Cc: Shahaf Shuler <shah...@mellanox.com>; dev@dpdk.org > > > Subject: Re: [PATCH v2 04/15] net/mlx5: support Rx tunnel type > > > identification > > > > > > On Wed, Apr 11, 2018 at 08:11:50AM +0000, Xueming(Steven) Li wrote: > > > > Hi Nelio, > > > > > > > > > -----Original Message----- > > > > > From: Nélio Laranjeiro <nelio.laranje...@6wind.com> > > > > > Sent: Tuesday, April 10, 2018 11:17 PM > > > > > To: Xueming(Steven) Li <xuemi...@mellanox.com> > > > > > Cc: Shahaf Shuler <shah...@mellanox.com>; dev@dpdk.org > > > > > Subject: Re: [PATCH v2 04/15] net/mlx5: support Rx tunnel type > > > > > identification > > > > > > > > > > On Tue, Apr 10, 2018 at 09:34:04PM +0800, Xueming Li wrote: > > > > > > This patch introduced tunnel type identification based on flow > rules. > > > > > > If flows of multiple tunnel types built on same queue, > > > > > > RTE_PTYPE_TUNNEL_MASK will be returned, bits in flow mark > > > > > > could be used as tunnel type identifier. > > > > > > > > > > I don't see anywhere in this patch where the bits are reserved > > > > > to identify a flow, nor values which can help to identify it. > > > > > > > > > > Is this missing? > > > > > > > > > > Anyway we have already very few bits in the mark making it > > > > > difficult to be used by the user, reserving again some to may > > > > > lead to remove the mark support from the flows. > > > > > > > > Not all users will use multiple tunnel types, this is not included > > > > in this patch set and left to user decision. I'll update comments > > > > to make > > > this clear. > > > > > > Thanks, > > > > > > > > > Signed-off-by: Xueming Li <xuemi...@mellanox.com> > > > <snip/> > > > > > > /** > > > > > > + * RXQ update after flow rule creation. > > > > > > + * > > > > > > + * @param dev > > > > > > + * Pointer to Ethernet device. > > > > > > + * @param flow > > > > > > + * Pointer to the flow rule. > > > > > > + */ > > > > > > +static void > > > > > > +mlx5_flow_create_update_rxqs(struct rte_eth_dev *dev, struct > > > > > > +rte_flow > > > > > > +*flow) { > > > > > > + struct priv *priv = dev->data->dev_private; > > > > > > + unsigned int i; > > > > > > + > > > > > > + if (!dev->data->dev_started) > > > > > > + return; > > > > > > + for (i = 0; i != flow->rss_conf.queue_num; ++i) { > > > > > > + struct mlx5_rxq_data *rxq_data = (*priv->rxqs) > > > > > > + [(*flow->queues)[i]]; > > > > > > + struct mlx5_rxq_ctrl *rxq_ctrl = > > > > > > + container_of(rxq_data, struct mlx5_rxq_ctrl, > > > > > > rxq); > > > > > > + uint8_t tunnel = PTYPE_IDX(flow->tunnel); > > > > > > + > > > > > > + rxq_data->mark |= flow->mark; > > > > > > + if (!tunnel) > > > > > > + continue; > > > > > > + rxq_ctrl->tunnel_types[tunnel] += 1; > > > > > > > > > > I don't understand why you need such array, the NIC is unable to > > > > > return the tunnel type has it returns only one bit saying tunnel. > > > > > Why don't it store in the priv structure the current configured > tunnel? > > > > > > > > This array is used to count tunnel types bound to queue, if only > > > > one tunnel type, ptype will report that tunnel type, TUNNEL > > > > MASK(max > > > > value) will be returned if multiple types bound to a queue. > > > > > > > > Flow rss action specifies queues that binding to tunnel, thus we > > > > can't assume all queues have same tunnel types, so this is a per > > > > queue > > > structure. > > > > > > There is something I am missing here, how in the dataplane the PMD > > > can understand from 1 bit which kind of tunnel the packet is matching? > > > > The code under this line is answer, let me post here: > > if (rxq_data->tunnel != flow->tunnel) > > rxq_data->tunnel = rxq_data->tunnel ? > > RTE_PTYPE_TUNNEL_MASK : > > flow->tunnel; > > If no tunnel type associated to rxq, use tunnel type from flow. > > If a new tunnel type from flow, use RTE_PTYPE_TUNNEL_MASK. > > From my understanding, when in the same queue there are several tunnel > offloads, the mbuf ptype will contains RTE_PTYPE_TUNNEL_MASK: > > @@ -1601,7 +1605,7 @@ rxq_cq_to_pkt_type(volatile struct mlx5_cqe *cqe) > * bit[7] = outer_l3_type > */ > idx = ((pinfo & 0x3) << 6) | ((ptype & 0xfc00) >> 10); > - return mlx5_ptype_table[idx]; > + return mlx5_ptype_table[idx] | rxq->tunnel * !!(idx & (1 << 6)); > } > > > Used by Rx burst functions, > > /* Update packet information. */ > pkt->packet_type = rxq_cq_to_pkt_type(cqe); > > Is this correct?
You got the point. > > There is another strange point here, > > + [PTYPE_IDX(RTE_PTYPE_TUNNEL_VXLAN)] = RTE_PTYPE_TUNNEL_VXLAN | > + RTE_PTYPE_L4_UDP, > > According to the RFC 7348 [1] having a VXLAN with an outer IPv6 is > possible. How do you handle it? The answer was hide in the code you pasted: @@ -1601,7 +1605,7 @@ rxq_cq_to_pkt_type(volatile struct mlx5_cqe *cqe) * bit[7] = outer_l3_type */ idx = ((pinfo & 0x3) << 6) | ((ptype & 0xfc00) >> 10); - return mlx5_ptype_table[idx]; + return mlx5_ptype_table[idx] | rxq->tunnel * !!(idx & (1 << 6)); In comment, Bit 7 is outer L3 type from CQE, PTYPE will be retrieved from mlx5_ptype_table lookup. > > > > <snip/> > > > > > > @@ -2334,9 +2414,9 @@ mlx5_flow_stop(struct rte_eth_dev *dev, > > > > > > struct mlx5_flows *list) { > > > > > > struct priv *priv = dev->data->dev_private; > > > > > > struct rte_flow *flow; > > > > > > + unsigned int i; > > > > > > > > > > > > TAILQ_FOREACH_REVERSE(flow, list, mlx5_flows, next) { > > > > > > - unsigned int i; > > > > > > struct mlx5_ind_table_ibv *ind_tbl = NULL; > > > > > > > > > > > > if (flow->drop) { > > > > > > @@ -2382,6 +2462,16 @@ mlx5_flow_stop(struct rte_eth_dev *dev, > > > > > > struct > > > > > mlx5_flows *list) > > > > > > DRV_LOG(DEBUG, "port %u flow %p removed", dev->data- > > > >port_id, > > > > > > (void *)flow); > > > > > > } > > > > > > + /* Cleanup Rx queue tunnel info. */ > > > > > > + for (i = 0; i != priv->rxqs_n; ++i) { > > > > > > + struct mlx5_rxq_data *q = (*priv->rxqs)[i]; > > > > > > + struct mlx5_rxq_ctrl *rxq_ctrl = > > > > > > + container_of(q, struct mlx5_rxq_ctrl, rxq); > > > > > > + > > > > > > + memset((void *)rxq_ctrl->tunnel_types, 0, > > > > > > + sizeof(rxq_ctrl->tunnel_types)); > > > > > > + q->tunnel = 0; > > > > > > + } > > > > > > } > > > > > > > > > > This hunk does not handle the fact the Rx queue array may have > > > > > some holes i.e. the application is allowed to ask for 10 queues > > > > > and only initialise some. In such situation this code will > segfault. > > > > > > > > In other words, "q" could be NULL, correct? I'll add check for this. > > > > > > Correct. > > > > > > > BTW, there should be an action item to add such check in rss/queue > > > > flow > > > creation. > > > > > > As it is the responsibility of the application/user to make rule > > > according to what it has configured, it has not been added. It can > > > still be added, but it cannot be considered as a fix. > > > > > > > > It should only memset the Rx queues making part of the flow not > > > > > the > > > others. > > > > > > > > Clean this(decrease tunnel_types counter of each queue) from each > > > > flow would be time consuming. > > > > > > Considering flows are already relying on syscall to communicate with > > > the kernel, the extra cycles consumption to only clear the queues > > > making part of this flow is neglectable. > > > > > > By the way in the same function the mark is cleared only for the > > > queues making part of the flow, the same loop can be used to clear > > > those tunnel informations at the same time. > > > > > > > If an error happened, counter will not be cleared and such state > > > > will impact tunnel type after port start again. > > > > > > Unless an implementation error which other kind of them do you fear > > > to happen? > > > > Mark of rxq simply reset to 0, this field is counter, the final target > > is to clear field value, so my code should be straight forward and > > error free 😊 > > > > From a quick look, this function could be much simple that what it is > today: > > 1. clean verb flow and hrex where possible, despite of flow type. > > 2. clean rxq state: mark and tunnel_types. > > Ok. > > Thanks, > > [1] > https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdpdk.or > g%2Fpatch%2F37965&data=02%7C01%7Cxuemingl%40mellanox.com%7Cc3de5d7cfc85463 > 41a6808d5a119c916%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C63659205449 > 1963568&sdata=Eoq30ySZ8gRhemDG6BDawVqFvWB1gI85GpcYIMwl32Q%3D&reserved=0 > > -- > Nélio Laranjeiro > 6WIND