[dpdk-dev,22/32] net/dpaa2: configure mac address at init

Message ID 1480875447-23680-23-git-send-email-hemant.agrawal@nxp.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
checkpatch/checkpatch success coding style OK

Commit Message

Hemant Agrawal Dec. 4, 2016, 6:17 p.m. UTC
  Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/net/dpaa2/base/dpaa2_hw_dpni.h |  3 +++
 drivers/net/dpaa2/dpaa2_ethdev.c       | 26 ++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)
  

Comments

Ferruh Yigit Dec. 6, 2016, 7:50 p.m. UTC | #1
On 12/4/2016 6:17 PM, Hemant Agrawal wrote:
> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
> ---
>  drivers/net/dpaa2/base/dpaa2_hw_dpni.h |  3 +++
>  drivers/net/dpaa2/dpaa2_ethdev.c       | 26 ++++++++++++++++++++++++++
>  2 files changed, 29 insertions(+)
> 
> diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.h b/drivers/net/dpaa2/base/dpaa2_hw_dpni.h
> index c109396..70d52b6 100644
> --- a/drivers/net/dpaa2/base/dpaa2_hw_dpni.h
> +++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.h
> @@ -63,7 +63,10 @@ struct dpaa2_dev_priv {
>  	void *rx_vq[MAX_RX_QUEUES];
>  	void *tx_vq[MAX_TX_QUEUES];
>  
> +	uint32_t options;
>  	uint16_t num_dist_per_tc[MAX_TCS];
> +	uint8_t max_mac_filters;
> +	uint8_t max_vlan_filters;
>  	uint8_t num_tc;
>  	uint8_t flags; /*dpaa2 config flags */
>  };
> diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
> index 094296a..65c3384 100644
> --- a/drivers/net/dpaa2/dpaa2_ethdev.c
> +++ b/drivers/net/dpaa2/dpaa2_ethdev.c
> @@ -64,8 +64,12 @@
>  	dev_info->driver_name = drivername;
>  	dev_info->if_index = priv->hw_id;
>  
> +	dev_info->max_mac_addrs = priv->max_mac_filters;
>  	dev_info->max_rx_queues = (uint16_t)priv->nb_rx_queues;
>  	dev_info->max_tx_queues = (uint16_t)priv->nb_tx_queues;
> +	dev_info->speed_capa = ETH_LINK_SPEED_1G |
> +			ETH_LINK_SPEED_2_5G |
> +			ETH_LINK_SPEED_10G;

Patch does a little more than what it says, this can be added to prev
patch that introduces dpaa2_dev_info_get()

>  }
>  
>  static int
> @@ -444,6 +448,9 @@

Overall this makes harder to review, there is no function name provided
int the patch, this is same for all patchset. There was a .gitattributes
patch in the mail list for this, can you please get it before sending
next revision of patches.

>  
>  	priv->hw = dpni_dev;
>  	priv->hw_id = hw_id;
> +	priv->options = attr.options;
> +	priv->max_mac_filters = attr.mac_filter_entries;
> +	priv->max_vlan_filters = attr.vlan_filter_entries;
>  	priv->flags = 0;
>  
>  	ret = dpaa2_alloc_rx_tx_queues(eth_dev);
> @@ -452,6 +459,25 @@
>  		return -ret;
>  	}
>  
> +	/* Allocate memory for storing MAC addresses */
> +	eth_dev->data->mac_addrs = rte_zmalloc("dpni",
> +		ETHER_ADDR_LEN * attr.mac_filter_entries, 0);
> +	if (eth_dev->data->mac_addrs == NULL) {
> +		PMD_INIT_LOG(ERR, "Failed to allocate %d bytes needed to "
> +						"store MAC addresses",
> +				ETHER_ADDR_LEN * attr.mac_filter_entries);
> +		return -ENOMEM;
> +	}
> +
> +	ret = dpni_get_primary_mac_addr(dpni_dev, CMD_PRI_LOW,
> +					priv->token,
> +			(uint8_t *)(eth_dev->data->mac_addrs[0].addr_bytes));
> +	if (ret) {
> +		PMD_INIT_LOG(ERR, "DPNI get mac address failed:"
> +					" Error Code = %d\n", ret);
> +		return -ret;
> +	}
> +
>  	eth_dev->dev_ops = &dpaa2_ethdev_ops;
>  	return 0;
>  }
>
  
Hemant Agrawal Dec. 19, 2016, 3:31 p.m. UTC | #2
On 12/7/2016 1:20 AM, Ferruh Yigit wrote:
> On 12/4/2016 6:17 PM, Hemant Agrawal wrote:
>> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
>> ---
>>  drivers/net/dpaa2/base/dpaa2_hw_dpni.h |  3 +++
>>  drivers/net/dpaa2/dpaa2_ethdev.c       | 26 ++++++++++++++++++++++++++
>>  2 files changed, 29 insertions(+)
>>
>> diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.h b/drivers/net/dpaa2/base/dpaa2_hw_dpni.h
>> index c109396..70d52b6 100644
>> --- a/drivers/net/dpaa2/base/dpaa2_hw_dpni.h
>> +++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.h
>> @@ -63,7 +63,10 @@ struct dpaa2_dev_priv {
>>  	void *rx_vq[MAX_RX_QUEUES];
>>  	void *tx_vq[MAX_TX_QUEUES];
>>
>> +	uint32_t options;
>>  	uint16_t num_dist_per_tc[MAX_TCS];
>> +	uint8_t max_mac_filters;
>> +	uint8_t max_vlan_filters;
>>  	uint8_t num_tc;
>>  	uint8_t flags; /*dpaa2 config flags */
>>  };
>> diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
>> index 094296a..65c3384 100644
>> --- a/drivers/net/dpaa2/dpaa2_ethdev.c
>> +++ b/drivers/net/dpaa2/dpaa2_ethdev.c
>> @@ -64,8 +64,12 @@
>>  	dev_info->driver_name = drivername;
>>  	dev_info->if_index = priv->hw_id;
>>
>> +	dev_info->max_mac_addrs = priv->max_mac_filters;
>>  	dev_info->max_rx_queues = (uint16_t)priv->nb_rx_queues;
>>  	dev_info->max_tx_queues = (uint16_t)priv->nb_tx_queues;
>> +	dev_info->speed_capa = ETH_LINK_SPEED_1G |
>> +			ETH_LINK_SPEED_2_5G |
>> +			ETH_LINK_SPEED_10G;
>
> Patch does a little more than what it says, this can be added to prev
> patch that introduces dpaa2_dev_info_get()
>
I have fixed it.

