Netdev List
 help / color / mirror / Atom feed
From: Grygorii Strashko <grygorii.strashko@ti.com>
To: "David S. Miller" <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: Sekhar Nori <nsekhar@ti.com>, <linux-kernel@vger.kernel.org>,
	<linux-omap@vger.kernel.org>,
	Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>,
	Murali Karicheri <m-karicheri2@ti.com>,
	Grygorii Strashko <grygorii.strashko@ti.com>
Subject: [PATCH net-next 08/11] net: ethernet: ti: ale: optimize ale entry mask bits configuartion
Date: Thu, 30 Nov 2017 18:21:17 -0600	[thread overview]
Message-ID: <20171201002120.13483-9-grygorii.strashko@ti.com> (raw)
In-Reply-To: <20171201002120.13483-1-grygorii.strashko@ti.com>

The ale->params.ale_ports parameter can be used to deriver values for all
ale entry mask bits: port_mask_bits, port_mask_bits, port_num_bits.
Hence, calculate above values and drop all hardcoded values. For
port_num_bits calcualtion use order_base_2() API.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/net/ethernet/ti/cpsw_ale.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index 5eaaf88..f8c523d 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -816,9 +816,9 @@ void cpsw_ale_start(struct cpsw_ale *ale)
 		 "ALE Table size %ld\n", ale->params.ale_entries);
 
 	/* set default bits for existing h/w */
-	ale->port_mask_bits = 3;
-	ale->port_num_bits = 2;
-	ale->vlan_field_bits = 3;
+	ale->port_mask_bits = ale->params.ale_ports;
+	ale->port_num_bits = order_base_2(ale->params.ale_ports);
+	ale->vlan_field_bits = ale->params.ale_ports;
 
 	/* Set defaults override for ALE on NetCP NU switch and for version
 	 * 1R3
@@ -847,13 +847,6 @@ void cpsw_ale_start(struct cpsw_ale *ale)
 		ale_controls[ALE_PORT_UNTAGGED_EGRESS].shift = 0;
 		ale_controls[ALE_PORT_UNTAGGED_EGRESS].offset =
 					ALE_UNKNOWNVLAN_FORCE_UNTAG_EGRESS;
-		ale->port_mask_bits = ale->params.ale_ports;
-		ale->port_num_bits = ale->params.ale_ports - 1;
-		ale->vlan_field_bits = ale->params.ale_ports;
-	} else if (ale->version == ALE_VERSION_1R3) {
-		ale->port_mask_bits = ale->params.ale_ports;
-		ale->port_num_bits = 3;
-		ale->vlan_field_bits = ale->params.ale_ports;
 	}
 
 	cpsw_ale_control_set(ale, 0, ALE_ENABLE, 1);
-- 
2.10.5

  parent reply	other threads:[~2017-12-01  0:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-01  0:21 [PATCH net-next 00/11] net: ethernet: ti: cpsw/ale clean up and optimization Grygorii Strashko
2017-12-01  0:21 ` [PATCH net-next 01/11] net: ethernet: ti: cpsw: drop unused var poll from cpsw_update_channels_res Grygorii Strashko
2017-12-01  0:21 ` [PATCH net-next 02/11] net: ethernet: ti: cpsw: use proper io apis Grygorii Strashko
2017-12-01  0:21 ` [PATCH net-next 03/11] net: ethernet: ti: cpsw: move platform data struct to .c file Grygorii Strashko
2017-12-01  0:21 ` [PATCH net-next 04/11] net: ethernet: ti: cpsw: move mac_hi/lo defines in cpsw.h Grygorii Strashko
2017-12-01  0:21 ` [PATCH net-next 05/11] net: ethernet: ti: cpsw: fix ale port numbers Grygorii Strashko
2017-12-01  0:21 ` [PATCH net-next 06/11] net: ethernet: ti: ale: use proper io apis Grygorii Strashko
2017-12-01  0:21 ` [PATCH net-next 07/11] net: ethernet: ti: ale: disable ale from stop() Grygorii Strashko
2017-12-01  0:21 ` Grygorii Strashko [this message]
2017-12-01  0:21 ` [PATCH net-next 09/11] net: ethernet: ti: ale: move static initialization in cpsw_ale_create() Grygorii Strashko
2017-12-01  0:21 ` [PATCH net-next 10/11] net: ethernet: ti: ale: use devm_kzalloc " Grygorii Strashko
2017-12-01  0:21 ` [PATCH net-next 11/11] net: ethernet: ti: ale: fix port check in cpsw_ale_control_set/get Grygorii Strashko
2017-12-01 21:36 ` [PATCH net-next 00/11] net: ethernet: ti: cpsw/ale clean up and optimization David Miller

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=20171201002120.13483-9-grygorii.strashko@ti.com \
    --to=grygorii.strashko@ti.com \
    --cc=davem@davemloft.net \
    --cc=ivan.khoronzhuk@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=m-karicheri2@ti.com \
    --cc=netdev@vger.kernel.org \
    --cc=nsekhar@ti.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