linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 00/11] net: ethernet: ti: cpsw/ale clean up and optimization
@ 2017-12-01  0:21 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
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Grygorii Strashko @ 2017-12-01  0:21 UTC (permalink / raw)
  To: David S. Miller, netdev
  Cc: Sekhar Nori, linux-kernel, linux-omap, Ivan Khoronzhuk,
	Murali Karicheri, Grygorii Strashko

This is set of non critical clean ups and optimizations for TI
CPSW and ALE drivers.

Rebased on top on net-next.

Grygorii Strashko (11):
  net: ethernet: ti: cpsw: drop unused var poll from
    cpsw_update_channels_res
  net: ethernet: ti: cpsw: use proper io apis
  net: ethernet: ti: cpsw: move platform data struct to .c file
  net: ethernet: ti: cpsw: move mac_hi/lo defines in cpsw.h
  net: ethernet: ti: cpsw: fix ale port numbers
  net: ethernet: ti: ale: use proper io apis
  net: ethernet: ti: ale: disable ale from stop()
  net: ethernet: ti: ale: optimize ale entry mask bits configuartion
  net: ethernet: ti: ale: move static initialization in
    cpsw_ale_create()
  net: ethernet: ti: ale: use devm_kzalloc in cpsw_ale_create()
  net: ethernet: ti: ale: fix port check in cpsw_ale_control_set/get

 drivers/net/ethernet/ti/cpsw.c        |  84 +++++++++++++++-----------
 drivers/net/ethernet/ti/cpsw.h        |  23 +------
 drivers/net/ethernet/ti/cpsw_ale.c    | 109 ++++++++++++++--------------------
 drivers/net/ethernet/ti/cpsw_ale.h    |   1 -
 drivers/net/ethernet/ti/netcp_ethss.c |   6 +-
 5 files changed, 98 insertions(+), 125 deletions(-)

-- 
2.10.5

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH net-next 01/11] net: ethernet: ti: cpsw: drop unused var poll from cpsw_update_channels_res
  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 ` Grygorii Strashko
  2017-12-01  0:21 ` [PATCH net-next 02/11] net: ethernet: ti: cpsw: use proper io apis Grygorii Strashko
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2017-12-01  0:21 UTC (permalink / raw)
  To: David S. Miller, netdev
  Cc: Sekhar Nori, linux-kernel, linux-omap, Ivan Khoronzhuk,
	Murali Karicheri, Grygorii Strashko