>>  }
>>
>>  static int
>> @@ -444,6 +448,9 @@
>
> Overall this makes harder to review, there is no function name provided
> int the patch, this is same for all patchset. There was a .gitattributes
> patch in the mail list for this, can you please get it before sending
> next revision of patches.

I have tried to take care of it in v2. Please check now.

>>
>>  	priv->hw = dpni_dev;
>>  	priv->hw_id = hw_id;
>> +	priv->options = attr.options;
>> +	priv->max_mac_filters = attr.mac_filter_entries;
>> +	priv->max_vlan_filters = attr.vlan_filter_entries;
>>  	priv->flags = 0;
>>
>>  	ret = dpaa2_alloc_rx_tx_queues(eth_dev);
>> @@ -452,6 +459,25 @@
>>  		return -ret;
>>  	}
>>
>> +	/* Allocate memory for storing MAC addresses */
>> +	eth_dev->data->mac_addrs = rte_zmalloc("dpni",
>> +		ETHER_ADDR_LEN * attr.mac_filter_entries, 0);
>> +	if (eth_dev->data->mac_addrs == NULL) {
>> +		PMD_INIT_LOG(ERR, "Failed to allocate %d bytes needed to "
>> +						"store MAC addresses",
>> +				ETHER_ADDR_LEN * attr.mac_filter_entries);
>> +		return -ENOMEM;
>> +	}
>> +
>> +	ret = dpni_get_primary_mac_addr(dpni_dev, CMD_PRI_LOW,
>> +					priv->token,
>> +			(uint8_t *)(eth_dev->data->mac_addrs[0].addr_bytes));
>> +	if (ret) {
>> +		PMD_INIT_LOG(ERR, "DPNI get mac address failed:"
>> +					" Error Code = %d\n", ret);
>> +		return -ret;
>> +	}
>> +
>>  	eth_dev->dev_ops = &dpaa2_ethdev_ops;
>>  	return 0;
>>  }
>>
>
>
  

Patch

diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.h b/drivers/net/dpaa2/base/dpaa2_hw_dpni.h
index c109396..70d52b6 100644
--- a/drivers/net/dpaa2/base/dpaa2_hw_dpni.h
+++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.h
@@ -63,7 +63,10 @@  struct dpaa2_dev_priv {
 	void *rx_vq[MAX_RX_QUEUES];
 	void *tx_vq[MAX_TX_QUEUES];
 
+	uint32_t options;
 	uint16_t num_dist_per_tc[MAX_TCS];
+	uint8_t max_mac_filters;
+	uint8_t max_vlan_filters;
 	uint8_t num_tc;
 	uint8_t flags; /*dpaa2 config flags */
 };
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 094296a..65c3384 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -64,8 +64,12 @@ 
 	dev_info->driver_name = drivername;
 	dev_info->if_index = priv->hw_id;
 
+	dev_info->max_mac_addrs = priv->max_mac_filters;
 	dev_info->max_rx_queues = (uint16_t)priv->nb_rx_queues;
 	dev_info->max_tx_queues = (uint16_t)priv->nb_tx_queues;
+	dev_info->speed_capa = ETH_LINK_SPEED_1G |
+			ETH_LINK_SPEED_2_5G |
+			ETH_LINK_SPEED_10G;
 }
 
 static int
@@ -444,6 +448,9 @@ 
 
 	priv->hw = dpni_dev;
 	priv->hw_id = hw_id;
+	priv->options = attr.options;
+	priv->max_mac_filters = attr.mac_filter_entries;
+	priv->max_vlan_filters = attr.vlan_filter_entries;
 	priv->flags = 0;
 
 	ret = dpaa2_alloc_rx_tx_queues(eth_dev);
@@ -452,6 +459,25 @@ 
 		return -ret;
 	}
 
+	/* Allocate memory for storing MAC addresses */
+	eth_dev->data->mac_addrs = rte_zmalloc("dpni",
+		ETHER_ADDR_LEN * attr.mac_filter_entries, 0);
+	if (eth_dev->data->mac_addrs == NULL) {
+		PMD_INIT_LOG(ERR, "Failed to allocate %d bytes needed to "
+						"store MAC addresses",
+				ETHER_ADDR_LEN * attr.mac_filter_entries);
+		return -ENOMEM;
+	}
+
+	ret = dpni_get_primary_mac_addr(dpni_dev, CMD_PRI_LOW,
+					priv->token,
+			(uint8_t *)(eth_dev->data->mac_addrs[0].addr_bytes));
+	if (ret) {
+		PMD_INIT_LOG(ERR, "DPNI get mac address failed:"
+					" Error Code = %d\n", ret);
+		return -ret;
+	}
+
 	eth_dev->dev_ops = &dpaa2_ethdev_ops;
 	return 0;
 }