From: "Zhang, Qi Z" <qi.z.zhang@intel.com>
To: "Qiao, Wenjing" <wenjing.qiao@intel.com>,
"Wu, Jingjing" <jingjing.wu@intel.com>,
"Xing, Beilei" <beilei.xing@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
"Pau, Christopher" <christopher.pau@intel.com>
Subject: RE: [PATCH v2 11/15] common/idpf: allocate static buffer at initialization
Date: Mon, 24 Apr 2023 12:15:16 +0000 [thread overview]
Message-ID: <DM4PR11MB5994C46F6D27D743D4DCE81BD7679@DM4PR11MB5994.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20230421084043.135503-12-wenjing.qiao@intel.com>
> -----Original Message-----
> From: Qiao, Wenjing <wenjing.qiao@intel.com>
> Sent: Friday, April 21, 2023 4:41 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org; Qiao, Wenjing <wenjing.qiao@intel.com>; Pau,
> Christopher <christopher.pau@intel.com>
> Subject: [PATCH v2 11/15] common/idpf: allocate static buffer at
> initialization
>
> Some OSs don't allow allocating DMA memory at runtime. So create an initial
> static buffer at initialization to hold this data.
Seems this is not for DPDK which should support DMA allocation, do we really need this patch?
Btw using global variables in a module can create issues in a multi-device environment where multiple devices share the same module.
We can consider to embedded this struct in idpf_hw.
>
> Signed-off-by: Christopher Pau <christopher.pau@intel.com>
> Signed-off-by: Wenjing Qiao <wenjing.qiao@intel.com>
> ---
> drivers/common/idpf/base/idpf_common.c | 26 +++++++++++++++-----------
> 1 file changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/common/idpf/base/idpf_common.c
> b/drivers/common/idpf/base/idpf_common.c
> index de82c3458f..f4a5707272 100644
> --- a/drivers/common/idpf/base/idpf_common.c
> +++ b/drivers/common/idpf/base/idpf_common.c
> @@ -6,6 +6,7 @@
> #include "idpf_prototype.h"
> #include "virtchnl.h"
>
> +struct idpf_dma_mem send_dma_mem = { 0 };
>
> /**
> * idpf_set_mac_type - Sets MAC type
> @@ -132,6 +133,15 @@ int idpf_init_hw(struct idpf_hw *hw, struct
> idpf_ctlq_size ctlq_size)
>
> idpf_free(hw, q_info);
>
> + /*
> + * Need an initial static buffer to copy DMA memory to send
> + * for drivers that do not allow this allocation at runtime
> + */
> + send_dma_mem.va = (struct idpf_dma_mem *)
> + idpf_alloc_dma_mem(hw, &send_dma_mem, 4096);
> + if (!send_dma_mem.va)
> + return -ENOMEM;
> +
> return 0;
> }
>
> @@ -152,7 +162,6 @@ int idpf_send_msg_to_cp(struct idpf_hw *hw, int
> v_opcode,
> int v_retval, u8 *msg, u16 msglen)
> {
> struct idpf_ctlq_msg ctlq_msg = { 0 };
> - struct idpf_dma_mem dma_mem = { 0 };
> int status;
>
> ctlq_msg.opcode = idpf_mbq_opc_send_msg_to_pf; @@ -162,19
> +171,11 @@ int idpf_send_msg_to_cp(struct idpf_hw *hw, int v_opcode,
> ctlq_msg.cookie.mbx.chnl_opcode = v_opcode;
>
> if (msglen > 0) {
> - dma_mem.va = (struct idpf_dma_mem *)
> - idpf_alloc_dma_mem(hw, &dma_mem, msglen);
> - if (!dma_mem.va)
> - return -ENOMEM;
> -
> - idpf_memcpy(dma_mem.va, msg, msglen,
> IDPF_NONDMA_TO_DMA);
> - ctlq_msg.ctx.indirect.payload = &dma_mem;
> + idpf_memcpy(send_dma_mem.va, msg, msglen,
> IDPF_NONDMA_TO_DMA);
> + ctlq_msg.ctx.indirect.payload = &send_dma_mem;
> }
> status = idpf_ctlq_send(hw, hw->asq, 1, &ctlq_msg);
>
> - if (dma_mem.va)
> - idpf_free_dma_mem(hw, &dma_mem);
> -
> return status;
> }
>
> @@ -262,6 +263,9 @@ int idpf_clean_arq_element(struct idpf_hw *hw,
> */
> int idpf_deinit_hw(struct idpf_hw *hw)
> {
> + if (send_dma_mem.va)
> + idpf_free_dma_mem(hw, &send_dma_mem);
> +
> hw->asq = NULL;
> hw->arq = NULL;
>
> --
> 2.25.1
next prev parent reply other threads:[~2023-04-24 12:15 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-13 9:44 [PATCH 00/18] update idpf shared code Wenjing Qiao
2023-04-13 9:44 ` [PATCH 01/18] common/idpf: support flow subscription Wenjing Qiao
2023-04-21 8:40 ` [PATCH v2 00/15] update idpf shared code Wenjing Qiao
2023-04-21 8:40 ` [PATCH v2 01/15] common/idpf: remove virtchnl related " Wenjing Qiao
2023-04-24 11:52 ` Zhang, Qi Z
2023-04-26 10:22 ` [PATCH v3 00/15] update idpf base code Wenjing Qiao
2023-04-26 10:22 ` [PATCH v3 01/15] common/idpf/base: remove virtchnl related " Wenjing Qiao
2023-04-26 10:22 ` [PATCH v3 02/15] common/idpf/base: fix ctlq message send and receive Wenjing Qiao
2023-04-26 10:22 ` [PATCH v3 03/15] common/idpf/base: fix ITR register definitions for AVF Wenjing Qiao
2023-04-26 10:22 ` [PATCH v3 04/15] common/idpf/base: remove qregion struct variables Wenjing Qiao
2023-04-26 10:22 ` [PATCH v3 05/15] common/idpf/base: move OEM capability to the last bit Wenjing Qiao
2023-04-26 10:22 ` [PATCH v3 06/15] common/idpf/base: modify SSO/LSO and ITR fields Wenjing Qiao
2023-04-26 10:22 ` [PATCH v3 07/15] common/idpf/base: add virtchnl2 error codes Wenjing Qiao
2023-04-26 10:22 ` [PATCH v3 08/15] common/idpf/base: swap opcode and retval location in msg struct Wenjing Qiao
2023-04-26 10:22 ` [PATCH v3 09/15] common/idpf/base: fix idpf_send_msg_to_cp prototypes Wenjing Qiao
2023-04-26 10:22 ` [PATCH v3 10/15] common/idpf/base: fix memory leaks on ctrlq functions Wenjing Qiao
2023-04-26 10:22 ` [PATCH v3 11/15] common/idpf/base: allocate static buffer at initialization Wenjing Qiao
2023-04-26 10:22 ` [PATCH v3 12/15] common/idpf/base: replace MAKEMASK to IDPF_M Wenjing Qiao
2023-04-26 10:22 ` [PATCH v3 13/15] common/idpf/base: add/delete queue groups commands Wenjing Qiao
2023-04-26 10:22 ` [PATCH v3 14/15] common/idpf/base: add func to clean all DESCs on controlq Wenjing Qiao
2023-04-26 10:22 ` [PATCH v3 15/15] common/idpf/base: update license and README Wenjing Qiao
2023-04-26 11:56 ` Zhang, Qi Z
2023-06-12 10:18 ` Thomas Monjalon
2023-04-26 12:40 ` [PATCH v3 00/15] update idpf base code Zhang, Qi Z
2023-04-21 8:40 ` [PATCH v2 02/15] common/idpf: fix ctlq message send and receive Wenjing Qiao
2023-04-21 8:40 ` [PATCH v2 03/15] common/idpf: fix ITR register definitions for AVF Wenjing Qiao
2023-04-21 8:40 ` [PATCH v2 04/15] common/idpf: remove qregion struct variables Wenjing Qiao
2023-04-21 8:40 ` [PATCH v2 05/15] common/idpf: move OEM capability to the last bit Wenjing Qiao
2023-04-21 8:40 ` [PATCH v2 06/15] common/idpf: modify SSO/LSO and ITR fields Wenjing Qiao
2023-04-21 8:40 ` [PATCH v2 07/15] common/idpf: add virtchnl2 error codes Wenjing Qiao
2023-04-21 8:40 ` [PATCH v2 08/15] common/idpf: swap opcode and retval location in msg struct Wenjing Qiao
2023-04-21 8:40 ` [PATCH v2 09/15] common/idpf: fix idpf_send_msg_to_cp prototypes Wenjing Qiao
2023-04-21 8:40 ` [PATCH v2 10/15] common/idpf: fix memory leaks on ctrlq functions Wenjing Qiao
2023-04-21 8:40 ` [PATCH v2 11/15] common/idpf: allocate static buffer at initialization Wenjing Qiao
2023-04-24 12:15 ` Zhang, Qi Z [this message]
2023-04-21 8:40 ` [PATCH v2 12/15] common/idpf: replace MAKEMASK to IDPF_M Wenjing Qiao
2023-04-21 8:40 ` [PATCH v2 13/15] common/idpf: add/delete queue groups commands Wenjing Qiao
2023-04-21 8:40 ` [PATCH v2 14/15] common/idpf: add func to clean all DESCs on controlq Wenjing Qiao
2023-04-21 8:40 ` [PATCH v2 15/15] common/idpf: update license and README Wenjing Qiao
2023-04-13 9:44 ` [PATCH 02/18] common/idpf: fix ctlq message send and receive Wenjing Qiao
2023-04-13 9:44 ` [PATCH 03/18] common/idpf: fix ITR register definitions for AVF Wenjing Qiao
2023-04-13 9:44 ` [PATCH 04/18] common/idpf: remove qregion struct variables Wenjing Qiao
2023-04-13 9:44 ` [PATCH 05/18] common/idpf: move OEM capability to the last bit Wenjing Qiao
2023-04-13 9:44 ` [PATCH 06/18] common/idpf: modify SSO/LSO and ITR fields Wenjing Qiao
2023-04-13 9:44 ` [PATCH 07/18] common/idpf: add virtchnl2 error codes Wenjing Qiao
2023-04-13 9:44 ` [PATCH 08/18] common/idpf: swap opcode and retval location in msg struct Wenjing Qiao
2023-04-13 9:44 ` [PATCH 09/18] common/idpf: fix idpf_send_msg_to_cp prototypes Wenjing Qiao
2023-04-13 9:44 ` [PATCH 10/18] common/idpf: fix memory leaks on ctrlq functions Wenjing Qiao
2023-04-13 9:44 ` [PATCH 11/18] common/idpf: allocate static buffer at initialization Wenjing Qiao
2023-04-13 9:44 ` [PATCH 12/18] common/idpf: add SyncE support over VF Wenjing Qiao
2023-04-13 9:44 ` [PATCH 13/18] common/idpf: replace MAKEMASK to IDPF_M Wenjing Qiao
2023-04-13 9:44 ` [PATCH 14/18] common/idpf: add GNSS support over VF Wenjing Qiao
2023-04-13 9:44 ` [PATCH 15/18] common/idpf: add/delete queue groups commands Wenjing Qiao
2023-04-13 9:45 ` [PATCH 16/18] common/idpf: add func to clean all DESCs on controlq Wenjing Qiao
2023-04-13 9:45 ` [PATCH 17/18] common/idpf: fix cannot understand warnings Wenjing Qiao
2023-04-13 9:45 ` [PATCH 18/18] common/idpf: update license and README Wenjing Qiao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DM4PR11MB5994C46F6D27D743D4DCE81BD7679@DM4PR11MB5994.namprd11.prod.outlook.com \
--to=qi.z.zhang@intel.com \
--cc=beilei.xing@intel.com \
--cc=christopher.pau@intel.com \
--cc=dev@dpdk.org \
--cc=jingjing.wu@intel.com \
--cc=wenjing.qiao@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).