Drop unused variable "poll" from cpsw_update_channels_res().

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

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index a73600d..523c110 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -2298,7 +2298,6 @@ static int cpsw_check_ch_settings(struct cpsw_common *cpsw,
 
 static int cpsw_update_channels_res(struct cpsw_priv *priv, int ch_num, int rx)
 {
-	int (*poll)(struct napi_struct *, int);
 	struct cpsw_common *cpsw = priv->cpsw;
 	void (*handler)(void *, int, int);
 	struct netdev_queue *queue;
@@ -2309,12 +2308,10 @@ static int cpsw_update_channels_res(struct cpsw_priv *priv, int ch_num, int rx)
 		ch = &cpsw->rx_ch_num;
 		vec = cpsw->rxv;
 		handler = cpsw_rx_handler;
-		poll = cpsw_rx_poll;
 	} else {
 		ch = &cpsw->tx_ch_num;
 		vec = cpsw->txv;
 		handler = cpsw_tx_handler;
-		poll = cpsw_tx_poll;
 	}
 
 	while (*ch < ch_num) {
-- 
2.10.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 02/11] net: ethernet: ti: cpsw: use proper io apis
  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 ` 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
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2017-12-01  0:21 UTC (permalink / raw)
  To: David S. Miller, netdev
  Cc: Sekhar Nori, linux-kernel, linux-omap, Ivan Khoronzhuk,
	Murali Karicheri, Grygorii Strashko

Switch to use writel_relaxed/readl_relaxed() IO API instead of raw version
as it is recommended.

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

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 523c110..f74a8fd 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -365,12 +365,12 @@ struct cpsw_slave {
 
 static inline u32 slave_read(struct cpsw_slave *slave, u32 offset)
 {
-	return __raw_readl(slave->regs + offset);
+	return readl_relaxed(slave->regs + offset);
 }
 
 static inline void slave_write(struct cpsw_slave *slave, u32 val, u32 offset)
 {
-	__raw_writel(val, slave->regs + offset);
+	writel_relaxed(val, slave->regs + offset);
 }
 
 struct cpsw_vector {
@@ -660,8 +660,8 @@ static void cpsw_ndo_set_rx_mode(struct net_device *ndev)
 
 static void cpsw_intr_enable(struct cpsw_common *cpsw)
 {
-	__raw_writel(0xFF, &cpsw->wr_regs->tx_en);
-	__raw_writel(0xFF, &cpsw->wr_regs->rx_en);
+	writel_relaxed(0xFF, &cpsw->wr_regs->tx_en);
+	writel_relaxed(0xFF, &cpsw->wr_regs->rx_en);
 
 	cpdma_ctlr_int_ctrl(cpsw->dma, true);
 	return;
@@ -669,8 +669,8 @@ static void cpsw_intr_enable(struct cpsw_common *cpsw)
 
 static void cpsw_intr_disable(struct cpsw_common *cpsw)
 {
-	__raw_writel(0, &cpsw->wr_regs->tx_en);
-	__raw_writel(0, &cpsw->wr_regs->rx_en);
+	writel_relaxed(0, &cpsw->wr_regs->tx_en);
+	writel_relaxed(0, &cpsw->wr_regs->rx_en);
 
 	cpdma_ctlr_int_ctrl(cpsw->dma, false);
 	return;
@@ -949,12 +949,12 @@ static inline void soft_reset(const char *module, void __iomem *reg)
 {
 	unsigned long timeout = jiffies + HZ;
 
-	__raw_writel(1, reg);
+	writel_relaxed(1, reg);
 	do {
 		cpu_relax();
-	} while ((__raw_readl(reg) & 1) && time_after(timeout, jiffies));
+	} while ((readl_relaxed(reg) & 1) && time_after(timeout, jiffies));
 
-	WARN(__raw_readl(reg) & 1, "failed to soft-reset %s\n", module);
+	WARN(readl_relaxed(reg) & 1, "failed to soft-reset %s\n", module);
 }
 
 #define mac_hi(mac)	(((mac)[0] << 0) | ((mac)[1] << 8) |	\
@@ -1015,7 +1015,7 @@ static void _cpsw_adjust_link(struct cpsw_slave *slave,
 
 	if (mac_control != slave->mac_control) {
 		phy_print_status(phy);
-		__raw_writel(mac_control, &slave->sliver->mac_control);
+		writel_relaxed(mac_control, &slave->sliver->mac_control);
 	}
 
 	slave->mac_control = mac_control;
@@ -1278,7 +1278,7 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
 	soft_reset_slave(slave);
 
 	/* setup priority mapping */
-	__raw_writel(RX_PRIORITY_MAPPING, &slave->sliver->rx_pri_map);
+	writel_relaxed(RX_PRIORITY_MAPPING, &slave->sliver->rx_pri_map);
 
 	switch (cpsw->version) {
 	case CPSW_VERSION_1:
@@ -1304,7 +1304,7 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
 	}
 
 	/* setup max packet size, and mac address */
-	__raw_writel(cpsw->rx_packet_max, &slave->sliver->rx_maxlen);
+	writel_relaxed(cpsw->rx_packet_max, &slave->sliver->rx_maxlen);
 	cpsw_set_slave_mac(slave, priv);
 
 	slave->mac_control = 0;	/* no link yet */
@@ -1395,9 +1395,9 @@ static void cpsw_init_host_port(struct cpsw_priv *priv)
 	writel(fifo_mode, &cpsw->host_port_regs->tx_in_ctl);
 
 	/* setup host port priority mapping */
-	__raw_writel(CPDMA_TX_PRIORITY_MAP,
-		     &cpsw->host_port_regs->cpdma_tx_pri_map);
-	__raw_writel(0, &cpsw->host_port_regs->cpdma_rx_chan_map);
+	writel_relaxed(CPDMA_TX_PRIORITY_MAP,
+		       &cpsw->host_port_regs->cpdma_tx_pri_map);
+	writel_relaxed(0, &cpsw->host_port_regs->cpdma_rx_chan_map);
 
 	cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM,
 			     ALE_PORT_STATE, ALE_PORT_STATE_FORWARD);
@@ -1514,10 +1514,10 @@ static int cpsw_ndo_open(struct net_device *ndev)
 	/* initialize shared resources for every ndev */
 	if (!cpsw->usage_count) {
 		/* disable priority elevation */
-		__raw_writel(0, &cpsw->regs->ptype);
+		writel_relaxed(0, &cpsw->regs->ptype);
 
 		/* enable statistics collection only on all ports */
-		__raw_writel(0x7, &cpsw->regs->stat_port_en);
+		writel_relaxed(0x7, &cpsw->regs->stat_port_en);
 
 		/* Enable internal fifo flow control */
 		writel(0x7, &cpsw->regs->flow_control);
@@ -1701,7 +1701,7 @@ static void cpsw_hwtstamp_v2(struct cpsw_priv *priv)
 
 	slave_write(slave, mtype, CPSW2_TS_SEQ_MTYPE);
 	slave_write(slave, ctrl, CPSW2_CONTROL);
-	__raw_writel(ETH_P_1588, &cpsw->regs->ts_ltype);
+	writel_relaxed(ETH_P_1588, &cpsw->regs->ts_ltype);
 }
 
 static int cpsw_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
-- 
2.10.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 03/11] net: ethernet: ti: cpsw: move platform data struct to .c file
  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 ` 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
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2017-12-01  0:21 UTC (permalink / raw)
  To: David S. Miller, netdev
  Cc: Sekhar Nori, linux-kernel, linux-omap, Ivan Khoronzhuk,
	Murali Karicheri, Grygorii Strashko

CPSW platform data struct cpsw_platform_data and struct cpsw_slave_data are
used only incide cpsw.c module, so move these definitions there.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/net/ethernet/ti/cpsw.c | 21 +++++++++++++++++++++
 drivers/net/ethernet/ti/cpsw.h | 21 ---------------------
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index f74a8fd..54c8758 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -352,6 +352,27 @@ struct cpsw_hw_stats {
 	u32	rxdmaoverruns;
 };
 
+struct cpsw_slave_data {
+	struct device_node *phy_node;
+	char		phy_id[MII_BUS_ID_SIZE];
+	int		phy_if;
+	u8		mac_addr[ETH_ALEN];
+	u16		dual_emac_res_vlan;	/* Reserved VLAN for DualEMAC */
+};
+
+struct cpsw_platform_data {
+	struct cpsw_slave_data	*slave_data;
+	u32	ss_reg_ofs;	/* Subsystem control register offset */
+	u32	channels;	/* number of cpdma channels (symmetric) */
+	u32	slaves;		/* number of slave cpgmac ports */
+	u32	active_slave; /* time stamping, ethtool and SIOCGMIIPHY slave */
+	u32	ale_entries;	/* ale table size */
+	u32	bd_ram_size;  /*buffer descriptor ram size */
+	u32	mac_control;	/* Mac control register */
+	u16	default_vlan;	/* Def VLAN for ALE lookup in VLAN aware mode*/
+	bool	dual_emac;	/* Enable Dual EMAC mode */
+};
+
 struct cpsw_slave {
 	void __iomem			*regs;
 	struct cpsw_sliver_regs __iomem	*sliver;
diff --git a/drivers/net/ethernet/ti/cpsw.h b/drivers/net/ethernet/ti/cpsw.h
index 6c3037a..a325f555 100644
--- a/drivers/net/ethernet/ti/cpsw.h
+++ b/drivers/net/ethernet/ti/cpsw.h
@@ -17,27 +17,6 @@
 #include <linux/if_ether.h>
 #include <linux/phy.h>
 
-struct cpsw_slave_data {
-	struct device_node *phy_node;
-	char		phy_id[MII_BUS_ID_SIZE];
-	int		phy_if;
-	u8		mac_addr[ETH_ALEN];
-	u16		dual_emac_res_vlan;	/* Reserved VLAN for DualEMAC */
-};
-
-struct cpsw_platform_data {
-	struct cpsw_slave_data	*slave_data;
-	u32	ss_reg_ofs;	/* Subsystem control register offset */
-	u32	channels;	/* number of cpdma channels (symmetric) */
-	u32	slaves;		/* number of slave cpgmac ports */
-	u32	active_slave; /* time stamping, ethtool and SIOCGMIIPHY slave */
-	u32	ale_entries;	/* ale table size */
-	u32	bd_ram_size;  /*buffer descriptor ram size */
-	u32	mac_control;	/* Mac control register */
-	u16	default_vlan;	/* Def VLAN for ALE lookup in VLAN aware mode*/
-	bool	dual_emac;	/* Enable Dual EMAC mode */
-};
-
 void cpsw_phy_sel(struct device *dev, phy_interface_t phy_mode, int slave);
 int ti_cm_get_macid(struct device *dev, int slave, u8 *mac_addr);
 
-- 
2.10.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 04/11] net: ethernet: ti: cpsw: move mac_hi/lo defines in cpsw.h
  2017-12-01  0:21 [PATCH net-next 00/11] net: ethernet: ti: cpsw/ale clean up and optimization Grygorii Strashko
                   ` (2 preceding siblings ...)
  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 ` Grygorii Strashko
  2017-12-01  0:21 ` [PATCH net-next 05/11] net: ethernet: ti: cpsw: fix ale port numbers Grygorii Strashko
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2017-12-01  0:21 UTC (permalink / raw)
  To: David S. Miller, netdev
  Cc: Sekhar Nori, linux-kernel, linux-omap, Ivan Khoronzhuk,
	Murali Karicheri, Grygorii Strashko

Move mac_hi/lo defines in common header cpsw.h and re-use
them for netcp_ethss.c.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/net/ethernet/ti/cpsw.c        | 4 ----
 drivers/net/ethernet/ti/cpsw.h        | 4 ++++
 drivers/net/ethernet/ti/netcp_ethss.c | 5 +----
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 54c8758..2bf0bda 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -978,10 +978,6 @@ static inline void soft_reset(const char *module, void __iomem *reg)
 	WARN(readl_relaxed(reg) & 1, "failed to soft-reset %s\n", module);
 }
 
-#define mac_hi(mac)	(((mac)[0] << 0) | ((mac)[1] << 8) |	\
-			 ((mac)[2] << 16) | ((mac)[3] << 24))
-#define mac_lo(mac)	(((mac)[4] << 0) | ((mac)[5] << 8))
-
 static void cpsw_set_slave_mac(struct cpsw_slave *slave,
 			       struct cpsw_priv *priv)
 {
diff --git a/drivers/net/ethernet/ti/cpsw.h b/drivers/net/ethernet/ti/cpsw.h
index a325f555..cf111db 100644
--- a/drivers/net/ethernet/ti/cpsw.h
+++ b/drivers/net/ethernet/ti/cpsw.h
@@ -17,6 +17,10 @@
 #include <linux/if_ether.h>
 #include <linux/phy.h>
 
+#define mac_hi(mac)	(((mac)[0] << 0) | ((mac)[1] << 8) |	\
+			 ((mac)[2] << 16) | ((mac)[3] << 24))
+#define mac_lo(mac)	(((mac)[4] << 0) | ((mac)[5] << 8))
+
 void cpsw_phy_sel(struct device *dev, phy_interface_t phy_mode, int slave);
 int ti_cm_get_macid(struct device *dev, int slave, u8 *mac_addr);
 
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index e831c49..12765e4 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -27,6 +27,7 @@
 #include <linux/net_tstamp.h>
 #include <linux/ethtool.h>
 
+#include "cpsw.h"
 #include "cpsw_ale.h"
 #include "netcp.h"
 #include "cpts.h"
@@ -2047,10 +2048,6 @@ static const struct ethtool_ops keystone_ethtool_ops = {
 	.get_ts_info		= keystone_get_ts_info,
 };
 
-#define mac_hi(mac)	(((mac)[0] << 0) | ((mac)[1] << 8) |	\
-			 ((mac)[2] << 16) | ((mac)[3] << 24))
-#define mac_lo(mac)	(((mac)[4] << 0) | ((mac)[5] << 8))
-
 static void gbe_set_slave_mac(struct gbe_slave *slave,
 			      struct gbe_intf *gbe_intf)
 {
-- 
2.10.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 05/11] net: ethernet: ti: cpsw: fix ale port numbers
  2017-12-01  0:21 [PATCH net-next 00/11] net: ethernet: ti: cpsw/ale clean up and optimization Grygorii Strashko
                   ` (3 preceding siblings ...)
  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 ` Grygorii Strashko
  2017-12-01  0:21 ` [PATCH net-next 06/11] net: ethernet: ti: ale: use proper io apis Grygorii Strashko
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2017-12-01  0:21 UTC (permalink / raw)
  To: David S. Miller, netdev
  Cc: Sekhar Nori, linux-kernel, linux-omap, Ivan Khoronzhuk,
	Murali Karicheri, Grygorii Strashko

TI OMAP/Sitara SoCs have fixed number of ALE ports 3, which includes Host
port also.

Hence, use fixed value instead of value calcualted from DT, which can be
set by user and might not reflect actual HW configuration.

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

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 2bf0bda..64bdd92 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -88,6 +88,7 @@ do {								\
 #define CPSW_VERSION_4		0x190112
 
 #define HOST_PORT_NUM		0
+#define CPSW_ALE_PORTS_NUM	3
 #define SLIVER_SIZE		0x40
 
 #define CPSW1_HOST_PORT_OFFSET	0x028
@@ -3074,7 +3075,7 @@ static int cpsw_probe(struct platform_device *pdev)
 	ale_params.dev			= &pdev->dev;
 	ale_params.ale_ageout		= ale_ageout;
 	ale_params.ale_entries		= data->ale_entries;
-	ale_params.ale_ports		= data->slaves;
+	ale_params.ale_ports		= CPSW_ALE_PORTS_NUM;
 
 	cpsw->ale = cpsw_ale_create(&ale_params);
 	if (!cpsw->ale) {
-- 
2.10.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 06/11] net: ethernet: ti: ale: use proper io apis
  2017-12-01  0:21 [PATCH net-next 00/11] net: ethernet: ti: cpsw/ale clean up and optimization Grygorii Strashko
                   ` (4 preceding siblings ...)
  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 ` Grygorii Strashko
  2017-12-01  0:21 ` [PATCH net-next 07/11] net: ethernet: ti: ale: disable ale from stop() Grygorii Strashko
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2017-12-01  0:21 UTC (permalink / raw)
  To: David S. Miller, netdev
  Cc: Sekhar Nori, linux-kernel, linux-omap, Ivan Khoronzhuk,
	Murali Karicheri, Grygorii Strashko

Switch to use writel_relaxed/readl_relaxed() IO API instead of raw version
as it is recommended.

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

diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index b432a75..fca5c29 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -150,11 +150,11 @@ static int cpsw_ale_read(struct cpsw_ale *ale, int idx, u32 *ale_entry)
 
 	WARN_ON(idx > ale->params.ale_entries);
 
-	__raw_writel(idx, ale->params.ale_regs + ALE_TABLE_CONTROL);
+	writel_relaxed(idx, ale->params.ale_regs + ALE_TABLE_CONTROL);
 
 	for (i = 0; i < ALE_ENTRY_WORDS; i++)
-		ale_entry[i] = __raw_readl(ale->params.ale_regs +
-					   ALE_TABLE + 4 * i);
+		ale_entry[i] = readl_relaxed(ale->params.ale_regs +
+					     ALE_TABLE + 4 * i);
 
 	return idx;
 }
@@ -166,11 +166,11 @@ static int cpsw_ale_write(struct cpsw_ale *ale, int idx, u32 *ale_entry)
 	WARN_ON(idx > ale->params.ale_entries);
 
 	for (i = 0; i < ALE_ENTRY_WORDS; i++)
-		__raw_writel(ale_entry[i], ale->params.ale_regs +
-			     ALE_TABLE + 4 * i);
+		writel_relaxed(ale_entry[i], ale->params.ale_regs +
+			       ALE_TABLE + 4 * i);
 
-	__raw_writel(idx | ALE_TABLE_WRITE, ale->params.ale_regs +
-		     ALE_TABLE_CONTROL);
+	writel_relaxed(idx | ALE_TABLE_WRITE, ale->params.ale_regs +
+		       ALE_TABLE_CONTROL);
 
 	return idx;
 }
@@ -733,9 +733,9 @@ int cpsw_ale_control_set(struct cpsw_ale *ale, int port, int control,
 	offset = info->offset + (port * info->port_offset);
 	shift  = info->shift  + (port * info->port_shift);
 
-	tmp = __raw_readl(ale->params.ale_regs + offset);
+	tmp = readl_relaxed(ale->params.ale_regs + offset);
 	tmp = (tmp & ~(mask << shift)) | (value << shift);
-	__raw_writel(tmp, ale->params.ale_regs + offset);
+	writel_relaxed(tmp, ale->params.ale_regs + offset);
 
 	return 0;
 }
@@ -760,7 +760,7 @@ int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control)
 	offset = info->offset + (port * info->port_offset);
 	shift  = info->shift  + (port * info->port_shift);
 
-	tmp = __raw_readl(ale->params.ale_regs + offset) >> shift;
+	tmp = readl_relaxed(ale->params.ale_regs + offset) >> shift;
 	return tmp & BITMASK(info->bits);
 }
 EXPORT_SYMBOL_GPL(cpsw_ale_control_get);
@@ -781,7 +781,7 @@ void cpsw_ale_start(struct cpsw_ale *ale)
 {
 	u32 rev, ale_entries;
 
-	rev = __raw_readl(ale->params.ale_regs + ALE_IDVER);
+	rev = readl_relaxed(ale->params.ale_regs + ALE_IDVER);
 	if (!ale->params.major_ver_mask)
 		ale->params.major_ver_mask = 0xff;
 	ale->version =
@@ -793,8 +793,8 @@ void cpsw_ale_start(struct cpsw_ale *ale)
 
 	if (!ale->params.ale_entries) {
 		ale_entries =
-			__raw_readl(ale->params.ale_regs + ALE_STATUS) &
-				    ALE_STATUS_SIZE_MASK;
+			readl_relaxed(ale->params.ale_regs + ALE_STATUS) &
+			ALE_STATUS_SIZE_MASK;
 		/* ALE available on newer NetCP switches has introduced
 		 * a register, ALE_STATUS, to indicate the size of ALE
 		 * table which shows the size as a multiple of 1024 entries.
-- 
2.10.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 07/11] net: ethernet: ti: ale: disable ale from stop()
  2017-12-01  0:21 [PATCH net-next 00/11] net: ethernet: ti: cpsw/ale clean up and optimization Grygorii Strashko
                   ` (5 preceding siblings ...)
  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 ` Grygorii Strashko
  2017-12-01  0:21 ` [PATCH net-next 08/11] net: ethernet: ti: ale: optimize ale entry mask bits configuartion Grygorii Strashko
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2017-12-01  0:21 UTC (permalink / raw)
  To: David S. Miller, netdev
  Cc: Sekhar Nori, linux-kernel, linux-omap, Ivan Khoronzhuk,
	Murali Karicheri, Grygorii Strashko

ALE is enabled from cpsw_ale_start() now, but disabled only from
cpsw_ale_destroy() which introduces inconsitance as cpsw_ale_start() is
called when netif[s] is opened, but cpsw_ale_destroy() is called when
driver is removed. Hence, move ALE disabling in cpsw_ale_stop().

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/net/ethernet/ti/cpsw_ale.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index fca5c29..5eaaf88 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -870,6 +870,7 @@ EXPORT_SYMBOL_GPL(cpsw_ale_start);
 void cpsw_ale_stop(struct cpsw_ale *ale)
 {
 	del_timer_sync(&ale->timer);
+	cpsw_ale_control_set(ale, 0, ALE_ENABLE, 0);
 }
 EXPORT_SYMBOL_GPL(cpsw_ale_stop);
 
@@ -892,7 +893,6 @@ int cpsw_ale_destroy(struct cpsw_ale *ale)
 {
 	if (!ale)
 		return -EINVAL;
-	cpsw_ale_control_set(ale, 0, ALE_ENABLE, 0);
 	kfree(ale);
 	return 0;
 }
-- 
2.10.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 08/11] net: ethernet: ti: ale: optimize ale entry mask bits configuartion
  2017-12-01  0:21 [PATCH net-next 00/11] net: ethernet: ti: cpsw/ale clean up and optimization Grygorii Strashko
                   ` (6 preceding siblings ...)
  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
  2017-12-01  0:21 ` [PATCH net-next 09/11] net: ethernet: ti: ale: move static initialization in cpsw_ale_create() Grygorii Strashko
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2017-12-01  0:21 UTC (permalink / raw)
  To: David S. Miller, netdev
  Cc: Sekhar Nori, linux-kernel, linux-omap, Ivan Khoronzhuk,
	Murali Karicheri, Grygorii Strashko

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 09/11] net: ethernet: ti: ale: move static initialization in cpsw_ale_create()
  2017-12-01  0:21 [PATCH net-next 00/11] net: ethernet: ti: cpsw/ale clean up and optimization Grygorii Strashko
                   ` (7 preceding siblings ...)
  2017-12-01  0:21 ` [PATCH net-next 08/11] net: ethernet: ti: ale: optimize ale entry mask bits configuartion Grygorii Strashko
