From: "Burakov, Anatoly" <anatoly.burakov@intel.com>
To: David Marchand <david.marchand@redhat.com>
Cc: <dev@dpdk.org>, <bruce.richardson@intel.com>,
Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Subject: Re: [PATCH v6 1/2] net/iavf: accept up to 32k unicast MAC addresses
Date: Fri, 11 Sep 2026 14:14:40 +0200 [thread overview]
Message-ID: <d4da5ffe-0c64-4c16-8fcc-c2b1fcbe7221@intel.com> (raw)
In-Reply-To: <CAJFAV8xfgJQpa2OedL+aDmaLyEHk8DVr=hVVf-muH-za0UOw+w@mail.gmail.com>
On 9/11/2026 1:52 PM, David Marchand wrote:
> On Fri, 11 Sept 2026 at 11:37, Burakov, Anatoly
> <anatoly.burakov@intel.com> wrote:
>>> I would have preferred it if the caller managed the chunking, not the
>>> "add_del_addr_bulk" function. There is precedent for this style of
>>> refactor already [1], and I would like to keep things consistent - keep
>>> the loop simple (without memsets etc.), and make the caller manage how
>>> many addresses are being sent at once.
>>>
>>> [1] https://patches.dpdk.org/project/dpdk/
>>> patch/5e6a55afa2b45e3ee5ec17af7a6c548c96e9698b.1771945933.git.anatoly.burakov@intel.com/
>>>
>>> This specific refactor is more about removing rte_malloc, but it does
>>> also reorganize the loop in a way that I find to be more readable.
>>>
>>
>> I tried prototyping a loop, and realized that the fact that MAC address
>> list has holes in it is making things a little difficult, but here's
>> what I came up with as an alternative implementation, I think it's a
>> little clearer:
>>
>> ```
>> #define IAVF_ETH_ADDR_PER_REQ \
>> ((IAVF_AQ_BUF_SZ - sizeof(struct virtchnl_ether_addr_list)) / \
>> sizeof(struct virtchnl_ether_addr))
>>
>> struct iavf_eth_addr_cmd {
>> struct virtchnl_ether_addr_list list;
>> struct virtchnl_ether_addr extra[IAVF_ETH_ADDR_PER_REQ];
>> };
>>
>> static int
>> iavf_send_uc_addr_list(struct iavf_adapter *adapter,
>> struct virtchnl_ether_addr_list *list, bool add)
>
> Passing the list object means the function *assumes* that the mac
> addresses array follows right after.
> Idem, the sending function now assumes the size of the passed object.
>
> If the filling happens at the caller, then I'd rather pass the full
> object and its size.
Yes, agreed, although `list` will have information about list size so
IMO just passing the full object is enough.
>
>
>> {
>> const char *opname = add ? "VIRTCHNL_OP_ADD_ETH_ADDR" :
>> "VIRTCHNL_OP_DEL_ETH_ADDR";
>> uint8_t msg_buf[IAVF_AQ_BUF_SZ] = {0};
>> struct iavf_cmd_info args = {0};
>> int err;
>>
>> args.ops = add ? VIRTCHNL_OP_ADD_ETH_ADDR : VIRTCHNL_OP_DEL_ETH_ADDR;
>> args.in_args = (uint8_t *)list;
>> args.in_args_size = sizeof(struct virtchnl_ether_addr_list) +
>> sizeof(struct virtchnl_ether_addr) * list->num_elements;
>> args.out_buffer = msg_buf;
>> args.out_size = IAVF_AQ_BUF_SZ;
>>
>> err = iavf_execute_vf_cmd_safe(adapter, &args);
>> if (err != 0)
>> PMD_DRV_LOG(ERR, "fail to execute command %s for %u macs",
>> opname, list->num_elements);
>> else
>> PMD_DRV_LOG(DEBUG, "executed command %s for %u macs",
>> opname, list->num_elements);
>>
>> return err;
>> }
>>
>> void
>> iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add)
>> {
>> struct rte_ether_addr *addrs = adapter->dev_data->mac_addrs;
>> struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
>> uint32_t idx = 1;
>>
>> /* Handle primary address (index 0) separately */
>> if (!rte_is_zero_ether_addr(&addrs[0]))
>> iavf_add_del_eth_addr(adapter, &addrs[0], add,
>> VIRTCHNL_ETHER_ADDR_PRIMARY);
>>
>> /* the secondary address list is sparse, so gather it into full batches */
>> while (idx < IAVF_UC_MACADDR_MAX) {
>> struct iavf_eth_addr_cmd cmd = {0};
>> uint16_t nb_addrs = 0;
>>
>> for (; idx < IAVF_UC_MACADDR_MAX && nb_addrs < IAVF_ETH_ADDR_PER_REQ;
>> idx++) {
>> if (rte_is_zero_ether_addr(&addrs[idx]))
>> continue;
>>
>> memcpy(cmd.list.list[nb_addrs].addr, addrs[idx].addr_bytes,
>> sizeof(cmd.list.list[nb_addrs].addr));
>> cmd.list.list[nb_addrs].type = VIRTCHNL_ETHER_ADDR_EXTRA;
>> nb_addrs++;
>> }
>>
>> if (nb_addrs == 0)
>> break;
>>
>> cmd.list.vsi_id = vf->vsi_res->vsi_id;
>> cmd.list.num_elements = nb_addrs;
>> if (iavf_send_uc_addr_list(adapter, &cmd.list, add) != 0)
>> break;
>> }
>> }
>> ```
>
> Well, if we go with such a refactoring, I am not a fan of the nested
> loops, but I get the idea.
> I'll have a try.
>
I would argue that nested loop doing compaction is idiomatic - it's
naturally a nested loop operation, so we're going to have nested loops
either way. However, the control flow is IMO much cleaner that way,
because there is no special casing inside the "send the list" function,
and additionally, such an approach lends itself to much fewer virtchnl
calls - with your code, in a degenerate "valid addr in every other
slot", you'd essentially be spamming virtchnl on every addr, while with
a nested loop like mine, you'd just compact it into a list straight away
and get away with far fewer virtchnl call-ins. So, I'd really like to
keep this kind of flow, if you don't mind :)
--
Thanks,
Anatoly
next prev parent reply other threads:[~2026-09-11 12:14 UTC|newest]
Thread overview: 97+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-03 9:18 [PATCH 0/4] Remove limitations coming from legacy VMDq David Marchand
2026-04-03 9:18 ` [PATCH 1/4] ethdev: skip VMDq pools unless configured David Marchand
2026-06-01 9:30 ` Andrew Rybchenko
2026-04-03 9:18 ` [PATCH 2/4] ethdev: announce VMDq capability David Marchand
2026-04-06 22:22 ` Kishore Padmanabha
2026-04-29 14:18 ` David Marchand
2026-05-18 22:12 ` Kishore Padmanabha
2026-06-01 9:32 ` Andrew Rybchenko
2026-04-03 9:18 ` [PATCH 3/4] ethdev: hide VMDq internal sizes David Marchand
2026-06-01 9:34 ` Andrew Rybchenko
2026-04-03 9:18 ` [PATCH 4/4] net/iavf: accept up to 32k unicast MAC addresses David Marchand
2026-04-05 18:47 ` [PATCH 0/4] Remove limitations coming from legacy VMDq Stephen Hemminger
2026-04-29 14:22 ` David Marchand
2026-05-06 12:35 ` [PATCH v2 0/5] " David Marchand
2026-05-06 12:35 ` [PATCH v2 1/5] ethdev: skip VMDq pools unless configured David Marchand
2026-06-01 9:35 ` Andrew Rybchenko
2026-05-06 12:35 ` [PATCH v2 2/5] ethdev: announce VMDq capability David Marchand
2026-06-01 9:36 ` Andrew Rybchenko
2026-05-06 12:35 ` [PATCH v2 3/5] ethdev: hide VMDq internal sizes David Marchand
2026-05-06 12:35 ` [PATCH v2 4/5] net/iavf: accept up to 32k unicast MAC addresses David Marchand
2026-05-06 12:35 ` [PATCH v2 5/5] net/iavf: fix duplicate MAC addresses install David Marchand
2026-05-07 2:51 ` [PATCH v2 0/5] Remove limitations coming from legacy VMDq Stephen Hemminger
2026-05-10 15:03 ` David Marchand
2026-05-10 17:03 ` [PATCH v3 " David Marchand
2026-05-10 17:03 ` [PATCH v3 1/5] ethdev: check VMDq availability David Marchand
2026-06-01 9:38 ` Andrew Rybchenko
2026-05-10 17:03 ` [PATCH v3 2/5] ethdev: skip VMDq pools unless configured David Marchand
2026-06-01 9:38 ` Andrew Rybchenko
2026-05-10 17:03 ` [PATCH v3 3/5] ethdev: hide VMDq internal sizes David Marchand
2026-06-01 9:39 ` Andrew Rybchenko
2026-05-10 17:03 ` [PATCH v3 4/5] net/iavf: accept up to 32k unicast MAC addresses David Marchand
2026-05-12 14:41 ` Stephen Hemminger
2026-05-27 13:25 ` David Marchand
2026-05-10 17:03 ` [PATCH v3 5/5] net/iavf: fix duplicate MAC addresses install David Marchand
2026-07-09 16:02 ` [PATCH v4 00/10] Remove limitations coming from legacy VMDq David Marchand
2026-07-09 16:02 ` [PATCH v4 01/10] ethdev: check VMDq availability David Marchand
2026-07-09 16:02 ` [PATCH v4 02/10] ethdev: skip VMDq pools unless configured David Marchand
2026-07-09 16:02 ` [PATCH v4 03/10] ethdev: hide VMDq internal sizes David Marchand
2026-07-09 16:02 ` [PATCH v4 04/10] net/iavf: accept up to 32k unicast MAC addresses David Marchand
2026-07-09 16:02 ` [PATCH v4 05/10] net/iavf: fix duplicate MAC addresses install David Marchand
2026-07-13 13:12 ` Loftus, Ciara
2026-07-13 14:10 ` David Marchand
2026-07-14 9:23 ` Loftus, Ciara
2026-07-09 16:02 ` [PATCH v4 06/10] net/mlx5: remove MAC addresses flush helper on Linux David Marchand
2026-07-09 16:02 ` [PATCH v4 07/10] net/mlx5: remove redundant MAC address index checks David Marchand
2026-07-09 16:02 ` [PATCH v4 08/10] net/mlx5: pass maximum number of unicast MAC to common code David Marchand
2026-07-09 16:02 ` [PATCH v4 09/10] net/mlx5: use bitset for tracking MAC addresses David Marchand
2026-07-09 16:02 ` [PATCH v4 10/10] net/mlx5: accept more unicast " David Marchand
2026-07-10 6:44 ` David Marchand
2026-07-10 7:48 ` David Marchand
2026-07-23 12:41 ` [PATCH v5 00/10] Remove limitations coming from legacy VMDq David Marchand
2026-07-23 12:41 ` [PATCH v5 01/10] ethdev: check VMDq availability David Marchand
2026-07-23 12:41 ` [PATCH v5 02/10] ethdev: skip VMDq pools unless configured David Marchand
2026-07-23 12:41 ` [PATCH v5 03/10] ethdev: hide VMDq internal sizes David Marchand
2026-07-23 12:41 ` [PATCH v5 04/10] net/iavf: accept up to 32k unicast MAC addresses David Marchand
2026-07-23 12:41 ` [PATCH v5 05/10] net/iavf: fix duplicate MAC addresses install David Marchand
2026-07-23 12:41 ` [PATCH v5 06/10] net/mlx5: remove MAC addresses flush helper on Linux David Marchand
2026-07-23 12:41 ` [PATCH v5 07/10] net/mlx5: remove redundant MAC address index checks David Marchand
2026-07-23 12:41 ` [PATCH v5 08/10] net/mlx5: pass maximum number of unicast MAC to common code David Marchand
2026-07-23 17:35 ` Stephen Hemminger
2026-07-23 12:41 ` [PATCH v5 09/10] net/mlx5: use bitset for tracking MAC addresses David Marchand
2026-07-23 12:41 ` [PATCH v5 10/10] net/mlx5: accept more unicast " David Marchand
2026-07-27 7:20 ` [PATCH v5 00/10] Remove limitations coming from legacy VMDq David Marchand
2026-08-24 11:42 ` [PATCH v6 0/3] " David Marchand
2026-08-24 11:42 ` [PATCH v6 1/3] ethdev: check VMDq availability David Marchand
2026-08-24 11:42 ` [PATCH v6 2/3] ethdev: skip VMDq pools unless configured David Marchand
2026-08-24 16:21 ` Stephen Hemminger
2026-08-24 16:24 ` David Marchand
2026-08-24 16:39 ` Stephen Hemminger
2026-08-24 11:42 ` [PATCH v6 3/3] ethdev: hide VMDq internal sizes David Marchand
2026-08-24 17:01 ` [PATCH v6 0/3] Remove limitations coming from legacy VMDq Stephen Hemminger
2026-09-04 12:28 ` [PATCH v6 1/2] net/iavf: accept up to 32k unicast MAC addresses David Marchand
2026-09-04 12:28 ` [PATCH v6 2/2] net/iavf: fix duplicate MAC addresses install David Marchand
2026-09-09 9:39 ` Loftus, Ciara
2026-09-11 14:14 ` David Marchand
2026-09-11 15:37 ` David Marchand
2026-09-11 16:26 ` David Marchand
2026-09-10 10:24 ` [PATCH v6 1/2] net/iavf: accept up to 32k unicast MAC addresses Burakov, Anatoly
2026-09-11 9:37 ` Burakov, Anatoly
2026-09-11 11:52 ` David Marchand
2026-09-11 12:14 ` Burakov, Anatoly [this message]
2026-09-10 12:13 ` Burakov, Anatoly
2026-09-10 12:20 ` Burakov, Anatoly
2026-09-10 12:30 ` David Marchand
2026-09-10 12:38 ` Burakov, Anatoly
2026-09-08 9:27 ` [PATCH v6 1/5] net/mlx5: remove MAC addresses flush helper on Linux David Marchand
2026-09-08 9:27 ` [PATCH v6 2/5] net/mlx5: remove redundant MAC address index checks David Marchand
2026-09-11 8:36 ` Dariusz Sosnowski
2026-09-08 9:27 ` [PATCH v6 3/5] net/mlx5: pass maximum number of unicast MAC to common code David Marchand
2026-09-11 8:38 ` Dariusz Sosnowski
2026-09-08 9:27 ` [PATCH v6 4/5] net/mlx5: use bitset for tracking MAC addresses David Marchand
2026-09-11 8:40 ` Dariusz Sosnowski
2026-09-08 9:27 ` [PATCH v6 5/5] net/mlx5: accept more unicast " David Marchand
2026-09-11 8:59 ` Dariusz Sosnowski
2026-09-11 9:55 ` David Marchand
2026-09-11 10:01 ` Dariusz Sosnowski
2026-09-11 8:35 ` [PATCH v6 1/5] net/mlx5: remove MAC addresses flush helper on Linux Dariusz Sosnowski
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=d4da5ffe-0c64-4c16-8fcc-c2b1fcbe7221@intel.com \
--to=anatoly.burakov@intel.com \
--cc=bruce.richardson@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=vladimir.medvedkin@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