DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Bingbin Chen <chen.bingbin@zte.com.cn>
Cc: wang.junlong1@zte.com.cn, yang.yonggang@zte.com.cn, dev@dpdk.org
Subject: Re: [PATCH v3 2/2] net/zxdh: add support flow director ops
Date: Sun, 3 Aug 2025 10:34:58 -0700	[thread overview]
Message-ID: <20250803103458.65408641@hermes.local> (raw)
In-Reply-To: <20250702073453.113779-3-chen.bingbin@zte.com.cn>

On Wed,  2 Jul 2025 15:34:45 +0800
Bingbin Chen <chen.bingbin@zte.com.cn> wrote:

> if (hw->is_pf) {
> +			dtb_qid = hw->dev_sd->dtb_sd.queueid;
> +			fd_entry = rte_malloc(NULL,
> +				sizeof(ZXDH_DTB_ACL_ENTRY_INFO_T) * ZXDH_MAX_FLOW_NUM, 1);
> +			key = rte_malloc(NULL, sizeof(struct fd_flow_key) * ZXDH_MAX_FLOW_NUM, 1);
> +			key_mask = rte_malloc(NULL,
> +				sizeof(struct fd_flow_key) * ZXDH_MAX_FLOW_NUM, 1);
> +			result = rte_malloc(NULL,
> +				sizeof(struct fd_flow_result) * ZXDH_MAX_FLOW_NUM, 1);
> +			if (!fd_entry || !key || !key_mask || !result) {
> +				PMD_DRV_LOG(ERR, "fd_entry malloc failed!");
> +				goto end;
> +			}
> +
> +			for (int i = 0; i < ZXDH_MAX_FLOW_NUM; i++) {
> +				fd_entry[i].key_data = key + i * sizeof(struct fd_flow_key);
> +				fd_entry[i].key_mask = key_mask + i * sizeof(struct fd_flow_key);
> +				fd_entry[i].p_as_rslt = result + i * sizeof(struct fd_flow_result);
> +			}
> +			ret = zxdh_np_dtb_acl_table_dump_by_vport(hw->dev_id, dtb_qid,
> +						ZXDH_SDT_FD_TABLE, hw->vport.vport, &entry_num,
> +						(uint8_t *)fd_entry);
> +			if (ret) {
> +				PMD_DRV_LOG(ERR, "dpp_dtb_acl_table_dump_by_vport failed!");
> +				goto end;
> +			}
> +			for (uint32_t i = 0; i < entry_num; i++) {
> +				offlow_key_dump((struct fd_flow_key *)fd_entry[i].key_data,
> +					(struct fd_flow_key *)fd_entry[i].key_mask, file);
> +				offlow_result_dump((struct fd_flow_result *)fd_entry[i].p_as_rslt,
> +						file);
> +			}
> +			rte_free(result);
> +			rte_free(key_mask);
> +			rte_free(key);
> +			rte_free(fd_entry);
> +		} else {

This code uses rte_malloc for temporary buffers.
It would be faster, safer, and better to use malloc, calloc or alloca
for these arrays. The rte_malloc library allocates from shared huge pages
and the algorithm is slower than malloc, so should only be used when needed.
Also, static analyzer and compiler tools know what malloc is and do
a better job checking that.

      parent reply	other threads:[~2025-08-03 17:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-17  9:31 [PATCH v1 0/2] " Bingbin Chen
2025-06-17  9:32 ` [PATCH v1 1/2] net/zxdh: npsdk add flow director table ops Bingbin Chen
2025-06-17 14:07   ` Stephen Hemminger
2025-06-17 14:08   ` Stephen Hemminger
2025-06-17  9:32 ` [PATCH v1 2/2] net/zxdh: add support flow director ops Bingbin Chen
2025-06-18  7:49 ` [PATCH v2 0/2] " Bingbin Chen
2025-06-18  7:49   ` [PATCH v2 1/2] net/zxdh: npsdk add flow director table ops Bingbin Chen
2025-06-18  7:49   ` [PATCH v2 2/2] net/zxdh: add support flow director ops Bingbin Chen
2025-06-30 16:56     ` Stephen Hemminger
2025-07-02  7:34   ` [PATCH v3 0/2] " Bingbin Chen
2025-07-02  7:34     ` [PATCH v3 1/2] net/zxdh: npsdk add flow director table ops Bingbin Chen
2025-07-02  7:34     ` [PATCH v3 2/2] net/zxdh: add support flow director ops Bingbin Chen
2025-07-02 15:02       ` Stephen Hemminger
2025-08-03 17:34       ` Stephen Hemminger [this message]

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=20250803103458.65408641@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=chen.bingbin@zte.com.cn \
    --cc=dev@dpdk.org \
    --cc=wang.junlong1@zte.com.cn \
    --cc=yang.yonggang@zte.com.cn \
    /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).