The services don't have a method to break the infinite loop, and
this will cause the DPDK app can't end normally.
Fixes: a36634e87e16 ("net/nfp: add flower ctrl VNIC Rx/Tx")
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/nfp/flower/nfp_flower.c | 1 +
drivers/net/nfp/flower/nfp_flower.h | 3 +++
drivers/net/nfp/flower/nfp_flower_ctrl.c | 3 ++-
drivers/net/nfp/nfp_common.h | 3 +++
drivers/net/nfp/nfp_cpp_bridge.c | 12 ++++++++----
drivers/net/nfp/nfp_cpp_bridge.h | 2 +-
drivers/net/nfp/nfp_ethdev.c | 2 +-
7 files changed, 19 insertions(+), 7 deletions(-)
@@ -1056,6 +1056,7 @@
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*/
@@ -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);
@@ -4,6 +4,7 @@
*/
#include <rte_common.h>
+#include <rte_service.h>
#include <ethdev_pci.h>
#include "../nfp_common.h"
@@ -238,7 +239,7 @@
/* 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;
@@ -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 {
@@ -80,7 +80,7 @@
}
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 @@
.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 @@
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 @@
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 @@
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",
@@ -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_ */
@@ -1065,7 +1065,7 @@
}
/* 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.");