DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Xueming(Steven) Li" <xuemingl@mellanox.com>
To: Adrien Mazarguil <adrien.mazarguil@6wind.com>,
	Shahaf Shuler <shahafs@mellanox.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 4/7] net/mlx5: re-indent generic probing function
Date: Mon, 11 Jun 2018 11:42:48 +0000	[thread overview]
Message-ID: <VI1PR05MB16785C898D2EA9B50A14E343AC780@VI1PR05MB1678.eurprd05.prod.outlook.com> (raw)
In-Reply-To: <20180525161814.13873-5-adrien.mazarguil@6wind.com>

Reviewed-by: Xueming(Steven) Li <xuemingl@mellanox.com>

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Adrien Mazarguil
> Sent: Saturday, May 26, 2018 12:35 AM
> To: Shahaf Shuler <shahafs@mellanox.com>
> Cc: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 4/7] net/mlx5: re-indent generic probing function
> 
> Since commit "net/mlx5: split PCI from generic probing code" extracted the inner loop to a separate
> function, mlx5_dev_spawn_one() is left with an unnecessary indent level.
> 
> This patch eliminates a block, moves its local variables to function scope, and re-indents its
> contents.
> 
> No functional impact.
> 
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> ---
>  drivers/net/mlx5/mlx5.c | 589 +++++++++++++++++++++----------------------
>  1 file changed, 286 insertions(+), 303 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 7a812ef93..d57e8118c 100644
> --- a/drivers/net/mlx5/mlx5.c
> +++ b/drivers/net/mlx5/mlx5.c
> @@ -658,8 +658,27 @@ mlx5_dev_spawn_one(struct rte_device *dpdk_dev,
>  		   unsigned int port)
>  {
>  	struct ibv_context *ctx;
> +	struct ibv_port_attr port_attr;
> +	struct ibv_pd *pd = NULL;
>  	struct mlx5dv_context dv_attr = { .comp_mask = 0 };
> +	struct mlx5_dev_config config = {
> +		.vf = !!vf,
> +		.tx_vec_en = 1,
> +		.rx_vec_en = 1,
> +		.mpw_hdr_dseg = 0,
> +		.txq_inline = MLX5_ARG_UNSET,
> +		.txqs_inline = MLX5_ARG_UNSET,
> +		.inline_max_packet_sz = MLX5_ARG_UNSET,
> +		.vf_nl_en = 1,
> +		.mprq = {
> +			.enabled = 0,
> +			.stride_num_n = MLX5_MPRQ_STRIDE_NUM_N,
> +			.max_memcpy_len = MLX5_MPRQ_MEMCPY_DEFAULT_LEN,
> +			.min_rxqs_num = MLX5_MPRQ_MIN_RXQS,
> +		},
> +	};
>  	struct rte_eth_dev *eth_dev = NULL;
> +	struct priv *priv = NULL;
>  	int err = 0;
>  	unsigned int mps;
>  	unsigned int cqe_comp;
> @@ -675,6 +694,8 @@ mlx5_dev_spawn_one(struct rte_device *dpdk_dev,  #ifdef
> HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT
>  	struct ibv_counter_set_description cs_desc;  #endif
> +	struct ether_addr mac;
> +	char name[RTE_ETH_NAME_MAX_LEN];
> 
>  	/* Prepare shared data between primary and secondary process. */
>  	mlx5_prepare_shared_data();
> @@ -710,11 +731,13 @@ mlx5_dev_spawn_one(struct rte_device *dpdk_dev,
>  		DRV_LOG(DEBUG, "MPW isn't supported");
>  		mps = MLX5_MPW_DISABLED;
>  	}
> +	config.mps = mps;
>  #ifdef HAVE_IBV_MLX5_MOD_SWP
>  	if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_SWP)
>  		swp = dv_attr.sw_parsing_caps.sw_parsing_offloads;
>  	DRV_LOG(DEBUG, "SWP support: %u", swp);  #endif
> +	config.swp = !!swp;
>  #ifdef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
>  	if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_STRIDING_RQ) {
>  		struct mlx5dv_striding_rq_caps mprq_caps = @@ -740,6 +763,8 @@ mlx5_dev_spawn_one(struct
> rte_device *dpdk_dev,
>  			mprq_caps.min_single_wqe_log_num_of_strides;
>  		mprq_max_stride_num_n =
>  			mprq_caps.max_single_wqe_log_num_of_strides;
> +		config.mprq.stride_num_n = RTE_MAX(MLX5_MPRQ_STRIDE_NUM_N,
> +						   mprq_min_stride_num_n);
>  	}
>  #endif
>  	if (RTE_CACHE_LINE_SIZE == 128 &&
> @@ -747,6 +772,7 @@ mlx5_dev_spawn_one(struct rte_device *dpdk_dev,
>  		cqe_comp = 0;
>  	else
>  		cqe_comp = 1;
> +	config.cqe_comp = cqe_comp;
>  #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
>  	if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS) {
>  		tunnel_en = ((dv_attr.tunnel_offloads_caps & @@ -760,6 +786,7 @@ mlx5_dev_spawn_one(struct
> rte_device *dpdk_dev,
>  	DRV_LOG(WARNING,
>  		"tunnel offloading disabled due to old OFED/rdma-core version");  #endif
> +	config.tunnel_en = tunnel_en;
>  #ifdef HAVE_IBV_DEVICE_MPLS_SUPPORT
>  	mpls_en = ((dv_attr.tunnel_offloads_caps &
>  		    MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_CW_MPLS_OVER_GRE) && @@ -771,325 +798,281 @@
> mlx5_dev_spawn_one(struct rte_device *dpdk_dev,
>  	DRV_LOG(WARNING, "MPLS over GRE/UDP tunnel offloading disabled due to"
>  		" old OFED/rdma-core version or firmware configuration");  #endif
> -	{
> -		char name[RTE_ETH_NAME_MAX_LEN];
> -		struct ibv_port_attr port_attr;
> -		struct ibv_pd *pd = NULL;
> -		struct priv *priv = NULL;
> -		struct ether_addr mac;
> -		struct mlx5_dev_config config = {
> -			.cqe_comp = cqe_comp,
> -			.mps = mps,
> -			.tunnel_en = tunnel_en,
> -			.mpls_en = mpls_en,
> -			.tx_vec_en = 1,
> -			.rx_vec_en = 1,
> -			.mpw_hdr_dseg = 0,
> -			.txq_inline = MLX5_ARG_UNSET,
> -			.txqs_inline = MLX5_ARG_UNSET,
> -			.inline_max_packet_sz = MLX5_ARG_UNSET,
> -			.vf_nl_en = 1,
> -			.swp = !!swp,
> -			.mprq = {
> -				.enabled = 0, /* Disabled by default. */
> -				.stride_num_n = RTE_MAX(MLX5_MPRQ_STRIDE_NUM_N,
> -							mprq_min_stride_num_n),
> -				.max_memcpy_len = MLX5_MPRQ_MEMCPY_DEFAULT_LEN,
> -				.min_rxqs_num = MLX5_MPRQ_MIN_RXQS,
> -			},
> -		};
> -
> -		if (attr->orig_attr.phys_port_cnt > 1)
> -			snprintf(name, sizeof(name), "%s", dpdk_dev->name);
> -		else
> -			snprintf(name, sizeof(name), "%s port %u",
> -				 dpdk_dev->name, port);
> -		if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
> -			eth_dev = rte_eth_dev_attach_secondary(name);
> -			if (eth_dev == NULL) {
> -				DRV_LOG(ERR, "can not attach rte ethdev");
> -				rte_errno = ENOMEM;
> -				err = rte_errno;
> -				goto error;
> -			}
> -			eth_dev->device = dpdk_dev;
> -			eth_dev->dev_ops = &mlx5_dev_sec_ops;
> -			err = mlx5_uar_init_secondary(eth_dev);
> -			if (err) {
> -				err = rte_errno;
> -				goto error;
> -			}
> -			/* Receive command fd from primary process */
> -			err = mlx5_socket_connect(eth_dev);
> -			if (err < 0) {
> -				err = rte_errno;
> -				goto error;
> -			}
> -			/* Remap UAR for Tx queues. */
> -			err = mlx5_tx_uar_remap(eth_dev, err);
> -			if (err) {
> -				err = rte_errno;
> -				goto error;
> -			}
> -			/*
> -			 * Ethdev pointer is still required as input since
> -			 * the primary device is not accessible from the
> -			 * secondary process.
> -			 */
> -			eth_dev->rx_pkt_burst =
> -				mlx5_select_rx_function(eth_dev);
> -			eth_dev->tx_pkt_burst =
> -				mlx5_select_tx_function(eth_dev);
> -			mlx5_glue->close_device(ctx);
> -			return eth_dev;
> +	config.mpls_en = mpls_en;
> +	if (attr->orig_attr.phys_port_cnt > 1)
> +		snprintf(name, sizeof(name), "%s", dpdk_dev->name);
> +	else
> +		snprintf(name, sizeof(name), "%s port %u",
> +			 dpdk_dev->name, port);
> +	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
> +		eth_dev = rte_eth_dev_attach_secondary(name);
> +		if (eth_dev == NULL) {
> +			DRV_LOG(ERR, "can not attach rte ethdev");
> +			rte_errno = ENOMEM;
> +			err = rte_errno;
> +			goto error;
>  		}
> -		DRV_LOG(DEBUG, "using port %u", port);
> -		/* Check port status. */
> -		err = mlx5_glue->query_port(ctx, port, &port_attr);
> +		eth_dev->device = dpdk_dev;
> +		eth_dev->dev_ops = &mlx5_dev_sec_ops;
> +		err = mlx5_uar_init_secondary(eth_dev);
>  		if (err) {
> -			DRV_LOG(ERR, "port query failed: %s", strerror(err));
> -			goto port_error;
> -		}
> -		if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) {
> -			DRV_LOG(ERR,
> -				"port %d is not configured in Ethernet mode",
> -				port);
> -			err = EINVAL;
> -			goto port_error;
> -		}
> -		if (port_attr.state != IBV_PORT_ACTIVE)
> -			DRV_LOG(DEBUG, "port %d is not active: \"%s\" (%d)",
> -				port,
> -				mlx5_glue->port_state_str(port_attr.state),
> -				port_attr.state);
> -		/* Allocate protection domain. */
> -		pd = mlx5_glue->alloc_pd(ctx);
> -		if (pd == NULL) {
> -			DRV_LOG(ERR, "PD allocation failure");
> -			err = ENOMEM;
> -			goto port_error;
> +			err = rte_errno;
> +			goto error;
>  		}
> -		/* from rte_ethdev.c */
> -		priv = rte_zmalloc("ethdev private structure",
> -				   sizeof(*priv),
> -				   RTE_CACHE_LINE_SIZE);
> -		if (priv == NULL) {
> -			DRV_LOG(ERR, "priv allocation failure");
> -			err = ENOMEM;
> -			goto port_error;
> +		/* Receive command fd from primary process */
> +		err = mlx5_socket_connect(eth_dev);
> +		if (err < 0) {
> +			err = rte_errno;
> +			goto error;
>  		}
> -		priv->ctx = ctx;
> -		strncpy(priv->ibdev_path, priv->ctx->device->ibdev_path,
> -			sizeof(priv->ibdev_path));
> -		priv->device_attr = *attr;
> -		priv->port = port;
> -		priv->pd = pd;
> -		priv->mtu = ETHER_MTU;
> -		err = mlx5_args(&config, dpdk_dev->devargs);
> +		/* Remap UAR for Tx queues. */
> +		err = mlx5_tx_uar_remap(eth_dev, err);
>  		if (err) {
>  			err = rte_errno;
> -			DRV_LOG(ERR, "failed to process device arguments: %s",
> -				strerror(rte_errno));
> -			goto port_error;
> +			goto error;
>  		}
> -		config.hw_csum = !!(attr->device_cap_flags_ex &
> -				    IBV_DEVICE_RAW_IP_CSUM);
> -		DRV_LOG(DEBUG, "checksum offloading is %ssupported",
> -			(config.hw_csum ? "" : "not "));
> +		/*
> +		 * Ethdev pointer is still required as input since
> +		 * the primary device is not accessible from the
> +		 * secondary process.
> +		 */
> +		eth_dev->rx_pkt_burst = mlx5_select_rx_function(eth_dev);
> +		eth_dev->tx_pkt_burst = mlx5_select_tx_function(eth_dev);
> +		mlx5_glue->close_device(ctx);
> +		return eth_dev;
> +	}
> +	DRV_LOG(DEBUG, "using port %u", port);
> +	/* Check port status. */
> +	err = mlx5_glue->query_port(ctx, port, &port_attr);
> +	if (err) {
> +		DRV_LOG(ERR, "port query failed: %s", strerror(err));
> +		goto error;
> +	}
> +	if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) {
> +		DRV_LOG(ERR, "port %d is not configured in Ethernet mode",
> +			port);
> +		err = EINVAL;
> +		goto error;
> +	}
> +	if (port_attr.state != IBV_PORT_ACTIVE)
> +		DRV_LOG(DEBUG, "port %d is not active: \"%s\" (%d)",
> +			port, mlx5_glue->port_state_str(port_attr.state),
> +			port_attr.state);
> +	/* Allocate protection domain. */
> +	pd = mlx5_glue->alloc_pd(ctx);
> +	if (pd == NULL) {
> +		DRV_LOG(ERR, "PD allocation failure");
> +		err = ENOMEM;
> +		goto error;
> +	}
> +	priv = rte_zmalloc("ethdev private structure",
> +			   sizeof(*priv),
> +			   RTE_CACHE_LINE_SIZE);
> +	if (priv == NULL) {
> +		DRV_LOG(ERR, "priv allocation failure");
> +		err = ENOMEM;
> +		goto error;
> +	}
> +	priv->ctx = ctx;
> +	strncpy(priv->ibdev_path, priv->ctx->device->ibdev_path,
> +		sizeof(priv->ibdev_path));
> +	priv->device_attr = *attr;
> +	priv->port = port;
> +	priv->pd = pd;
> +	priv->mtu = ETHER_MTU;
> +	err = mlx5_args(&config, dpdk_dev->devargs);
> +	if (err) {
> +		err = rte_errno;
> +		DRV_LOG(ERR, "failed to process device arguments: %s",
> +			strerror(rte_errno));
> +		goto error;
> +	}
> +	config.hw_csum = !!(attr->device_cap_flags_ex & IBV_DEVICE_RAW_IP_CSUM);
> +	DRV_LOG(DEBUG, "checksum offloading is %ssupported",
> +		(config.hw_csum ? "" : "not "));
>  #ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT
> -		config.flow_counter_en = !!attr->max_counter_sets;
> -		mlx5_glue->describe_counter_set(ctx, 0, &cs_desc);
> -		DRV_LOG(DEBUG,
> -			"counter type = %d, num of cs = %ld, attributes = %d",
> -			cs_desc.counter_type, cs_desc.num_of_cs,
> -			cs_desc.attributes);
> +	config.flow_counter_en = !!attr->max_counter_sets;
> +	mlx5_glue->describe_counter_set(ctx, 0, &cs_desc);
> +	DRV_LOG(DEBUG, "counter type = %d, num of cs = %ld, attributes = %d",
> +		cs_desc.counter_type, cs_desc.num_of_cs,
> +		cs_desc.attributes);
>  #endif
> -		config.ind_table_max_size =
> -			attr->rss_caps.max_rwq_indirection_table_size;
> -		/* Remove this check once DPDK supports larger/variable
> -		 * indirection tables. */
> -		if (config.ind_table_max_size >
> -				(unsigned int)ETH_RSS_RETA_SIZE_512)
> -			config.ind_table_max_size = ETH_RSS_RETA_SIZE_512;
> -		DRV_LOG(DEBUG, "maximum Rx indirection table size is %u",
> -			config.ind_table_max_size);
> -		config.hw_vlan_strip = !!(attr->raw_packet_caps &
> -					 IBV_RAW_PACKET_CAP_CVLAN_STRIPPING);
> -		DRV_LOG(DEBUG, "VLAN stripping is %ssupported",
> -			(config.hw_vlan_strip ? "" : "not "));
> -
> -		config.hw_fcs_strip = !!(attr->raw_packet_caps &
> -					 IBV_RAW_PACKET_CAP_SCATTER_FCS);
> -		DRV_LOG(DEBUG, "FCS stripping configuration is %ssupported",
> -			(config.hw_fcs_strip ? "" : "not "));
> -
> +	config.ind_table_max_size =
> +		attr->rss_caps.max_rwq_indirection_table_size;
> +	/*
> +	 * Remove this check once DPDK supports larger/variable
> +	 * indirection tables.
> +	 */
> +	if (config.ind_table_max_size > (unsigned int)ETH_RSS_RETA_SIZE_512)
> +		config.ind_table_max_size = ETH_RSS_RETA_SIZE_512;
> +	DRV_LOG(DEBUG, "maximum Rx indirection table size is %u",
> +		config.ind_table_max_size);
> +	config.hw_vlan_strip = !!(attr->raw_packet_caps &
> +				  IBV_RAW_PACKET_CAP_CVLAN_STRIPPING);
> +	DRV_LOG(DEBUG, "VLAN stripping is %ssupported",
> +		(config.hw_vlan_strip ? "" : "not "));
> +	config.hw_fcs_strip = !!(attr->raw_packet_caps &
> +				 IBV_RAW_PACKET_CAP_SCATTER_FCS);
> +	DRV_LOG(DEBUG, "FCS stripping configuration is %ssupported",
> +		(config.hw_fcs_strip ? "" : "not "));
>  #ifdef HAVE_IBV_WQ_FLAG_RX_END_PADDING
> -		config.hw_padding = !!attr->rx_pad_end_addr_align;
> +	config.hw_padding = !!attr->rx_pad_end_addr_align;
>  #endif
> -		DRV_LOG(DEBUG,
> -			"hardware Rx end alignment padding is %ssupported",
> -			(config.hw_padding ? "" : "not "));
> -		config.vf = vf;
> -		config.tso = (attr->tso_caps.max_tso > 0 &&
> -			      (attr->tso_caps.supported_qpts &
> -			      (1 << IBV_QPT_RAW_PACKET)));
> -		if (config.tso)
> -			config.tso_max_payload_sz = attr->tso_caps.max_tso;
> -		if (config.mps && !mps) {
> -			DRV_LOG(ERR,
> -				"multi-packet send not supported on this device"
> -				" (" MLX5_TXQ_MPW_EN ")");
> -			err = ENOTSUP;
> -			goto port_error;
> -		}
> -		DRV_LOG(INFO, "%s MPS is %s",
> -			config.mps == MLX5_MPW_ENHANCED ? "enhanced " : "",
> -			config.mps != MLX5_MPW_DISABLED ? "enabled" :
> -			"disabled");
> -		if (config.cqe_comp && !cqe_comp) {
> -			DRV_LOG(WARNING, "Rx CQE compression isn't supported");
> -			config.cqe_comp = 0;
> -		}
> -		config.mprq.enabled = config.mprq.enabled && mprq;
> -		if (config.mprq.enabled) {
> -			if (config.mprq.stride_num_n > mprq_max_stride_num_n ||
> -			    config.mprq.stride_num_n < mprq_min_stride_num_n) {
> -				config.mprq.stride_num_n =
> -					RTE_MAX(MLX5_MPRQ_STRIDE_NUM_N,
> -						mprq_min_stride_num_n);
> -				DRV_LOG(WARNING,
> -					"the number of strides"
> -					" for Multi-Packet RQ is out of range,"
> -					" setting default value (%u)",
> -					1 << config.mprq.stride_num_n);
> -			}
> -			config.mprq.min_stride_size_n = mprq_min_stride_size_n;
> -			config.mprq.max_stride_size_n = mprq_max_stride_size_n;
> -		}
> -		eth_dev = rte_eth_dev_allocate(name);
> -		if (eth_dev == NULL) {
> -			DRV_LOG(ERR, "can not allocate rte ethdev");
> -			err = ENOMEM;
> -			goto port_error;
> -		}
> -		eth_dev->data->dev_private = priv;
> -		priv->dev_data = eth_dev->data;
> -		eth_dev->data->mac_addrs = priv->mac;
> -		eth_dev->device = dpdk_dev;
> -		eth_dev->device->driver = &mlx5_driver.driver;
> -		err = mlx5_uar_init_primary(eth_dev);
> -		if (err) {
> -			err = rte_errno;
> -			goto port_error;
> -		}
> -		/* Configure the first MAC address by default. */
> -		if (mlx5_get_mac(eth_dev, &mac.addr_bytes)) {
> -			DRV_LOG(ERR,
> -				"port %u cannot get MAC address, is mlx5_en"
> -				" loaded? (errno: %s)",
> -				eth_dev->data->port_id, strerror(rte_errno));
> -			err = ENODEV;
> -			goto port_error;
> +	DRV_LOG(DEBUG, "hardware Rx end alignment padding is %ssupported",
> +		(config.hw_padding ? "" : "not "));
> +	config.tso = (attr->tso_caps.max_tso > 0 &&
> +		      (attr->tso_caps.supported_qpts &
> +		       (1 << IBV_QPT_RAW_PACKET)));
> +	if (config.tso)
> +		config.tso_max_payload_sz = attr->tso_caps.max_tso;
> +	if (config.mps && !mps) {
> +		DRV_LOG(ERR,
> +			"multi-packet send not supported on this device"
> +			" (" MLX5_TXQ_MPW_EN ")");
> +		err = ENOTSUP;
> +		goto error;
> +	}
> +	DRV_LOG(INFO, "%sMPS is %s",
> +		config.mps == MLX5_MPW_ENHANCED ? "enhanced " : "",
> +		config.mps != MLX5_MPW_DISABLED ? "enabled" : "disabled");
> +	if (config.cqe_comp && !cqe_comp) {
> +		DRV_LOG(WARNING, "Rx CQE compression isn't supported");
> +		config.cqe_comp = 0;
> +	}
> +	config.mprq.enabled = config.mprq.enabled && mprq;
> +	if (config.mprq.enabled) {
> +		if (config.mprq.stride_num_n > mprq_max_stride_num_n ||
> +		    config.mprq.stride_num_n < mprq_min_stride_num_n) {
> +			config.mprq.stride_num_n =
> +				RTE_MAX(MLX5_MPRQ_STRIDE_NUM_N,
> +					mprq_min_stride_num_n);
> +			DRV_LOG(WARNING,
> +				"the number of strides"
> +				" for Multi-Packet RQ is out of range,"
> +				" setting default value (%u)",
> +				1 << config.mprq.stride_num_n);
>  		}
> -		DRV_LOG(INFO,
> -			"port %u MAC address is %02x:%02x:%02x:%02x:%02x:%02x",
> -			eth_dev->data->port_id,
> -			mac.addr_bytes[0], mac.addr_bytes[1],
> -			mac.addr_bytes[2], mac.addr_bytes[3],
> -			mac.addr_bytes[4], mac.addr_bytes[5]);
> +		config.mprq.min_stride_size_n = mprq_min_stride_size_n;
> +		config.mprq.max_stride_size_n = mprq_max_stride_size_n;
> +	}
> +	eth_dev = rte_eth_dev_allocate(name);
> +	if (eth_dev == NULL) {
> +		DRV_LOG(ERR, "can not allocate rte ethdev");
> +		err = ENOMEM;
> +		goto error;
> +	}
> +	eth_dev->data->dev_private = priv;
> +	priv->dev_data = eth_dev->data;
> +	eth_dev->data->mac_addrs = priv->mac;
> +	eth_dev->device = dpdk_dev;
> +	eth_dev->device->driver = &mlx5_driver.driver;
> +	err = mlx5_uar_init_primary(eth_dev);
> +	if (err) {
> +		err = rte_errno;
> +		goto error;
> +	}
> +	/* Configure the first MAC address by default. */
> +	if (mlx5_get_mac(eth_dev, &mac.addr_bytes)) {
> +		DRV_LOG(ERR,
> +			"port %u cannot get MAC address, is mlx5_en"
> +			" loaded? (errno: %s)",
> +			eth_dev->data->port_id, strerror(rte_errno));
> +		err = ENODEV;
> +		goto error;
> +	}
> +	DRV_LOG(INFO,
> +		"port %u MAC address is %02x:%02x:%02x:%02x:%02x:%02x",
> +		eth_dev->data->port_id,
> +		mac.addr_bytes[0], mac.addr_bytes[1],
> +		mac.addr_bytes[2], mac.addr_bytes[3],
> +		mac.addr_bytes[4], mac.addr_bytes[5]);
>  #ifndef NDEBUG
> -		{
> -			char ifname[IF_NAMESIZE];
> -
> -			if (mlx5_get_ifname(eth_dev, &ifname) == 0)
> -				DRV_LOG(DEBUG, "port %u ifname is \"%s\"",
> -					eth_dev->data->port_id, ifname);
> -			else
> -				DRV_LOG(DEBUG, "port %u ifname is unknown",
> -					eth_dev->data->port_id);
> -		}
> +	{
> +		char ifname[IF_NAMESIZE];
> +
> +		if (mlx5_get_ifname(eth_dev, &ifname) == 0)
> +			DRV_LOG(DEBUG, "port %u ifname is \"%s\"",
> +				eth_dev->data->port_id, ifname);
> +		else
> +			DRV_LOG(DEBUG, "port %u ifname is unknown",
> +				eth_dev->data->port_id);
> +	}
>  #endif
> -		/* Get actual MTU if possible. */
> -		err = mlx5_get_mtu(eth_dev, &priv->mtu);
> -		if (err) {
> -			err = rte_errno;
> -			goto port_error;
> -		}
> -		DRV_LOG(DEBUG, "port %u MTU is %u", eth_dev->data->port_id,
> -			priv->mtu);
> -		/*
> -		 * Initialize burst functions to prevent crashes before link-up.
> -		 */
> -		eth_dev->rx_pkt_burst = removed_rx_burst;
> -		eth_dev->tx_pkt_burst = removed_tx_burst;
> -		eth_dev->dev_ops = &mlx5_dev_ops;
> -		/* Register MAC address. */
> -		claim_zero(mlx5_mac_addr_add(eth_dev, &mac, 0, 0));
> -		priv->nl_socket = -1;
> -		priv->nl_sn = 0;
> -		if (vf && config.vf_nl_en) {
> -			priv->nl_socket = mlx5_nl_init(RTMGRP_LINK);
> -			if (priv->nl_socket < 0)
> -				priv->nl_socket = -1;
> -			mlx5_nl_mac_addr_sync(eth_dev);
> -		}
> -		TAILQ_INIT(&priv->flows);
> -		TAILQ_INIT(&priv->ctrl_flows);
> -		/* Hint libmlx5 to use PMD allocator for data plane resources */
> -		struct mlx5dv_ctx_allocators alctr = {
> -			.alloc = &mlx5_alloc_verbs_buf,
> -			.free = &mlx5_free_verbs_buf,
> -			.data = priv,
> -		};
> -		mlx5_glue->dv_set_context_attr(ctx,
> -					       MLX5DV_CTX_ATTR_BUF_ALLOCATORS,
> -					       (void *)((uintptr_t)&alctr));
> -		/* Bring Ethernet device up. */
> -		DRV_LOG(DEBUG, "port %u forcing Ethernet interface up",
> -			eth_dev->data->port_id);
> -		mlx5_set_link_up(eth_dev);
> -		/*
> -		 * Even though the interrupt handler is not installed yet,
> -		 * interrupts will still trigger on the asyn_fd from
> -		 * Verbs context returned by ibv_open_device().
> -		 */
> -		mlx5_link_update(eth_dev, 0);
> -		/* Store device configuration on private structure. */
> -		priv->config = config;
> -		/* Create drop queue. */
> -		err = mlx5_flow_create_drop_queue(eth_dev);
> -		if (err) {
> -			DRV_LOG(ERR, "port %u drop queue allocation failed: %s",
> -				eth_dev->data->port_id, strerror(rte_errno));
> -			err = rte_errno;
> -			goto port_error;
> -		}
> -		/* Supported Verbs flow priority number detection. */
> -		if (verb_priorities == 0)
> -			verb_priorities = mlx5_get_max_verbs_prio(eth_dev);
> -		if (verb_priorities < MLX5_VERBS_FLOW_PRIO_8) {
> -			DRV_LOG(ERR, "port %u wrong Verbs flow priorities: %u",
> -				eth_dev->data->port_id, verb_priorities);
> -			err = ENOTSUP;
> -			goto port_error;
> -		}
> -		priv->config.max_verbs_prio = verb_priorities;
> -		/* Add device to memory callback list. */
> -		rte_rwlock_write_lock(&mlx5_shared_data->mem_event_rwlock);
> -		LIST_INSERT_HEAD(&mlx5_shared_data->mem_event_cb_list,
> -				 priv, mem_event_cb);
> -		rte_rwlock_write_unlock(&mlx5_shared_data->mem_event_rwlock);
> -		rte_eth_dev_probing_finish(eth_dev);
> -		return eth_dev;
> -port_error:
> -		if (priv)
> -			rte_free(priv);
> -		if (pd)
> -			claim_zero(mlx5_glue->dealloc_pd(pd));
> -		if (eth_dev && rte_eal_process_type() == RTE_PROC_PRIMARY)
> -			rte_eth_dev_release_port(eth_dev);
> +	/* Get actual MTU if possible. */
> +	err = mlx5_get_mtu(eth_dev, &priv->mtu);
> +	if (err) {
> +		err = rte_errno;
> +		goto error;
> +	}
> +	DRV_LOG(DEBUG, "port %u MTU is %u", eth_dev->data->port_id,
> +		priv->mtu);
> +	/* Initialize burst functions to prevent crashes before link-up. */
> +	eth_dev->rx_pkt_burst = removed_rx_burst;
> +	eth_dev->tx_pkt_burst = removed_tx_burst;
> +	eth_dev->dev_ops = &mlx5_dev_ops;
> +	/* Register MAC address. */
> +	claim_zero(mlx5_mac_addr_add(eth_dev, &mac, 0, 0));
> +	priv->nl_socket = -1;
> +	priv->nl_sn = 0;
> +	if (vf && config.vf_nl_en) {
> +		priv->nl_socket = mlx5_nl_init(RTMGRP_LINK);
> +		if (priv->nl_socket < 0)
> +			priv->nl_socket = -1;
> +		mlx5_nl_mac_addr_sync(eth_dev);
> +	}
> +	TAILQ_INIT(&priv->flows);
> +	TAILQ_INIT(&priv->ctrl_flows);
> +	/* Hint libmlx5 to use PMD allocator for data plane resources */
> +	struct mlx5dv_ctx_allocators alctr = {
> +		.alloc = &mlx5_alloc_verbs_buf,
> +		.free = &mlx5_free_verbs_buf,
> +		.data = priv,
> +	};
> +	mlx5_glue->dv_set_context_attr(ctx, MLX5DV_CTX_ATTR_BUF_ALLOCATORS,
> +				       (void *)((uintptr_t)&alctr));
> +	/* Bring Ethernet device up. */
> +	DRV_LOG(DEBUG, "port %u forcing Ethernet interface up",
> +		eth_dev->data->port_id);
> +	mlx5_set_link_up(eth_dev);
> +	/*
> +	 * Even though the interrupt handler is not installed yet,
> +	 * interrupts will still trigger on the asyn_fd from
> +	 * Verbs context returned by ibv_open_device().
> +	 */
> +	mlx5_link_update(eth_dev, 0);
> +	/* Store device configuration on private structure. */
> +	priv->config = config;
> +	/* Create drop queue. */
> +	err = mlx5_flow_create_drop_queue(eth_dev);
> +	if (err) {
> +		DRV_LOG(ERR, "port %u drop queue allocation failed: %s",
> +			eth_dev->data->port_id, strerror(rte_errno));
> +		err = rte_errno;
> +		goto error;
> +	}
> +	/* Supported Verbs flow priority number detection. */
> +	if (verb_priorities == 0)
> +		verb_priorities = mlx5_get_max_verbs_prio(eth_dev);
> +	if (verb_priorities < MLX5_VERBS_FLOW_PRIO_8) {
> +		DRV_LOG(ERR, "port %u wrong Verbs flow priorities: %u",
> +			eth_dev->data->port_id, verb_priorities);
> +		err = ENOTSUP;
> +		goto error;
>  	}
> +	priv->config.max_verbs_prio = verb_priorities;
> +	/* Add device to memory callback list. */
> +	rte_rwlock_write_lock(&mlx5_shared_data->mem_event_rwlock);
> +	LIST_INSERT_HEAD(&mlx5_shared_data->mem_event_cb_list,
> +			 priv, mem_event_cb);
> +	rte_rwlock_write_unlock(&mlx5_shared_data->mem_event_rwlock);
> +	return eth_dev;
>  error:
> +	if (priv)
> +		rte_free(priv);
> +	if (pd)
> +		claim_zero(mlx5_glue->dealloc_pd(pd));
> +	if (eth_dev)
> +		rte_eth_dev_release_port(eth_dev);
>  	if (ctx)
>  		claim_zero(mlx5_glue->close_device(ctx));
>  	assert(err > 0);
> --
> 2.11.0

  reply	other threads:[~2018-06-11 11:42 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-25 16:35 [dpdk-dev] [PATCH 0/7] net/mlx5: add port representor support Adrien Mazarguil
2018-05-25 16:35 ` [dpdk-dev] [PATCH 1/7] net/mlx5: rename confusing object in probe code Adrien Mazarguil
2018-06-10 11:00   ` Xueming(Steven) Li
2018-06-12 13:19     ` Adrien Mazarguil
2018-05-25 16:35 ` [dpdk-dev] [PATCH 2/7] net/mlx5: remove redundant objects " Adrien Mazarguil
2018-06-10 11:00   ` Xueming(Steven) Li
2018-06-12 13:19     ` Adrien Mazarguil
2018-05-25 16:35 ` [dpdk-dev] [PATCH 3/7] net/mlx5: split PCI from generic probing code Adrien Mazarguil
2018-06-10 12:59   ` Xueming(Steven) Li
2018-06-12 13:20     ` Adrien Mazarguil
2018-05-25 16:35 ` [dpdk-dev] [PATCH 4/7] net/mlx5: re-indent generic probing function Adrien Mazarguil
2018-06-11 11:42   ` Xueming(Steven) Li [this message]
2018-05-25 16:35 ` [dpdk-dev] [PATCH 5/7] net/mlx5: add port representor awareness Adrien Mazarguil
2018-05-25 16:35 ` [dpdk-dev] [PATCH 6/7] net/mlx5: probe all port representors Adrien Mazarguil
2018-06-12  6:42   ` Xueming(Steven) Li
2018-06-12 13:20     ` Adrien Mazarguil
2018-05-25 16:35 ` [dpdk-dev] [PATCH 7/7] net/mlx5: add parameter for " Adrien Mazarguil
2018-06-12  8:02   ` Xueming(Steven) Li
2018-06-12 13:20     ` Adrien Mazarguil
2018-06-12 13:43       ` Xueming(Steven) Li
2018-06-14  8:01         ` Adrien Mazarguil
2018-06-12 14:44   ` Xueming(Steven) Li
2018-06-13 13:11     ` Adrien Mazarguil
2018-06-14  8:34 ` [dpdk-dev] [PATCH v2 0/7] net/mlx5: add port representor support Adrien Mazarguil
2018-06-14  8:34   ` [dpdk-dev] [PATCH v2 1/7] net/mlx5: rename confusing object in probe code Adrien Mazarguil
2018-06-16  8:24     ` Xueming(Steven) Li
2018-06-14  8:34   ` [dpdk-dev] [PATCH v2 2/7] net/mlx5: remove redundant objects " Adrien Mazarguil
2018-06-16  8:27     ` Xueming(Steven) Li
2018-06-17 10:14     ` Shahaf Shuler
2018-06-27 13:30       ` Adrien Mazarguil
2018-06-28  5:35         ` Shahaf Shuler
2018-06-14  8:34   ` [dpdk-dev] [PATCH v2 3/7] net/mlx5: split PCI from generic probing code Adrien Mazarguil
2018-06-16  8:29     ` Xueming(Steven) Li
2018-06-17 10:14     ` Shahaf Shuler
2018-06-27 13:31       ` Adrien Mazarguil
2018-06-14  8:34   ` [dpdk-dev] [PATCH v2 4/7] net/mlx5: re-indent generic probing function Adrien Mazarguil
2018-06-14  8:34   ` [dpdk-dev] [PATCH v2 5/7] net/mlx5: add port representor awareness Adrien Mazarguil
2018-06-16  8:37     ` Xueming(Steven) Li
2018-06-27 13:32       ` Adrien Mazarguil
2018-06-14  8:35   ` [dpdk-dev] [PATCH v2 6/7] net/mlx5: probe all port representors Adrien Mazarguil
2018-06-16  8:57     ` Xueming(Steven) Li
2018-06-17 10:15       ` Shahaf Shuler
2018-06-24 13:33         ` Shahaf Shuler
2018-06-27 13:32           ` Adrien Mazarguil
2018-06-28  5:57             ` Shahaf Shuler
2018-06-28  9:13               ` Adrien Mazarguil
2018-06-27 13:32         ` Adrien Mazarguil
2018-06-27 17:30           ` Xueming(Steven) Li
2018-06-28  6:01           ` Shahaf Shuler
2018-06-28  8:45             ` Adrien Mazarguil
2018-06-28  9:06               ` Shahaf Shuler
2018-06-27 13:32       ` Adrien Mazarguil
2018-06-14  8:35   ` [dpdk-dev] [PATCH v2 7/7] net/mlx5: add parameter for " Adrien Mazarguil
2018-06-16  8:59     ` Xueming(Steven) Li
2018-07-04 17:27   ` [dpdk-dev] [PATCH v3 00/10] net/mlx5: add port representor support Adrien Mazarguil
2018-07-04 17:27     ` [dpdk-dev] [PATCH v3 01/10] net/mlx5: rename confusing object in probe code Adrien Mazarguil
2018-07-04 17:27     ` [dpdk-dev] [PATCH v3 02/10] net/mlx5: remove redundant objects " Adrien Mazarguil
2018-07-04 17:27     ` [dpdk-dev] [PATCH v3 03/10] net/mlx5: drop useless support for several Verbs ports Adrien Mazarguil
2018-07-04 17:27     ` [dpdk-dev] [PATCH v3 04/10] net/mlx5: split PCI from generic probing code Adrien Mazarguil
2018-07-04 17:27     ` [dpdk-dev] [PATCH v3 05/10] net/mlx5: re-indent generic probing function Adrien Mazarguil
2018-07-04 17:27     ` [dpdk-dev] [PATCH v3 06/10] net/mlx5: add port representor awareness Adrien Mazarguil
2018-07-04 17:27     ` [dpdk-dev] [PATCH v3 07/10] net/mlx5: probe all port representors Adrien Mazarguil
2018-07-04 17:27     ` [dpdk-dev] [PATCH v3 08/10] net/mlx5: probe port representors in natural order Adrien Mazarguil
2018-07-04 17:27     ` [dpdk-dev] [PATCH v3 09/10] net/mlx5: add parameter for port representors Adrien Mazarguil
2018-07-04 17:27     ` [dpdk-dev] [PATCH v3 10/10] net/mlx5: support negative identifiers " Adrien Mazarguil
2018-07-05  8:45     ` [dpdk-dev] [PATCH v4 00/10] net/mlx5: add port representor support Adrien Mazarguil
2018-07-05  8:45       ` [dpdk-dev] [PATCH v4 01/10] net/mlx5: rename confusing object in probe code Adrien Mazarguil
2018-07-05  8:45       ` [dpdk-dev] [PATCH v4 02/10] net/mlx5: remove redundant objects " Adrien Mazarguil
2018-07-05  8:45       ` [dpdk-dev] [PATCH v4 03/10] net/mlx5: drop useless support for several Verbs ports Adrien Mazarguil
2018-07-05  8:45       ` [dpdk-dev] [PATCH v4 04/10] net/mlx5: split PCI from generic probing code Adrien Mazarguil
2018-07-05  8:45       ` [dpdk-dev] [PATCH v4 05/10] net/mlx5: re-indent generic probing function Adrien Mazarguil
2018-07-05  8:45       ` [dpdk-dev] [PATCH v4 06/10] net/mlx5: add port representor awareness Adrien Mazarguil
2018-07-05  8:45       ` [dpdk-dev] [PATCH v4 07/10] net/mlx5: probe all port representors Adrien Mazarguil
2018-07-09 11:57         ` Shahaf Shuler
2018-07-10  9:37           ` Adrien Mazarguil
2018-07-10 10:13             ` Shahaf Shuler
2018-07-10 10:58               ` Adrien Mazarguil
2018-07-10 11:17                 ` Shahaf Shuler
2018-07-05  8:45       ` [dpdk-dev] [PATCH v4 08/10] net/mlx5: probe port representors in natural order Adrien Mazarguil
2018-07-05  8:45       ` [dpdk-dev] [PATCH v4 09/10] net/mlx5: add parameter for port representors Adrien Mazarguil
2018-07-09 11:57         ` Shahaf Shuler
2018-07-10  9:37           ` Adrien Mazarguil
2018-07-10 10:16             ` Shahaf Shuler
2018-07-10 10:58               ` Adrien Mazarguil
2018-07-10 11:15                 ` Shahaf Shuler
2018-07-05  8:45       ` [dpdk-dev] [PATCH v4 10/10] net/mlx5: support negative identifiers " Adrien Mazarguil
2018-07-09 11:58         ` Shahaf Shuler
2018-07-10  9:37           ` Adrien Mazarguil
2018-07-10 16:04       ` [dpdk-dev] [PATCH v5 00/10] net/mlx5: add port representor support Adrien Mazarguil
2018-07-10 16:04         ` [dpdk-dev] [PATCH v5 01/10] net/mlx5: rename confusing object in probe code Adrien Mazarguil
2018-07-10 16:04         ` [dpdk-dev] [PATCH v5 02/10] net/mlx5: remove redundant objects " Adrien Mazarguil
2018-07-10 16:04         ` [dpdk-dev] [PATCH v5 03/10] net/mlx5: drop useless support for several Verbs ports Adrien Mazarguil
2018-07-10 16:04         ` [dpdk-dev] [PATCH v5 04/10] net/mlx5: split PCI from generic probing code Adrien Mazarguil
2018-07-10 16:04         ` [dpdk-dev] [PATCH v5 05/10] net/mlx5: re-indent generic probing function Adrien Mazarguil
2018-07-10 16:04         ` [dpdk-dev] [PATCH v5 06/10] net/mlx5: add port representor awareness Adrien Mazarguil
2018-07-10 16:04         ` [dpdk-dev] [PATCH v5 07/10] net/mlx5: probe all port representors Adrien Mazarguil
2018-07-10 16:04         ` [dpdk-dev] [PATCH v5 08/10] net/mlx5: probe port representors in natural order Adrien Mazarguil
2018-07-10 16:04         ` [dpdk-dev] [PATCH v5 09/10] net/mlx5: add parameter for port representors Adrien Mazarguil
2018-07-10 16:05         ` [dpdk-dev] [PATCH v5 10/10] net/mlx5: support negative identifiers " Adrien Mazarguil
2018-07-12  7:51         ` [dpdk-dev] [PATCH v5 00/10] net/mlx5: add port representor support Shahaf Shuler

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=VI1PR05MB16785C898D2EA9B50A14E343AC780@VI1PR05MB1678.eurprd05.prod.outlook.com \
    --to=xuemingl@mellanox.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=shahafs@mellanox.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).