DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@amd.com>
To: wanry@3snic.com, dev@dpdk.org
Cc: Steven Song <steven.song@3snic.com>
Subject: Re: [PATCH v5 11/32] net/sssnic: add dev MAC ops
Date: Tue, 26 Sep 2023 14:07:42 +0100	[thread overview]
Message-ID: <45fcc835-57b8-44fb-8690-a3b96602eeac@amd.com> (raw)
In-Reply-To: <20230904045658.238185-12-wanry@3snic.com>

On 9/4/2023 5:56 AM, wanry@3snic.com wrote:
> From: Renyong Wan <wanry@3snic.com>
> 
> Signed-off-by: Steven Song <steven.song@3snic.com>
> Signed-off-by: Renyong Wan <wanry@3snic.com>
> 

<...>

> +int
> +sssnic_mac_addr_update(struct sssnic_hw *hw, uint8_t *new, uint8_t *old)
> +{
> +	int ret;
> +	struct sssnic_mac_addr_update_cmd cmd;
> +	struct sssnic_msg msg;
> +	uint32_t cmd_len;
> +	uint16_t func;
> +
> +	if (hw == NULL || new == NULL || old == NULL)
> +		return -EINVAL;
> +
> +	if (SSSNIC_FUNC_TYPE(hw) == SSSNIC_FUNC_TYPE_VF)
> +		func = SSSNIC_PF_FUNC_IDX(hw);
> +	else
> +		func = SSSNIC_MPU_FUNC_IDX;
> +
> +	memset(&cmd, 0, sizeof(cmd));
> +	cmd_len = sizeof(cmd);
> +	cmd.function = SSSNIC_FUNC_IDX(hw);
> +	rte_memcpy(cmd.new_addr, new, 6);
> +	rte_memcpy(cmd.old_addr, old, 6);>

Can use 'RTE_ETHER_ADDR_LEN' instead of hardcoded '6', same for a few
other locations,

<...>

> +static int
> +sssnic_ethdev_mac_addrs_init(struct rte_eth_dev *ethdev)
> +{
> +	int ret;
> +	struct sssnic_netdev *netdev;
> +	struct sssnic_hw *hw;
> +	struct rte_ether_addr default_addr;
> +	char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
> +
> +	PMD_INIT_FUNC_TRACE();
> +
> +	netdev = SSSNIC_ETHDEV_PRIVATE(ethdev);
> +	hw = SSSNIC_NETDEV_TO_HW(netdev);
> +
> +	ethdev->data->mac_addrs = rte_zmalloc(NULL,
> +		SSSNIC_ETHDEV_MAX_NUM_UC_MAC * sizeof(struct rte_ether_addr),
> +		0);
> +	if (ethdev->data->mac_addrs == NULL) {
> +		PMD_DRV_LOG(ERR,
> +			"Failed to allocate memory to store %u mac addresses",
> +			SSSNIC_ETHDEV_MAX_NUM_UC_MAC);
> +		return -ENOMEM;
> +	}
> +
> +	netdev->mcast_addrs = rte_zmalloc(NULL,
> +		SSSNIC_ETHDEV_MAX_NUM_MC_MAC * sizeof(struct rte_ether_addr),
> +		0);
> +	if (netdev->mcast_addrs == NULL) {
> +		PMD_DRV_LOG(ERR,
> +			"Failed to allocate memory to store %u mcast addresses",
> +			SSSNIC_ETHDEV_MAX_NUM_MC_MAC);
> +		ret = -ENOMEM;
> +		goto alloc_mcast_addr_fail;
> +	}
> +
> +	/* initialize default MAC address */
> +	memset(&default_addr, 0, sizeof(default_addr));
> +	ret = sssnic_mac_addr_get(hw, default_addr.addr_bytes);
> +	if (ret != 0)
> +		PMD_DRV_LOG(NOTICE,
> +			"Could not get default MAC address, will use random address");
> +
> +	if (rte_is_zero_ether_addr(&default_addr))
> +		rte_eth_random_addr(default_addr.addr_bytes);
> +
> +	rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, &default_addr);
> +
> +	ret = sssnic_mac_addr_add(hw, default_addr.addr_bytes);
> +	if (ret != 0) {
> +		PMD_DRV_LOG(ERR, "Failed to add default MAC address: %s",
> +			mac_str);
> +		goto add_ether_addr_fail;
> +	}
> +
> +	rte_ether_addr_copy(&default_addr, &ethdev->data->mac_addrs[0]);
> +	rte_ether_addr_copy(&default_addr, &netdev->default_addr);
> +
>

Is there a reason to keep 'default_addr' in the device private data,
when it is already stored in 'ethdev->data->mac_addrs[0]'?

<...>

> @@ -80,6 +333,7 @@ sssnic_ethdev_release(struct rte_eth_dev *ethdev)
>  {
>  	struct sssnic_hw *hw = SSSNIC_ETHDEV_TO_HW(ethdev);
>  
> +	sssnic_ethdev_mac_addrs_clean(ethdev);
>

Should 'netdev->mcast_addrs' freed in this context?
As far as I can see it is not freed anywhere.

<...>

> @@ -140,7 +408,7 @@ sssnic_ethdev_uninit(struct rte_eth_dev *ethdev)
>  
>  	sssnic_ethdev_release(ethdev);
>  
> -	return -EINVAL;
> +	return 0;
>

This should be in previous patch, 4/32, which updates uninit function.



  reply	other threads:[~2023-09-26 13:07 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04  4:56 [PATCH v5 00/32] Introduce sssnic PMD for 3SNIC's 9x0 serials Ethernet adapters wanry
2023-09-04  4:56 ` [PATCH v5 01/32] net/sssnic: add build and doc infrastructure wanry
2023-09-26 13:06   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 02/32] net/sssnic: add log type and log macros wanry
2023-09-04  4:56 ` [PATCH v5 03/32] net/sssnic: support probe and remove wanry
2023-09-18 16:08   ` Stephen Hemminger
2023-09-19  2:00     ` Renyong Wan
2023-09-04  4:56 ` [PATCH v5 04/32] net/sssnic: initialize hardware base wanry
2023-09-18  2:28   ` Stephen Hemminger
2023-09-18  4:47     ` Renyong Wan
2023-09-04  4:56 ` [PATCH v5 05/32] net/sssnic: add event queue wanry
2023-09-04  4:56 ` [PATCH v5 06/32] net/sssnic/base: add message definition and utility wanry
2023-09-18  2:31   ` Stephen Hemminger
2023-09-18  5:08     ` Renyong Wan
2023-09-04  4:56 ` [PATCH v5 07/32] net/sssnic/base: add mailbox support wanry
2023-09-18  2:32   ` Stephen Hemminger
2023-09-18  5:10     ` Renyong Wan
2023-09-26 13:13   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 08/32] net/sssnic/base: add work queue wanry
2023-09-18  2:33   ` Stephen Hemminger
2023-09-18  5:11     ` Renyong Wan
2023-09-04  4:56 ` [PATCH v5 09/32] net/sssnic/base: add control queue wanry
2023-09-18  2:36   ` Stephen Hemminger
2023-09-18  5:22     ` Renyong Wan
2023-09-04  4:56 ` [PATCH v5 10/32] net/sssnic: add dev configure and infos get wanry
2023-09-04  4:56 ` [PATCH v5 11/32] net/sssnic: add dev MAC ops wanry
2023-09-26 13:07   ` Ferruh Yigit [this message]
2023-09-04  4:56 ` [PATCH v5 12/32] net/sssnic: support dev link status wanry
2023-09-04  4:56 ` [PATCH v5 13/32] net/sssnic: support link status event wanry
2023-09-26 13:08   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 14/32] net/sssnic: support Rx queue setup and release wanry
2023-09-04  4:56 ` [PATCH v5 15/32] net/sssnic: support Tx " wanry
2023-09-04  4:56 ` [PATCH v5 16/32] net/sssnic: support Rx queue start and stop wanry
2023-09-04  4:56 ` [PATCH v5 17/32] net/sssnic: support Tx " wanry
2023-09-04  4:56 ` [PATCH v5 18/32] net/sssnic: add Rx interrupt support wanry
2023-09-04  4:56 ` [PATCH v5 19/32] net/sssnic: support dev start and stop wanry
2023-09-26 13:09   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 20/32] net/sssnic: support dev close and reset wanry
2023-09-26 13:09   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 21/32] net/sssnic: add allmulticast and promiscuous ops wanry
2023-09-04  4:56 ` [PATCH v5 22/32] net/sssnic: add basic and extended stats ops wanry
2023-09-04  4:56 ` [PATCH v5 23/32] net/sssnic: support Rx packet burst wanry
2023-09-04  4:56 ` [PATCH v5 24/32] net/sssnic: support Tx " wanry
2023-09-26 13:10   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 25/32] net/sssnic: add RSS support wanry
2023-09-04  4:56 ` [PATCH v5 26/32] net/sssnic: support dev MTU set wanry
2023-09-04  4:56 ` [PATCH v5 27/32] net/sssnic: support dev queue info get wanry
2023-09-04  4:56 ` [PATCH v5 28/32] net/sssnic: support dev firmware version get wanry
2023-09-04  4:56 ` [PATCH v5 29/32] net/sssnic: add dev flow control ops wanry
2023-09-26 13:12   ` Ferruh Yigit
2023-09-04  4:56 ` [PATCH v5 30/32] net/sssnic: support VLAN offload and filter wanry
2023-09-04  4:56 ` [PATCH v5 31/32] net/sssnic: add generic flow ops wanry
2023-09-04  4:56 ` [PATCH v5 32/32] net/sssnic: add VF dev support wanry
2023-09-26 13:11   ` Ferruh Yigit
2023-09-18  2:37 ` [PATCH v5 00/32] Introduce sssnic PMD for 3SNIC's 9x0 serials Ethernet adapters Stephen Hemminger
2023-09-18  3:23   ` Renyong Wan
2023-09-19  3:19 ` Stephen Hemminger
2023-09-19  5:18   ` Renyong Wan
2023-09-19  3:21 ` Stephen Hemminger
2023-09-19  5:18   ` Renyong Wan
2023-09-19  3:23 ` Stephen Hemminger
2023-09-19  5:19   ` Renyong Wan
2023-09-19 15:24 ` Stephen Hemminger
2023-09-26 13:13 ` Ferruh Yigit
2024-03-29 11:32   ` Ferruh Yigit

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=45fcc835-57b8-44fb-8690-a3b96602eeac@amd.com \
    --to=ferruh.yigit@amd.com \
    --cc=dev@dpdk.org \
    --cc=steven.song@3snic.com \
    --cc=wanry@3snic.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).