net/nfp: fix infinite loop

The services don't have a method to break the infinite loop, and
this will cause the DPDK app can't end normally.

Fixes: a36634e87e ("net/nfp: add flower ctrl VNIC Rx/Tx")

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
This commit is contained in:
Chaoyong He 2022-10-21 16:01:39 +08:00 committed by Ferruh Yigit
parent dee23e6c36
commit bab0e6f48b
7 changed files with 19 additions and 7 deletions

View File

@ -1056,6 +1056,7 @@ nfp_flower_enable_services(struct nfp_app_fw_flower *app_fw_flower)
return -EINVAL;
}
app_fw_flower->ctrl_vnic_id = service_id;
PMD_INIT_LOG(INFO, "%s registered", flower_service.name);
/* Map them to available service cores*/

View File

@ -51,6 +51,9 @@ struct nfp_app_fw_flower {
/* PF representor */
struct nfp_flower_representor *pf_repr;
/* service id of ctrl vnic service */
uint32_t ctrl_vnic_id;
};
int nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev);

View File

@ -4,6 +4,7 @@
*/
#include <rte_common.h>
#include <rte_service.h>
#include <ethdev_pci.h>
#include "../nfp_common.h"
@ -238,7 +239,7 @@ nfp_flower_ctrl_vnic_poll(struct nfp_app_fw_flower *app_fw_flower)
/* ctrl vNIC only has a single Rx queue */
rxq = ctrl_eth_dev->data->rx_queues[0];
while (true) {
while (rte_service_runstate_get(app_fw_flower->ctrl_vnic_id) != 0) {
count = nfp_flower_ctrl_vnic_recv(rxq, pkts_burst, MAX_PKT_BURST);
if (count != 0) {
app_fw_flower->ctrl_vnic_rx_count += count;

View File

@ -171,6 +171,9 @@ struct nfp_pf_dev {
struct nfp_hwinfo *hwinfo;
struct nfp_rtsym_table *sym_tbl;
/* service id of cpp bridge service */
uint32_t cpp_bridge_id;
};
struct nfp_app_fw_nic {

View File

@ -80,7 +80,7 @@ nfp_map_service(uint32_t service_id)
}
int
nfp_enable_cpp_service(struct nfp_cpp *cpp)
nfp_enable_cpp_service(struct nfp_pf_dev *pf_dev)
{
int ret;
uint32_t service_id = 0;
@ -89,7 +89,7 @@ nfp_enable_cpp_service(struct nfp_cpp *cpp)
.callback = nfp_cpp_bridge_service_func,
};
cpp_service.callback_userdata = (void *)cpp;
cpp_service.callback_userdata = (void *)pf_dev;
/* Register the cpp service */
ret = rte_service_component_register(&cpp_service, &service_id);
@ -98,6 +98,7 @@ nfp_enable_cpp_service(struct nfp_cpp *cpp)
return -EINVAL;
}
pf_dev->cpp_bridge_id = service_id;
PMD_INIT_LOG(INFO, "NFP cpp service registered");
/* Map it to available service core*/
@ -375,7 +376,8 @@ static int
nfp_cpp_bridge_service_func(void *args)
{
struct sockaddr address;
struct nfp_cpp *cpp = args;
struct nfp_cpp *cpp;
struct nfp_pf_dev *pf_dev;
int sockfd, datafd, op, ret;
unlink("/tmp/nfp_cpp");
@ -408,7 +410,9 @@ nfp_cpp_bridge_service_func(void *args)
return ret;
}
for (;;) {
pf_dev = args;
cpp = pf_dev->cpp;
while (rte_service_runstate_get(pf_dev->cpp_bridge_id) != 0) {
datafd = accept(sockfd, NULL, NULL);
if (datafd < 0) {
RTE_LOG(ERR, PMD, "%s: accept call error (%d)\n",

View File

@ -26,7 +26,7 @@
#define NFP_IOCTL 'n'
#define NFP_IOCTL_CPP_IDENTIFICATION _IOW(NFP_IOCTL, 0x8f, uint32_t)
int nfp_enable_cpp_service(struct nfp_cpp *cpp);
int nfp_enable_cpp_service(struct nfp_pf_dev *pf_dev);
int nfp_map_service(uint32_t service_id);
#endif /* _NFP_CPP_BRIDGE_H_ */

View File

@ -1071,7 +1071,7 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
}
/* register the CPP bridge service here for primary use */
ret = nfp_enable_cpp_service(pf_dev->cpp);
ret = nfp_enable_cpp_service(pf_dev);
if (ret != 0)
PMD_INIT_LOG(INFO, "Enable cpp service failed.");