Re: [dpdk-dev] [PATCH] vfio: fix expanding DMA area in ppc64le

2019-06-17 Thread Mo, YufengX
Sorry, missed send this mail. Ignore it pls.


> -Original Message-
> From: Mo, YufengX
> Sent: Tuesday, June 18, 2019 10:38 AM
> To: Mo, YufengX ; dev@dpdk.org
> Cc: d...@ibm.com; prad...@us.ibm.com; Takeshi Yoshimura 
> Subject: [dpdk-dev] [PATCH] vfio: fix expanding DMA area in ppc64le
> 
> From: Takeshi Yoshimura 
> 
> In ppc64le, expanding DMA areas always fail because we cannot remove
> a DMA window. As a result, we cannot allocate more than one memseg in
> ppc64le. This is because vfio_spapr_dma_mem_map() doesn't unmap all
> the mapped DMA before removing the window. This patch fixes this
> incorrect behavior.
> 
> I added a global variable to track current window size since we do
> not have better ways to get exact size of it than doing so. sPAPR
> IOMMU seems not to provide any ways to get window size with ioctl
> interfaces. rte_memseg_walk*() is currently used to calculate window
> size, but it walks memsegs that are marked as used, not mapped. So,
> we need to determine if a given memseg is mapped or not, otherwise
> the ioctl reports errors due to attempting to unregister memory
> addresses that are not registered. The global variable is excluded
> in non-ppc64le binaries.
> 
> Similar problems happen in user maps. We need to avoid attempting to
> unmap the address that is given as the function's parameter. The
> compaction of user maps prevents us from passing correct length for
> unmapping DMA at the window recreation. So, I removed it in ppc64le.
> 
> I also fixed the order of ioctl for unregister and unmap. The ioctl
> for unregister sometimes report device busy errors due to the
> existence of mapped area.
> 
> Signed-off-by: Takeshi Yoshimura 
> ---
>  lib/librte_eal/linux/eal/eal_vfio.c | 154 +++-
>  1 file changed, 103 insertions(+), 51 deletions(-)
> 
> diff --git a/lib/librte_eal/linux/eal/eal_vfio.c 
> b/lib/librte_eal/linux/eal/eal_vfio.c
> index f16c5c3c0..c1b275b56 100644
> --- a/lib/librte_eal/linux/eal/eal_vfio.c
> +++ b/lib/librte_eal/linux/eal/eal_vfio.c
> @@ -93,6 +93,7 @@ is_null_map(const struct user_mem_map *map)
>   return map->addr == 0 && map->iova == 0 && map->len == 0;
>  }
> 
> +#ifndef RTE_ARCH_PPC_64
>  /* we may need to merge user mem maps together in case of user 
> mapping/unmapping
>   * chunks of memory, so we'll need a comparator function to sort segments.
>   */
> @@ -126,6 +127,7 @@ user_mem_map_cmp(const void *a, const void *b)
> 
>   return 0;
>  }
> +#endif
> 
>  /* adjust user map entry. this may result in shortening of existing map, or 
> in
>   * splitting existing map in two pieces.
> @@ -162,6 +164,7 @@ adjust_map(struct user_mem_map *src, struct user_mem_map 
> *end,
>   }
>  }
> 
> +#ifndef RTE_ARCH_PPC_64
>  /* try merging two maps into one, return 1 if succeeded */
>  static int
>  merge_map(struct user_mem_map *left, struct user_mem_map *right)
> @@ -177,6 +180,7 @@ merge_map(struct user_mem_map *left, struct user_mem_map 
> *right)
> 
>   return 1;
>  }
> +#endif
> 
>  static struct user_mem_map *
>  find_user_mem_map(struct user_mem_maps *user_mem_maps, uint64_t addr,
> @@ -211,6 +215,16 @@ find_user_mem_map(struct user_mem_maps *user_mem_maps, 
> uint64_t addr,
>   return NULL;
>  }
> 
> +#ifdef RTE_ARCH_PPC_64
> +/* Recreation of DMA window requires unregistering DMA memory.
> + * Compaction confuses the logic and causes false reports in the recreation.
> + * For now, we do not compact user maps in ppc64le.
> + */
> +static void
> +compact_user_maps(__rte_unused struct user_mem_maps *user_mem_maps)
> +{
> +}
> +#else
>  /* this will sort all user maps, and merge/compact any adjacent maps */
>  static void
>  compact_user_maps(struct user_mem_maps *user_mem_maps)
> @@ -256,6 +270,7 @@ compact_user_maps(struct user_mem_maps *user_mem_maps)
>   user_mem_maps->n_maps = cur_idx;
>   }
>  }
> +#endif
> 
>  static int
>  vfio_open_group_fd(int iommu_group_num)
> @@ -1306,6 +1321,7 @@ vfio_type1_dma_map(int vfio_container_fd)
>   return rte_memseg_walk(type1_map, &vfio_container_fd);
>  }
> 
> +#ifdef RTE_ARCH_PPC_64
>  static int
>  vfio_spapr_dma_do_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova,
>   uint64_t len, int do_map)
> @@ -1357,14 +1373,6 @@ vfio_spapr_dma_do_map(int vfio_container_fd, uint64_t 
> vaddr, uint64_t iova,
>   }
> 
>   } else {
> - ret = ioctl(vfio_container_fd,
> - VFIO_IOMMU_SPAPR_UNREGISTER_MEMORY, ®);
> - if (ret) {
> - RTE_LOG

Re: [dpdk-dev] [PATCH 1/2] lib/librte_ethdev: add in default value of rte_eth_dev_info

2019-06-13 Thread Mo, YufengX
Hi, Sunil Kumar Kori

This series' patches have been merged on dpdk/master. They cause testpmd core 
dumped on intel nics.

./usertools/dpdk-devbind.py -b igb_uio :xx:00.0 :xx:00.1
./x86_64-native-linuxapp-gcc/app/testpmd -v -c 0x3f -n 4  -- -i

Running environment as the following:

* OS:
fedora 20/22/27/30
3.16.4/4.4.14/5.1.0

* Compiler:
gcc version 5.3.1
gcc version 7.3.1
gcc version 4.8.3

* Hardware platform:
Broadwell-EP Xeon E5-2600
Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz
Intel(R) Xeon(R) Platinum 8160 CPU @ 2.10GHz

* NIC hardware:
fortville_spirit
Ethernet Controller XL710 for 40GbE QSFP+ 1583
version: 1.5.16
firmware-version: 6.01 0x800034a4 1.1747.0

fortville(25G 2 ports nic)
Ethernet Controller XXV710 for 25GbE SFP28 158b
driver: i40e
version: 2.1.14-k
firmware-version: 6.01 0x80003554 1.1747.0

fortville(10G 2 ports nic)
Ethernet Controller X710 for 10GbE SFP+ 1572
driver: i40e
version: 2.1.14-k
firmware-version: 6.01 0x800035b0 1.1747.0

niantic
Device_str: 82599ES 10-Gigabit SFI/SFP+ Network Connection
firmware: 0x61bf0001
ixgbe: 4.3.13
ixgbevf: 2.12.1-k


> -Original Message-
> From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Sunil Kumar Kori
> Sent: Monday, May 27, 2019 4:35 PM
> To: tho...@monjalon.net; Yigit, Ferruh ; 
> arybche...@solarflare.com; Lu, Wenzhuo ;
> Wu, Jingjing ; Iremonger, Bernard 
> 
> Cc: dev@dpdk.org; Sunil Kumar Kori 
> Subject: [dpdk-dev] [PATCH 1/2] lib/librte_ethdev: add in default value of 
> rte_eth_dev_info
> 
> rte_eth_dev_info structure exposes, nb_seg_max & nb_mtu_seg_max
> to provide maximum number of supported segments for a given platform.
> 
> Defining UINT16_MAX as default value of above mentioned variables to
> expose support of infinite/maximum segments.
> 
> Based on above values, application can decide best size for buffers
> while creating mbuf pool.
> 
> Signed-off-by: Sunil Kumar Kori 
> ---
>  lib/librte_ethdev/rte_ethdev.c | 2 ++
>  lib/librte_ethdev/rte_ethdev.h | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
> index d7cfa3d..6933757 100644
> --- a/lib/librte_ethdev/rte_ethdev.c
> +++ b/lib/librte_ethdev/rte_ethdev.c
> @@ -2543,6 +2543,8 @@ struct rte_eth_dev *
>   .nb_max = UINT16_MAX,
>   .nb_min = 0,
>   .nb_align = 1,
> + .nb_seg_max = UINT16_MAX,
> + .nb_mtu_seg_max = UINT16_MAX,
>   };
> 
>   RTE_ETH_VALID_PORTID_OR_RET(port_id);
> diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
> index 1f35e1d..6bd30b1 100644
> --- a/lib/librte_ethdev/rte_ethdev.h
> +++ b/lib/librte_ethdev/rte_ethdev.h
> @@ -2333,6 +2333,8 @@ int rte_eth_dev_set_rx_queue_stats_mapping(uint16_t 
> port_id,
>   *  .nb_max = UINT16_MAX,
>   *  .nb_min = 0,
>   *  .nb_align = 1,
> + *   .nb_seg_max = UINT16_MAX,
> + *   .nb_mtu_seg_max = UINT16_MAX,
>   *  };
>   *
>   * device = dev->device
> --
> 1.8.3.1



Re: [dpdk-dev] [PATCH 1/2] lib/librte_ethdev: add in default value of rte_eth_dev_info

2019-06-16 Thread Mo, YufengX
Hi, Ferruh  Yigit

Sorry, reply late, I have no vpn/laptop to connect to intel servers. 
Daily regression is running good today since your patch has been merged 
yesterday.
I have applied your patch manually, it is ok.


> -Original Message-
> From: Yigit, Ferruh
> Sent: Saturday, June 15, 2019 1:22 AM
> To: Mo, YufengX ; Sunil Kumar Kori ; 
> tho...@monjalon.net; arybche...@solarflare.com;
> Lu, Wenzhuo ; Wu, Jingjing ; 
> Iremonger, Bernard 
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 1/2] lib/librte_ethdev: add in default value 
> of rte_eth_dev_info
> 
> On 6/14/2019 5:51 PM, Ferruh Yigit wrote:
> > On 6/14/2019 6:31 AM, Mo, YufengX wrote:
> >> Hi, Sunil Kumar Kori
> >>
> >> This series' patches have been merged on dpdk/master. They cause testpmd 
> >> core dumped on intel nics.
> >
> > Right, since they can provide values as "nb_seg_max = 0, nb_mtu_seg_max = 
> > 0",
> > I am sending a patch now.
> 
> @Yufeng, Can you please try with patch https://patches.dpdk.org/patch/54811/?
> 
> @Thomas, Can it be possible to merge fix to master? Or I can merge if you 
> want?