On Mon, 10 Feb 2025 09:47:02 +0800 Bingbin Chen <chen.bing...@zte.com.cn> wrote:
> Add agent channel to access (np)network processor registers > that are not mapped by PCIE. > > Signed-off-by: Bingbin Chen <chen.bing...@zte.com.cn> > --- > drivers/net/zxdh/zxdh_np.c | 481 ++++++++++++++++++++++++++++++++++++- > drivers/net/zxdh/zxdh_np.h | 77 ++++++ > 2 files changed, 557 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/zxdh/zxdh_np.c b/drivers/net/zxdh/zxdh_np.c > index 538e3829aa..bab8b23a68 100644 > --- a/drivers/net/zxdh/zxdh_np.c > +++ b/drivers/net/zxdh/zxdh_np.c > @@ -13,6 +13,7 @@ > > #include "zxdh_np.h" > #include "zxdh_logs.h" > +#include "zxdh_msg.h" > > static ZXDH_DEV_MGR_T g_dev_mgr; > static ZXDH_SDT_MGR_T g_sdt_mgr; > @@ -234,6 +235,21 @@ do {\ > } \ > } while (0) > > +#define ZXDH_COMM_CHECK_DEV_RC_UNLOCK(dev_id, rc, becall, mutex)\ > +do {\ > + uint32_t temp_rc = rc;\ > + if ((temp_rc) != ZXDH_OK) {\ > + PMD_DRV_LOG(ERR, "ZXDH %s:%d [ErrorCode:0x%x]!-- %s"\ > + "Call %s Fail!", __FILE__, __LINE__, temp_rc, __func__, > becall);\ > + if (zxdh_np_comm_mutex_unlock(mutex) != 0) { \ > + PMD_DRV_LOG(ERR, "File: [%s], Function:[%s], Line:%u > mutex"\ > + "unlock failed!-->Return ERROR",\ > + __FILE__, __func__, __LINE__);\ > + } \ > + RTE_ASSERT(0);\ > + } \ > +} while (0) > + > #define ZXDH_COMM_CHECK_POINT_NO_ASSERT(point)\ > do {\ > if ((point) == NULL) {\ > @@ -330,6 +346,66 @@ zxdh_np_comm_convert32(uint32_t dw_data) > #define ZXDH_DTB_QUEUE_INIT_FLAG_GET(DEV_ID, QUEUE_ID) \ > (p_dpp_dtb_mgr[(DEV_ID)]->queue_info[(QUEUE_ID)].init_flag) > > +static uint32_t > +zxdh_np_comm_mutex_create(ZXDH_MUTEX_T *p_mutex) > +{ > + int32_t rc = 0; > + > + rc = pthread_mutex_init(&p_mutex->mutex, NULL); > + if (rc != 0) { > + PMD_DRV_LOG(ERR, "ErrCode[ 0x%x ]: Create mutex failed", > + ZXDH_MUTEX_LOCK_INIT_FAIL); > + return ZXDH_MUTEX_LOCK_INIT_FAIL; > + } > + > + return ZXDH_OK; > +} Why do you need a pthread mutex versus one of the other existing DPDK locking primitives. A pthread_mutex is slower, has more errors to check, and is not portable. The one reason would be if you are trying to synchronize something that is slow (might sleep) or with an external non-DPDK program