@ 2017-12-01  0:21 ` Grygorii Strashko
  2017-12-01  0:21 ` [PATCH net-next 10/11] net: ethernet: ti: ale: use devm_kzalloc " Grygorii Strashko
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2017-12-01  0:21 UTC (permalink / raw)
  To: David S. Miller, netdev
  Cc: Sekhar Nori, linux-kernel, linux-omap, Ivan Khoronzhuk,
	Murali Karicheri, Grygorii Strashko

Move static initialization from cpsw_ale_start() to cpsw_ale_create() as it
does not make much sence to perform static initializtion in
cpsw_ale_start() which is called everytime netif[s] is opened.

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

diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index f8c523d..53aa721 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -779,8 +779,36 @@ static void cpsw_ale_timer(struct timer_list *t)
 
 void cpsw_ale_start(struct cpsw_ale *ale)
 {
+	cpsw_ale_control_set(ale, 0, ALE_ENABLE, 1);
+	cpsw_ale_control_set(ale, 0, ALE_CLEAR, 1);
+
+	timer_setup(&ale->timer, cpsw_ale_timer, 0);
+	if (ale->ageout) {
+		ale->timer.expires = jiffies + ale->ageout;
+		add_timer(&ale->timer);
+	}
+}
+EXPORT_SYMBOL_GPL(cpsw_ale_start);
+
+void cpsw_ale_stop(struct cpsw_ale *ale)
+{
+	del_timer_sync(&ale->timer);
+	cpsw_ale_control_set(ale, 0, ALE_ENABLE, 0);
+}
+EXPORT_SYMBOL_GPL(cpsw_ale_stop);
+
+struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
+{
+	struct cpsw_ale *ale;
 	u32 rev, ale_entries;
 
+	ale = kzalloc(sizeof(*ale), GFP_KERNEL);
+	if (!ale)
+		return NULL;
+
+	ale->params = *params;
+	ale->ageout = ale->params.ale_ageout * HZ;
+
 	rev = readl_relaxed(ale->params.ale_regs + ALE_IDVER);
 	if (!ale->params.major_ver_mask)
 		ale->params.major_ver_mask = 0xff;
@@ -849,35 +877,6 @@ void cpsw_ale_start(struct cpsw_ale *ale)
 					ALE_UNKNOWNVLAN_FORCE_UNTAG_EGRESS;
 	}
 
