Skip to content

Commit 0b0e30c

Browse files
committed
Merge branch 'cpsw-host_port'
Grygorii Strashko says: ==================== drivers: net: cpsw: fix ale calls and drop host_port field from cpsw_priv This clean up series intended to: - fix port_mask parameters in ale calls and drop unnecessary shifts - drop host_port field from struct cpsw_priv ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 61618ee + 71a2cbb commit 0b0e30c

File tree

1 file changed

+21
-31
lines changed

1 file changed

+21
-31
lines changed

drivers/net/ethernet/ti/cpsw.c

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,6 @@ struct cpsw_priv {
381381
u32 coal_intvl;
382382
u32 bus_freq_mhz;
383383
int rx_packet_max;
384-
int host_port;
385384
struct clk *clk;
386385
u8 mac_addr[ETH_ALEN];
387386
struct cpsw_slave *slaves;
@@ -531,21 +530,18 @@ static const struct cpsw_stats cpsw_gstrings_stats[] = {
531530
int slave_port = cpsw_get_slave_port(priv, \
532531
slave->slave_num); \
533532
cpsw_ale_add_mcast(priv->ale, addr, \
534-
1 << slave_port | 1 << priv->host_port, \
533+
1 << slave_port | ALE_PORT_HOST, \
535534
ALE_VLAN, slave->port_vlan, 0); \
536535
} else { \
537536
cpsw_ale_add_mcast(priv->ale, addr, \
538-
ALE_ALL_PORTS << priv->host_port, \
537+
ALE_ALL_PORTS, \
539538
0, 0, 0); \
540539
} \
541540
} while (0)
542541

543542
static inline int cpsw_get_slave_port(struct cpsw_priv *priv, u32 slave_num)
544543
{
545-
if (priv->host_port == 0)
546-
return slave_num + 1;
547-
else
548-
return slave_num;
544+
return slave_num + 1;
549545
}
550546

551547
static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
@@ -602,8 +598,7 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
602598
cpsw_ale_control_set(ale, 0, ALE_AGEOUT, 1);
603599

604600
/* Clear all mcast from ALE */
605-
cpsw_ale_flush_multicast(ale, ALE_ALL_PORTS <<
606-
priv->host_port, -1);
601+
cpsw_ale_flush_multicast(ale, ALE_ALL_PORTS, -1);
607602

608603
/* Flood All Unicast Packets to Host port */
609604
cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 1);
@@ -648,8 +643,7 @@ static void cpsw_ndo_set_rx_mode(struct net_device *ndev)
648643
cpsw_ale_set_allmulti(priv->ale, priv->ndev->flags & IFF_ALLMULTI);
649644

650645
/* Clear all mcast from ALE */
651-
cpsw_ale_flush_multicast(priv->ale, ALE_ALL_PORTS << priv->host_port,
652-
vid);
646+
cpsw_ale_flush_multicast(priv->ale, ALE_ALL_PORTS, vid);
653647

654648
if (!netdev_mc_empty(ndev)) {
655649
struct netdev_hw_addr *ha;
@@ -1092,7 +1086,7 @@ static inline void cpsw_add_dual_emac_def_ale_entries(
10921086
struct cpsw_priv *priv, struct cpsw_slave *slave,
10931087
u32 slave_port)
10941088
{
1095-
u32 port_mask = 1 << slave_port | 1 << priv->host_port;
1089+
u32 port_mask = 1 << slave_port | ALE_PORT_HOST;
10961090

10971091
if (priv->version == CPSW_VERSION_1)
10981092
slave_write(slave, slave->port_vlan, CPSW1_PORT_VLAN);
@@ -1103,7 +1097,7 @@ static inline void cpsw_add_dual_emac_def_ale_entries(
11031097
cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
11041098
port_mask, ALE_VLAN, slave->port_vlan, 0);
11051099
cpsw_ale_add_ucast(priv->ale, priv->mac_addr,
1106-
priv->host_port, ALE_VLAN | ALE_SECURE, slave->port_vlan);
1100+
HOST_PORT_NUM, ALE_VLAN | ALE_SECURE, slave->port_vlan);
11071101
}
11081102

11091103
static void soft_reset_slave(struct cpsw_slave *slave)
@@ -1172,7 +1166,6 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
11721166
static inline void cpsw_add_default_vlan(struct cpsw_priv *priv)
11731167
{
11741168
const int vlan = priv->data.default_vlan;
1175-
const int port = priv->host_port;
11761169
u32 reg;
11771170
int i;
11781171
int unreg_mcast_mask;
@@ -1190,9 +1183,9 @@ static inline void cpsw_add_default_vlan(struct cpsw_priv *priv)
11901183
else
11911184
unreg_mcast_mask = ALE_PORT_1 | ALE_PORT_2;
11921185

1193-
cpsw_ale_add_vlan(priv->ale, vlan, ALE_ALL_PORTS << port,
1194-
ALE_ALL_PORTS << port, ALE_ALL_PORTS << port,
1195-
unreg_mcast_mask << port);
1186+
cpsw_ale_add_vlan(priv->ale, vlan, ALE_ALL_PORTS,
1187+
ALE_ALL_PORTS, ALE_ALL_PORTS,
1188+
unreg_mcast_mask);
11961189
}
11971190

11981191
static void cpsw_init_host_port(struct cpsw_priv *priv)
@@ -1205,7 +1198,7 @@ static void cpsw_init_host_port(struct cpsw_priv *priv)
12051198
cpsw_ale_start(priv->ale);
12061199

