<div class="__aliyun_email_body_block"><div  style="font-family: Tahoma, Arial, STHeitiSC-Light, SimSun"><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span  style="font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;">Hi <span  style="color: rgb(0, 0, 0); font-family: Tahoma, Arial, STHeiti, SimSun; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; float: none; display: inline !important;">Anatoly,</span></span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span  style="font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><br ></span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span  style="font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span >I feel there might be a point that needs attention.</span></span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><br ></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;">The old rte_vfio_get_group_num function returns <= 0 to indicate failure,</div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><div  style="clear: both;">while the new rte_vfio_get_group_num function returns < 0 to indicate failure.<br ></div><div  style="clear: both;">Therefore, all DPDK code that checks the return value of the rte_vfio_get_group_num function should be modified.<br ></div><div  style="clear: both;"><br ></div><div  style="clear: both;">For example, in the nbl net driver, there is the following code:<br ></div><div  style="clear: both;">ret = rte_vfio_get_group_num(pathname, dev_name, &common->iommu_group_num);<br ></div><div  style="clear: both;">if (ret <= 0) {<br ></div><div  style="clear: both;">    NBL_LOG(ERR, "nbl vfio group number failed");<br ></div><div  style="clear: both;">    return -1;<br ></div><div  style="clear: both;">}<br ></div><div  style="clear: both;"><br ></div><div  style="clear: both;">It should be modified to:<br ></div><div  style="clear: both;">ret = rte_vfio_get_group_num(pathname, dev_name, &common->iommu_group_num);<br ></div><div  style="clear: both;">if (ret < 0) {<br ></div><div  style="clear: both;">    NBL_LOG(ERR, "nbl vfio group number failed");<br ></div><div  style="clear: both;">    return -1;<br ></div><div ><span >}</span></div><p  class="ds-markdown-paragraph" style="margin: 16px 0px; color: rgb(15, 17, 21); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;"><span ></span><br ></p><div ></div><span  style="font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><br ></span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span  style="font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><br ></span></div><blockquote  _quote="1" style="margin-right: 0px; margin-top: 0px; margin-bottom: 0px; font-family: Tahoma, Arial, STHeiti, SimSun; font-size: 14px; color: rgb(0, 0, 0);"><div  class="alimail-quote"><div  style="clear: both;">------------------------------------------------------------------</div><div  style="clear: both;">发件人:Anatoly Burakov <anatoly.burakov@intel.com></div><div  style="clear: both;">发送时间:2025年11月15日(周六) 01:40</div><div  style="clear: both;">收件人:dev<dev@dpdk.org>; Dimon<dimon.zhao@nebula-matrix.com>; Kyo Liu<kyo.liu@nebula-matrix.com>; Leon<leon.yu@nebula-matrix.com>; Sam<sam.chen@nebula-matrix.com></div><div  style="clear: both;">主 题:[PATCH v2 07/19] net/nbl: do not use VFIO group bind API</div><div  style="clear: both;"><br ></div>The NBL driver currently uses group bind API, but it is using it only to<br >get group fd and nothing else. In context of NBL driver, this is the only<br >usage of VFIO API's in the driver, and it is not necessary to use it for<br >what NBL driver is trying to accomplish.<br ><br >Use a direct `open()` call instead, and store the group fd in common<br >structure.<br ><br >Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com><br >---<br > drivers/net/nbl/nbl_common/nbl_userdev.c  | 18 +++++++++++-------<br > drivers/net/nbl/nbl_include/nbl_include.h |  1 +<br > 2 files changed, 12 insertions(+), 7 deletions(-)<br ><br >diff --git a/drivers/net/nbl/nbl_common/nbl_userdev.c b/drivers/net/nbl/nbl_common/nbl_userdev.c<br >index 566f3a11ee..d641ecd9a8 100644<br >--- a/drivers/net/nbl/nbl_common/nbl_userdev.c<br >+++ b/drivers/net/nbl/nbl_common/nbl_userdev.c<br >@@ -387,6 +387,13 @@ nbl_userdev_mem_event_callback(enum rte_mem_event type, const void *addr, size_t<br >  }<br > }<br > <br >+static int nbl_open_group_fd(int iommu_group_num)<br >+{<br >+ char path[PATH_MAX];<br >+ snprintf(path, sizeof(path), RTE_VFIO_GROUP_FMT, iommu_group_num);<br >+ return open(path, O_RDWR);<br >+}<br >+<br > static int nbl_mdev_map_device(struct nbl_adapter *adapter)<br > {<br >  const struct rte_pci_device *pci_dev = adapter->pci_dev;<br >@@ -424,11 +431,12 @@ static int nbl_mdev_map_device(struct nbl_adapter *adapter)<br >  }<br > <br >  NBL_LOG(DEBUG, "nbl vfio container %d", container);<br >- vfio_group_fd = rte_vfio_container_group_bind(container, common->iommu_group_num);<br >+ vfio_group_fd = nbl_open_group_fd(common->iommu_group_num);<br >  if (vfio_group_fd < 0) {<br >   NBL_LOG(ERR, "nbl vfio group bind failed, %d", vfio_group_fd);<br >   goto free_container;<br >  }<br >+ common->groupfd = vfio_group_fd;<br > <br >  /* check if the group is viable */<br >  ret = ioctl(vfio_group_fd, VFIO_GROUP_GET_STATUS, &group_status);<br >@@ -535,7 +543,6 @@ static int nbl_mdev_map_device(struct nbl_adapter *adapter)<br >  }<br > free_group:<br >  close(vfio_group_fd);<br >- rte_vfio_clear_group(vfio_group_fd);<br > free_container:<br >  if (container_create)<br >   rte_vfio_container_destroy(container);<br >@@ -549,17 +556,14 @@ static int nbl_mdev_unmap_device(struct nbl_adapter *adapter)<br > <br >  close(common->devfd);<br >  rte_mcfg_mem_read_lock();<br >- vfio_group_fd = rte_vfio_container_group_bind(nbl_default_container,<br >-            common->iommu_group_num);<br >+ vfio_group_fd = common->groupfd;<br >  NBL_LOG(DEBUG, "close vfio_group_fd %d", vfio_group_fd);<br >  ret = ioctl(vfio_group_fd, VFIO_GROUP_UNSET_CONTAINER, &nbl_default_container);<br >  if (ret)<br >   NBL_LOG(ERR, "unset container, error %i (%s) %d",<br >    errno, strerror(errno), ret);<br >  nbl_group_count--;<br >- ret = rte_vfio_container_group_unbind(nbl_default_container, common->iommu_group_num);<br >- if (ret)<br >-  NBL_LOG(ERR, "vfio container group unbind failed %d", ret);<br >+ close(vfio_group_fd);<br >  if (!nbl_group_count) {<br >   rte_mem_event_callback_unregister(NBL_USERDEV_EVENT_CLB_NAME, NULL);<br >   nbl_userdev_dma_free();<br >diff --git a/drivers/net/nbl/nbl_include/nbl_include.h b/drivers/net/nbl/nbl_include/nbl_include.h<br >index eeae6a3301..ba99b9f8e7 100644<br >--- a/drivers/net/nbl/nbl_include/nbl_include.h<br >+++ b/drivers/net/nbl/nbl_include/nbl_include.h<br >@@ -132,6 +132,7 @@ struct nbl_common_info {<br >  u16 vsi_id;<br >  u16 instance_id;<br >  int devfd;<br >+ int groupfd;<br >  int eventfd;<br >  int ifindex;<br >  int iommu_group_num;<br >-- <br >2.47.3</div></blockquote><div  style="line-height: 20px; clear: both;"><br ></div></div></div>
<div style="clear: both;"><span style="font-size: 10px; color: rgb(216, 216, 216);">本邮件所含信息及其任何附件为保密信息且可能属于专有信息。任何非指定接收人均无权访问本邮件。如果您不是该邮件的指定接收人,那么任何对本邮件内容进行披露,复制或使用的行为均是禁止的。如果您不是该邮件的指定接收人,请您立即通过邮件通知 compliance@nebula-matrix.com并立即删除您错误接受的邮件。</span></div><div style="clear: both;"><span style="font-size: 10px; color: rgb(216, 216, 216);">The information in this message and any attachments is confidential and may be privileged.  Access to this email by anyone other than the intended recipient is not authorized.  If you are not the intended recipient, disclosure, copying or use of the contents of this email is prohibited.  If you are not the intended recipient, please notify  compliance@nebula-matrix.com immediately by email, and please destroy the email you received in error.</span></div>