-	cpsw_ale_control_set(ale, 0, ALE_ENABLE, 1);
-	cpsw_ale_control_set(ale, 0, ALE_CLEAR, 1);
-
-	timer_setup(&ale->timer, cpsw_ale_timer, 0);
-	if (ale->ageout) {
-		ale->timer.expires = jiffies + ale->ageout;
-		add_timer(&ale->timer);
-	}
-}
-EXPORT_SYMBOL_GPL(cpsw_ale_start);
-
-void cpsw_ale_stop(struct cpsw_ale *ale)
-{
-	del_timer_sync(&ale->timer);
-	cpsw_ale_control_set(ale, 0, ALE_ENABLE, 0);
-}
-EXPORT_SYMBOL_GPL(cpsw_ale_stop);
-
-struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
-{
-	struct cpsw_ale *ale;
-
-	ale = kzalloc(sizeof(*ale), GFP_KERNEL);
-	if (!ale)
-		return NULL;
-
-	ale->params = *params;
-	ale->ageout = ale->params.ale_ageout * HZ;
-
 	return ale;
 }
 EXPORT_SYMBOL_GPL(cpsw_ale_create);
-- 
2.10.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 10/11] net: ethernet: ti: ale: use devm_kzalloc in cpsw_ale_create()
  2017-12-01  0:21 [PATCH net-next 00/11] net: ethernet: ti: cpsw/ale clean up and optimization Grygorii Strashko
                   ` (8 preceding siblings ...)
  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 ` 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
  11 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2017-12-01  0:21 UTC (permalink / raw)
  To: David S. Miller, netdev
  Cc: Sekhar Nori, linux-kernel, linux-omap, Ivan Khoronzhuk,
	Murali Karicheri, Grygorii Strashko

