Hi Kai, A few comments below
Thanks, Pablo > -----Original Message----- > From: Ji, Kai <kai...@intel.com> > Sent: Tuesday, October 25, 2022 10:48 PM > To: dev@dpdk.org > Cc: gak...@marvell.com; Ji, Kai <kai...@intel.com>; De Lara Guarch, Pablo > <pablo.de.lara.gua...@intel.com>; Burakov, Anatoly > <anatoly.bura...@intel.com> > Subject: [dpdk-dev v3] crypto/ipsec_mb: multi-process IPC request handler > > As the secondary process needs queue-pair to be configured by the primary > process before use. This sentence looks incomplete: as the secondary process needs...., then what? > This patch adds an IPC register function to allow > secondary process to setup cryptodev queue-pair via IPC messages during > the runtime. A new "qp_in_used_pid" param stores the PID to provide the > ownership of the queue-pair so that only the PID matched queue-pair can be > free'd in the request. > > Signed-off-by: Kai Ji <kai...@intel.com> > --- > > v3: > - remove shared memzone as qp_conf params can be passed directly from > ipc message. > > v2: > - add in shared memzone for data exchange between multi-process > --- > drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 130 > ++++++++++++++++++++- > drivers/crypto/ipsec_mb/ipsec_mb_private.c | 24 +++- > drivers/crypto/ipsec_mb/ipsec_mb_private.h | 46 ++++++++ > 3 files changed, 196 insertions(+), 4 deletions(-) > > diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c > b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c > index cedcaa2742..c29656b746 100644 > --- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c > +++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c > @@ -3,6 +3,7 @@ > */ > > #include <string.h> > +#include <unistd.h> > > #include <rte_common.h> > #include <rte_malloc.h> > @@ -93,6 +94,46 @@ ipsec_mb_info_get(struct rte_cryptodev *dev, > } > } > > +static int > +ipsec_mb_secondary_qp_op(int dev_id, int qp_id, > + const struct rte_cryptodev_qp_conf *qp_conf, > + int socket_id, uint16_t pid, enum ipsec_mb_mp_req_type > op_type) { > + int ret; > + struct rte_mp_msg qp_req_msg; > + struct rte_mp_msg *qp_resp_msg; > + struct rte_mp_reply qp_resp; > + struct ipsec_mb_mp_param *req_param; > + struct ipsec_mb_mp_param *resp_param; > + struct timespec ts = {.tv_sec = 1, .tv_nsec = 0}; > + > + memset(&qp_req_msg, 0, sizeof(IPSEC_MB_MP_MSG)); > + memcpy(qp_req_msg.name, IPSEC_MB_MP_MSG, > sizeof(IPSEC_MB_MP_MSG)); > + req_param = (struct ipsec_mb_mp_param *)&qp_req_msg.param; > + > + qp_req_msg.len_param = sizeof(struct ipsec_mb_mp_param); > + req_param->type = op_type; > + req_param->dev_id = dev_id; > + req_param->qp_id = qp_id; > + req_param->socket_id = socket_id; > + req_param->process_id = pid; I think you can use "get_pid()" here and not have "pid" argument in the function, as I believe it is always called within the same process. > + if (qp_conf) { > + req_param->nb_descriptors = qp_conf->nb_descriptors; > + req_param->mp_session = (void *)qp_conf->mp_session; > + } > + > + qp_req_msg.num_fds = 0; > + ret = rte_mp_request_sync(&qp_req_msg, &qp_resp, &ts); > + if (ret) { > + RTE_LOG(ERR, USER1, "Create MR request to primary > process failed."); > + return -1; > + } > + qp_resp_msg = &qp_resp.msgs[0]; > + resp_param = (struct ipsec_mb_mp_param *)qp_resp_msg->param; > + > + return resp_param->result; > +} > + .. > diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_private.h > b/drivers/crypto/ipsec_mb/ipsec_mb_private.h > index b56eaf061e..a2b52f808e 100644 > --- a/drivers/crypto/ipsec_mb/ipsec_mb_private.h > +++ b/drivers/crypto/ipsec_mb/ipsec_mb_private.h ... > + > /** All supported device types */ > enum ipsec_mb_pmd_types { > IPSEC_MB_PMD_TYPE_AESNI_MB = 0, > @@ -149,11 +155,51 @@ struct ipsec_mb_qp { > IMB_MGR *mb_mgr; > /* Multi buffer manager */ > const struct rte_memzone *mb_mgr_mz; > + /** The process id used for queue pairs **/ > + uint16_t qp_in_used_by_pid; I would rename this to "qp_in_use_by_pid" or "qp_used_by_pid". > /* Shared memzone for storing mb_mgr */ Check these comments. This last one "Shared memzone..." applies to the field "mb_mgr_mz". Also, they should use "/**< ". > __extension__ uint8_t additional_data[]; > /**< Storing PMD specific additional data */ }; >