DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Hemant Agrawal <hemant.agrawal@nxp.com>, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH 1/3] kni: support for MAC addr change
Date: Fri, 22 Dec 2017 13:55:52 -0800	[thread overview]
Message-ID: <1146be98-43a9-91f5-8ad2-53ae31b48b4c@intel.com> (raw)
In-Reply-To: <1512042367-6361-1-git-send-email-hemant.agrawal@nxp.com>

On 11/30/2017 3:46 AM, Hemant Agrawal wrote:
> This patch adds following:
> 1. Option to configure the mac address during create. Generate random
>    address only if the user has not provided any valid address.
> 2. Inform usespace, if mac address is being changed in linux.
> 3. Implement default handling of mac address change in the corresponding
>    ethernet device.>
> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

Overall lgtm, there are a few issues commented below.

Thanks,
ferruh

<...>

> @@ -269,11 +275,15 @@ The code for allocating the kernel NIC interfaces for a specific port is as foll
>                      conf.addr = dev_info.pci_dev->addr;
>                      conf.id = dev_info.pci_dev->id;
>  
> +                    /* Get the interface default mac address */
> +                    rte_eth_macaddr_get(port_id, struct ether_addr *)&conf.mac_addr);

a parentheses is missing, good to fix although this is document :)

<...>

> @@ -587,3 +603,26 @@ Currently, setting a new MTU and configuring the network interface (up/ down) ar
>              RTE_LOG(ERR, APP, "Failed to start port %d\n", port_id);
>          return ret;
>      }
> +
> +    /* Callback for request of configuring device mac address */
> +
> +    static int
> +    kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[])
> +    {
> +        int ret = 0;
> +
> +        if (port_id >= rte_eth_dev_count() || port_id >= RTE_MAX_ETHPORTS) {
> +                RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id);
> +                return -EINVAL;
> +        }
> +
> +        RTE_LOG(INFO, KNI, "Configure mac address of %d", port_id);
> +        /* Configure network interface mac address */
> +        ret = rte_eth_dev_default_mac_addr_set(port_id,
> +                                               (struct ether_addr *)mac_addr);
> +        if (ret < 0)
> +                RTE_LOG(ERR, KNI, "Failed to config mac_addr for port %d\n",
> +                        port_id);
> +
> +        return ret;
> +    }


It is hard to maintain code in doc, I am aware other related code is already in
document but what do you think keeping this minimal, like:

    static int
    kni_config_mac_address(uint16_t port_id, uint8_t mac_addr[])
    {
       ....
    }


<...>

> @@ -559,6 +583,14 @@ rte_kni_handle_request(struct rte_kni *kni)
>  			req->result = kni->ops.config_network_if(\
>  					kni->ops.port_id, req->if_up);
>  		break;
> +	case RTE_KNI_REQ_CHANGE_MAC_ADDR: /* Change MAC Address */
> +		if (kni->ops.config_mac_address)
> +			req->result = kni->ops.config_mac_address(
> +					kni->ops.port_id, req->mac_addr);
> +		else
> +			req->result = kni_config_mac_address(
> +					kni->ops.port_id, req->mac_addr);

ops.port_id can be unset if there is no physically backing device the kni
interface. And I guess for that case port_id will be 0 and it will corrupt other
interface's data. There needs to find a way to handle the port_id not set case.

Since kni sample always creates a KNI interface backed by pyhsical device, this
is not an issue for kni sample app but please think about kni pmd case.

<...>

> @@ -87,6 +91,7 @@ struct rte_kni_conf {
>  	unsigned mbuf_size; /* mbuf size */
>  	struct rte_pci_addr addr;
>  	struct rte_pci_id id;
> +	char mac_addr[ETHER_ADDR_LEN]; /* MAC address assigned to KNI */
>  
>  	__extension__
>  	uint8_t force_bind : 1; /* Flag to bind kernel thread */

"struct rte_kni_conf" is a public struct. Adding a variable into the middle of
the struct will break the ABI.
But I think it is OK to add to the end, unless struct is not used as array.

<...>

  parent reply	other threads:[~2017-12-22 21:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-30 11:46 Hemant Agrawal
2017-11-30 11:46 ` [dpdk-dev] [PATCH 2/3] kni: add support for promisc mode set Hemant Agrawal
2017-12-22 21:57   ` Ferruh Yigit
2017-11-30 11:46 ` [dpdk-dev] [PATCH 3/3] kni: set initial value for MTU Hemant Agrawal
2017-12-22 22:01   ` Ferruh Yigit
2017-12-22 21:55 ` Ferruh Yigit [this message]
2017-12-26 10:08   ` [dpdk-dev] [PATCH 1/3] kni: support for MAC addr change Hemant Agrawal
2017-12-26 10:36 ` [dpdk-dev] [PATCH v2 " Hemant Agrawal
2017-12-26 10:36   ` [dpdk-dev] [PATCH v2 2/3] kni: add support for promisc mode set Hemant Agrawal
2017-12-26 10:36   ` [dpdk-dev] [PATCH v2 3/3] kni: set initial value for MTU Hemant Agrawal
2018-01-18  6:12   ` [dpdk-dev] [PATCH v3 1/3] kni: support for MAC addr change Hemant Agrawal
2018-01-18  6:12     ` [dpdk-dev] [PATCH v3 2/3] kni: add support for promisc mode set Hemant Agrawal
2018-01-18  6:13     ` [dpdk-dev] [PATCH v3 3/3] kni: set initial value for MTU Hemant Agrawal
2018-01-21 22:07     ` [dpdk-dev] [PATCH v3 1/3] kni: support for MAC addr change Ferruh Yigit
2018-01-22  5:20       ` Hemant Agrawal
2018-01-22 15:48         ` Ferruh Yigit
2018-02-01  0:04           ` Thomas Monjalon

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=1146be98-43a9-91f5-8ad2-53ae31b48b4c@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.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).