Use cpsw_ale_create in cpsw_ale_create(). This also makes
cpsw_ale_destroy() function nop, so remove it.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/net/ethernet/ti/cpsw.c        | 17 +++++++----------
 drivers/net/ethernet/ti/cpsw_ale.c    | 11 +----------
 drivers/net/ethernet/ti/cpsw_ale.h    |  1 -
 drivers/net/ethernet/ti/netcp_ethss.c |  1 -
 4 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 64bdd92..a60a378 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -3087,14 +3087,14 @@ static int cpsw_probe(struct platform_device *pdev)
 	cpsw->cpts = cpts_create(cpsw->dev, cpts_regs, cpsw->dev->of_node);
 	if (IS_ERR(cpsw->cpts)) {
 		ret = PTR_ERR(cpsw->cpts);
-		goto clean_ale_ret;
+		goto clean_dma_ret;
 	}
 
 	ndev->irq = platform_get_irq(pdev, 1);
 	if (ndev->irq < 0) {
 		dev_err(priv->dev, "error getting irq resource\n");
 		ret = ndev->irq;
-		goto clean_ale_ret;
+		goto clean_dma_ret;
 	}
 
 	of_id = of_match_device(cpsw_of_mtable, &pdev->dev);
@@ -3118,7 +3118,7 @@ static int cpsw_probe(struct platform_device *pdev)
 	if (ret) {
 		dev_err(priv->dev, "error registering net device\n");
 		ret = -ENODEV;
-		goto clean_ale_ret;
+		goto clean_dma_ret;
 	}
 
 	if (cpsw->data.dual_emac) {
@@ -3141,7 +3141,7 @@ static int cpsw_probe(struct platform_device *pdev)
 	irq = platform_get_irq(pdev, 1);
 	if (irq < 0) {
 		ret = irq;
-		goto clean_ale_ret;
+		goto clean_dma_ret;
 	}
 
 	cpsw->irqs_table[0] = irq;
@@ -3149,14 +3149,14 @@ static int cpsw_probe(struct platform_device *pdev)
 			       0, dev_name(&pdev->dev), cpsw);
 	if (ret < 0) {
 		dev_err(priv->dev, "error attaching irq (%d)\n", ret);
-		goto clean_ale_ret;
+		goto clean_dma_ret;
 	}
 
 	/* TX IRQ */
 	irq = platform_get_irq(pdev, 2);
 	if (irq < 0) {
 		ret = irq;
-		goto clean_ale_ret;
+		goto clean_dma_ret;
 	}
 
 	cpsw->irqs_table[1] = irq;
