realtek: Replace C++ style comments
The only exception to C++ style comments are SPDX license identifier markers at the start of C files (even headers have C style markers). Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
This commit is contained in:
committed by
Sander Vanheule
parent
758c88b969
commit
0a931767cf
@@ -58,28 +58,28 @@ int rtl83xx_port_get_stp_state(struct rtl838x_switch_priv *priv, int port)
|
||||
}
|
||||
|
||||
static struct table_reg rtl838x_tbl_regs[] = {
|
||||
TBL_DESC(0x6900, 0x6908, 3, 15, 13, 1), // RTL8380_TBL_L2
|
||||
TBL_DESC(0x6914, 0x6918, 18, 14, 12, 1), // RTL8380_TBL_0
|
||||
TBL_DESC(0xA4C8, 0xA4CC, 6, 14, 12, 1), // RTL8380_TBL_1
|
||||
TBL_DESC(0x6900, 0x6908, 3, 15, 13, 1), /* RTL8380_TBL_L2 */
|
||||
TBL_DESC(0x6914, 0x6918, 18, 14, 12, 1), /* RTL8380_TBL_0 */
|
||||
TBL_DESC(0xA4C8, 0xA4CC, 6, 14, 12, 1), /* RTL8380_TBL_1 */
|
||||
|
||||
TBL_DESC(0x1180, 0x1184, 3, 16, 14, 0), // RTL8390_TBL_L2
|
||||
TBL_DESC(0x1190, 0x1194, 17, 15, 12, 0), // RTL8390_TBL_0
|
||||
TBL_DESC(0x6B80, 0x6B84, 4, 14, 12, 0), // RTL8390_TBL_1
|
||||
TBL_DESC(0x611C, 0x6120, 9, 8, 6, 0), // RTL8390_TBL_2
|
||||
TBL_DESC(0x1180, 0x1184, 3, 16, 14, 0), /* RTL8390_TBL_L2 */
|
||||
TBL_DESC(0x1190, 0x1194, 17, 15, 12, 0), /* RTL8390_TBL_0 */
|
||||
TBL_DESC(0x6B80, 0x6B84, 4, 14, 12, 0), /* RTL8390_TBL_1 */
|
||||
TBL_DESC(0x611C, 0x6120, 9, 8, 6, 0), /* RTL8390_TBL_2 */
|
||||
|
||||
TBL_DESC(0xB320, 0xB334, 3, 18, 16, 0), // RTL9300_TBL_L2
|
||||
TBL_DESC(0xB340, 0xB344, 19, 16, 12, 0), // RTL9300_TBL_0
|
||||
TBL_DESC(0xB3A0, 0xB3A4, 20, 16, 13, 0), // RTL9300_TBL_1
|
||||
TBL_DESC(0xCE04, 0xCE08, 6, 14, 12, 0), // RTL9300_TBL_2
|
||||
TBL_DESC(0xD600, 0xD604, 30, 7, 6, 0), // RTL9300_TBL_HSB
|
||||
TBL_DESC(0x7880, 0x7884, 22, 9, 8, 0), // RTL9300_TBL_HSA
|
||||
TBL_DESC(0xB320, 0xB334, 3, 18, 16, 0), /* RTL9300_TBL_L2 */
|
||||
TBL_DESC(0xB340, 0xB344, 19, 16, 12, 0), /* RTL9300_TBL_0 */
|
||||
TBL_DESC(0xB3A0, 0xB3A4, 20, 16, 13, 0), /* RTL9300_TBL_1 */
|
||||
TBL_DESC(0xCE04, 0xCE08, 6, 14, 12, 0), /* RTL9300_TBL_2 */
|
||||
TBL_DESC(0xD600, 0xD604, 30, 7, 6, 0), /* RTL9300_TBL_HSB */
|
||||
TBL_DESC(0x7880, 0x7884, 22, 9, 8, 0), /* RTL9300_TBL_HSA */
|
||||
|
||||
TBL_DESC(0x8500, 0x8508, 8, 19, 15, 0), // RTL9310_TBL_0
|
||||
TBL_DESC(0x40C0, 0x40C4, 22, 16, 14, 0), // RTL9310_TBL_1
|
||||
TBL_DESC(0x8528, 0x852C, 6, 18, 14, 0), // RTL9310_TBL_2
|
||||
TBL_DESC(0x0200, 0x0204, 9, 15, 12, 0), // RTL9310_TBL_3
|
||||
TBL_DESC(0x20dc, 0x20e0, 29, 7, 6, 0), // RTL9310_TBL_4
|
||||
TBL_DESC(0x7e1c, 0x7e20, 53, 8, 6, 0), // RTL9310_TBL_5
|
||||
TBL_DESC(0x8500, 0x8508, 8, 19, 15, 0), /* RTL9310_TBL_0 */
|
||||
TBL_DESC(0x40C0, 0x40C4, 22, 16, 14, 0), /* RTL9310_TBL_1 */
|
||||
TBL_DESC(0x8528, 0x852C, 6, 18, 14, 0), /* RTL9310_TBL_2 */
|
||||
TBL_DESC(0x0200, 0x0204, 9, 15, 12, 0), /* RTL9310_TBL_3 */
|
||||
TBL_DESC(0x20dc, 0x20e0, 29, 7, 6, 0), /* RTL9310_TBL_4 */
|
||||
TBL_DESC(0x7e1c, 0x7e20, 53, 8, 6, 0), /* RTL9310_TBL_5 */
|
||||
};
|
||||
|
||||
void rtl_table_init(void)
|
||||
@@ -113,9 +113,9 @@ void rtl_table_release(struct table_reg *r)
|
||||
if (!r)
|
||||
return;
|
||||
|
||||
// pr_info("Unlocking %08x\n", (u32)r);
|
||||
/* pr_info("Unlocking %08x\n", (u32)r); */
|
||||
mutex_unlock(&r->lock);
|
||||
// pr_info("Unlock done\n");
|
||||
/* pr_info("Unlock done\n"); */
|
||||
}
|
||||
|
||||
static int rtl_table_exec(struct table_reg *r, bool is_write, int idx)
|
||||
@@ -359,7 +359,7 @@ static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
|
||||
led_set = 0;
|
||||
priv->ports[pn].led_set = led_set;
|
||||
|
||||
// Check for the integrated SerDes of the RTL8380M first
|
||||
/* Check for the integrated SerDes of the RTL8380M first */
|
||||
if (of_property_read_bool(phy_node, "phy-is-integrated")
|
||||
&& priv->id == 0x8380 && pn >= 24) {
|
||||
pr_debug("----> FÓUND A SERDES\n");
|
||||
@@ -475,15 +475,15 @@ int rtl83xx_lag_add(struct dsa_switch *ds, int group, int port, struct netdev_la
|
||||
case NETDEV_LAG_HASH_L23:
|
||||
algomsk |= TRUNK_DISTRIBUTION_ALGO_DMAC_BIT;
|
||||
algomsk |= TRUNK_DISTRIBUTION_ALGO_SMAC_BIT;
|
||||
algomsk |= TRUNK_DISTRIBUTION_ALGO_SIP_BIT; //source ip
|
||||
algomsk |= TRUNK_DISTRIBUTION_ALGO_DIP_BIT; //dest ip
|
||||
algomsk |= TRUNK_DISTRIBUTION_ALGO_SIP_BIT; /* source ip */
|
||||
algomsk |= TRUNK_DISTRIBUTION_ALGO_DIP_BIT; /* dest ip */
|
||||
algoidx = 1;
|
||||
break;
|
||||
case NETDEV_LAG_HASH_L34:
|
||||
algomsk |= TRUNK_DISTRIBUTION_ALGO_SRC_L4PORT_BIT; //sport
|
||||
algomsk |= TRUNK_DISTRIBUTION_ALGO_DST_L4PORT_BIT; //dport
|
||||
algomsk |= TRUNK_DISTRIBUTION_ALGO_SIP_BIT; //source ip
|
||||
algomsk |= TRUNK_DISTRIBUTION_ALGO_DIP_BIT; //dest ip
|
||||
algomsk |= TRUNK_DISTRIBUTION_ALGO_SRC_L4PORT_BIT; /* sport */
|
||||
algomsk |= TRUNK_DISTRIBUTION_ALGO_DST_L4PORT_BIT; /* dport */
|
||||
algomsk |= TRUNK_DISTRIBUTION_ALGO_SIP_BIT; /* source ip */
|
||||
algomsk |= TRUNK_DISTRIBUTION_ALGO_DIP_BIT; /* dest ip */
|
||||
algoidx = 2;
|
||||
break;
|
||||
default:
|
||||
@@ -519,7 +519,7 @@ int rtl83xx_lag_del(struct dsa_switch *ds, int group, int port)
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
// 0x7f algo mask all
|
||||
/* 0x7f algo mask all */
|
||||
priv->r->mask_port_reg_be(BIT_ULL(port), 0, priv->r->trk_mbr_ctr(group));
|
||||
priv->lags_port_members[group] &= ~BIT_ULL(port);
|
||||
|
||||
@@ -603,7 +603,7 @@ int rtl83xx_l2_nexthop_add(struct rtl838x_switch_priv *priv, struct rtl83xx_next
|
||||
u64_to_ether_addr(nh->mac, &e.mac[0]);
|
||||
e.port = nh->port;
|
||||
|
||||
// Loop over all entries in the hash-bucket and over the second block on 93xx SoCs
|
||||
/* Loop over all entries in the hash-bucket and over the second block on 93xx SoCs */
|
||||
for (i = 0; i < priv->l2_bucket_size; i++) {
|
||||
entry = priv->r->read_l2_entry_using_hash(key, i, &e);
|
||||
|
||||
@@ -619,14 +619,14 @@ int rtl83xx_l2_nexthop_add(struct rtl838x_switch_priv *priv, struct rtl83xx_next
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Found an existing (e->valid is true) or empty entry, make it a nexthop entry
|
||||
/* Found an existing (e->valid is true) or empty entry, make it a nexthop entry */
|
||||
nh->l2_id = idx;
|
||||
if (e.valid) {
|
||||
nh->port = e.port;
|
||||
nh->vid = e.vid; // Save VID
|
||||
nh->vid = e.vid; /* Save VID */
|
||||
nh->rvid = e.rvid;
|
||||
nh->dev_id = e.stack_dev;
|
||||
// If the entry is already a valid next hop entry, don't change it
|
||||
/* If the entry is already a valid next hop entry, don't change it */
|
||||
if (e.next_hop)
|
||||
return 0;
|
||||
} else {
|
||||
@@ -638,12 +638,12 @@ int rtl83xx_l2_nexthop_add(struct rtl838x_switch_priv *priv, struct rtl83xx_next
|
||||
e.block_da = false;
|
||||
e.block_sa = false;
|
||||
e.suspended = false;
|
||||
e.age = 0; // With port-ignore
|
||||
e.age = 0; /* With port-ignore */
|
||||
e.port = priv->port_ignore;
|
||||
u64_to_ether_addr(nh->mac, &e.mac[0]);
|
||||
}
|
||||
e.next_hop = true;
|
||||
e.nh_route_id = nh->id; // NH route ID takes place of VID
|
||||
e.nh_route_id = nh->id; /* NH route ID takes place of VID */
|
||||
e.nh_vlan_target = false;
|
||||
|
||||
priv->r->write_l2_entry_using_hash(idx >> 2, idx & 0x3, &e);
|
||||
@@ -671,7 +671,7 @@ int rtl83xx_l2_nexthop_rm(struct rtl838x_switch_priv *priv, struct rtl83xx_nexth
|
||||
if (e.is_static)
|
||||
e.valid = false;
|
||||
e.next_hop = false;
|
||||
e.vid = nh->vid; // Restore VID
|
||||
e.vid = nh->vid; /* Restore VID */
|
||||
e.rvid = nh->rvid;
|
||||
|
||||
priv->r->write_l2_entry_using_hash(key, i, &e);
|
||||
@@ -740,11 +740,12 @@ int rtl83xx_port_is_under(const struct net_device * dev, struct rtl838x_switch_p
|
||||
{
|
||||
int i;
|
||||
|
||||
// TODO: On 5.12:
|
||||
// if(!dsa_slave_dev_check(dev)) {
|
||||
// netdev_info(dev, "%s: not a DSA device.\n", __func__);
|
||||
// return -EINVAL;
|
||||
// }
|
||||
/* TODO: On 5.12:
|
||||
* if(!dsa_slave_dev_check(dev)) {
|
||||
* netdev_info(dev, "%s: not a DSA device.\n", __func__);
|
||||
* return -EINVAL;
|
||||
* }
|
||||
*/
|
||||
|
||||
for (i = 0; i < priv->cpu_port; i++) {
|
||||
if (!priv->ports[i].dp)
|
||||
@@ -804,7 +805,7 @@ static int rtl83xx_l3_nexthop_update(struct rtl838x_switch_priv *priv, __be32 i
|
||||
pr_info("%s: Setting up fwding: ip %pI4, GW mac %016llx\n",
|
||||
__func__, &ip_addr, mac);
|
||||
|
||||
// Reads the ROUTING table entry associated with the route
|
||||
/* Reads the ROUTING table entry associated with the route */
|
||||
priv->r->route_read(r->id, r);
|
||||
pr_info("Route with id %d to %pI4 / %d\n", r->id, &r->dst_ip, r->prefix_len);
|
||||
|
||||
@@ -812,19 +813,19 @@ static int rtl83xx_l3_nexthop_update(struct rtl838x_switch_priv *priv, __be32 i
|
||||
r->nh.port = priv->port_ignore;
|
||||
r->nh.id = r->id;
|
||||
|
||||
// Do we need to explicitly add a DMAC entry with the route's nh index?
|
||||
/* Do we need to explicitly add a DMAC entry with the route's nh index? */
|
||||
if (priv->r->set_l3_egress_mac)
|
||||
priv->r->set_l3_egress_mac(r->id, mac);
|
||||
|
||||
// Update ROUTING table: map gateway-mac and switch-mac id to route id
|
||||
/* Update ROUTING table: map gateway-mac and switch-mac id to route id */
|
||||
rtl83xx_l2_nexthop_add(priv, &r->nh);
|
||||
|
||||
r->attr.valid = true;
|
||||
r->attr.action = ROUTE_ACT_FORWARD;
|
||||
r->attr.type = 0;
|
||||
r->attr.hit = false; // Reset route-used indicator
|
||||
r->attr.hit = false; /* Reset route-used indicator */
|
||||
|
||||
// Add PIE entry with dst_ip and prefix_len
|
||||
/* Add PIE entry with dst_ip and prefix_len */
|
||||
r->pr.dip = r->dst_ip;
|
||||
r->pr.dip_m = inet_make_mask(r->prefix_len);
|
||||
|
||||
@@ -948,7 +949,7 @@ static struct rtl83xx_route *rtl83xx_route_alloc(struct rtl838x_switch_priv *pri
|
||||
|
||||
r->id = idx;
|
||||
r->gw_ip = ip;
|
||||
r->pr.id = -1; // We still need to allocate a rule in HW
|
||||
r->pr.id = -1; /* We still need to allocate a rule in HW */
|
||||
r->is_host_route = false;
|
||||
|
||||
err = rhltable_insert(&priv->routes, &r->linkage, route_ht_params);
|
||||
@@ -993,7 +994,7 @@ static struct rtl83xx_route *rtl83xx_host_route_alloc(struct rtl838x_switch_priv
|
||||
r->id = idx + MAX_ROUTES;
|
||||
|
||||
r->gw_ip = ip;
|
||||
r->pr.id = -1; // We still need to allocate a rule in HW
|
||||
r->pr.id = -1; /* We still need to allocate a rule in HW */
|
||||
r->is_host_route = true;
|
||||
|
||||
err = rhltable_insert(&priv->routes, &r->linkage, route_ht_params);
|
||||
@@ -1031,7 +1032,7 @@ static void rtl83xx_route_rm(struct rtl838x_switch_priv *priv, struct rtl83xx_ro
|
||||
priv->r->host_route_write(id, r);
|
||||
clear_bit(r->id - MAX_ROUTES, priv->host_route_use_bm);
|
||||
} else {
|
||||
// If there is a HW representation of the route, delete it
|
||||
/* If there is a HW representation of the route, delete it */
|
||||
if (priv->r->route_lookup_hw) {
|
||||
id = priv->r->route_lookup_hw(r);
|
||||
pr_info("%s: Got id for prefix route: %d\n", __func__, id);
|
||||
@@ -1110,13 +1111,13 @@ static int rtl83xx_alloc_router_mac(struct rtl838x_switch_priv *priv, u64 mac)
|
||||
|
||||
m.valid = true;
|
||||
m.mac = mac;
|
||||
m.p_type = 0; // An individual port, not a trunk port
|
||||
m.p_id = 0x3f; // Listen on any port
|
||||
m.p_type = 0; /* An individual port, not a trunk port */
|
||||
m.p_id = 0x3f; /* Listen on any port */
|
||||
m.p_id_mask = 0;
|
||||
m.vid = 0; // Listen on any VLAN...
|
||||
m.vid_mask = 0; // ... so mask needs to be 0
|
||||
m.mac_mask = 0xffffffffffffULL; // We want an exact match of the interface MAC
|
||||
m.action = L3_FORWARD; // Route the packet
|
||||
m.vid = 0; /* Listen on any VLAN... */
|
||||
m.vid_mask = 0; /* ... so mask needs to be 0 */
|
||||
m.mac_mask = 0xffffffffffffULL; /* We want an exact match of the interface MAC */
|
||||
m.action = L3_FORWARD; /* Route the packet */
|
||||
priv->r->set_l3_router_mac(free_mac, &m);
|
||||
|
||||
mutex_unlock(&priv->reg_mutex);
|
||||
@@ -1148,15 +1149,15 @@ static int rtl83xx_alloc_egress_intf(struct rtl838x_switch_priv *priv, u64 mac,
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set up default egress interface 1
|
||||
/* Set up default egress interface 1 */
|
||||
intf.vid = vlan;
|
||||
intf.smac_idx = free_mac;
|
||||
intf.ip4_mtu_id = 1;
|
||||
intf.ip6_mtu_id = 1;
|
||||
intf.ttl_scope = 1; // TTL
|
||||
intf.hl_scope = 1; // Hop Limit
|
||||
intf.ip4_icmp_redirect = intf.ip6_icmp_redirect = 2; // FORWARD
|
||||
intf.ip4_pbr_icmp_redirect = intf.ip6_pbr_icmp_redirect = 2; // FORWARD;
|
||||
intf.ttl_scope = 1; /* TTL */
|
||||
intf.hl_scope = 1; /* Hop Limit */
|
||||
intf.ip4_icmp_redirect = intf.ip6_icmp_redirect = 2; /* FORWARD */
|
||||
intf.ip4_pbr_icmp_redirect = intf.ip6_pbr_icmp_redirect = 2; /* FORWARD; */
|
||||
priv->r->set_l3_egress_intf(free_mac, &intf);
|
||||
|
||||
priv->r->set_l3_egress_mac(L3_EGRESS_DMACS + free_mac, mac);
|
||||
@@ -1190,22 +1191,22 @@ static int rtl83xx_fib4_add(struct rtl838x_switch_priv *priv,
|
||||
if (port < 0)
|
||||
return -1;
|
||||
|
||||
// For now we only work with routes that have a gateway and are not ourself
|
||||
// if ((!nh->fib_nh_gw4) && (info->dst_len != 32))
|
||||
// return 0;
|
||||
/* For now we only work with routes that have a gateway and are not ourself */
|
||||
/* if ((!nh->fib_nh_gw4) && (info->dst_len != 32)) */
|
||||
/* return 0; */
|
||||
|
||||
if ((info->dst & 0xff) == 0xff)
|
||||
return 0;
|
||||
|
||||
// Do not offload routes to 192.168.100.x
|
||||
/* Do not offload routes to 192.168.100.x */
|
||||
if ((info->dst & 0xffffff00) == 0xc0a86400)
|
||||
return 0;
|
||||
|
||||
// Do not offload routes to 127.x.x.x
|
||||
/* Do not offload routes to 127.x.x.x */
|
||||
if ((info->dst & 0xff000000) == 0x7f000000)
|
||||
return 0;
|
||||
|
||||
// Allocate route or host-route (entry if hardware supports this)
|
||||
/* Allocate route or host-route (entry if hardware supports this) */
|
||||
if (info->dst_len == 32 && priv->r->host_route_write)
|
||||
r = rtl83xx_host_route_alloc(priv, nh->fib_nh_gw4);
|
||||
else
|
||||
@@ -1229,7 +1230,7 @@ static int rtl83xx_fib4_add(struct rtl838x_switch_priv *priv,
|
||||
if (rtl83xx_alloc_router_mac(priv, mac))
|
||||
goto out_free_rt;
|
||||
|
||||
// vid = 0: Do not care about VID
|
||||
/* vid = 0: Do not care about VID */
|
||||
r->nh.if_id = rtl83xx_alloc_egress_intf(priv, mac, vlan);
|
||||
if (r->nh.if_id < 0)
|
||||
goto out_free_rmac;
|
||||
@@ -1249,7 +1250,7 @@ static int rtl83xx_fib4_add(struct rtl838x_switch_priv *priv,
|
||||
}
|
||||
}
|
||||
|
||||
// We need to resolve the mac address of the GW
|
||||
/* We need to resolve the mac address of the GW */
|
||||
if (!to_localhost)
|
||||
rtl83xx_port_ipv4_resolve(priv, dev, nh->fib_nh_gw4);
|
||||
|
||||
@@ -1266,7 +1267,7 @@ static int rtl83xx_fib6_add(struct rtl838x_switch_priv *priv,
|
||||
struct fib6_entry_notifier_info *info)
|
||||
{
|
||||
pr_debug("In %s\n", __func__);
|
||||
// nh->fib_nh_flags |= RTNH_F_OFFLOAD;
|
||||
/* nh->fib_nh_flags |= RTNH_F_OFFLOAD; */
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1462,7 +1463,7 @@ static int __init rtl83xx_sw_probe(struct platform_device *pdev)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
// Initialize access to RTL switch tables
|
||||
/* Initialize access to RTL switch tables */
|
||||
rtl_table_init();
|
||||
|
||||
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||
@@ -1623,7 +1624,7 @@ static int __init rtl83xx_sw_probe(struct platform_device *pdev)
|
||||
goto err_register_nb;
|
||||
}
|
||||
|
||||
// Initialize hash table for L3 routing
|
||||
/* Initialize hash table for L3 routing */
|
||||
rhltable_init(&priv->routes, &route_ht_params);
|
||||
|
||||
/* Register netevent notifier callback to catch notifications about neighboring
|
||||
@@ -1647,13 +1648,13 @@ static int __init rtl83xx_sw_probe(struct platform_device *pdev)
|
||||
if (err)
|
||||
goto err_register_fib_nb;
|
||||
|
||||
// TODO: put this into l2_setup()
|
||||
// Flood BPDUs to all ports including cpu-port
|
||||
/* TODO: put this into l2_setup() */
|
||||
/* Flood BPDUs to all ports including cpu-port */
|
||||
if (soc_info.family != RTL9300_FAMILY_ID) {
|
||||
bpdu_mask = soc_info.family == RTL8380_FAMILY_ID ? 0x1FFFFFFF : 0x1FFFFFFFFFFFFF;
|
||||
priv->r->set_port_reg_be(bpdu_mask, priv->r->rma_bpdu_fld_pmask);
|
||||
|
||||
// TRAP 802.1X frames (EAPOL) to the CPU-Port, bypass STP and VLANs
|
||||
/* TRAP 802.1X frames (EAPOL) to the CPU-Port, bypass STP and VLANs */
|
||||
sw_w32(7, priv->r->spcl_trap_eapol_ctrl);
|
||||
|
||||
rtl838x_dbgfs_init(priv);
|
||||
@@ -1673,7 +1674,7 @@ err_register_nb:
|
||||
|
||||
static int rtl83xx_sw_remove(struct platform_device *pdev)
|
||||
{
|
||||
// TODO:
|
||||
/* TODO: */
|
||||
pr_debug("Removing platform driver for rtl83xx-sw\n");
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user