diff mbox series

[net-next,4/9] ibmvnic: Use/rename local vars in init_tx_pools

Message ID 20210901000812.120968-5-sukadev@linux.ibm.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series ibmvnic: Reuse ltb, rx, tx pools | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 7 maintainers not CCed: mpe@ellerman.id.au paulus@samba.org tlfalcon@linux.ibm.com davem@davemloft.net linuxppc-dev@lists.ozlabs.org kuba@kernel.org benh@kernel.crashing.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 4 this patch: 4
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 81 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Sukadev Bhattiprolu Sept. 1, 2021, 12:08 a.m. UTC
Use/rename local variables in init_tx_pools() for consistency with
init_rx_pools() and for readability. Also add some comments

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

Comments

Dany Madden Sept. 1, 2021, 1:30 a.m. UTC | #1
On 2021-08-31 17:08, Sukadev Bhattiprolu wrote:
> Use/rename local variables in init_tx_pools() for consistency with
> init_rx_pools() and for readability. Also add some comments
> 
> Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.ibm.com>
Reviewed-by: Dany Madden <drt@linux.ibm.com>

> ---
>  drivers/net/ethernet/ibm/ibmvnic.c | 30 ++++++++++++++++--------------
>  1 file changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ibm/ibmvnic.c
> b/drivers/net/ethernet/ibm/ibmvnic.c
> index a611bd3f2539..4c6739b250df 100644
> --- a/drivers/net/ethernet/ibm/ibmvnic.c
> +++ b/drivers/net/ethernet/ibm/ibmvnic.c
> @@ -777,31 +777,31 @@ static void release_tx_pools(struct
> ibmvnic_adapter *adapter)
> 
>  static int init_one_tx_pool(struct net_device *netdev,
>  			    struct ibmvnic_tx_pool *tx_pool,
> -			    int num_entries, int buf_size)
> +			    int pool_size, int buf_size)
>  {
>  	struct ibmvnic_adapter *adapter = netdev_priv(netdev);
>  	int i;
> 
> -	tx_pool->tx_buff = kcalloc(num_entries,
> +	tx_pool->tx_buff = kcalloc(pool_size,
>  				   sizeof(struct ibmvnic_tx_buff),
>  				   GFP_KERNEL);
>  	if (!tx_pool->tx_buff)
>  		return -1;
> 
>  	if (alloc_long_term_buff(adapter, &tx_pool->long_term_buff,
> -				 num_entries * buf_size))
> +				 pool_size * buf_size))
>  		return -1;
> 
> -	tx_pool->free_map = kcalloc(num_entries, sizeof(int), GFP_KERNEL);
> +	tx_pool->free_map = kcalloc(pool_size, sizeof(int), GFP_KERNEL);
>  	if (!tx_pool->free_map)
>  		return -1;
> 
> -	for (i = 0; i < num_entries; i++)
> +	for (i = 0; i < pool_size; i++)
>  		tx_pool->free_map[i] = i;
> 
>  	tx_pool->consumer_index = 0;
>  	tx_pool->producer_index = 0;
> -	tx_pool->num_buffers = num_entries;
> +	tx_pool->num_buffers = pool_size;
>  	tx_pool->buf_size = buf_size;
> 
>  	return 0;
> @@ -811,17 +811,20 @@ static int init_tx_pools(struct net_device 
> *netdev)
>  {
>  	struct ibmvnic_adapter *adapter = netdev_priv(netdev);
>  	struct device *dev = &adapter->vdev->dev;
> -	int tx_subcrqs;
> +	int num_pools;
> +	u64 pool_size;		/* # of buffers in pool */
>  	u64 buff_size;
>  	int i, rc;
> 
> -	tx_subcrqs = adapter->num_active_tx_scrqs;
> -	adapter->tx_pool = kcalloc(tx_subcrqs,
> +	pool_size = adapter->req_tx_entries_per_subcrq;
> +	num_pools = adapter->num_active_tx_scrqs;
> +
> +	adapter->tx_pool = kcalloc(num_pools,
>  				   sizeof(struct ibmvnic_tx_pool), GFP_KERNEL);
>  	if (!adapter->tx_pool)
>  		return -1;
> 
> -	adapter->tso_pool = kcalloc(tx_subcrqs,
> +	adapter->tso_pool = kcalloc(num_pools,
>  				    sizeof(struct ibmvnic_tx_pool), GFP_KERNEL);
>  	/* To simplify release_tx_pools() ensure that ->tx_pool and
>  	 * ->tso_pool are either both NULL or both non-NULL.
> @@ -835,9 +838,9 @@ static int init_tx_pools(struct net_device *netdev)
>  	/* Set num_active_tx_pools early. If we fail below after partial
>  	 * allocation, release_tx_pools() will know how many to look for.
>  	 */
> -	adapter->num_active_tx_pools = tx_subcrqs;
> +	adapter->num_active_tx_pools = num_pools;
> 
> -	for (i = 0; i < tx_subcrqs; i++) {
> +	for (i = 0; i < num_pools; i++) {
>  		buff_size = adapter->req_mtu + VLAN_HLEN;
>  		buff_size = ALIGN(buff_size, L1_CACHE_BYTES);
> 
> @@ -845,8 +848,7 @@ static int init_tx_pools(struct net_device *netdev)
>  			i, adapter->req_tx_entries_per_subcrq, buff_size);
> 
>  		rc = init_one_tx_pool(netdev, &adapter->tx_pool[i],
> -				      adapter->req_tx_entries_per_subcrq,
> -				      buff_size);
> +				      pool_size, buff_size);
>  		if (rc) {
>  			release_tx_pools(adapter);
>  			return rc;
diff mbox series

Patch

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index a611bd3f2539..4c6739b250df 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -777,31 +777,31 @@  static void release_tx_pools(struct ibmvnic_adapter *adapter)
 
 static int init_one_tx_pool(struct net_device *netdev,
 			    struct ibmvnic_tx_pool *tx_pool,
-			    int num_entries, int buf_size)
+			    int pool_size, int buf_size)
 {
 	struct ibmvnic_adapter *adapter = netdev_priv(netdev);
 	int i;
 
-	tx_pool->tx_buff = kcalloc(num_entries,
+	tx_pool->tx_buff = kcalloc(pool_size,
 				   sizeof(struct ibmvnic_tx_buff),
 				   GFP_KERNEL);
 	if (!tx_pool->tx_buff)
 		return -1;
 
 	if (alloc_long_term_buff(adapter, &tx_pool->long_term_buff,
-				 num_entries * buf_size))
+				 pool_size * buf_size))
 		return -1;
 
-	tx_pool->free_map = kcalloc(num_entries, sizeof(int), GFP_KERNEL);
+	tx_pool->free_map = kcalloc(pool_size, sizeof(int), GFP_KERNEL);
 	if (!tx_pool->free_map)
 		return -1;
 
-	for (i = 0; i < num_entries; i++)
+	for (i = 0; i < pool_size; i++)
 		tx_pool->free_map[i] = i;
 
 	tx_pool->consumer_index = 0;
 	tx_pool->producer_index = 0;
-	tx_pool->num_buffers = num_entries;
+	tx_pool->num_buffers = pool_size;
 	tx_pool->buf_size = buf_size;
 
 	return 0;
@@ -811,17 +811,20 @@  static int init_tx_pools(struct net_device *netdev)
 {
 	struct ibmvnic_adapter *adapter = netdev_priv(netdev);
 	struct device *dev = &adapter->vdev->dev;
-	int tx_subcrqs;
+	int num_pools;
+	u64 pool_size;		/* # of buffers in pool */
 	u64 buff_size;
 	int i, rc;
 
-	tx_subcrqs = adapter->num_active_tx_scrqs;
-	adapter->tx_pool = kcalloc(tx_subcrqs,
+	pool_size = adapter->req_tx_entries_per_subcrq;
+	num_pools = adapter->num_active_tx_scrqs;
+
+	adapter->tx_pool = kcalloc(num_pools,
 				   sizeof(struct ibmvnic_tx_pool), GFP_KERNEL);
 	if (!adapter->tx_pool)
 		return -1;
 
-	adapter->tso_pool = kcalloc(tx_subcrqs,
+	adapter->tso_pool = kcalloc(num_pools,
 				    sizeof(struct ibmvnic_tx_pool), GFP_KERNEL);
 	/* To simplify release_tx_pools() ensure that ->tx_pool and
 	 * ->tso_pool are either both NULL or both non-NULL.
@@ -835,9 +838,9 @@  static int init_tx_pools(struct net_device *netdev)
 	/* Set num_active_tx_pools early. If we fail below after partial
 	 * allocation, release_tx_pools() will know how many to look for.
 	 */
-	adapter->num_active_tx_pools = tx_subcrqs;
+	adapter->num_active_tx_pools = num_pools;
 
-	for (i = 0; i < tx_subcrqs; i++) {
+	for (i = 0; i < num_pools; i++) {
 		buff_size = adapter->req_mtu + VLAN_HLEN;
 		buff_size = ALIGN(buff_size, L1_CACHE_BYTES);
 
@@ -845,8 +848,7 @@  static int init_tx_pools(struct net_device *netdev)
 			i, adapter->req_tx_entries_per_subcrq, buff_size);
 
 		rc = init_one_tx_pool(netdev, &adapter->tx_pool[i],
-				      adapter->req_tx_entries_per_subcrq,
-				      buff_size);
+				      pool_size, buff_size);
 		if (rc) {
 			release_tx_pools(adapter);
 			return rc;