@@ -3164,7 +3164,7 @@ static int cpsw_probe(struct platform_device *pdev)
 			       0, dev_name(&pdev->dev), cpsw);
 	if (ret < 0) {
 		dev_err(priv->dev, "error attaching irq (%d)\n", ret);
-		goto clean_ale_ret;
+		goto clean_dma_ret;
 	}
 
 	cpsw_notice(priv, probe,
@@ -3177,8 +3177,6 @@ static int cpsw_probe(struct platform_device *pdev)
 
 clean_unregister_netdev_ret:
 	unregister_netdev(ndev);
-clean_ale_ret:
-	cpsw_ale_destroy(cpsw->ale);
 clean_dma_ret:
 	cpdma_ctlr_destroy(cpsw->dma);
 clean_dt_ret:
@@ -3208,7 +3206,6 @@ static int cpsw_remove(struct platform_device *pdev)
 	unregister_netdev(ndev);
 
 	cpts_release(cpsw->cpts);
-	cpsw_ale_destroy(cpsw->ale);
 	cpdma_ctlr_destroy(cpsw->dma);
 	cpsw_remove_dt(pdev);
 	pm_runtime_put_sync(&pdev->dev);
diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index 53aa721..e513248 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -802,7 +802,7 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
 	struct cpsw_ale *ale;
 	u32 rev, ale_entries;
 
-	ale = kzalloc(sizeof(*ale), GFP_KERNEL);
+	ale = devm_kzalloc(params->dev, sizeof(*ale), GFP_KERNEL);
 	if (!ale)
 		return NULL;
 
@@ -881,15 +881,6 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
 }
 EXPORT_SYMBOL_GPL(cpsw_ale_create);
 
