DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Zhang, Qi Z" <qi.z.zhang@intel.com>
To: "Pei, Andy" <andy.pei@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "Wu, Jingjing" <jingjing.wu@intel.com>,
	"Xing, Beilei" <beilei.xing@intel.com>,
	"Yigit, Ferruh" <ferruh.yigit@intel.com>,
	"Xu, Rosen" <rosen.xu@intel.com>,
	"Ye, Xiaolong" <xiaolong.ye@intel.com>,
	"Zhang, Roy Fan" <roy.fan.zhang@intel.com>,
	"stable@dpdk.org" <stable@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v6 1/2] net/i40e: i40e get link status update from ipn3ke
Date: Thu, 11 Jul 2019 04:36:32 +0000	[thread overview]
Message-ID: <039ED4275CED7440929022BC67E7061153D64E1C@SHSMSX105.ccr.corp.intel.com> (raw)
In-Reply-To: <1562751666-435953-1-git-send-email-andy.pei@intel.com>



> -----Original Message-----
> From: Pei, Andy
> Sent: Wednesday, July 10, 2019 5:41 PM
> To: dev@dpdk.org
> Cc: Pei, Andy <andy.pei@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; Wu,
> Jingjing <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>; Yigit,
> Ferruh <ferruh.yigit@intel.com>; Xu, Rosen <rosen.xu@intel.com>; Ye,
> Xiaolong <xiaolong.ye@intel.com>; Zhang, Roy Fan
> <roy.fan.zhang@intel.com>; stable@dpdk.org
> Subject: [PATCH v6 1/2] net/i40e: i40e get link status update from ipn3ke

You can merge patch 2/2 with this patch.

...

> 
> +static struct rte_eth_dev *
> +i40e_eth_dev_get_by_switch_mode_name(const char *cfg_str) {
> +	char switch_name[RTE_ETH_NAME_MAX_LEN];
> +	char port_name[RTE_ETH_NAME_MAX_LEN];
> +	char switch_ethdev_name[RTE_ETH_NAME_MAX_LEN];
> +	uint16_t port_id;
> +	const char *p_src;
> +	char *p_dst;
> +	int ret;
> +
> +	/* An example of cfg_str is "IPN3KE_0@b3:00.0_0" */
> +	if (!strncmp(cfg_str, "IPN3KE", strlen("IPN3KE"))) {
> +		p_src = cfg_str;
> +		PMD_DRV_LOG(DEBUG, "cfg_str is %s", cfg_str);
> +
> +		/* move over "IPN3KE" */
> +		while ((*p_src != '_') && (*p_src))
> +			p_src++;
> +
> +		/* move over the first underline */
> +		p_src++;
> +
> +		p_dst = switch_name;
> +		while ((*p_src != '_') && (*p_src)) {
> +			if (*p_src == '@') {
> +				*p_dst++ = '|';
> +				p_src++;
> +			} else {
> +				*p_dst++ = *p_src++;
> +			}
> +		}
> +		*p_dst = 0;
> +		PMD_DRV_LOG(DEBUG, "switch_name is %s", switch_name);
> +
> +		/* move over the second underline */
> +		p_src++;
> +
> +		p_dst = port_name;
> +		while (*p_src)
> +			*p_dst++ = *p_src++;
> +		*p_dst = 0;
> +		PMD_DRV_LOG(DEBUG, "port_name is %s", port_name);
> +
> +		snprintf(switch_ethdev_name, sizeof(switch_ethdev_name),
> +			"net_%s_representor_%s", switch_name, port_name);
> +		PMD_DRV_LOG(DEBUG, "switch_ethdev_name is %s",
> +			switch_ethdev_name);
> +
> +		ret = rte_eth_dev_get_port_by_name(switch_ethdev_name,
> +			&port_id);
> +		if (ret)
> +			return NULL;
> +		else
> +			return &rte_eth_devices[port_id];
> +	} else {
> +		return NULL;
> +	}

This code can simplified to

If (... ) {
	...
	If (!ret)
		return &ret_eth_devices[port_id];
}

return NULL;


> +}
> +
> +static void
> +eth_i40e_pf_switch_dev_init(struct rte_eth_dev *dev, struct i40e_pf
> +*pf) {

Argument "pf" is redundant, please remove it and use
 pf =I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); 