12071200
/* switch to vlan unaware mode */
1208-
cpsw_ale_control_set(priv->ale, priv->host_port, ALE_VLAN_AWARE,
1201+
cpsw_ale_control_set(priv->ale, HOST_PORT_NUM, ALE_VLAN_AWARE,
12091202
CPSW_ALE_VLAN_AWARE);
12101203
control_reg = readl(&priv->regs->control);
12111204
control_reg |= CPSW_VLAN_AWARE;
@@ -1219,14 +1212,14 @@ static void cpsw_init_host_port(struct cpsw_priv *priv)
12191212
&priv->host_port_regs->cpdma_tx_pri_map);
12201213
__raw_writel(0, &priv->host_port_regs->cpdma_rx_chan_map);
12211214

1222-
cpsw_ale_control_set(priv->ale, priv->host_port,
1215+
cpsw_ale_control_set(priv->ale, HOST_PORT_NUM,
12231216
ALE_PORT_STATE, ALE_PORT_STATE_FORWARD);
12241217

12251218
if (!priv->data.dual_emac) {
1226-
cpsw_ale_add_ucast(priv->ale, priv->mac_addr, priv->host_port,
1219+
cpsw_ale_add_ucast(priv->ale, priv->mac_addr, HOST_PORT_NUM,
12271220
0, 0);
12281221
cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
1229-
1 << priv->host_port, 0, 0, ALE_MCAST_FWD_2);
1222+
ALE_PORT_HOST, 0, 0, ALE_MCAST_FWD_2);
12301223
}
12311224
}
12321225

@@ -1273,8 +1266,7 @@ static int cpsw_ndo_open(struct net_device *ndev)
12731266
cpsw_add_default_vlan(priv);
12741267
else
12751268
cpsw_ale_add_vlan(priv->ale, priv->data.default_vlan,
1276-
ALE_ALL_PORTS << priv->host_port,
1277-
ALE_ALL_PORTS << priv->host_port, 0, 0);
1269+
ALE_ALL_PORTS, ALE_ALL_PORTS, 0, 0);
12781270

12791271
if (!cpsw_common_res_usage_state(priv)) {
12801272
struct cpsw_priv *priv_sl0 = cpsw_get_slave_priv(priv, 0);
@@ -1620,9 +1612,9 @@ static int cpsw_ndo_set_mac_address(struct net_device *ndev, void *p)
16201612
flags = ALE_VLAN;
16211613
}
16221614

1623-
cpsw_ale_del_ucast(priv->ale, priv->mac_addr, priv->host_port,
1615+
cpsw_ale_del_ucast(priv->ale, priv->mac_addr, HOST_PORT_NUM,
16241616
flags, vid);
1625-
cpsw_ale_add_ucast(priv->ale, addr->sa_data, priv->host_port,
1617+
cpsw_ale_add_ucast(priv->ale, addr->sa_data, HOST_PORT_NUM,
16261618
flags, vid);
16271619

16281620
memcpy(priv->mac_addr, addr->sa_data, ETH_ALEN);
@@ -1666,12 +1658,12 @@ static inline int cpsw_add_vlan_ale_entry(struct cpsw_priv *priv,
16661658
}
16671659

16681660
ret = cpsw_ale_add_vlan(priv->ale, vid, port_mask, 0, port_mask,
1669-
unreg_mcast_mask << priv->host_port);
1661+
unreg_mcast_mask);
16701662
if (ret != 0)
16711663
return ret;
16721664

16731665
ret = cpsw_ale_add_ucast(priv->ale, priv->mac_addr,
1674-
priv->host_port, ALE_VLAN, vid);
1666+
HOST_PORT_NUM, ALE_VLAN, vid);
16751667
if (ret != 0)
16761668
goto clean_vid;
16771669

@@ -1683,7 +1675,7 @@ static inline int cpsw_add_vlan_ale_entry(struct cpsw_priv *priv,
16831675

16841676
clean_vlan_ucast:
16851677
cpsw_ale_del_ucast(priv->ale, priv->mac_addr,
1686-
priv->host_port, ALE_VLAN, vid);
1678+
HOST_PORT_NUM, ALE_VLAN, vid);
16871679
clean_vid:
16881680
cpsw_ale_del_vlan(priv->ale, vid, 0);
16891681
return ret;
@@ -1738,7 +1730,7 @@ static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev,
17381730
return ret;
17391731

17401732
ret = cpsw_ale_del_ucast(priv->ale, priv->mac_addr,
1741-
priv->host_port, ALE_VLAN, vid);
1733+
HOST_PORT_NUM, ALE_VLAN, vid);
17421734
if (ret != 0)
17431735
return ret;
17441736

@@ -2152,7 +2144,6 @@ static int cpsw_probe_dual_emac(struct platform_device *pdev,
21522144
priv_sl2->bus_freq_mhz = priv->bus_freq_mhz;
21532145

21542146
priv_sl2->regs = priv->regs;
2155-
priv_sl2->host_port = priv->host_port;
21562147
priv_sl2->host_port_regs = priv->host_port_regs;
21572148
priv_sl2->wr_regs = priv->wr_regs;
21582149
priv_sl2->hw_stats = priv->hw_stats;
@@ -2321,7 +2312,6 @@ static int cpsw_probe(struct platform_device *pdev)
23212312
goto clean_runtime_disable_ret;
23222313
}
23232314
priv->regs = ss_regs;
2324-
priv->host_port = HOST_PORT_NUM;
23252315

23262316
/* Need to enable clocks with runtime PM api to access module
23272317
* registers

0 commit comments

Comments
 (0)