-int cpsw_ale_destroy(struct cpsw_ale *ale)
-{
-	if (!ale)
-		return -EINVAL;
-	kfree(ale);
-	return 0;
-}
-EXPORT_SYMBOL_GPL(cpsw_ale_destroy);
-
 void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data)
 {
 	int i;
diff --git a/drivers/net/ethernet/ti/cpsw_ale.h b/drivers/net/ethernet/ti/cpsw_ale.h
index 25d24e8..d4fe901 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.h
+++ b/drivers/net/ethernet/ti/cpsw_ale.h
@@ -100,7 +100,6 @@ enum cpsw_ale_port_state {
 #define ALE_ENTRY_WORDS	DIV_ROUND_UP(ALE_ENTRY_BITS, 32)
 
 struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params);
-int cpsw_ale_destroy(struct cpsw_ale *ale);
 
 void cpsw_ale_start(struct cpsw_ale *ale);
 void cpsw_ale_stop(struct cpsw_ale *ale);
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 12765e4..56dbc0b 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -3689,7 +3689,6 @@ static int gbe_remove(struct netcp_device *netcp_device, void *inst_priv)
 	del_timer_sync(&gbe_dev->timer);
 	cpts_release(gbe_dev->cpts);
 	cpsw_ale_stop(gbe_dev->ale);
-	cpsw_ale_destroy(gbe_dev->ale);
 	netcp_txpipe_close(&gbe_dev->tx_pipe);
 	free_secondary_ports(gbe_dev);
 
-- 
2.10.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next 11/11] net: ethernet: ti: ale: fix port check in cpsw_ale_control_set/get
  2017-12-01  0:21 [PATCH net-next 00/11] net: ethernet: ti: cpsw/ale clean up and optimization Grygorii Strashko
                   ` (9 preceding siblings ...)
  2017-12-01  0:21 ` [PATCH net-next 10/11] net: ethernet: ti: ale: use devm_kzalloc " Grygorii Strashko