> +	char switch_cfg_str[RTE_ETH_NAME_MAX_LEN];
> +	struct rte_kvargs *kvlist = NULL;
> +	struct rte_devargs *devargs;
> +	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
> +
> +	pf->switch_ethdev_support_flag = 0;
> +	pf->switch_ethdev = NULL;
> +
> +	devargs = pci_dev->device.devargs;
> +	if (!devargs)
> +		return;
> +
> +	kvlist = rte_kvargs_parse(devargs->args, valid_keys);
> +	if (kvlist) {
> +		if (rte_kvargs_count(kvlist, ETH_I40E_SWITCH_MODE_ARG) == 1) {
> +			pf->switch_ethdev_support_flag = 1;
> +
> +			if (!rte_kvargs_process(kvlist,
> +				ETH_I40E_SWITCH_MODE_ARG,
> +				&i40e_pf_parse_switch_mode, switch_cfg_str)) {
> +				pf->switch_ethdev =
> +					i40e_eth_dev_get_by_switch_mode_name
> +					(switch_cfg_str);
"(" should follow above line.

> +			}
> +		}
> +	rte_kvargs_free(kvlist);
Wrong intend
> +	}
> +}
> +static void
> +eth_i40e_pf_switch_dev_uninit(struct i40e_pf *pf) {
> +	pf->switch_ethdev_support_flag = 0;
> +	pf->switch_ethdev = NULL;
> +}

