mirror of
git://git.openwrt.org/openwrt/openwrt.git
synced 2026-06-11 05:47:27 -04:00
Compare commits
5 Commits
00ceb1ed17
...
75c772899c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75c772899c | ||
|
|
9a0bd2d1aa | ||
|
|
42a311bac9 | ||
|
|
b74e261d56 | ||
|
|
8e33c40c7f |
@@ -368,24 +368,24 @@
|
||||
managed = "in-band-status";
|
||||
sfp = <&sfp0>;
|
||||
};
|
||||
port@49 {
|
||||
reg = <49>;
|
||||
port@50 {
|
||||
reg = <50>;
|
||||
label = "lan50";
|
||||
pcs-handle = <&serdes9>;
|
||||
phy-mode = "1000base-x";
|
||||
managed = "in-band-status";
|
||||
sfp = <&sfp1>;
|
||||
};
|
||||
port@50 {
|
||||
reg = <50>;
|
||||
port@52 {
|
||||
reg = <52>;
|
||||
label = "lan51";
|
||||
pcs-handle = <&serdes10>;
|
||||
phy-mode = "1000base-x";
|
||||
managed = "in-band-status";
|
||||
sfp = <&sfp2>;
|
||||
};
|
||||
port@51 {
|
||||
reg = <51>;
|
||||
port@53 {
|
||||
reg = <53>;
|
||||
label = "lan52";
|
||||
pcs-handle = <&serdes11>;
|
||||
phy-mode = "1000base-x";
|
||||
@@ -404,3 +404,19 @@
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&serdes8 {
|
||||
realtek,pnswap-tx;
|
||||
};
|
||||
|
||||
&serdes9 {
|
||||
realtek,pnswap-tx;
|
||||
};
|
||||
|
||||
&serdes10 {
|
||||
realtek,pnswap-tx;
|
||||
};
|
||||
|
||||
&serdes11 {
|
||||
realtek,pnswap-tx;
|
||||
};
|
||||
|
||||
@@ -473,7 +473,7 @@ int rtl83xx_lag_del(struct dsa_switch *ds, int group, int port)
|
||||
// mutex_lock(&priv->reg_mutex);
|
||||
|
||||
// idx = find_first_zero_bit(priv->octet_cntr_use_bm, MAX_COUNTERS);
|
||||
// if (idx >= priv->n_counters) {
|
||||
// if (idx >= priv->r->n_counters) {
|
||||
// mutex_unlock(&priv->reg_mutex);
|
||||
// return -1;
|
||||
// }
|
||||
@@ -499,9 +499,9 @@ int rtl83xx_packet_cntr_alloc(struct rtl838x_switch_priv *priv)
|
||||
* a 0-bit means the counter is already allocated (for octets)
|
||||
*/
|
||||
idx = find_first_bit(priv->packet_cntr_use_bm, MAX_COUNTERS * 2);
|
||||
if (idx >= priv->n_counters * 2) {
|
||||
if (idx >= priv->r->n_counters * 2) {
|
||||
j = find_first_zero_bit(priv->octet_cntr_use_bm, MAX_COUNTERS);
|
||||
if (j >= priv->n_counters) {
|
||||
if (j >= priv->r->n_counters) {
|
||||
mutex_unlock(&priv->reg_mutex);
|
||||
return -1;
|
||||
}
|
||||
@@ -1411,60 +1411,46 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
|
||||
priv->cpu_port = RTL838X_CPU_PORT;
|
||||
priv->port_mask = 0x1f;
|
||||
priv->port_width = 1;
|
||||
priv->irq_mask = 0x0FFFFFFF;
|
||||
priv->ds->num_ports = RTL838X_CPU_PORT + 1;
|
||||
priv->fib_entries = 8192;
|
||||
priv->ds->num_lag_ids = 8;
|
||||
priv->l2_bucket_size = 4;
|
||||
priv->n_mst = 64;
|
||||
priv->n_pie_blocks = 12;
|
||||
priv->n_counters = 128;
|
||||
break;
|
||||
case RTL8390_FAMILY_ID:
|
||||
priv->ds->ops = &rtldsa_83xx_switch_ops;
|
||||
priv->cpu_port = RTL839X_CPU_PORT;
|
||||
priv->port_mask = 0x3f;
|
||||
priv->port_width = 2;
|
||||
priv->irq_mask = 0xFFFFFFFFFFFFFULL;
|
||||
priv->ds->num_ports = RTL839X_CPU_PORT + 1;
|
||||
priv->fib_entries = 16384;
|
||||
priv->ds->num_lag_ids = 16;
|
||||
priv->l2_bucket_size = 4;
|
||||
priv->n_mst = 256;
|
||||
priv->n_pie_blocks = 18;
|
||||
priv->n_counters = 1024;
|
||||
break;
|
||||
case RTL9300_FAMILY_ID:
|
||||
priv->ds->ops = &rtldsa_93xx_switch_ops;
|
||||
priv->cpu_port = RTL930X_CPU_PORT;
|
||||
priv->port_mask = 0x1f;
|
||||
priv->port_width = 1;
|
||||
priv->irq_mask = 0x0FFFFFFF;
|
||||
priv->ds->num_ports = RTL930X_CPU_PORT + 1;
|
||||
priv->fib_entries = 16384;
|
||||
priv->ds->num_lag_ids = 16;
|
||||
sw_w32(0, RTL930X_ST_CTRL);
|
||||
priv->l2_bucket_size = 8;
|
||||
priv->n_mst = 64;
|
||||
priv->n_pie_blocks = 16;
|
||||
priv->n_counters = 2048;
|
||||
break;
|
||||
case RTL9310_FAMILY_ID:
|
||||
priv->ds->ops = &rtldsa_93xx_switch_ops;
|
||||
priv->cpu_port = RTL931X_CPU_PORT;
|
||||
priv->port_mask = 0x3f;
|
||||
priv->port_width = 2;
|
||||
priv->irq_mask = GENMASK_ULL(priv->cpu_port - 1, 0);
|
||||
priv->ds->num_ports = RTL931X_CPU_PORT + 1;
|
||||
priv->fib_entries = 16384;
|
||||
priv->ds->num_lag_ids = 16;
|
||||
sw_w32(0, RTL931x_ST_CTRL);
|
||||
priv->l2_bucket_size = 8;
|
||||
priv->n_mst = 128;
|
||||
priv->n_pie_blocks = 16;
|
||||
priv->n_counters = 2048;
|
||||
break;
|
||||
}
|
||||
priv->ds->num_ports = priv->cpu_port + 1;
|
||||
priv->irq_mask = GENMASK_ULL(priv->cpu_port - 1, 0);
|
||||
|
||||
err = rtl83xx_mdio_probe(priv);
|
||||
if (err) {
|
||||
|
||||
@@ -1430,7 +1430,7 @@ static int rtl838x_pie_rule_add(struct rtl838x_switch_priv *priv, struct pie_rul
|
||||
|
||||
mutex_lock(&priv->pie_mutex);
|
||||
|
||||
for (block = 0; block < priv->n_pie_blocks; block++) {
|
||||
for (block = 0; block < priv->r->n_pie_blocks; block++) {
|
||||
for (j = 0; j < 3; j++) {
|
||||
int t = (sw_r32(RTL838X_ACL_BLK_TMPLTE_CTRL(block)) >> (j * 3)) & 0x7;
|
||||
|
||||
@@ -1443,7 +1443,7 @@ static int rtl838x_pie_rule_add(struct rtl838x_switch_priv *priv, struct pie_rul
|
||||
break;
|
||||
}
|
||||
|
||||
if (block >= priv->n_pie_blocks) {
|
||||
if (block >= priv->r->n_pie_blocks) {
|
||||
mutex_unlock(&priv->pie_mutex);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
@@ -1487,14 +1487,14 @@ static void rtl838x_pie_init(struct rtl838x_switch_priv *priv)
|
||||
sw_w32(1, RTL838X_ACL_PORT_LOOKUP_CTRL(i));
|
||||
|
||||
/* Power on all PIE blocks */
|
||||
for (int i = 0; i < priv->n_pie_blocks; i++)
|
||||
for (int i = 0; i < priv->r->n_pie_blocks; i++)
|
||||
sw_w32_mask(0, BIT(i), RTL838X_ACL_BLK_PWR_CTRL);
|
||||
|
||||
/* Include IPG in metering */
|
||||
sw_w32(1, RTL838X_METER_GLB_CTRL);
|
||||
|
||||
/* Delete all present rules */
|
||||
rtl838x_pie_rule_del(priv, 0, priv->n_pie_blocks * PIE_BLOCK_SIZE - 1);
|
||||
rtl838x_pie_rule_del(priv, 0, priv->r->n_pie_blocks * PIE_BLOCK_SIZE - 1);
|
||||
|
||||
/* Routing bypasses source port filter */
|
||||
sw_w32_mask(0, 1, RTL838X_DMY_REG27);
|
||||
@@ -1506,7 +1506,7 @@ static void rtl838x_pie_init(struct rtl838x_switch_priv *priv)
|
||||
|
||||
/* Enable predefined templates 0, 3 and 4 (IPv6 support) for odd blocks */
|
||||
template_selectors = 0 | (3 << 3) | (4 << 6);
|
||||
for (int i = 1; i < priv->n_pie_blocks; i += 2)
|
||||
for (int i = 1; i < priv->r->n_pie_blocks; i += 2)
|
||||
sw_w32(template_selectors, RTL838X_ACL_BLK_TMPLTE_CTRL(i));
|
||||
|
||||
/* Group each pair of physical blocks together to a logical block */
|
||||
@@ -1700,6 +1700,8 @@ const struct rtldsa_config rtldsa_838x_cfg = {
|
||||
.isr_port_link_sts_chg = RTL838X_ISR_PORT_LINK_STS_CHG,
|
||||
.imr_port_link_sts_chg = RTL838X_IMR_PORT_LINK_STS_CHG,
|
||||
.imr_glb = RTL838X_IMR_GLB,
|
||||
.n_counters = 128,
|
||||
.n_pie_blocks = 12,
|
||||
.port_ignore = 0x1f,
|
||||
.vlan_tables_read = rtl838x_vlan_tables_read,
|
||||
.vlan_set_tagged = rtl838x_vlan_set_tagged,
|
||||
|
||||
@@ -1273,6 +1273,8 @@ struct rtldsa_config {
|
||||
int isr_port_link_sts_chg;
|
||||
int imr_port_link_sts_chg;
|
||||
int imr_glb;
|
||||
int n_counters;
|
||||
int n_pie_blocks;
|
||||
u8 port_ignore;
|
||||
void (*vlan_tables_read)(u32 vlan, struct rtl838x_vlan_info *info);
|
||||
void (*vlan_set_tagged)(u32 vlan, struct rtl838x_vlan_info *info);
|
||||
@@ -1388,10 +1390,8 @@ struct rtl838x_switch_priv {
|
||||
struct notifier_block fib_nb;
|
||||
bool eee_enabled;
|
||||
unsigned long mc_group_bm[MAX_MC_GROUPS >> 5];
|
||||
int n_pie_blocks;
|
||||
struct rhashtable tc_ht;
|
||||
unsigned long pie_use_bm[MAX_PIE_ENTRIES >> 5];
|
||||
int n_counters;
|
||||
unsigned long octet_cntr_use_bm[MAX_COUNTERS >> 5];
|
||||
unsigned long packet_cntr_use_bm[MAX_COUNTERS >> 4];
|
||||
struct rhltable routes;
|
||||
|
||||
@@ -1333,11 +1333,11 @@ static int rtl839x_pie_rule_add(struct rtl838x_switch_priv *priv, struct pie_rul
|
||||
{
|
||||
int idx, block, j, t;
|
||||
int min_block = 0;
|
||||
int max_block = priv->n_pie_blocks / 2;
|
||||
int max_block = priv->r->n_pie_blocks / 2;
|
||||
|
||||
if (pr->is_egress) {
|
||||
min_block = max_block;
|
||||
max_block = priv->n_pie_blocks;
|
||||
max_block = priv->r->n_pie_blocks;
|
||||
}
|
||||
|
||||
mutex_lock(&priv->pie_mutex);
|
||||
@@ -1353,7 +1353,7 @@ static int rtl839x_pie_rule_add(struct rtl838x_switch_priv *priv, struct pie_rul
|
||||
break;
|
||||
}
|
||||
|
||||
if (block >= priv->n_pie_blocks) {
|
||||
if (block >= priv->r->n_pie_blocks) {
|
||||
mutex_unlock(&priv->pie_mutex);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
@@ -1388,7 +1388,7 @@ static void rtl839x_pie_init(struct rtl838x_switch_priv *priv)
|
||||
mutex_init(&priv->pie_mutex);
|
||||
|
||||
/* Power on all PIE blocks */
|
||||
for (int i = 0; i < priv->n_pie_blocks; i++)
|
||||
for (int i = 0; i < priv->r->n_pie_blocks; i++)
|
||||
sw_w32_mask(0, BIT(i), RTL839X_PS_ACL_PWR_CTRL);
|
||||
|
||||
/* Set ingress and egress ACL blocks to 50/50: first Egress block is 9 */
|
||||
@@ -1398,7 +1398,7 @@ static void rtl839x_pie_init(struct rtl838x_switch_priv *priv)
|
||||
sw_w32(1, RTL839X_METER_GLB_CTRL);
|
||||
|
||||
/* Delete all present rules */
|
||||
rtl839x_pie_rule_del(priv, 0, priv->n_pie_blocks * PIE_BLOCK_SIZE - 1);
|
||||
rtl839x_pie_rule_del(priv, 0, priv->r->n_pie_blocks * PIE_BLOCK_SIZE - 1);
|
||||
|
||||
/* Enable predefined templates 0, 1 for blocks 0-2 */
|
||||
template_selectors = 0 | (1 << 3);
|
||||
@@ -1640,6 +1640,8 @@ const struct rtldsa_config rtldsa_839x_cfg = {
|
||||
.isr_port_link_sts_chg = RTL839X_ISR_PORT_LINK_STS_CHG,
|
||||
.imr_port_link_sts_chg = RTL839X_IMR_PORT_LINK_STS_CHG,
|
||||
.imr_glb = RTL839X_IMR_GLB,
|
||||
.n_counters = 1024,
|
||||
.n_pie_blocks = 18,
|
||||
.port_ignore = 0x3f,
|
||||
.vlan_tables_read = rtl839x_vlan_tables_read,
|
||||
.vlan_set_tagged = rtl839x_vlan_set_tagged,
|
||||
|
||||
@@ -1951,11 +1951,11 @@ static int rtl930x_pie_rule_add(struct rtl838x_switch_priv *priv, struct pie_rul
|
||||
{
|
||||
int idx, block, j, t;
|
||||
int min_block = 0;
|
||||
int max_block = priv->n_pie_blocks / 2;
|
||||
int max_block = priv->r->n_pie_blocks / 2;
|
||||
|
||||
if (pr->is_egress) {
|
||||
min_block = max_block;
|
||||
max_block = priv->n_pie_blocks;
|
||||
max_block = priv->r->n_pie_blocks;
|
||||
}
|
||||
pr_debug("In %s\n", __func__);
|
||||
|
||||
@@ -1975,7 +1975,7 @@ static int rtl930x_pie_rule_add(struct rtl838x_switch_priv *priv, struct pie_rul
|
||||
break;
|
||||
}
|
||||
|
||||
if (block >= priv->n_pie_blocks) {
|
||||
if (block >= priv->r->n_pie_blocks) {
|
||||
mutex_unlock(&priv->pie_mutex);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
@@ -2037,29 +2037,29 @@ static void rtl930x_pie_init(struct rtl838x_switch_priv *priv)
|
||||
sw_w32_mask(0, 1, RTL930X_METER_GLB_CTRL);
|
||||
|
||||
/* Delete all present rules, block size is 128 on all SoC families */
|
||||
rtl930x_pie_rule_del(priv, 0, priv->n_pie_blocks * 128 - 1);
|
||||
rtl930x_pie_rule_del(priv, 0, priv->r->n_pie_blocks * 128 - 1);
|
||||
|
||||
/* Assign blocks 0-7 to VACL phase (bit = 0), blocks 8-15 to IACL (bit = 1) */
|
||||
sw_w32(0xff00, RTL930X_PIE_BLK_PHASE_CTRL);
|
||||
|
||||
/* Enable predefined templates 0, 1 for first quarter of all blocks */
|
||||
template_selectors = 0 | (1 << 4);
|
||||
for (int i = 0; i < priv->n_pie_blocks / 4; i++)
|
||||
for (int i = 0; i < priv->r->n_pie_blocks / 4; i++)
|
||||
sw_w32(template_selectors, RTL930X_PIE_BLK_TMPLTE_CTRL(i));
|
||||
|
||||
/* Enable predefined templates 2, 3 for second quarter of all blocks */
|
||||
template_selectors = 2 | (3 << 4);
|
||||
for (int i = priv->n_pie_blocks / 4; i < priv->n_pie_blocks / 2; i++)
|
||||
for (int i = priv->r->n_pie_blocks / 4; i < priv->r->n_pie_blocks / 2; i++)
|
||||
sw_w32(template_selectors, RTL930X_PIE_BLK_TMPLTE_CTRL(i));
|
||||
|
||||
/* Enable predefined templates 0, 1 for third half of all blocks */
|
||||
template_selectors = 0 | (1 << 4);
|
||||
for (int i = priv->n_pie_blocks / 2; i < priv->n_pie_blocks * 3 / 4; i++)
|
||||
for (int i = priv->r->n_pie_blocks / 2; i < priv->r->n_pie_blocks * 3 / 4; i++)
|
||||
sw_w32(template_selectors, RTL930X_PIE_BLK_TMPLTE_CTRL(i));
|
||||
|
||||
/* Enable predefined templates 2, 3 for fourth quater of all blocks */
|
||||
template_selectors = 2 | (3 << 4);
|
||||
for (int i = priv->n_pie_blocks * 3 / 4; i < priv->n_pie_blocks; i++)
|
||||
for (int i = priv->r->n_pie_blocks * 3 / 4; i < priv->r->n_pie_blocks; i++)
|
||||
sw_w32(template_selectors, RTL930X_PIE_BLK_TMPLTE_CTRL(i));
|
||||
}
|
||||
|
||||
@@ -2645,6 +2645,8 @@ const struct rtldsa_config rtldsa_930x_cfg = {
|
||||
.isr_port_link_sts_chg = RTL930X_ISR_PORT_LINK_STS_CHG,
|
||||
.imr_port_link_sts_chg = RTL930X_IMR_PORT_LINK_STS_CHG,
|
||||
.imr_glb = RTL930X_IMR_GLB,
|
||||
.n_counters = 2048,
|
||||
.n_pie_blocks = 16,
|
||||
.port_ignore = 0x3f,
|
||||
.vlan_tables_read = rtl930x_vlan_tables_read,
|
||||
.vlan_set_tagged = rtl930x_vlan_set_tagged,
|
||||
|
||||
@@ -1326,11 +1326,11 @@ static int rtl931x_pie_rule_add(struct rtl838x_switch_priv *priv, struct pie_rul
|
||||
{
|
||||
int idx, block, j;
|
||||
int min_block = 0;
|
||||
int max_block = priv->n_pie_blocks / 2;
|
||||
int max_block = priv->r->n_pie_blocks / 2;
|
||||
|
||||
if (pr->is_egress) {
|
||||
min_block = max_block;
|
||||
max_block = priv->n_pie_blocks;
|
||||
max_block = priv->r->n_pie_blocks;
|
||||
}
|
||||
pr_debug("In %s\n", __func__);
|
||||
|
||||
@@ -1351,7 +1351,7 @@ static int rtl931x_pie_rule_add(struct rtl838x_switch_priv *priv, struct pie_rul
|
||||
break;
|
||||
}
|
||||
|
||||
if (block >= priv->n_pie_blocks) {
|
||||
if (block >= priv->r->n_pie_blocks) {
|
||||
mutex_unlock(&priv->pie_mutex);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
@@ -1415,18 +1415,18 @@ static void rtl931x_pie_init(struct rtl838x_switch_priv *priv)
|
||||
sw_w32_mask(0, 1, RTL931X_METER_GLB_CTRL);
|
||||
|
||||
/* Delete all present rules, block size is 128 on all SoC families */
|
||||
rtl931x_pie_rule_del(priv, 0, priv->n_pie_blocks * 128 - 1);
|
||||
rtl931x_pie_rule_del(priv, 0, priv->r->n_pie_blocks * 128 - 1);
|
||||
|
||||
/* Assign first half blocks 0-7 to VACL phase, second half to IACL */
|
||||
/* 3 bits are used for each block, values for PIE blocks are */
|
||||
/* 6: Disabled, 0: VACL, 1: IACL, 2: EACL */
|
||||
/* And for OpenFlow Flow blocks: 3: Ingress Flow table 0, */
|
||||
/* 4: Ingress Flow Table 3, 5: Egress flow table 0 */
|
||||
for (int i = 0; i < priv->n_pie_blocks; i++) {
|
||||
for (int i = 0; i < priv->r->n_pie_blocks; i++) {
|
||||
int pos = (i % 10) * 3;
|
||||
u32 r = RTL931X_PIE_BLK_PHASE_CTRL + 4 * (i / 10);
|
||||
|
||||
if (i < priv->n_pie_blocks / 2)
|
||||
if (i < priv->r->n_pie_blocks / 2)
|
||||
sw_w32_mask(0x7 << pos, 0, r);
|
||||
else
|
||||
sw_w32_mask(0x7 << pos, 1 << pos, r);
|
||||
@@ -1434,22 +1434,22 @@ static void rtl931x_pie_init(struct rtl838x_switch_priv *priv)
|
||||
|
||||
/* Enable predefined templates 0, 1 for first quarter of all blocks */
|
||||
template_selectors = 0 | (1 << 4);
|
||||
for (int i = 0; i < priv->n_pie_blocks / 4; i++)
|
||||
for (int i = 0; i < priv->r->n_pie_blocks / 4; i++)
|
||||
sw_w32(template_selectors, RTL931X_PIE_BLK_TMPLTE_CTRL(i));
|
||||
|
||||
/* Enable predefined templates 2, 3 for second quarter of all blocks */
|
||||
template_selectors = 2 | (3 << 4);
|
||||
for (int i = priv->n_pie_blocks / 4; i < priv->n_pie_blocks / 2; i++)
|
||||
for (int i = priv->r->n_pie_blocks / 4; i < priv->r->n_pie_blocks / 2; i++)
|
||||
sw_w32(template_selectors, RTL931X_PIE_BLK_TMPLTE_CTRL(i));
|
||||
|
||||
/* Enable predefined templates 0, 1 for third quater of all blocks */
|
||||
template_selectors = 0 | (1 << 4);
|
||||
for (int i = priv->n_pie_blocks / 2; i < priv->n_pie_blocks * 3 / 4; i++)
|
||||
for (int i = priv->r->n_pie_blocks / 2; i < priv->r->n_pie_blocks * 3 / 4; i++)
|
||||
sw_w32(template_selectors, RTL931X_PIE_BLK_TMPLTE_CTRL(i));
|
||||
|
||||
/* Enable predefined templates 2, 3 for fourth quater of all blocks */
|
||||
template_selectors = 2 | (3 << 4);
|
||||
for (int i = priv->n_pie_blocks * 3 / 4; i < priv->n_pie_blocks; i++)
|
||||
for (int i = priv->r->n_pie_blocks * 3 / 4; i < priv->r->n_pie_blocks; i++)
|
||||
sw_w32(template_selectors, RTL931X_PIE_BLK_TMPLTE_CTRL(i));
|
||||
}
|
||||
|
||||
@@ -1801,6 +1801,8 @@ const struct rtldsa_config rtldsa_931x_cfg = {
|
||||
.isr_port_link_sts_chg = RTL931X_ISR_PORT_LINK_STS_CHG,
|
||||
.imr_port_link_sts_chg = RTL931X_IMR_PORT_LINK_STS_CHG,
|
||||
/* imr_glb does not exist on RTL931X */
|
||||
.n_counters = 2048,
|
||||
.n_pie_blocks = 16,
|
||||
.port_ignore = 0x3f,
|
||||
.vlan_tables_read = rtl931x_vlan_tables_read,
|
||||
.vlan_set_tagged = rtl931x_vlan_set_tagged,
|
||||
|
||||
@@ -196,6 +196,24 @@ struct rteth_ctrl {
|
||||
struct rteth_tx *tx_data;
|
||||
};
|
||||
|
||||
static inline void rteth_confirm_and_disable_irqs(struct rteth_ctrl *ctrl,
|
||||
unsigned long *rings, bool *l2)
|
||||
{
|
||||
u32 mask = GENMASK(ctrl->r->rx_rings - 1, 0);
|
||||
u32 shift = ctrl->r->rx_rings % 32;
|
||||
u32 reg = ctrl->r->rx_rings / 32;
|
||||
u32 active;
|
||||
|
||||
/* get all irqs, disable only rx (on RTL839x this keeps L2), confirm all */
|
||||
active = sw_r32(ctrl->r->dma_if_intr_sts + reg * 4);
|
||||
sw_w32_mask(active & (mask << shift), 0, ctrl->r->dma_if_intr_msk + reg * 4);
|
||||
sw_w32(active, ctrl->r->dma_if_intr_sts + reg * 4);
|
||||
|
||||
/* ~mask filters out RTL93xx devices */
|
||||
*l2 = !!(active & ~mask & RTL839X_DMA_IF_INTR_NOTIFY_MASK);
|
||||
*rings = (active >> shift) & mask;
|
||||
}
|
||||
|
||||
static void rteth_disable_all_irqs(struct rteth_ctrl *ctrl)
|
||||
{
|
||||
int registers = ((ctrl->r->rx_rings * 2 + 7) / 32) + 1;
|
||||
@@ -386,74 +404,22 @@ static void rtl839x_l2_notification_handler(struct rteth_ctrl *ctrl)
|
||||
ctrl->lastEvent = e;
|
||||
}
|
||||
|
||||
static irqreturn_t rteth_83xx_net_irq(int irq, void *dev_id)
|
||||
static irqreturn_t rteth_net_irq(int irq, void *dev_id)
|
||||
{
|
||||
struct net_device *ndev = dev_id;
|
||||
struct rteth_ctrl *ctrl = netdev_priv(ndev);
|
||||
u32 status = sw_r32(ctrl->r->dma_if_intr_sts);
|
||||
unsigned long ring, rings;
|
||||
bool l2;
|
||||
|
||||
netdev_dbg(ndev, "rx interrupt received, status %08x\n", status);
|
||||
|
||||
if (status & RTL83XX_DMA_IF_INTR_RX_RUN_OUT_MASK)
|
||||
if (net_ratelimit())
|
||||
netdev_warn(ndev, "rx ring overrun, status 0x%08x, mask 0x%08x\n",
|
||||
status, sw_r32(ctrl->r->dma_if_intr_msk));
|
||||
|
||||
rings = FIELD_GET(RTL83XX_DMA_IF_INTR_RX_DONE_MASK, status);
|
||||
rteth_confirm_and_disable_irqs(ctrl, &rings, &l2);
|
||||
for_each_set_bit(ring, &rings, RTETH_RX_RINGS) {
|
||||
netdev_dbg(ndev, "schedule rx ring %lu\n", ring);
|
||||
sw_w32_mask(RTL83XX_DMA_IF_INTR_RX_MASK(ring), 0, ctrl->r->dma_if_intr_msk);
|
||||
napi_schedule(&ctrl->rx_qs[ring].napi);
|
||||
}
|
||||
|
||||
if (status & RTL839X_DMA_IF_INTR_NOTIFY_MASK)
|
||||
if (unlikely(l2))
|
||||
rtl839x_l2_notification_handler(ctrl);
|
||||
|
||||
sw_w32(status, ctrl->r->dma_if_intr_sts);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static irqreturn_t rteth_93xx_net_irq(int irq, void *dev_id)
|
||||
{
|
||||
struct net_device *dev = dev_id;
|
||||
struct rteth_ctrl *ctrl = netdev_priv(dev);
|
||||
u32 status_rx_r = sw_r32(ctrl->r->dma_if_intr_sts);
|
||||
u32 status_rx = sw_r32(ctrl->r->dma_if_intr_rx_done_sts);
|
||||
u32 status_tx = sw_r32(ctrl->r->dma_if_intr_tx_done_sts);
|
||||
|
||||
pr_debug("In %s, status_tx: %08x, status_rx: %08x, status_rx_r: %08x\n",
|
||||
__func__, status_tx, status_rx, status_rx_r);
|
||||
|
||||
/* Ignore TX interrupt */
|
||||
if (status_tx) {
|
||||
/* Clear ISR */
|
||||
pr_debug("TX done\n");
|
||||
sw_w32(status_tx, ctrl->r->dma_if_intr_tx_done_sts);
|
||||
}
|
||||
|
||||
/* RX interrupt */
|
||||
if (status_rx) {
|
||||
pr_debug("RX IRQ\n");
|
||||
/* ACK and disable RX interrupt for given rings */
|
||||
sw_w32(status_rx, ctrl->r->dma_if_intr_rx_done_sts);
|
||||
sw_w32_mask(status_rx, 0, ctrl->r->dma_if_intr_rx_done_msk);
|
||||
for (int i = 0; i < RTETH_RX_RINGS; i++) {
|
||||
if (status_rx & BIT(i)) {
|
||||
pr_debug("Scheduling queue: %d\n", i);
|
||||
napi_schedule(&ctrl->rx_qs[i].napi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* RX buffer overrun */
|
||||
if (status_rx_r) {
|
||||
pr_debug("RX buffer overrun: status %x, mask: %x\n",
|
||||
status_rx_r, sw_r32(ctrl->r->dma_if_intr_msk));
|
||||
sw_w32(status_rx_r, ctrl->r->dma_if_intr_sts);
|
||||
}
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
@@ -1419,7 +1385,6 @@ static const struct rteth_config rteth_838x_cfg = {
|
||||
.rx_rings = 8,
|
||||
.tx_rx_enable = 0xc,
|
||||
.tx_trigger_mask = BIT(1),
|
||||
.net_irq = rteth_83xx_net_irq,
|
||||
.mac_l2_port_ctrl = RTETH_838X_MAC_L2_PORT_CTRL,
|
||||
.qm_pkt2cpu_intpri_map = RTETH_838X_QM_PKT2CPU_INTPRI_MAP,
|
||||
.qm_rsn2cpuqid_ctrl = RTETH_838X_QM_PKT2CPU_INTPRI_0,
|
||||
@@ -1467,7 +1432,6 @@ static const struct rteth_config rteth_839x_cfg = {
|
||||
.rx_rings = 8,
|
||||
.tx_rx_enable = 0xc,
|
||||
.tx_trigger_mask = BIT(1),
|
||||
.net_irq = rteth_83xx_net_irq,
|
||||
.mac_l2_port_ctrl = RTETH_839X_MAC_L2_PORT_CTRL,
|
||||
.qm_pkt2cpu_intpri_map = RTETH_839X_QM_PKT2CPU_INTPRI_MAP,
|
||||
.qm_rsn2cpuqid_ctrl = RTETH_839X_QM_PKT2CPU_INTPRI_0,
|
||||
@@ -1515,16 +1479,13 @@ static const struct rteth_config rteth_930x_cfg = {
|
||||
.rx_rings = 32,
|
||||
.tx_rx_enable = 0x30,
|
||||
.tx_trigger_mask = GENMASK(3, 2),
|
||||
.net_irq = rteth_93xx_net_irq,
|
||||
.mac_l2_port_ctrl = RTETH_930X_MAC_L2_PORT_CTRL,
|
||||
.qm_rsn2cpuqid_ctrl = RTETH_930X_QM_RSN2CPUQID_CTRL_0,
|
||||
.qm_rsn2cpuqid_cnt = RTETH_930X_QM_RSN2CPUQID_CTRL_CNT,
|
||||
.dma_if_intr_sts = RTETH_930X_DMA_IF_INTR_STS,
|
||||
.dma_if_intr_rx_done_sts = RTL930X_DMA_IF_INTR_RX_DONE_STS,
|
||||
.dma_if_intr_tx_done_sts = RTL930X_DMA_IF_INTR_TX_DONE_STS,
|
||||
.dma_if_intr_msk = RTETH_930X_DMA_IF_INTR_MSK,
|
||||
.dma_if_intr_rx_done_msk = RTL930X_DMA_IF_INTR_RX_DONE_MSK,
|
||||
.dma_if_intr_tx_done_msk = RTL930X_DMA_IF_INTR_TX_DONE_MSK,
|
||||
.l2_ntfy_if_intr_sts = RTL930X_L2_NTFY_IF_INTR_STS,
|
||||
.l2_ntfy_if_intr_msk = RTL930X_L2_NTFY_IF_INTR_MSK,
|
||||
.dma_if_ctrl = RTL930X_DMA_IF_CTRL,
|
||||
@@ -1567,16 +1528,13 @@ static const struct rteth_config rteth_931x_cfg = {
|
||||
.rx_rings = 32,
|
||||
.tx_rx_enable = 0x30,
|
||||
.tx_trigger_mask = GENMASK(3, 2),
|
||||
.net_irq = rteth_93xx_net_irq,
|
||||
.mac_l2_port_ctrl = RTETH_931X_MAC_L2_PORT_CTRL,
|
||||
.qm_rsn2cpuqid_ctrl = RTETH_931X_QM_RSN2CPUQID_CTRL_0,
|
||||
.qm_rsn2cpuqid_cnt = RTETH_931X_QM_RSN2CPUQID_CTRL_CNT,
|
||||
.dma_if_intr_sts = RTETH_931X_DMA_IF_INTR_STS,
|
||||
.dma_if_intr_rx_done_sts = RTL931X_DMA_IF_INTR_RX_DONE_STS,
|
||||
.dma_if_intr_tx_done_sts = RTL931X_DMA_IF_INTR_TX_DONE_STS,
|
||||
.dma_if_intr_msk = RTETH_931X_DMA_IF_INTR_MSK,
|
||||
.dma_if_intr_rx_done_msk = RTL931X_DMA_IF_INTR_RX_DONE_MSK,
|
||||
.dma_if_intr_tx_done_msk = RTL931X_DMA_IF_INTR_TX_DONE_MSK,
|
||||
.l2_ntfy_if_intr_sts = RTL931X_L2_NTFY_IF_INTR_STS,
|
||||
.l2_ntfy_if_intr_msk = RTL931X_L2_NTFY_IF_INTR_MSK,
|
||||
.dma_if_ctrl = RTL931X_DMA_IF_CTRL,
|
||||
@@ -1680,8 +1638,7 @@ static int rtl838x_eth_probe(struct platform_device *pdev)
|
||||
return -ENODEV;
|
||||
|
||||
rteth_disable_all_irqs(ctrl);
|
||||
err = devm_request_irq(&pdev->dev, dev->irq, ctrl->r->net_irq,
|
||||
IRQF_SHARED, dev->name, dev);
|
||||
err = devm_request_irq(&pdev->dev, dev->irq, rteth_net_irq, IRQF_SHARED, dev->name, dev);
|
||||
if (err) {
|
||||
dev_err(&pdev->dev, "%s: could not acquire interrupt: %d\n",
|
||||
__func__, err);
|
||||
|
||||
@@ -64,26 +64,22 @@
|
||||
#define RTL839X_DMA_IF_CTRL (0x786c)
|
||||
|
||||
#define RTL930X_DMA_IF_CTRL (0xe028)
|
||||
#define RTL930X_DMA_IF_INTR_RX_DONE_STS (0xe020)
|
||||
#define RTL930X_DMA_IF_INTR_TX_DONE_STS (0xe024)
|
||||
#define RTL930X_DMA_IF_INTR_RX_DONE_MSK (0xe014)
|
||||
#define RTL930X_DMA_IF_INTR_TX_DONE_MSK (0xe018)
|
||||
#define RTL930X_L2_NTFY_IF_INTR_MSK (0xe04C)
|
||||
#define RTL930X_L2_NTFY_IF_INTR_STS (0xe050)
|
||||
|
||||
/* TODO: RTL931X_DMA_IF_CTRL has different bits meanings */
|
||||
#define RTL931X_DMA_IF_CTRL (0x0928)
|
||||
#define RTL931X_DMA_IF_INTR_RX_DONE_STS (0x0920)
|
||||
#define RTL931X_DMA_IF_INTR_TX_DONE_STS (0x0924)
|
||||
#define RTL931X_DMA_IF_INTR_RX_DONE_MSK (0x0914)
|
||||
#define RTL931X_DMA_IF_INTR_TX_DONE_MSK (0x0918)
|
||||
#define RTL931X_L2_NTFY_IF_INTR_MSK (0x09E4)
|
||||
#define RTL931X_L2_NTFY_IF_INTR_STS (0x09E8)
|
||||
|
||||
#define RTL839X_DMA_IF_INTR_NOTIFY_MASK GENMASK(22, 20)
|
||||
#define RTL83XX_DMA_IF_INTR_RX_DONE_MASK GENMASK(15, 8)
|
||||
#define RTL83XX_DMA_IF_INTR_RX_RUN_OUT_MASK GENMASK(7, 0)
|
||||
#define RTL83XX_DMA_IF_INTR_RX_MASK(ring) (BIT(ring) | BIT(ring + 8))
|
||||
#define RTL83XX_DMA_IF_INTR_RX_MASK(ring) (BIT(ring + 8))
|
||||
#define RTL93XX_DMA_IF_INTR_RX_MASK(ring) (BIT(ring))
|
||||
|
||||
/* MAC address settings */
|
||||
@@ -411,17 +407,14 @@ struct rteth_config {
|
||||
int rx_rings;
|
||||
int tx_rx_enable;
|
||||
int tx_trigger_mask;
|
||||
irqreturn_t (*net_irq)(int irq, void *dev_id);
|
||||
int mac_l2_port_ctrl;
|
||||
int qm_pkt2cpu_intpri_map;
|
||||
int qm_rsn2cpuqid_ctrl;
|
||||
int qm_rsn2cpuqid_cnt;
|
||||
int dma_if_intr_sts;
|
||||
int dma_if_intr_msk;
|
||||
int dma_if_intr_rx_done_sts;
|
||||
int dma_if_intr_tx_done_sts;
|
||||
int dma_if_intr_rx_done_msk;
|
||||
int dma_if_intr_tx_done_msk;
|
||||
int l2_ntfy_if_intr_sts;
|
||||
int l2_ntfy_if_intr_msk;
|
||||
int dma_if_ctrl;
|
||||
|
||||
Reference in New Issue
Block a user