@ 2017-12-01  0:21 ` Grygorii Strashko
  2017-12-01 21:36 ` [PATCH net-next 00/11] net: ethernet: ti: cpsw/ale clean up and optimization David Miller
  11 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2017-12-01  0:21 UTC (permalink / raw)
  To: David S. Miller, netdev
  Cc: Sekhar Nori, linux-kernel, linux-omap, Ivan Khoronzhuk,
	Murali Karicheri, Grygorii Strashko

ALE ports number includes the Host port and ext Ports, and
ALE ports numbering starts from 0, so correct corresponding port
checks in cpsw_ale_control_set/get().

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

diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index e513248..93dc05c 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -723,7 +723,7 @@ int cpsw_ale_control_set(struct cpsw_ale *ale, int port, int control,
 	if (info->port_offset == 0 && info->port_shift == 0)
 		port = 0; /* global, port is a dont care */
 
-	if (port < 0 || port > ale->params.ale_ports)
+	if (port < 0 || port >= ale->params.ale_ports)
 		return -EINVAL;
 
 	mask = BITMASK(info->bits);
@@ -754,7 +754,7 @@ int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control)
 	if (info->port_offset == 0 && info->port_shift == 0)
 		port = 0; /* global, port is a dont care */
 
-	if (port < 0 || port > ale->params.ale_ports)
+	if (port < 0 || port >= ale->params.ale_ports)
 		return -EINVAL;
 
 	offset = info->offset + (port * info->port_offset);
-- 
2.10.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next 00/11] net: ethernet: ti: cpsw/ale clean up and optimization
  2017-12-01  0:21 [PATCH net-next 00/11] net: ethernet: ti: cpsw/ale clean up and optimization Grygorii Strashko
                   ` (10 preceding siblings ...)
  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 ` David Miller
  11 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2017-12-01 21:36 UTC (permalink / raw)
  To: grygorii.strashko
  Cc: netdev, nsekhar, linux-kernel, linux-omap, ivan.khoronzhuk, m-karicheri2

From: Grygorii Strashko <grygorii.strashko@ti.com>
Date: Thu, 30 Nov 2017 18:21:09 -0600

> This is set of non critical clean ups and optimizations for TI
> CPSW and ALE drivers.
> 
> Rebased on top on net-next.

Series applied, thank you.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-12-01 21:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH net-next 08/11] net: ethernet: ti: ale: optimize ale entry mask bits configuartion Grygorii Strashko
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

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).