This function is not necessary, after dev_init must be called after dev_unit, and above reset is performed in eth_i40e_pf_switch_dev_init already.
> +
> +static int
>  eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused)
> {
>  	struct rte_pci_device *pci_dev;
> @@ -1582,6 +1701,11 @@ static inline void i40e_config_automask(struct
> i40e_pf *pf)
>  	memset(&pf->rss_info, 0,
>  		sizeof(struct i40e_rte_flow_rss_conf));
> 
> +	/* parse the switch device from devargs, try to bind to the switch
> +	 * device, if binding not succeed, bind again when i40e_dev_link_update
> +	 */
> +	eth_i40e_pf_switch_dev_init(dev, pf);
> +
>  	/* reset all stats of the device, including pf and main vsi */
>  	i40e_dev_stats_reset(dev);
> 
> @@ -1762,6 +1886,8 @@ void i40e_flex_payload_reg_set_default(struct
> i40e_hw *hw)
>  		rte_free(p_flow);
>  	}
> 
> +	eth_i40e_pf_switch_dev_uninit(pf);
> +
>  	/* Remove all Traffic Manager configuration */
>  	i40e_tm_conf_uninit(dev);
> 
> @@ -2779,13 +2905,52 @@ void i40e_flex_payload_reg_set_default(struct
> i40e_hw *hw)
>  	}
>  }
> 
> +static void
> +i40e_pf_linkstatus_get_from_switch_ethdev
> +(struct rte_eth_dev *switch_ethdev, struct rte_eth_link *link) {
> +	if (switch_ethdev) {
> +		rte_eth_linkstatus_get(switch_ethdev, link);
> +	} else {
> +		link->link_autoneg = ETH_LINK_SPEED_FIXED;
> +		link->link_duplex  = ETH_LINK_FULL_DUPLEX;
> +		link->link_speed   = ETH_SPEED_NUM_25G;
> +		link->link_status  = 0;
> +	}
> +}
> +
> +static struct rte_eth_dev *
> +i40e_get_switch_ethdev_from_devargs(struct rte_devargs *devargs) {
> +	struct rte_kvargs *kvlist = NULL;
> +	struct rte_eth_dev *switch_ethdev = NULL;
> +	char switch_cfg_str[RTE_ETH_NAME_MAX_LEN];
> +
> +	kvlist = rte_kvargs_parse(devargs->args, valid_keys);
> +	if (kvlist) {
> +		if (rte_kvargs_count(kvlist, ETH_I40E_SWITCH_MODE_ARG) == 1) {
> +			if (!rte_kvargs_process(kvlist,
> +				ETH_I40E_SWITCH_MODE_ARG,
> +				&i40e_pf_parse_switch_mode, switch_cfg_str)) {
> +				switch_ethdev =
> +					i40e_eth_dev_get_by_switch_mode_name
> +					(switch_cfg_str);
"(" should follow above line

> +			}
> +		}
> +		rte_kvargs_free(kvlist);
> +	}
> +	return switch_ethdev;
> +}
> +
>  int
>  i40e_dev_link_update(struct rte_eth_dev *dev,
>  		     int wait_to_complete)
>  {
>  	struct i40e_hw *hw =
> I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> +	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
>  	struct rte_eth_link link;
>  	bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false;
> +	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
>  	int ret;
> 
>  	memset(&link, 0, sizeof(link));
> @@ -2800,6 +2965,17 @@ void i40e_flex_payload_reg_set_default(struct
> i40e_hw *hw)
>  	else
>  		update_link_aq(hw, &link, enable_lse, wait_to_complete);
> 
> +	if (pf->switch_ethdev_support_flag) {
> +		if (!pf->switch_ethdev) {
> +			if (pci_dev->device.devargs)

No need to check here, 
If swtch_ethdev_support_flag is 1, pci_dev->device.devargs should not be null, right?

> +				pf->switch_ethdev =
> +					i40e_get_switch_ethdev_from_devargs
> +						(pci_dev->device.devargs);
> +		}
> +		i40e_pf_linkstatus_get_from_switch_ethdev(pf->switch_ethdev,
> +			&link);
> +	}
> +
>  	ret = rte_eth_linkstatus_set(dev, &link);
>  	i40e_notify_all_vfs_link_status(dev);
> 
> @@ -12773,4 +12949,5 @@ struct i40e_customized_pctype*
>  			      ETH_I40E_FLOATING_VEB_LIST_ARG "=<string>"
>  			      ETH_I40E_QUEUE_NUM_PER_VF_ARG "=1|2|4|8|16"
>  			      ETH_I40E_SUPPORT_MULTI_DRIVER "=1"
> -			      ETH_I40E_USE_LATEST_VEC "=0|1");
> +			      ETH_I40E_USE_LATEST_VEC "=0|1"
> +			      ETH_I40E_SWITCH_MODE_ARG "=IPN3KE");
> diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
> index 38ac3ea..cfdcecb 100644
> --- a/drivers/net/i40e/i40e_ethdev.h
> +++ b/drivers/net/i40e/i40e_ethdev.h
> @@ -975,6 +975,12 @@ struct i40e_pf {
>  	struct i40e_customized_pctype
> customized_pctype[I40E_CUSTOMIZED_MAX];
>  	/* Switch Domain Id */
>  	uint16_t switch_domain_id;
> +
> +	/* flag indicating if switch mode is required like other devargs */
> +	bool switch_ethdev_support_flag;
> +
> +	/* point to switch_ethdev specific by "switch_mode" in devargs */
> +	struct rte_eth_dev *switch_ethdev;
>  };
> 
>  enum pending_msg {
> --
> 1.8.3.1


  reply	other threads:[~2019-07-11  4:36 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23  9:14 [dpdk-dev] [PATCH] net/i40e: i40e rework for ipn3ke Andy Pei
2019-05-24  1:05 ` Xu, Rosen
2019-05-24 13:12   ` Ferruh Yigit
2019-05-27  1:42     ` Pei, Andy
2019-06-10  6:14   ` Pei, Andy
2019-06-11  2:35     ` Xu, Rosen
2019-06-25  9:06       ` Pei, Andy
2019-06-26 15:33 ` Ye Xiaolong
2019-06-27  1:20   ` Pei, Andy
2019-06-28  8:33 ` [dpdk-dev] [PATCH v2] net/i40e: i40e get link status update from ipn3ke Andy Pei
2019-06-30  0:35   ` Zhang, Qi Z
2019-07-04  7:03     ` Pei, Andy
2019-07-04  6:56   ` [dpdk-dev] [PATCH v3] " Andy Pei
2019-07-08  3:03     ` [dpdk-dev] [PATCH v4] " Andy Pei
2019-07-08  7:27       ` Zhang, Qi Z
2019-07-09  6:43       ` [dpdk-dev] [PATCH v5] " Andy Pei
2019-07-10  9:41         ` [dpdk-dev] [PATCH v6 1/2] " Andy Pei
2019-07-11  4:36           ` Zhang, Qi Z [this message]
2019-07-11  5:56             ` Pei, Andy
2019-07-11  6:05             ` Pei, Andy
2019-07-11  6:39           ` [dpdk-dev] [PATCH v7] " Andy Pei
2019-07-11  8:45             ` Zhang, Qi Z
2019-07-10  9:41         ` [dpdk-dev] [PATCH v6 2/2] doc: add switch mode devargs Andy Pei
2019-07-08  5:56     ` [dpdk-dev] [PATCH v3] net/i40e: i40e get link status update from ipn3ke Zhang, Qi Z
2019-07-08  8:59       ` Pei, Andy

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=039ED4275CED7440929022BC67E7061153D64E1C@SHSMSX105.ccr.corp.intel.com \
    --to=qi.z.zhang@intel.com \
    --cc=andy.pei@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=jingjing.wu@intel.com \
    --cc=rosen.xu@intel.com \
    --cc=roy.fan.zhang@intel.com \
    --cc=stable@dpdk.org \
    --cc=xiaolong.ye@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).