diff options
author | Olliver Schinagl <oliver@schinagl.nl> | 2022-12-22 11:27:59 +0100 |
---|---|---|
committer | Sander Vanheule <sander@svanheule.net> | 2022-12-27 16:33:01 +0100 |
commit | 0a931767cf2a4c2592bb37c1109299a56fb0ee89 (patch) | |
tree | a07c91db89eb128d91199d7f661dab29d7909c69 /target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx | |
parent | 758c88b969639d0e6b684669d2e54dd1be3102f4 (diff) |
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>
Diffstat (limited to 'target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx')
10 files changed, 718 insertions, 717 deletions
diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/common.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/common.c index de75b83e2d..2f68a0a1ce 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/common.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/common.c @@ -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(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(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(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(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 */ }; 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; diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/debugfs.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/debugfs.c index bc7b3f1461..0ad4872c38 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/debugfs.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/debugfs.c @@ -109,21 +109,21 @@ const char *rtl930x_drop_cntr[] = { const char *rtl931x_drop_cntr[] = { "ALE_RX_GOOD_PKTS", "RX_MAX_FRAME_SIZE", "MAC_RX_DROP", "OPENFLOW_IP_MPLS_TTL", "OPENFLOW_TBL_MISS", - "IGR_BW", "SPECIAL_CONGEST", "EGR_QUEUE", "RESERVED", "EGR_LINK_STATUS", "STACK_UCAST_NONUCAST_TTL", // 10 + "IGR_BW", "SPECIAL_CONGEST", "EGR_QUEUE", "RESERVED", "EGR_LINK_STATUS", "STACK_UCAST_NONUCAST_TTL", /* 10 */ "STACK_NONUC_BLOCKING_PMSK", "L2_CRC", "SRC_PORT_FILTER", "PARSER_PACKET_TOO_LONG", "PARSER_MALFORM_PACKET", - "MPLS_OVER_2_LBL", "EACL_METER", "IACL_METER", "PROTO_STORM", "INVALID_CAPWAP_HEADER", // 20 + "MPLS_OVER_2_LBL", "EACL_METER", "IACL_METER", "PROTO_STORM", "INVALID_CAPWAP_HEADER", /* 20 */ "MAC_IP_SUBNET_BASED_VLAN", "OAM_PARSER", "UC_MC_RPF", "IP_MAC_BINDING_MATCH_MISMATCH", "SA_BLOCK", - "TUNNEL_IP_ADDRESS_CHECK", "EACL_DROP", "IACL_DROP", "ATTACK_PREVENT", "SYSTEM_PORT_LIMIT_LEARN", // 30, + "TUNNEL_IP_ADDRESS_CHECK", "EACL_DROP", "IACL_DROP", "ATTACK_PREVENT", "SYSTEM_PORT_LIMIT_LEARN", /* 30 */ "OAMPDU", "CCM_RX", "CFM_UNKNOWN_TYPE", "LBM_LBR_LTM_LTR", "Y_1731", "VLAN_LIMIT_LEARN", - "VLAN_ACCEPT_FRAME_TYPE", "CFI_1", "STATIC_DYNAMIC_PORT_MOVING", "PORT_MOVE_FORBID", // 40 + "VLAN_ACCEPT_FRAME_TYPE", "CFI_1", "STATIC_DYNAMIC_PORT_MOVING", "PORT_MOVE_FORBID", /* 40 */ "L3_CRC", "BPDU_PTP_LLDP_EAPOL_RMA", "MSTP_SRC_DROP_DISABLED_BLOCKING", "INVALID_SA", "NEW_SA", - "VLAN_IGR_FILTER", "IGR_VLAN_CONVERT", "GRATUITOUS_ARP", "MSTP_SRC_DROP", "L2_HASH_FULL", // 50 + "VLAN_IGR_FILTER", "IGR_VLAN_CONVERT", "GRATUITOUS_ARP", "MSTP_SRC_DROP", "L2_HASH_FULL", /* 50 */ "MPLS_UNKNOWN_LBL", "L3_IPUC_NON_IP", "TTL", "MTU", "ICMP_REDIRECT", "STORM_CONTROL", "L3_DIP_DMAC_MISMATCH", - "IP4_IP_OPTION", "IP6_HBH_EXT_HEADER", "IP4_IP6_HEADER_ERROR", // 60 + "IP4_IP_OPTION", "IP6_HBH_EXT_HEADER", "IP4_IP6_HEADER_ERROR", /* 60 */ "ROUTING_IP_ADDR_CHECK", "ROUTING_EXCEPTION", "DA_BLOCK", "OAM_MUX", "PORT_ISOLATION", "VLAN_EGR_FILTER", - "MIRROR_ISOLATE", "MSTP_DESTINATION_DROP", "L2_MC_BRIDGE", "IP_UC_MC_ROUTING_LOOK_UP_MISS", // 70 + "MIRROR_ISOLATE", "MSTP_DESTINATION_DROP", "L2_MC_BRIDGE", "IP_UC_MC_ROUTING_LOOK_UP_MISS", /* 70 */ "L2_UC", "L2_MC", "IP4_MC", "IP6_MC", "L3_UC_MC_ROUTE", "UNKNOWN_L2_UC_FLPM", "BC_FLPM", - "VLAN_PRO_UNKNOWN_L2_MC_FLPM", "VLAN_PRO_UNKNOWN_IP4_MC_FLPM", "VLAN_PROFILE_UNKNOWN_IP6_MC_FLPM" // 80, + "VLAN_PRO_UNKNOWN_L2_MC_FLPM", "VLAN_PRO_UNKNOWN_IP4_MC_FLPM", "VLAN_PROFILE_UNKNOWN_IP6_MC_FLPM", /* 80 */ }; static ssize_t rtl838x_common_read(char __user *buffer, size_t count, @@ -465,7 +465,7 @@ void rtl838x_dbgfs_cleanup(struct rtl838x_switch_priv *priv) { debugfs_remove_recursive(priv->dbgfs_dir); -// kfree(priv->dbgfs_entries); +/* kfree(priv->dbgfs_entries); */ } static int rtl838x_dbgfs_port_init(struct dentry *parent, struct rtl838x_switch_priv *priv, diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index f6e1f55a20..c940ffb9b9 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -122,22 +122,22 @@ static void rtl83xx_vlan_setup(struct rtl838x_switch_priv *priv) pr_info("UNKNOWN_MC_PMASK: %016llx\n", priv->r->read_mcast_pmask(UNKNOWN_MC_PMASK)); priv->r->vlan_profile_dump(0); - info.fid = 0; // Default Forwarding ID / MSTI - info.hash_uc_fid = false; // Do not build the L2 lookup hash with FID, but VID - info.hash_mc_fid = false; // Do the same for Multicast packets - info.profile_id = 0; // Use default Vlan Profile 0 - info.tagged_ports = 0; // Initially no port members + info.fid = 0; /* Default Forwarding ID / MSTI */ + info.hash_uc_fid = false; /* Do not build the L2 lookup hash with FID, but VID */ + info.hash_mc_fid = false; /* Do the same for Multicast packets */ + info.profile_id = 0; /* Use default Vlan Profile 0 */ + info.tagged_ports = 0; /* Initially no port members */ if (priv->family_id == RTL9310_FAMILY_ID) { info.if_id = 0; info.multicast_grp_mask = 0; info.l2_tunnel_list_id = -1; } - // Initialize all vlans 0-4095 + /* Initialize all vlans 0-4095 */ for (i = 0; i < MAX_VLANS; i ++) priv->r->vlan_set_tagged(i, &info); - // reset PVIDs; defaults to 1 on reset + /* reset PVIDs; defaults to 1 on reset */ for (i = 0; i <= priv->ds->num_ports; i++) { priv->r->vlan_port_pvid_set(i, PBVLAN_TYPE_INNER, 0); priv->r->vlan_port_pvid_set(i, PBVLAN_TYPE_OUTER, 0); @@ -145,7 +145,7 @@ static void rtl83xx_vlan_setup(struct rtl838x_switch_priv *priv) priv->r->vlan_port_pvidmode_set(i, PBVLAN_TYPE_OUTER, PBVLAN_MODE_UNTAG_AND_PRITAG); } - // Set forwarding action based on inner VLAN tag + /* Set forwarding action based on inner VLAN tag */ for (i = 0; i < priv->cpu_port; i++) priv->r->vlan_fwd_on_inner(i, true); } @@ -248,7 +248,7 @@ static int rtl93xx_setup(struct dsa_switch *ds) sw_w32(0, RTL931X_SMI_PORT_POLLING_CTRL + 4); } - // Disable all ports except CPU port + /* Disable all ports except CPU port */ for (i = 0; i < ds->num_ports; i++) priv->ports[i].enable = false; priv->ports[priv->cpu_port].enable = true; @@ -263,7 +263,7 @@ static int rtl93xx_setup(struct dsa_switch *ds) rtl930x_print_matrix(); - // TODO: Initialize statistics + /* TODO: Initialize statistics */ rtl83xx_vlan_setup(priv); @@ -408,7 +408,7 @@ static void rtl93xx_phylink_validate(struct dsa_switch *ds, int port, phylink_set(mask, 1000baseT_Half); } - // Internal phys of the RTL93xx family provide 10G + /* Internal phys of the RTL93xx family provide 10G */ if (priv->ports[port].phy_is_integrated && state->interface == PHY_INTERFACE_MODE_1000BASEX) { phylink_set(mask, 1000baseX_Full); @@ -679,7 +679,7 @@ static void rtl83xx_phylink_mac_config(struct dsa_switch *ds, int port, reg |= 1 << speed_bit; break; default: - break; // Ignore, including 10MBit which has a speed value of 0 + break; /* Ignore, including 10MBit which has a speed value of 0 */ } if (priv->family_id == RTL8380_FAMILY_ID) { @@ -696,7 +696,7 @@ static void rtl83xx_phylink_mac_config(struct dsa_switch *ds, int port, reg |= RTL839X_DUPLEX_MODE; } - // LAG members must use DUPLEX and we need to enable the link + /* LAG members must use DUPLEX and we need to enable the link */ if (priv->lagmembers & BIT_ULL(port)) { switch(priv->family_id) { case RTL8380_FAMILY_ID: @@ -708,7 +708,7 @@ static void rtl83xx_phylink_mac_config(struct dsa_switch *ds, int port, } } - // Disable AN + /* Disable AN */ if (priv->family_id == RTL8380_FAMILY_ID) reg &= ~RTL838X_NWAY_EN; sw_w32(reg, priv->r->mac_force_mode_ctrl(port)); @@ -746,7 +746,7 @@ static void rtl931x_phylink_mac_config(struct dsa_switch *ds, int port, rtl931x_sds_init(sds_num, PHY_INTERFACE_MODE_10GBASER); break; case PHY_INTERFACE_MODE_USXGMII: - // Translates to MII_USXGMII_10GSXGMII + /* Translates to MII_USXGMII_10GSXGMII */ band = rtl931x_sds_cmu_band_get(sds_num, PHY_INTERFACE_MODE_USXGMII); rtl931x_sds_init(sds_num, PHY_INTERFACE_MODE_USXGMII); break; @@ -772,7 +772,7 @@ static void rtl931x_phylink_mac_config(struct dsa_switch *ds, int port, reg &= ~(RTL931X_DUPLEX_MODE | RTL931X_FORCE_EN | RTL931X_FORCE_LINK_EN); reg &= ~(0xf << 12); - reg |= 0x2 << 12; // Set SMI speed to 0x2 + reg |= 0x2 << 12; /* Set SMI speed to 0x2 */ reg |= RTL931X_TX_PAUSE_EN | RTL931X_RX_PAUSE_EN; @@ -797,7 +797,7 @@ static void rtl93xx_phylink_mac_config(struct dsa_switch *ds, int port, pr_info("%s port %d, mode %x, phy-mode: %s, speed %d, link %d\n", __func__, port, mode, phy_modes(state->interface), state->speed, state->link); - // Nothing to be done for the CPU-port + /* Nothing to be done for the CPU-port */ if (port == priv->cpu_port) return; @@ -819,7 +819,7 @@ static void rtl93xx_phylink_mac_config(struct dsa_switch *ds, int port, break; case PHY_INTERFACE_MODE_10GBASER: case PHY_INTERFACE_MODE_10GKR: - sds_mode = 0x1b; // 10G 1000X Auto + sds_mode = 0x1b; /* 10G 1000X Auto */ break; case PHY_INTERFACE_MODE_USXGMII: sds_mode = 0x0d; @@ -864,7 +864,7 @@ static void rtl93xx_phylink_mac_config(struct dsa_switch *ds, int port, reg |= RTL930X_DUPLEX_MODE; if (priv->ports[port].phy_is_integrated) - reg &= ~RTL930X_FORCE_EN; // Clear MAC_FORCE_EN to allow SDS-MAC link + reg &= ~RTL930X_FORCE_EN; /* Clear MAC_FORCE_EN to allow SDS-MAC link */ else reg |= RTL930X_FORCE_EN; @@ -880,7 +880,7 @@ static void rtl83xx_phylink_mac_link_down(struct dsa_switch *ds, int port, /* Stop TX/RX to port */ sw_w32_mask(0x3, 0, priv->r->mac_port_ctrl(port)); - // No longer force link + /* No longer force link */ sw_w32_mask(0x3, 0, priv->r->mac_force_mode_ctrl(port)); } @@ -894,7 +894,7 @@ static void rtl93xx_phylink_mac_link_down(struct dsa_switch *ds, int port, /* Stop TX/RX to port */ sw_w32_mask(0x3, 0, priv->r->mac_port_ctrl(port)); - // No longer force link + /* No longer force link */ if (priv->family_id == RTL9300_FAMILY_ID) v = RTL930X_FORCE_EN | RTL930X_FORCE_LINK_EN; else if (priv->family_id == RTL9310_FAMILY_ID) @@ -912,7 +912,7 @@ static void rtl83xx_phylink_mac_link_up(struct dsa_switch *ds, int port, struct rtl838x_switch_priv *priv = ds->priv; /* Restart TX/RX to port */ sw_w32_mask(0, 0x3, priv->r->mac_port_ctrl(port)); - // TODO: Set speed/duplex/pauses + /* TODO: Set speed/duplex/pauses */ } static void rtl93xx_phylink_mac_link_up(struct dsa_switch *ds, int port, @@ -926,7 +926,7 @@ static void rtl93xx_phylink_mac_link_up(struct dsa_switch *ds, int port, /* Restart TX/RX to port */ sw_w32_mask(0, 0x3, priv->r->mac_port_ctrl(port)); - // TODO: Set speed/duplex/pauses + /* TODO: Set speed/duplex/pauses */ } static void rtl83xx_get_strings(struct dsa_switch *ds, @@ -983,7 +983,7 @@ static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port) } set_bit(mc_group, priv->mc_group_bm); - mc_group++; // We cannot use group 0, as this is used for lookup miss flooding + mc_group++; /* We cannot use group 0, as this is used for lookup miss flooding */ portmask = BIT_ULL(port) | BIT_ULL(priv->cpu_port); priv->r->write_mcast_pmask(mc_group, portmask); @@ -1079,7 +1079,7 @@ static int rtl83xx_port_enable(struct dsa_switch *ds, int port, v |= priv->ports[port].pm; priv->r->traffic_set(port, v); - // TODO: Figure out if this is necessary + /* TODO: Figure out if this is necessary */ if (priv->family_id == RTL9300_FAMILY_ID) { sw_w32_mask(0, BIT(port), RTL930X_L2_PORT_SABLK_CTRL); sw_w32_mask(0, BIT(port), RTL930X_L2_PORT_DABLK_CTRL); @@ -1101,7 +1101,7 @@ static void rtl83xx_port_disable(struct dsa_switch *ds, int port) if (!dsa_is_user_port(ds, port)) return; - // BUG: This does not work on RTL931X + /* BUG: This does not work on RTL931X */ /* remove port from switch mask of CPU_PORT */ priv->r->traffic_disable(priv->cpu_port, port); store_mcgroups(priv, port); @@ -1589,7 +1589,7 @@ static int rtl83xx_find_l2_hash_entry(struct rtl838x_switch_priv *priv, u64 seed u64 entry; pr_debug("%s: using key %x, for seed %016llx\n", __func__, key, seed); - // 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); pr_debug("valid %d, mac %016llx\n", e->valid, ether_addr_to_u64(&e->mac[0])); @@ -1649,14 +1649,14 @@ static int rtl83xx_port_fdb_add(struct dsa_switch *ds, int port, idx = rtl83xx_find_l2_hash_entry(priv, seed, false, &e); - // Found an existing or empty entry + /* Found an existing or empty entry */ if (idx >= 0) { rtl83xx_setup_l2_uc_entry(&e, port, vid, mac); priv->r->write_l2_entry_using_hash(idx >> 2, idx & 0x3, &e); goto out; } - // Hash buckets full, try CAM + /* Hash buckets full, try CAM */ rtl83xx_find_l2_cam_entry(priv, seed, false, &e); if (idx >= 0) { @@ -1772,7 +1772,7 @@ static int rtl83xx_port_mdb_add(struct dsa_switch *ds, int port, idx = rtl83xx_find_l2_hash_entry(priv, seed, false, &e); - // Found an existing or empty entry + /* Found an existing or empty entry */ if (idx >= 0) { if (e.valid) { pr_debug("Found an existing entry %016llx, mc_group %d\n", @@ -1791,7 +1791,7 @@ static int rtl83xx_port_mdb_add(struct dsa_switch *ds, int port, goto out; } - // Hash buckets full, try CAM + /* Hash buckets full, try CAM */ rtl83xx_find_l2_cam_entry(priv, seed, false, &e); if (idx >= 0) { @@ -1865,7 +1865,7 @@ int rtl83xx_port_mdb_del(struct dsa_switch *ds, int port, } goto out; } - // TODO: Re-enable with a newer kernel: err = -ENOENT; + /* TODO: Re-enable with a newer kernel: err = -ENOENT; */ out: mutex_unlock(&priv->reg_mutex); @@ -2032,7 +2032,7 @@ static int rtl83xx_port_lag_change(struct dsa_switch *ds, int port) struct rtl838x_switch_priv *priv = ds->priv; pr_debug("%s: %d\n", __func__, port); - // Nothing to be done... + /* Nothing to be done... */ return 0; } diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/qos.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/qos.c index 8a2621fb28..59d043581b 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/qos.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/qos.c @@ -47,7 +47,7 @@ static void rtl839x_read_out_q_table(int port) static void rtl838x_storm_enable(struct rtl838x_switch_priv *priv, int port, bool enable) { - // Enable Storm control for that port for UC, MC, and BC + /* Enable Storm control for that port for UC, MC, and BC */ if (enable) sw_w32(0x7, RTL838X_STORM_CTRL_LB_CTRL(port)); else @@ -96,24 +96,24 @@ static void rtl838x_rate_control_init(struct rtl838x_switch_priv *priv) int i; pr_info("Enabling Storm control\n"); - // TICK_PERIOD_PPS + /* TICK_PERIOD_PPS */ if (priv->id == 0x8380) sw_w32_mask(0x3ff << 20, 434 << 20, RTL838X_SCHED_LB_TICK_TKN_CTRL_0); - // Set burst rate - sw_w32(0x00008000, RTL838X_STORM_CTRL_BURST_0); // UC - sw_w32(0x80008000, RTL838X_STORM_CTRL_BURST_1); // MC and BC + /* Set burst rate */ + sw_w32(0x00008000, RTL838X_STORM_CTRL_BURST_0); /* UC */ + sw_w32(0x80008000, RTL838X_STORM_CTRL_BURST_1); /* MC and BC */ - // Set burst Packets per Second to 32 - sw_w32(0x00000020, RTL838X_STORM_CTRL_BURST_PPS_0); // UC - sw_w32(0x00200020, RTL838X_STORM_CTRL_BURST_PPS_1); // MC and BC + /* Set burst Packets per Second to 32 */ + sw_w32(0x00000020, RTL838X_STORM_CTRL_BURST_PPS_0); /* UC */ + sw_w32(0x00200020, RTL838X_STORM_CTRL_BURST_PPS_1); /* MC and BC */ - // Include IFG in storm control, rate based on bytes/s (0 = packets) + /* Include IFG in storm control, rate based on bytes/s (0 = packets) */ sw_w32_mask(0, 1 << 6 | 1 << 5, RTL838X_STORM_CTRL); - // Bandwidth control includes preamble and IFG (10 Bytes) + /* Bandwidth control includes preamble and IFG (10 Bytes) */ sw_w32_mask(0, 1, RTL838X_SCHED_CTRL); - // On SoCs except RTL8382M, set burst size of port egress + /* On SoCs except RTL8382M, set burst size of port egress */ if (priv->id != 0x8382) sw_w32_mask(0xffff, 0x800, RTL838X_SCHED_LB_THR); @@ -129,14 +129,14 @@ static void rtl838x_rate_control_init(struct rtl838x_switch_priv *priv) } } - // Attack prevention, enable all attack prevention measures - //sw_w32(0x1ffff, RTL838X_ATK_PRVNT_CTRL); + /* Attack prevention, enable all attack prevention measures */ + /* sw_w32(0x1ffff, RTL838X_ATK_PRVNT_CTRL); */ /* Attack prevention, drop (bit = 0) problematic packets on all ports. * Setting bit = 1 means: trap to CPU */ - //sw_w32(0, RTL838X_ATK_PRVNT_ACT); - // Enable attack prevention on all ports - //sw_w32(0x0fffffff, RTL838X_ATK_PRVNT_PORT_EN); + /* sw_w32(0, RTL838X_ATK_PRVNT_ACT); */ + /* Enable attack prevention on all ports */ + /* sw_w32(0x0fffffff, RTL838X_ATK_PRVNT_PORT_EN); */ } /* Sets the rate limit, 10MBit/s is equal to a rate value of 625 */ @@ -228,21 +228,21 @@ static void rtl839x_rate_control_init(struct rtl838x_switch_priv *priv) /* Tick length and token size settings for SoC with 250MHz, * RTL8350 family would use 50MHz */ - // Set the special tick period + /* Set the special tick period */ sw_w32(976563, RTL839X_STORM_CTRL_SPCL_LB_TICK_TKN_CTRL); - // Ingress tick period and token length 10G + /* Ingress tick period and token length 10G */ sw_w32(18 << 11 | 151, RTL839X_IGR_BWCTRL_LB_TICK_TKN_CTRL_0); - // Ingress tick period and token length 1G + /* Ingress tick period and token length 1G */ sw_w32(245 << 11 | 129, RTL839X_IGR_BWCTRL_LB_TICK_TKN_CTRL_1); - // Egress tick period 10G, bytes/token 10G and tick period 1G, bytes/token 1G + /* Egress tick period 10G, bytes/token 10G and tick period 1G, bytes/token 1G */ sw_w32(18 << 24 | 151 << 16 | 185 << 8 | 97, RTL839X_SCHED_LB_TICK_TKN_CTRL); - // Set the tick period of the CPU and the Token Len + /* Set the tick period of the CPU and the Token Len */ sw_w32(3815 << 8 | 1, RTL839X_SCHED_LB_TICK_TKN_PPS_CTRL); - // Set the Weighted Fair Queueing burst size + /* Set the Weighted Fair Queueing burst size */ sw_w32_mask(0xffff, 4500, RTL839X_SCHED_LB_THR); - // Storm-rate calculation is based on bytes/sec (bit 5), include IFG (bit 6) + /* Storm-rate calculation is based on bytes/sec (bit 5), include IFG (bit 6) */ sw_w32_mask(0, 1 << 5 | 1 << 6, RTL839X_STORM_CTRL); /* Based on the rate control mode being bytes/s @@ -270,24 +270,24 @@ static void rtl839x_rate_control_init(struct rtl838x_switch_priv *priv) continue; if (priv->ports[p].is10G) - rtl839x_set_egress_rate(priv, p, 625000); // 10GB/s + rtl839x_set_egress_rate(priv, p, 625000); /* 10GB/s */ else - rtl839x_set_egress_rate(priv, p, 62500); // 1GB/s + rtl839x_set_egress_rate(priv, p, 62500); /* 1GB/s */ - // Setup queues: all RTL83XX SoCs have 8 queues, maximum rate + /* Setup queues: all RTL83XX SoCs have 8 queues, maximum rate */ for (q = 0; q < 8; q++) rtl839x_egress_rate_queue_limit(priv, p, q, 0xfffff); if (priv->ports[p].is10G) { - // Set high threshold to maximum + /* Set high threshold to maximum */ sw_w32_mask(0xffff, 0xffff, RTL839X_IGR_BWCTRL_PORT_CTRL_10G_0(p)); } else { - // Set high threshold to maximum + /* Set high threshold to maximum */ sw_w32_mask(0xffff, 0xffff, RTL839X_IGR_BWCTRL_PORT_CTRL_1(p)); } } - // Set global ingress low watermark rate + /* Set global ingress low watermark rate */ sw_w32(65532, RTL839X_IGR_BWCTRL_CTRL_LB_THR); } @@ -382,24 +382,24 @@ void rtl839x_set_scheduling_algorithm(struct rtl838x_switch_priv *priv, int port mutex_lock(&priv->reg_mutex); /* Check whether we need to empty the egress queue of that port due to Errata E0014503 */ if (sched == WEIGHTED_FAIR_QUEUE && t == WEIGHTED_ROUND_ROBIN && port != priv->cpu_port) { - // Read Operations, Adminstatrion and Management control register + /* Read Operations, Adminstatrion and Management control register */ oam_state = sw_r32(RTL839X_OAM_CTRL); - // Get current OAM state + /* Get current OAM state */ oam_port_state = sw_r32(RTL839X_OAM_PORT_ACT_CTRL(port)); - // Disable OAM to block traffice + /* Disable OAM to block traffice */ v = sw_r32(RTL839X_OAM_CTRL); sw_w32_mask(0, 1, RTL839X_OAM_CTRL); v = sw_r32(RTL839X_OAM_CTRL); - // Set to trap action OAM forward (bits 1, 2) and OAM Mux Action Drop (bit 0) + /* Set to trap action OAM forward (bits 1, 2) and OAM Mux Action Drop (bit 0) */ sw_w32(0x2, RTL839X_OAM_PORT_ACT_CTRL(port)); - // Set port egress rate to unlimited + /* Set port egress rate to unlimited */ egress_rate = rtl839x_set_egress_rate(priv, port, 0xFFFFF); - // Wait until the egress used page count of that port is 0 + /* Wait until the egress used page count of that port is 0 */ i = 0; do { usleep_range(100, 200); @@ -410,19 +410,19 @@ void rtl839x_set_scheduling_algorithm(struct rtl838x_switch_priv *priv, int port } while (i < 3500 && count > 0); } - // Actually set the scheduling algorithm + /* Actually set the scheduling algorithm */ rtl839x_read_scheduling_table(port); sw_w32_mask(BIT(19), sched ? BIT(19) : 0, RTL839X_TBL_ACCESS_DATA_2(8)); rtl839x_write_scheduling_table(port); if (sched == WEIGHTED_FAIR_QUEUE && t == WEIGHTED_ROUND_ROBIN && port != priv->cpu_port) { - // Restore OAM state to control register + /* Restore OAM state to control register */ sw_w32(oam_state, RTL839X_OAM_CTRL); - // Restore trap action state + /* Restore trap action state */ sw_w32(oam_port_state, RTL839X_OAM_PORT_ACT_CTRL(port)); - // Restore port egress rate + /* Restore port egress rate */ rtl839x_set_egress_rate(priv, port, egress_rate); } @@ -463,7 +463,7 @@ void rtl838x_config_qos(void) pr_info("RTL838X_PRI_SEL_TBL_CTRL(i): %08x\n", sw_r32(RTL838X_PRI_SEL_TBL_CTRL(0))); rtl83xx_setup_default_prio2queue(); - // Enable inner (bit 12) and outer (bit 13) priority remapping from DSCP + /* Enable inner (bit 12) and outer (bit 13) priority remapping from DSCP */ sw_w32_mask(0, BIT(12) | BIT(13), RTL838X_PRI_DSCP_INVLD_CTRL0); /* Set default weight for calculating internal priority, in prio selection group 0 @@ -472,7 +472,7 @@ void rtl838x_config_qos(void) v = 3 | (4 << 3) | (5 << 6) | (6 << 9) | (7 << 12); sw_w32(v, RTL838X_PRI_SEL_TBL_CTRL(0)); - // Set the inner and outer priority one-to-one to re-marked outer dot1p priority + /* Set the inner and outer priority one-to-one to re-marked outer dot1p priority */ v = 0; for (p = 0; p < 8; p++) v |= p << (3 * p); @@ -484,19 +484,19 @@ void rtl838x_config_qos(void) v |= (dot1p_priority_remapping[p] & 0x7) << (p * 3); sw_w32(v, RTL838X_PRI_SEL_IPRI_REMAP); - // On all ports set scheduler type to WFQ + /* On all ports set scheduler type to WFQ */ for (i = 0; i <= soc_info.cpu_port; i++) sw_w32(0, RTL838X_SCHED_P_TYPE_CTRL(i)); - // Enable egress scheduler for CPU-Port + /* Enable egress scheduler for CPU-Port */ sw_w32_mask(0, BIT(8), RTL838X_SCHED_LB_CTRL(soc_info.cpu_port)); - // Enable egress drop allways on + /* Enable egress drop allways on */ sw_w32_mask(0, BIT(11), RTL838X_FC_P_EGR_DROP_CTRL(soc_info.cpu_port)); - // Give special trap frames priority 7 (BPDUs) and routing exceptions: + /* Give special trap frames priority 7 (BPDUs) and routing exceptions: */ sw_w32_mask(0, 7 << 3 | 7, RTL838X_QM_PKT2CPU_INTPRI_2); - // Give RMA frames priority 7: + /* Give RMA frames priority 7: */ sw_w32_mask(0, 7, RTL838X_QM_PKT2CPU_INTPRI_1); } @@ -513,18 +513,18 @@ void rtl839x_config_qos(void) for (port = 0; port < soc_info.cpu_port; port++) sw_w32(7, RTL839X_QM_PORT_QNUM(port)); - // CPU-port gets queue number 7 + /* CPU-port gets queue number 7 */ sw_w32(7, RTL839X_QM_PORT_QNUM(soc_info.cpu_port)); for (port = 0; port <= soc_info.cpu_port; port++) { rtl83xx_set_ingress_priority(port, 0); rtl839x_set_scheduling_algorithm(priv, port, WEIGHTED_FAIR_QUEUE); rtl839x_set_scheduling_queue_weights(priv, port, default_queue_weights); - // Do re-marking based on outer tag + /* Do re-marking based on outer tag */ sw_w32_mask(0, BIT(port % 32), RTL839X_RMK_PORT_DEI_TAG_CTRL(port)); } - // Remap dot1p priorities to internal priority, for this the outer tag needs be re-marked + /* Remap dot1p priorities to internal priority, for this the outer tag needs be re-marked */ v = 0; for (p = 0; p < 8; p++) v |= (dot1p_priority_remapping[p] & 0x7) << (p * 3); @@ -537,7 +537,7 @@ void rtl839x_config_qos(void) */ sw_w32(2 << 2, RTL839X_PRI_SEL_DEI2DP_REMAP); - // Re-mark DEI: 4 bit-fields of 2 bits each, field 0 is bits 0-1, ... + /* Re-mark DEI: 4 bit-fields of 2 bits each, field 0 is bits 0-1, ... */ sw_w32((0x1 << 2) | (0x1 << 4), RTL839X_RMK_DEI_CTRL); /* Set Congestion avoidance drop probability to 0 for drop precedences 0-2 (bits 24-31) diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c index bd24b4e0ac..124cd56478 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c @@ -24,54 +24,54 @@ extern struct mutex smi_lock; -// see_dal_maple_acl_log2PhyTmplteField and src/app/diag_v2/src/diag_acl.c +/* see_dal_maple_acl_log2PhyTmplteField and src/app/diag_v2/src/diag_acl.c */ /* Definition of the RTL838X-specific template field IDs as used in the PIE */ enum template_field_id { TEMPLATE_FIELD_SPMMASK = 0, - TEMPLATE_FIELD_SPM0 = 1, // Source portmask ports 0-15 - TEMPLATE_FIELD_SPM1 = 2, // Source portmask ports 16-28 + TEMPLATE_FIELD_SPM0 = 1, /* Source portmask ports 0-15 */ + TEMPLATE_FIELD_SPM1 = 2, /* Source portmask ports 16-28 */ TEMPLATE_FIELD_RANGE_CHK = 3, - TEMPLATE_FIELD_DMAC0 = 4, // Destination MAC [15:0] - TEMPLATE_FIELD_DMAC1 = 5, // Destination MAC [31:16] - TEMPLATE_FIELD_DMAC2 = 6, // Destination MAC [47:32] - TEMPLATE_FIELD_SMAC0 = 7, // Source MAC [15:0] - TEMPLATE_FIELD_SMAC1 = 8, // Source MAC [31:16] - TEMPLATE_FIELD_SMAC2 = 9, // Source MAC [47:32] - TEMPLATE_FIELD_ETHERTYPE = 10, // Ethernet typ - TEMPLATE_FIELD_OTAG = 11, // Outer VLAN tag - TEMPLATE_FIELD_ITAG = 12, // Inner VLAN tag - TEMPLATE_FIELD_SIP0 = 13, // IPv4 or IPv6 source IP[15:0] or ARP/RARP - // source protocol address in header - TEMPLATE_FIELD_SIP1 = 14, // IPv4 or IPv6 source IP[31:16] or ARP/RARP - TEMPLATE_FIELD_DIP0 = 15, // IPv4 or IPv6 destination IP[15:0] - TEMPLATE_FIELD_DIP1 = 16, // IPv4 or IPv6 destination IP[31:16] - TEMPLATE_FIELD_IP_TOS_PROTO = 17, // IPv4 TOS/IPv6 traffic class and - // IPv4 proto/IPv6 next header fields - TEMPLATE_FIELD_L34_HEADER = 18, // packet with extra tag and IPv6 with auth, dest, - // frag, route, hop-by-hop option header, - // IGMP type, TCP flag - TEMPLATE_FIELD_L4_SPORT = 19, // TCP/UDP source port - TEMPLATE_FIELD_L4_DPORT = 20, // TCP/UDP destination port + TEMPLATE_FIELD_DMAC0 = 4, /* Destination MAC [15:0] */ + TEMPLATE_FIELD_DMAC1 = 5, /* Destination MAC [31:16] */ + TEMPLATE_FIELD_DMAC2 = 6, /* Destination MAC [47:32] */ + TEMPLATE_FIELD_SMAC0 = 7, /* Source MAC [15:0] */ + TEMPLATE_FIELD_SMAC1 = 8, /* Source MAC [31:16] */ + TEMPLATE_FIELD_SMAC2 = 9, /* Source MAC [47:32] */ + TEMPLATE_FIELD_ETHERTYPE = 10, /* Ethernet typ */ + TEMPLATE_FIELD_OTAG = 11, /* Outer VLAN tag */ + TEMPLATE_FIELD_ITAG = 12, /* Inner VLAN tag */ + TEMPLATE_FIELD_SIP0 = 13, /* IPv4 or IPv6 source IP[15:0] or ARP/RARP */ + /* source protocol address in header */ + TEMPLATE_FIELD_SIP1 = 14, /* IPv4 or IPv6 source IP[31:16] or ARP/RARP */ + TEMPLATE_FIELD_DIP0 = 15, /* IPv4 or IPv6 destination IP[15:0] */ + TEMPLATE_FIELD_DIP1 = 16, /* IPv4 or IPv6 destination IP[31:16] */ + TEMPLATE_FIELD_IP_TOS_PROTO = 17, /* IPv4 TOS/IPv6 traffic class and */ + /* IPv4 proto/IPv6 next header fields */ + TEMPLATE_FIELD_L34_HEADER = 18, /* packet with extra tag and IPv6 with auth, dest, */ + /* frag, route, hop-by-hop option header, */ + /* IGMP type, TCP flag */ + TEMPLATE_FIELD_L4_SPORT = 19, /* TCP/UDP source port */ + TEMPLATE_FIELD_L4_DPORT = 20, /* TCP/UDP destination port */ TEMPLATE_FIELD_ICMP_IGMP = 21, TEMPLATE_FIELD_IP_RANGE = 22, - TEMPLATE_FIELD_FIELD_SELECTOR_VALID = 23, // Field selector mask + TEMPLATE_FIELD_FIELD_SELECTOR_VALID = 23, /* Field selector mask */ TEMPLATE_FIELD_FIELD_SELECTOR_0 = 24, TEMPLATE_FIELD_FIELD_SELECTOR_1 = 25, TEMPLATE_FIELD_FIELD_SELECTOR_2 = 26, TEMPLATE_FIELD_FIELD_SELECTOR_3 = 27, - TEMPLATE_FIELD_SIP2 = 28, // IPv6 source IP[47:32] - TEMPLATE_FIELD_SIP3 = 29, // IPv6 source IP[63:48] - TEMPLATE_FIELD_SIP4 = 30, // IPv6 source IP[79:64] - TEMPLATE_FIELD_SIP5 = 31, // IPv6 source IP[95:80] - TEMPLATE_FIELD_SIP6 = 32, // IPv6 source IP[111:96] - TEMPLATE_FIELD_SIP7 = 33, // IPv6 source IP[127:112] - TEMPLATE_FIELD_DIP2 = 34, // IPv6 destination IP[47:32] - TEMPLATE_FIELD_DIP3 = 35, // IPv6 destination IP[63:48] - TEMPLATE_FIELD_DIP4 = 36, // IPv6 destination IP[79:64] - TEMPLATE_FIELD_DIP5 = 37, // IPv6 destination IP[95:80] - TEMPLATE_FIELD_DIP6 = 38, // IPv6 destination IP[111:96] - TEMPLATE_FIELD_DIP7 = 39, // IPv6 destination IP[127:112] - TEMPLATE_FIELD_FWD_VID = 40, // Forwarding VLAN-ID + TEMPLATE_FIELD_SIP2 = 28, /* IPv6 source IP[47:32] */ + TEMPLATE_FIELD_SIP3 = 29, /* IPv6 source IP[63:48] */ + TEMPLATE_FIELD_SIP4 = 30, /* IPv6 source IP[79:64] */ + TEMPLATE_FIELD_SIP5 = 31, /* IPv6 source IP[95:80] */ + TEMPLATE_FIELD_SIP6 = 32, /* IPv6 source IP[111:96] */ + TEMPLATE_FIELD_SIP7 = 33, /* IPv6 source IP[127:112] */ + TEMPLATE_FIELD_DIP2 = 34, /* IPv6 destination IP[47:32] */ + TEMPLATE_FIELD_DIP3 = 35, /* IPv6 destination IP[63:48] */ + TEMPLATE_FIELD_DIP4 = 36, /* IPv6 destination IP[79:64] */ + TEMPLATE_FIELD_DIP5 = 37, /* IPv6 destination IP[95:80] */ + TEMPLATE_FIELD_DIP6 = 38, /* IPv6 destination IP[111:96] */ + TEMPLATE_FIELD_DIP7 = 39, /* IPv6 destination IP[127:112] */ + TEMPLATE_FIELD_FWD_VID = 40, /* Forwarding VLAN-ID */ TEMPLATE_FIELD_FLOW_LABEL = 41, }; @@ -151,7 +151,7 @@ static inline int rtl838x_tbl_access_data_0(int i) static void rtl838x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info) { u32 v; - // Read VLAN table (0) via register 0 + /* Read VLAN table (0) via register 0 */ struct table_reg *r = rtl_table_get(RTL8380_TBL_0, 0); rtl_table_read(r, vlan); @@ -165,7 +165,7 @@ static void rtl838x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info) info->hash_uc_fid = !!(v & 0x10); info->fid = (v >> 5) & 0x3f; - // Read UNTAG table (0) via table register 1 + /* Read UNTAG table (0) via table register 1 */ r = rtl_table_get(RTL8380_TBL_1, 0); rtl_table_read(r, vlan); info->untagged_ports = sw_r32(rtl_table_data(r, 0)); @@ -175,7 +175,7 @@ static void rtl838x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info) static void rtl838x_vlan_set_tagged(u32 vlan, struct rtl838x_vlan_info *info) { u32 v; - // Access VLAN table (0) via register 0 + /* Access VLAN table (0) via register 0 */ struct table_reg *r = rtl_table_get(RTL8380_TBL_0, 0); sw_w32(info->tagged_ports, rtl_table_data(r, 0)); @@ -192,7 +192,7 @@ static void rtl838x_vlan_set_tagged(u32 vlan, struct rtl838x_vlan_info *info) static void rtl838x_vlan_set_untagged(u32 vlan, u64 portmask) { - // Access UNTAG table (0) via register 1 + /* Access UNTAG table (0) via register 1 */ struct table_reg *r = rtl_table_get(RTL8380_TBL_1, 0); sw_w32(portmask & 0x1fffffff, rtl_table_data(r, 0)); @@ -320,13 +320,13 @@ static void rtl838x_fill_l2_entry(u32 r[], struct rtl838x_l2_entry *e) e->valid = false; else e->type = L2_UNICAST; - } else { // L2 multicast + } else { /* L2 multicast */ pr_debug("Got L2 MC entry: %08x %08x %08x\n", r[0], r[1], r[2]); e->valid = true; e->type = L2_MULTICAST; e->mc_portmask_index = (r[0] >> 12) & 0x1ff; } - } else { // IPv4 and IPv6 multicast + } else { /* IPv4 and IPv6 multicast */ e->valid = true; e->mc_portmask_index = (r[0] >> 12) & 0x1ff; e->mc_gip = (r[1] << 20) | (r[2] >> 12); @@ -370,13 +370,13 @@ static void rtl838x_fill_l2_row(u32 r[], struct rtl838x_l2_entry *e) r[0] |= e->nh_route_id & 0x1ff; } r[0] |= (e->age & 0x3) << 17; - } else { // L2 Multicast + } else { /* L2 Multicast */ r[0] |= (e->mc_portmask_index & 0x1ff) << 12; r[2] |= e->rvid & 0xfff; r[0] |= e->vid & 0xfff; pr_debug("FILL MC: %08x %08x %08x\n", r[0], r[1], r[2]); } - } else { // IPv4 and IPv6 multicast + } else { /* IPv4 and IPv6 multicast */ r[0] |= (e->mc_portmask_index & 0x1ff) << 12; r[1] = e->mc_gip >> 20; r[2] = e->mc_gip << 12; @@ -391,8 +391,8 @@ static void rtl838x_fill_l2_row(u32 r[], struct rtl838x_l2_entry *e) static u64 rtl838x_read_l2_entry_using_hash(u32 hash, u32 pos, struct rtl838x_l2_entry *e) { u32 r[3]; - struct table_reg *q = rtl_table_get(RTL8380_TBL_L2, 0); // Access L2 Table 0 - u32 idx = (0 << 14) | (hash << 2) | pos; // Search SRAM, with hash and at pos in bucket + struct table_reg *q = rtl_table_get(RTL8380_TBL_L2, 0); /* Access L2 Table 0 */ + u32 idx = (0 << 14) | (hash << 2) | pos; /* Search SRAM, with hash and at pos in bucket */ int i; rtl_table_read(q, idx); @@ -405,7 +405,7 @@ static u64 rtl838x_read_l2_entry_using_hash(u32 hash, u32 pos, struct rtl838x_l2 if (!e->valid) return 0; - return (((u64) r[1]) << 32) | (r[2]); // mac and vid concatenated as hash seed + return (((u64) r[1]) << 32) | (r[2]); /* mac and vid concatenated as hash seed */ } static void rtl838x_write_l2_entry_using_hash(u32 hash, u32 pos, struct rtl838x_l2_entry *e) @@ -414,7 +414,7 @@ static void rtl838x_write_l2_entry_using_hash(u32 hash, u32 pos, struct rtl838x_ struct table_reg *q = rtl_table_get(RTL8380_TBL_L2, 0); int i; - u32 idx = (0 << 14) | (hash << 2) | pos; // Access SRAM, with hash and at pos in bucket + u32 idx = (0 << 14) | (hash << 2) | pos; /* Access SRAM, with hash and at pos in bucket */ rtl838x_fill_l2_row(r, e); @@ -428,7 +428,7 @@ static void rtl838x_write_l2_entry_using_hash(u32 hash, u32 pos, struct rtl838x_ static u64 rtl838x_read_cam(int idx, struct rtl838x_l2_entry *e) { u32 r[3]; - struct table_reg *q = rtl_table_get(RTL8380_TBL_L2, 1); // Access L2 Table 1 + struct table_reg *q = rtl_table_get(RTL8380_TBL_L2, 1); /* Access L2 Table 1 */ int i; rtl_table_read(q, idx); @@ -443,14 +443,14 @@ static u64 rtl838x_read_cam(int idx, struct rtl838x_l2_entry *e) pr_debug("Found in CAM: R1 %x R2 %x R3 %x\n", r[0], r[1], r[2]); - // Return MAC with concatenated VID ac concatenated ID + /* Return MAC with concatenated VID ac concatenated ID */ return (((u64) r[1]) << 32) | r[2]; } static void rtl838x_write_cam(int idx, struct rtl838x_l2_entry *e) { u32 r[3]; - struct table_reg *q = rtl_table_get(RTL8380_TBL_L2, 1); // Access L2 Table 1 + struct table_reg *q = rtl_table_get(RTL8380_TBL_L2, 1); /* Access L2 Table 1 */ int i; rtl838x_fill_l2_row(r, e); @@ -465,7 +465,7 @@ static void rtl838x_write_cam(int idx, struct rtl838x_l2_entry *e) static u64 rtl838x_read_mcast_pmask(int idx) { u32 portmask; - // Read MC_PMSK (2) via register RTL8380_TBL_L2 + /* Read MC_PMSK (2) via register RTL8380_TBL_L2 */ struct table_reg *q = rtl_table_get(RTL8380_TBL_L2, 2); rtl_table_read(q, idx); @@ -477,7 +477,7 @@ static u64 rtl838x_read_mcast_pmask(int idx) static void rtl838x_write_mcast_pmask(int idx, u64 portmask) { - // Access MC_PMSK (2) via register RTL8380_TBL_L2 + /* Access MC_PMSK (2) via register RTL8380_TBL_L2 */ struct table_reg *q = rtl_table_get(RTL8380_TBL_L2, 2); sw_w32(((u32)portmask) & 0x1fffffff, rtl_table_data(q, 0)); @@ -488,7 +488,7 @@ static void rtl838x_write_mcast_pmask(int idx, u64 portmask) static void rtl838x_vlan_profile_setup(int profile) { u32 pmask_id = UNKNOWN_MC_PMASK; - // Enable L2 Learning BIT 0, portmask UNKNOWN_MC_PMASK for unknown MC traffic flooding + /* Enable L2 Learning BIT 0, portmask UNKNOWN_MC_PMASK for unknown MC traffic flooding */ u32 p = 1 | pmask_id << 1 | pmask_id << 10 | pmask_id << 19; sw_w32(p, RTL838X_VLAN_PROFILE(profile)); @@ -512,16 +512,16 @@ static void rtl838x_l2_learning_setup(void) * and per vlan (bit 2) */ sw_w32(0x7, RTL838X_L2_LRN_CONSTRT_EN); - // Limit learning to maximum: 16k entries, after that just flood (bits 0-1) + /* Limit learning to maximum: 16k entries, after that just flood (bits 0-1) */ sw_w32((0x3fff << 2) | 0, RTL838X_L2_LRN_CONSTRT); - // Do not trap ARP packets to CPU_PORT + /* Do not trap ARP packets to CPU_PORT */ sw_w32(0, RTL838X_SPCL_TRAP_ARP_CTRL); } static void rtl838x_enable_learning(int port, bool enable) { - // Limit learning to maximum: 16k entries + /* Limit learning to maximum: 16k entries */ sw_w32_mask(0x3fff << 2, enable ? (0x3fff << 2) : 0, RTL838X_L2_PORT_LRN_CONSTRT + (port << 2)); @@ -599,17 +599,17 @@ static void rtl838x_port_eee_set(struct rtl838x_switch_priv *priv, int port, boo { u32 v; - // This works only for Ethernet ports, and on the RTL838X, ports from 24 are SFP + /* This works only for Ethernet ports, and on the RTL838X, ports from 24 are SFP */ if (port >= 24) return; pr_debug("In %s: setting port %d to %d\n", __func__, port, enable); v = enable ? 0x3 : 0x0; - // Set EEE state for 100 (bit 9) & 1000MBit (bit 10) + /* Set EEE state for 100 (bit 9) & 1000MBit (bit 10) */ sw_w32_mask(0x3 << 9, v << 9, priv->r->mac_force_mode_ctrl(port)); - // Set TX/RX EEE state + /* Set TX/RX EEE state */ if (enable) { sw_w32_mask(0, BIT(port), RTL838X_EEE_PORT_TX_EN); sw_w32_mask(0, BIT(port), RTL838X_EEE_PORT_RX_EN); @@ -660,7 +660,7 @@ static void rtl838x_init_eee(struct rtl838x_switch_priv *priv, bool enable) sw_w32(0x5001411, RTL838X_EEE_TX_TIMER_GIGA_CTRL); sw_w32(0x5001417, RTL838X_EEE_TX_TIMER_GELITE_CTRL); - // Enable EEE MAC support on ports + /* Enable EEE MAC support on ports */ for (i = 0; i < priv->cpu_port; i++) { if (priv->ports[i].phy) rtl838x_port_eee_set(priv, i, enable); @@ -673,7 +673,7 @@ static void rtl838x_pie_lookup_enable(struct rtl838x_switch_priv *priv, int inde int block = index / PIE_BLOCK_SIZE; u32 block_state = sw_r32(RTL838X_ACL_BLK_LOOKUP_CTRL); - // Make sure rule-lookup is enabled in the block + /* Make sure rule-lookup is enabled in the block */ if (!(block_state & BIT(block))) sw_w32(block_state | BIT(block), RTL838X_ACL_BLK_LOOKUP_CTRL); } @@ -689,23 +689,23 @@ static void rtl838x_pie_rule_del(struct rtl838x_switch_priv *priv, int index_fro pr_debug("%s: from %d to %d\n", __func__, index_from, index_to); mutex_lock(&priv->reg_mutex); - // Remember currently active blocks + /* Remember currently active blocks */ block_state = sw_r32(RTL838X_ACL_BLK_LOOKUP_CTRL); - // Make sure rule-lookup is disabled in the relevant blocks + /* Make sure rule-lookup is disabled in the relevant blocks */ for (block = block_from; block <= block_to; block++) { if (block_state & BIT(block)) sw_w32(block_state & (~BIT(block)), RTL838X_ACL_BLK_LOOKUP_CTRL); } - // Write from-to and execute bit into control register + /* Write from-to and execute bit into control register */ sw_w32(v, RTL838X_ACL_CLR_CTRL); - // Wait until command has completed + /* Wait until command has completed */ do { } while (sw_r32(RTL838X_ACL_CLR_CTRL) & BIT(0)); - // Re-enable rule lookup + /* Re-enable rule lookup */ for (block = block_from; block <= block_to; block++) { if (!(block_state & BIT(block))) sw_w32(block_state | BIT(block), RTL838X_ACL_BLK_LOOKUP_CTRL); @@ -969,7 +969,7 @@ static void rtl838x_read_pie_templated(u32 r[], struct pie_rule *pr, enum templa break; case TEMPLATE_FIELD_SIP2: pr->is_ipv6 = true; - // Make use of limitiations on the position of the match values + /* Make use of limitiations on the position of the match values */ ipv6_addr_set(&pr->sip6, pr->sip, r[5 - i / 2], r[4 - i / 2], r[3 - i / 2]); ipv6_addr_set(&pr->sip6_m, pr->sip_m, r[5 - i / 2], @@ -1112,7 +1112,7 @@ static void rtl838x_write_pie_fixed_fields(u32 r[], struct pie_rule *pr) r[14] |= pr->ivalid ? BIT(27) : 0; if (pr->drop) - r[17] = 0x1 << 14; // Standard drop action + r[17] = 0x1 << 14; /* Standard drop action */ else r[17] = 0; r[17] |= pr->fwd_sel ? BIT(13) : 0; @@ -1145,8 +1145,8 @@ static int rtl838x_write_pie_action(u32 r[], struct pie_rule *pr) * defines which Action Information Field (0-4) in the IACL table stores * the additional data of the action (like e.g. the port number a packet is * forwarded to) */ - // TODO: count bits in selectors to limit to a maximum number of actions - if (pr->fwd_sel) { // Forwarding action + /* TODO: count bits in selectors to limit to a maximum number of actions */ + if (pr->fwd_sel) { /* Forwarding action */ data = pr->fwd_act << 13; data |= pr->fwd_data; data |= pr->bypass_all ? BIT(12) : 0; @@ -1156,89 +1156,89 @@ static int rtl838x_write_pie_action(u32 r[], struct pie_rule *pr) fields_used++; } - if (pr->ovid_sel) { // Outer VID action + if (pr->ovid_sel) { /* Outer VID action */ data = (pr->ovid_act & 0x3) << 12; data |= pr->ovid_data; *aif-- = data; fields_used++; } - if (pr->ivid_sel) { // Inner VID action + if (pr->ivid_sel) { /* Inner VID action */ data = (pr->ivid_act & 0x3) << 12; data |= pr->ivid_data; *aif-- = data; fields_used++; } - if (pr->flt_sel) { // Filter action + if (pr->flt_sel) { /* Filter action */ *aif-- = pr->flt_data; fields_used++; } - if (pr->log_sel) { // Log action + if (pr->log_sel) { /* Log action */ if (fields_used >= 4) return -1; *aif-- = pr->log_data; fields_used++; } - if (pr->rmk_sel) { // Remark action + if (pr->rmk_sel) { /* Remark action */ if (fields_used >= 4) return -1; *aif-- = pr->rmk_data; fields_used++; } - if (pr->meter_sel) { // Meter action + if (pr->meter_sel) { /* Meter action */ if (fields_used >= 4) return -1; *aif-- = pr->meter_data; fields_used++; } - if (pr->tagst_sel) { // Egress Tag Status action + if (pr->tagst_sel) { /* Egress Tag Status action */ if (fields_used >= 4) return -1; *aif-- = pr->tagst_data; fields_used++; } - if (pr->mir_sel) { // Mirror action + if (pr->mir_sel) { /* Mirror action */ if (fields_used >= 4) return -1; *aif-- = pr->mir_data; fields_used++; } - if (pr->nopri_sel) { // Normal Priority action + if (pr->nopri_sel) { /* Normal Priority action */ if (fields_used >= 4) return -1; *aif-- = pr->nopri_data; fields_used++; } - if (pr->cpupri_sel) { // CPU Priority action + if (pr->cpupri_sel) { /* CPU Priority action */ if (fields_used >= 4) return -1; *aif-- = pr->nopri_data; fields_used++; } - if (pr->otpid_sel) { // OTPID action + if (pr->otpid_sel) { /* OTPID action */ if (fields_used >= 4) return -1; *aif-- = pr->otpid_data; fields_used++; } - if (pr->itpid_sel) { // ITPID action + if (pr->itpid_sel) { /* ITPID action */ if (fields_used >= 4) return -1; *aif-- = pr->itpid_data; fields_used++; } - if (pr->shaper_sel) { // Traffic shaper action + if (pr->shaper_sel) { /* Traffic shaper action */ if (fields_used >= 4) return -1; *aif-- = pr->shaper_data; @@ -1258,7 +1258,7 @@ static void rtl838x_read_pie_action(u32 r[], struct pie_rule *pr) if (pr->drop) pr_debug("%s: Action Drop: %d", __func__, pr->drop); - if (pr->fwd_sel){ // Forwarding action + if (pr->fwd_sel){ /* Forwarding action */ pr->fwd_act = *aif >> 13; pr->fwd_data = *aif--; pr->bypass_all = pr->fwd_data & BIT(12); @@ -1267,31 +1267,31 @@ static void rtl838x_read_pie_action(u32 r[], struct pie_rule *pr) if (pr->bypass_all || pr->bypass_ibc_sc || pr->bypass_igr_stp) pr->bypass_sel = true; } - if (pr->ovid_sel) // Outer VID action + if (pr->ovid_sel) /* Outer VID action */ pr->ovid_data = *aif--; - if (pr->ivid_sel) // Inner VID action + if (pr->ivid_sel) /* Inner VID action */ pr->ivid_data = *aif--; - if (pr->flt_sel) // Filter action + if (pr->flt_sel) /* Filter action */ pr->flt_data = *aif--; - if (pr->log_sel) // Log action + if (pr->log_sel) /* Log action */ pr->log_data = *aif--; - if (pr->rmk_sel) // Remark action + if (pr->rmk_sel) /* Remark action */ pr->rmk_data = *aif--; - if (pr->meter_sel) // Meter action + if (pr->meter_sel) /* Meter action */ pr->meter_data = *aif--; - if (pr->tagst_sel) // Egress Tag Status action + if (pr->tagst_sel) /* Egress Tag Status action */ pr->tagst_data = *aif--; - if (pr->mir_sel) // Mirror action + if (pr->mir_sel) /* Mirror action */ pr->mir_data = *aif--; - if (pr->nopri_sel) // Normal Priority action + if (pr->nopri_sel) /* Normal Priority action */ pr->nopri_data = *aif--; - if (pr->cpupri_sel) // CPU Priority action + if (pr->cpupri_sel) /* CPU Priority action */ pr->nopri_data = *aif--; - if (pr->otpid_sel) // OTPID action + if (pr->otpid_sel) /* OTPID action */ pr->otpid_data = *aif--; - if (pr->itpid_sel) // ITPID action + if (pr->itpid_sel) /* ITPID action */ pr->itpid_data = *aif--; - if (pr->shaper_sel) // Traffic shaper action + if (pr->shaper_sel) /* Traffic shaper action */ pr->shaper_data = *aif--; } @@ -1318,7 +1318,7 @@ static void rtl838x_pie_rule_dump(struct pie_rule *pr) static int rtl838x_pie_rule_read(struct rtl838x_switch_priv *priv, int idx, struct pie_rule *pr) { - // Read IACL table (1) via register 0 + /* Read IACL table (1) via register 0 */ struct table_reg *q = rtl_table_get(RTL8380_TBL_0, 1); u32 r[18]; int i; @@ -1348,7 +1348,7 @@ static int rtl838x_pie_rule_read(struct rtl838x_switch_priv *priv, int idx, stru static int rtl838x_pie_rule_write(struct rtl838x_switch_priv *priv, int idx, struct pie_rule *pr) { - // Access IACL table (1) via register 0 + /* Access IACL table (1) via register 0 */ struct table_reg *q = rtl_table_get(RTL8380_TBL_0, 1); u32 r[18]; int i, err = 0; @@ -1373,7 +1373,7 @@ static int rtl838x_pie_rule_write(struct rtl838x_switch_priv *priv, int idx, str goto err_out; } -// rtl838x_pie_rule_dump_raw(r); +/* rtl838x_pie_rule_dump_raw(r); */ for (i = 0; i < 18; i++) sw_w32(r[i], rtl_table_data(q, i)); @@ -1431,7 +1431,7 @@ static int rtl838x_pie_verify_template(struct rtl838x_switch_priv *priv, if (ether_addr_to_u64(pr->dmac) && !rtl838x_pie_templ_has(t, TEMPLATE_FIELD_DMAC0)) return -1; - // TODO: Check more + /* TODO: Check more */ i = find_first_zero_bit(&priv->pie_use_bm[block * 4], PIE_BLOCK_SIZE); @@ -1470,7 +1470,7 @@ static int rtl838x_pie_rule_add(struct rtl838x_switch_priv *priv, struct pie_rul set_bit(idx, priv->pie_use_bm); pr->valid = true; - pr->tid = j; // Mapped to template number + pr->tid = j; /* Mapped to template number */ pr->tid_m = 0x3; pr->id = idx; @@ -1501,36 +1501,36 @@ static void rtl838x_pie_init(struct rtl838x_switch_priv *priv) mutex_init(&priv->pie_mutex); - // Enable ACL lookup on all ports, including CPU_PORT + /* Enable ACL lookup on all ports, including CPU_PORT */ for (i = 0; i <= priv->cpu_port; i++) sw_w32(1, RTL838X_ACL_PORT_LOOKUP_CTRL(i)); - // Power on all PIE blocks + /* Power on all PIE blocks */ for (i = 0; i < priv->n_pie_blocks; i++) sw_w32_mask(0, BIT(i), RTL838X_ACL_BLK_PWR_CTRL); - // Include IPG in metering + /* Include IPG in metering */ sw_w32(1, RTL838X_METER_GLB_CTRL); - // Delete all present rules + /* Delete all present rules */ rtl838x_pie_rule_del(priv, 0, priv->n_pie_blocks * PIE_BLOCK_SIZE - 1); - // Routing bypasses source port filter: disable write-protection, first + /* Routing bypasses source port filter: disable write-protection, first */ sw_w32_mask(0, 3, RTL838X_INT_RW_CTRL); sw_w32_mask(0, 1, RTL838X_DMY_REG27); sw_w32_mask(3, 0, RTL838X_INT_RW_CTRL); - // Enable predefined templates 0, 1 and 2 for even blocks + /* Enable predefined templates 0, 1 and 2 for even blocks */ template_selectors = 0 | (1 << 3) | (2 << 6); for (i = 0; i < 6; i += 2) sw_w32(template_selectors, RTL838X_ACL_BLK_TMPLTE_CTRL(i)); - // Enable predefined templates 0, 3 and 4 (IPv6 support) for odd blocks + /* Enable predefined templates 0, 3 and 4 (IPv6 support) for odd blocks */ template_selectors = 0 | (3 << 3) | (4 << 6); for (i = 1; i < priv->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 + /* Group each pair of physical blocks together to a logical block */ sw_w32(0b10101010101, RTL838X_ACL_BLK_GROUP_CTRL); } @@ -1538,7 +1538,7 @@ static u32 rtl838x_packet_cntr_read(int counter) { u32 v; - // Read LOG table (3) via register RTL8380_TBL_0 + /* Read LOG table (3) via register RTL8380_TBL_0 */ struct table_reg *r = rtl_table_get(RTL8380_TBL_0, 3); pr_debug("In %s, id %d\n", __func__, counter); @@ -1546,7 +1546,7 @@ static u32 rtl838x_packet_cntr_read(int counter) pr_debug("Registers: %08x %08x\n", sw_r32(rtl_table_data(r, 0)), sw_r32(rtl_table_data(r, 1))); - // The table has a size of 2 registers + /* The table has a size of 2 registers */ if (counter % 2) v = sw_r32(rtl_table_data(r, 0)); else @@ -1559,11 +1559,11 @@ static u32 rtl838x_packet_cntr_read(int counter) static void rtl838x_packet_cntr_clear(int counter) { - // Access LOG table (3) via register RTL8380_TBL_0 + /* Access LOG table (3) via register RTL8380_TBL_0 */ struct table_reg *r = rtl_table_get(RTL8380_TBL_0, 3); pr_debug("In %s, id %d\n", __func__, counter); - // The table has a size of 2 registers + /* The table has a size of 2 registers */ if (counter % 2) sw_w32(0, rtl_table_data(r, 0)); else @@ -1576,13 +1576,13 @@ static void rtl838x_packet_cntr_clear(int counter) static void rtl838x_route_read(int idx, struct rtl83xx_route *rt) { - // Read ROUTING table (2) via register RTL8380_TBL_1 + /* Read ROUTING table (2) via register RTL8380_TBL_1 */ struct table_reg *r = rtl_table_get(RTL8380_TBL_1, 2); pr_debug("In %s, id %d\n", __func__, idx); rtl_table_read(r, idx); - // The table has a size of 2 registers + /* The table has a size of 2 registers */ rt->nh.gw = sw_r32(rtl_table_data(r, 0)); rt->nh.gw <<= 32; rt->nh.gw |= sw_r32(rtl_table_data(r, 1)); @@ -1592,7 +1592,7 @@ static void rtl838x_route_read(int idx, struct rtl83xx_route *rt) static void rtl838x_route_write(int idx, struct rtl83xx_route *rt) { - // Access ROUTING table (2) via register RTL8380_TBL_1 + /* Access ROUTING table (2) via register RTL8380_TBL_1 */ struct table_reg *r = rtl_table_get(RTL8380_TBL_1, 2); pr_debug("In %s, id %d, gw: %016llx\n", __func__, idx, rt->nh.gw); @@ -1605,7 +1605,7 @@ static void rtl838x_route_write(int idx, struct rtl83xx_route *rt) static int rtl838x_l3_setup(struct rtl838x_switch_priv *priv) { - // Nothing to be done + /* Nothing to be done */ return 0; } @@ -1664,7 +1664,7 @@ static void rtl838x_set_egr_filter(int port, enum egr_filter state) void rtl838x_set_distribution_algorithm(int group, int algoidx, u32 algomsk) { - algoidx &= 1; // RTL838X only supports 2 concurrent algorithms + algoidx &= 1; /* RTL838X only supports 2 concurrent algorithms */ sw_w32_mask(1 << (group % 8), algoidx << (group % 8), RTL838X_TRK_HASH_IDX_CTRL + ((group >> 3) << 2)); sw_w32(algomsk, RTL838X_TRK_HASH_CTRL + (algoidx << 2)); diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h index 68a4675e11..a4bfc285a6 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h @@ -518,13 +518,13 @@ typedef enum { #define RTL930X_PIE_BLK_PHASE_CTRL (0xA5A4) #define RTL931X_PIE_BLK_PHASE_CTRL (0x4184) -// PIE actions +/* PIE actions */ #define PIE_ACT_COPY_TO_PORT 2 #define PIE_ACT_REDIRECT_TO_PORT 4 #define PIE_ACT_ROUTE_UC 6 #define PIE_ACT_VID_ASSIGN 0 -// L3 actions +/* L3 actions */ #define L3_FORWARD 0 #define L3_DROP 1 #define L3_TRAP2CPU 2 @@ -533,7 +533,7 @@ typedef enum { #define L3_COPY2MASTERCPU 5 #define L3_HARDDROP 6 -// Route actions +/* Route actions */ #define ROUTE_ACT_FORWARD 0 #define ROUTE_ACT_TRAP2CPU 1 #define ROUTE_ACT_COPY2CPU 2 @@ -631,10 +631,10 @@ struct rtl838x_vlan_info { u8 profile_id; bool hash_mc_fid; bool hash_uc_fid; - u8 fid; // AKA MSTI + u8 fid; /* AKA MSTI */ - // The following fields are used only by the RTL931X - int if_id; // Interface (index in L3_EGR_INTF_IDX) + /* The following fields are used only by the RTL931X */ + int if_id; /* Interface (index in L3_EGR_INTF_IDX) */ u16 multicast_grp_mask; int l2_tunnel_list_id; }; @@ -670,9 +670,9 @@ struct rtl838x_l2_entry { u32 mc_sip; u16 mc_mac_index; u16 nh_route_id; - bool nh_vlan_target; // Only RTL83xx: VLAN used for next hop + bool nh_vlan_target; /* Only RTL83xx: VLAN used for next hop */ - // The following is only valid on RTL931x + /* The following is only valid on RTL931x */ bool is_open_flow; bool is_pe_forward; bool is_local_forward; @@ -709,35 +709,35 @@ enum egr_filter { * to SoC family (e.g. because of different port ranges) */ struct pie_rule { int id; - enum pie_phase phase; // Phase in which this template is applied - int packet_cntr; // ID of a packet counter assigned to this rule - int octet_cntr; // ID of a byte counter assigned to this rule + enum pie_phase phase; /* Phase in which this template is applied */ + int packet_cntr; /* ID of a packet counter assigned to this rule */ + int octet_cntr; /* ID of a byte counter assigned to this rule */ u32 last_packet_cnt; u64 last_octet_cnt; - // The following are requirements for the pie template + /* The following are requirements for the pie template */ bool is_egress; - bool is_ipv6; // This is a rule with IPv6 fields + bool is_ipv6; /* This is a rule with IPv6 fields */ - // Fixed fields that are always matched against on RTL8380 + /* Fixed fields that are always matched against on RTL8380 */ u8 spmmask_fix; - u8 spn; // Source port number - bool stacking_port; // Source port is stacking port - bool mgnt_vlan; // Packet arrived on management VLAN - bool dmac_hit_sw; // The packet's destination MAC matches one of the device's - bool content_too_deep; // The content of the packet cannot be parsed: too many layers - bool not_first_frag; // Not the first IP fragment - u8 frame_type_l4; // 0: UDP, 1: TCP, 2: ICMP/ICMPv6, 3: IGMP - u8 frame_type; // 0: ARP, 1: L2 only, 2: IPv4, 3: IPv6 - bool otag_fmt; // 0: outer tag packet, 1: outer priority tag or untagged - bool itag_fmt; // 0: inner tag packet, 1: inner priority tag or untagged - bool otag_exist; // packet with outer tag - bool itag_exist; // packet with inner tag - bool frame_type_l2; // 0: Ethernet, 1: LLC_SNAP, 2: LLC_Other, 3: Reserved - bool igr_normal_port; // Ingress port is not cpu or stacking port - u8 tid; // The template ID defining the what the templated fields mean - - // Masks for the fields that are always matched against on RTL8380 + u8 spn; /* Source port number */ + bool stacking_port; /* Source port is stacking port */ + bool mgnt_vlan; /* Packet arrived on management VLAN */ + bool dmac_hit_sw; /* The packet's destination MAC matches one of the device's */ + bool content_too_deep; /* The content of the packet cannot be parsed: too many layers */ + bool not_first_frag; /* Not the first IP fragment */ + u8 frame_type_l4; /* 0: UDP, 1: TCP, 2: ICMP/ICMPv6, 3: IGMP */ + u8 frame_type; /* 0: ARP, 1: L2 only, 2: IPv4, 3: IPv6 */ + bool otag_fmt; /* 0: outer tag packet, 1: outer priority tag or untagged */ + bool itag_fmt; /* 0: inner tag packet, 1: inner priority tag or untagged */ + bool otag_exist; /* packet with outer tag */ + bool itag_exist; /* packet with inner tag */ + bool frame_type_l2; /* 0: Ethernet, 1: LLC_SNAP, 2: LLC_Other, 3: Reserved */ + bool igr_normal_port; /* Ingress port is not cpu or stacking port */ + u8 tid; /* The template ID defining the what the templated fields mean */ + + /* Masks for the fields that are always matched against on RTL8380 */ u8 spmmask_fix_m; u8 spn_m; bool stacking_port_m; @@ -755,52 +755,52 @@ struct pie_rule { bool igr_normal_port_m; u8 tid_m; - // Logical operations between rules, special rules for rule numbers apply + /* Logical operations between rules, special rules for rule numbers apply */ bool valid; - bool cond_not; // Matches when conditions not match - bool cond_and1; // And this rule 2n with the next rule 2n+1 in same block - bool cond_and2; // And this rule m in block 2n with rule m in block 2n+1 + bool cond_not; /* Matches when conditions not match */ + bool cond_and1; /* And this rule 2n with the next rule 2n+1 in same block */ + bool cond_and2; /* And this rule m in block 2n with rule m in block 2n+1 */ bool ivalid; - // Actions to be performed - bool drop; // Drop the packet - bool fwd_sel; // Forward packet: to port, portmask, dest route, next rule, drop - bool ovid_sel; // So something to outer vlan-id: shift, re-assign - bool ivid_sel; // Do something to inner vlan-id: shift, re-assign - bool flt_sel; // Filter the packet when sending to certain ports - bool log_sel; // Log the packet in one of the LOG-table counters - bool rmk_sel; // Re-mark the packet, i.e. change the priority-tag - bool meter_sel; // Meter the packet, i.e. limit rate of this type of packet - bool tagst_sel; // Change the ergress tag - bool mir_sel; // Mirror the packet to a Link Aggregation Group - bool nopri_sel; // Change the normal priority - bool cpupri_sel; // Change the CPU priority - bool otpid_sel; // Change Outer Tag Protocol Identifier (802.1q) - bool itpid_sel; // Change Inner Tag Protocol Identifier (802.1q) - bool shaper_sel; // Apply traffic shaper - bool mpls_sel; // MPLS actions - bool bypass_sel; // Bypass actions - bool fwd_sa_lrn; // Learn the source address when forwarding - bool fwd_mod_to_cpu; // Forward the modified VLAN tag format to CPU-port - - // Fields used in predefined templates 0-2 on RTL8380 / 90 / 9300 - u64 spm; // Source Port Matrix - u16 otag; // Outer VLAN-ID - u8 smac[ETH_ALEN]; // Source MAC address - u8 dmac[ETH_ALEN]; // Destination MAC address - u16 ethertype; // Ethernet frame type field in ethernet header - u16 itag; // Inner VLAN-ID + /* Actions to be performed */ + bool drop; /* Drop the packet */ + bool fwd_sel; /* Forward packet: to port, portmask, dest route, next rule, drop */ + bool ovid_sel; /* So something to outer vlan-id: shift, re-assign */ + bool ivid_sel; /* Do something to inner vlan-id: shift, re-assign */ + bool flt_sel; /* Filter the packet when sending to certain ports */ + bool log_sel; /* Log the packet in one of the LOG-table counters */ + bool rmk_sel; /* Re-mark the packet, i.e. change the priority-tag */ + bool meter_sel; /* Meter the packet, i.e. limit rate of this type of packet */ + bool tagst_sel; /* Change the ergress tag */ + bool mir_sel; /* Mirror the packet to a Link Aggregation Group */ + bool nopri_sel; /* Change the normal priority */ + bool cpupri_sel; /* Change the CPU priority */ + bool otpid_sel; /* Change Outer Tag Protocol Identifier (802.1q) */ + bool itpid_sel; /* Change Inner Tag Protocol Identifier (802.1q) */ + bool shaper_sel; /* Apply traffic shaper */ + bool mpls_sel; /* MPLS actions */ + bool bypass_sel; /* Bypass actions */ + bool fwd_sa_lrn; /* Learn the source address when forwarding */ + bool fwd_mod_to_cpu; /* Forward the modified VLAN tag format to CPU-port */ + + /* Fields used in predefined templates 0-2 on RTL8380 / 90 / 9300 */ + u64 spm; /* Source Port Matrix */ + u16 otag; /* Outer VLAN-ID */ + u8 smac[ETH_ALEN]; /* Source MAC address */ + u8 dmac[ETH_ALEN]; /* Destination MAC address */ + u16 ethertype; /* Ethernet frame type field in ethernet header */ + u16 itag; /* Inner VLAN-ID */ u16 field_range_check; - u32 sip; // Source IP - struct in6_addr sip6; // IPv6 Source IP - u32 dip; // Destination IP - struct in6_addr dip6; // IPv6 Destination IP - u16 tos_proto; // IPv4: TOS + Protocol fields, IPv6: Traffic class + next header - u16 sport; // TCP/UDP source port - u16 dport; // TCP/UDP destination port + u32 sip; /* Source IP */ + struct in6_addr sip6; /* IPv6 Source IP */ + u32 dip; /* Destination IP */ + struct in6_addr dip6; /* IPv6 Destination IP */ + u16 tos_proto; /* IPv4: TOS + Protocol fields, IPv6: Traffic class + next header */ + u16 sport; /* TCP/UDP source port */ + u16 dport; /* TCP/UDP destination port */ u16 icmp_igmp; u16 tcp_info; - u16 dsap_ssap; // Destination / Source Service Access Point bytes (802.3) + u16 dsap_ssap; /* Destination / Source Service Access Point bytes (802.3) */ u64 spm_m; u16 otag_m; @@ -810,9 +810,9 @@ struct pie_rule { u16 itag_m; u16 field_range_check_m; u32 sip_m; - struct in6_addr sip6_m; // IPv6 Source IP mask + struct in6_addr sip6_m; /* IPv6 Source IP mask */ u32 dip_m; - struct in6_addr dip6_m; // IPv6 Destination IP mask + struct in6_addr dip6_m; /* IPv6 Destination IP mask */ u16 tos_proto_m; u16 sport_m; u16 dport_m; @@ -820,25 +820,25 @@ struct pie_rule { u16 tcp_info_m; u16 dsap_ssap_m; - // Data associated with actions - u8 fwd_act; // Type of forwarding action - // 0: permit, 1: drop, 2: copy to port id, 4: copy to portmask - // 4: redirect to portid, 5: redirect to portmask - // 6: route, 7: vlan leaky (only 8380) - u16 fwd_data; // Additional data for forwarding action, e.g. destination port + /* Data associated with actions */ + u8 fwd_act; /* Type of forwarding action */ + /* 0: permit, 1: drop, 2: copy to port id, 4: copy to portmask */ + /* 4: redirect to portid, 5: redirect to portmask */ + /* 6: route, 7: vlan leaky (only 8380) */ + u16 fwd_data; /* Additional data for forwarding action, e.g. destination port */ u8 ovid_act; - u16 ovid_data; // Outer VLAN ID + u16 ovid_data; /* Outer VLAN ID */ u8 ivid_act; - u16 ivid_data; // Inner VLAN ID - u16 flt_data; // Filtering data - u16 log_data; // ID of packet or octet counter in LOG table, on RTL93xx - // unnecessary since PIE-Rule-ID == LOG-counter-ID + u16 ivid_data; /* Inner VLAN ID */ + u16 flt_data; /* Filtering data */ + u16 log_data; /* ID of packet or octet counter in LOG table, on RTL93xx */ + /* unnecessary since PIE-Rule-ID == LOG-counter-ID */ bool log_octets; - u8 mpls_act; // MPLS action type - u16 mpls_lib_idx; // MPLS action data + u8 mpls_act; /* MPLS action type */ + u16 mpls_lib_idx; /* MPLS action data */ - u16 rmk_data; // Data for remarking - u16 meter_data; // ID of meter for bandwidth control + u16 rmk_data; /* Data for remarking */ + u16 meter_data; /* ID of meter for bandwidth control */ u16 tagst_data; u16 mir_data; u16 nopri_data; @@ -847,10 +847,10 @@ struct pie_rule { u16 itpid_data; u16 shaper_data; - // Bypass actions, ignored on RTL8380 - bool bypass_all; // Not clear - bool bypass_igr_stp; // Bypass Ingress STP state - bool bypass_ibc_sc; // Bypass Ingress Bandwidth Control and Storm Control + /* Bypass actions, ignored on RTL8380 */ + bool bypass_all; /* Not clear */ + bool bypass_igr_stp; /* Bypass Ingress STP state */ + bool bypass_ibc_sc; /* Bypass Ingress Bandwidth Control and Storm Control */ }; struct rtl838x_l3_intf { @@ -874,30 +874,30 @@ struct rtl838x_l3_intf { * Mask fields state whether the corresponding data fields matter for matching */ struct rtl93xx_rt_mac { - bool valid; // Valid or not - bool p_type; // Individual (0) or trunk (1) port - bool p_mask; // Whether the port type is used + bool valid; /* Valid or not */ + bool p_type; /* Individual (0) or trunk (1) port */ + bool p_mask; /* Whether the port type is used */ u8 p_id; - u8 p_id_mask; // Mask for the port - u8 action; // Routing action performed: 0: FORWARD, 1: DROP, 2: TRAP2CPU - // 3: COPY2CPU, 4: TRAP2MASTERCPU, 5: COPY2MASTERCPU, 6: HARDDROP + u8 p_id_mask; /* Mask for the port */ + u8 action; /* Routing action performed: 0: FORWARD, 1: DROP, 2: TRAP2CPU */ + /* 3: COPY2CPU, 4: TRAP2MASTERCPU, 5: COPY2MASTERCPU, 6: HARDDROP */ u16 vid; u16 vid_mask; - u64 mac; // MAC address used as source MAC in the routed packet + u64 mac; /* MAC address used as source MAC in the routed packet */ u64 mac_mask; }; struct rtl83xx_nexthop { - u16 id; // ID: L3_NEXT_HOP table-index or route-index set in L2_NEXT_HOP + u16 id; /* ID: L3_NEXT_HOP table-index or route-index set in L2_NEXT_HOP */ u32 dev_id; u16 port; - u16 vid; // VLAN-ID for L2 table entry (saved from L2-UC entry) - u16 rvid; // Relay VID/FID for the L2 table entry - u64 mac; // The MAC address of the entry in the L2_NEXT_HOP table + u16 vid; /* VLAN-ID for L2 table entry (saved from L2-UC entry) */ + u16 rvid; /* Relay VID/FID for the L2 table entry */ + u64 mac; /* The MAC address of the entry in the L2_NEXT_HOP table */ u16 mac_id; - u16 l2_id; // Index of this next hop forwarding entry in L2 FIB table - u64 gw; // The gateway MAC address packets are forwarded to - int if_id; // Interface (into L3_EGR_INTF_IDX) + u16 l2_id; /* Index of this next hop forwarding entry in L2 FIB table */ + u64 gw; /* The gateway MAC address packets are forwarded to */ + int if_id; /* Interface (into L3_EGR_INTF_IDX) */ }; struct rtl838x_switch_priv; @@ -924,14 +924,14 @@ struct rtl93xx_route_attr { }; struct rtl83xx_route { - u32 gw_ip; // IP of the route's gateway - u32 dst_ip; // IP of the destination net + u32 gw_ip; /* IP of the route's gateway */ + u32 dst_ip; /* IP of the destination net */ struct in6_addr dst_ip6; - int prefix_len; // Network prefix len of the destination net + int prefix_len; /* Network prefix len of the destination net */ bool is_host_route; - int id; // ID number of this route + int id; /* ID number of this route */ struct rhlist_head linkage; - u16 switch_mac_id; // Index into switch's own MACs, RTL839X only + u16 switch_mac_id; /* Index into switch's own MACs, RTL839X only */ struct rtl83xx_nexthop nh; struct pie_rule pr; struct rtl93xx_route_attr attr; @@ -1043,8 +1043,8 @@ struct rtl838x_switch_priv { u16 family_id; char version; struct rtl838x_port ports[57]; - struct mutex reg_mutex; // Mutex for individual register manipulations - struct mutex pie_mutex; // Mutex for Packet Inspection Engine + struct mutex reg_mutex; /* Mutex for individual register manipulations */ + struct mutex pie_mutex; /* Mutex for Packet Inspection Engine */ int link_state_irq; int mirror_group_ports[4]; struct mii_bus *mii_bus; @@ -1063,7 +1063,7 @@ struct rtl838x_switch_priv { u32 lag_primary[MAX_LAGS]; u32 is_lagmember[57]; u64 lagmembers; - struct notifier_block nb; // TODO: change to different name + struct notifier_block nb; /* TODO: change to different name */ struct notifier_block ne_nb; struct notifier_block fib_nb; bool eee_enabled; diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl839x.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl839x.c index 6fac8bd674..01461edc4b 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl839x.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl839x.c @@ -25,18 +25,18 @@ extern struct rtl83xx_soc_info soc_info; /* Definition of the RTL839X-specific template field IDs as used in the PIE */ enum template_field_id { TEMPLATE_FIELD_SPMMASK = 0, - TEMPLATE_FIELD_SPM0 = 1, // Source portmask ports 0-15 - TEMPLATE_FIELD_SPM1 = 2, // Source portmask ports 16-31 - TEMPLATE_FIELD_SPM2 = 3, // Source portmask ports 32-47 - TEMPLATE_FIELD_SPM3 = 4, // Source portmask ports 48-56 - TEMPLATE_FIELD_DMAC0 = 5, // Destination MAC [15:0] - TEMPLATE_FIELD_DMAC1 = 6, // Destination MAC [31:16] - TEMPLATE_FIELD_DMAC2 = 7, // Destination MAC [47:32] - TEMPLATE_FIELD_SMAC0 = 8, // Source MAC [15:0] - TEMPLATE_FIELD_SMAC1 = 9, // Source MAC [31:16] - TEMPLATE_FIELD_SMAC2 = 10, // Source MAC [47:32] - TEMPLATE_FIELD_ETHERTYPE = 11, // Ethernet frame type field - // Field-ID 12 is not used + TEMPLATE_FIELD_SPM0 = 1, /* Source portmask ports 0-15 */ + TEMPLATE_FIELD_SPM1 = 2, /* Source portmask ports 16-31 */ + TEMPLATE_FIELD_SPM2 = 3, /* Source portmask ports 32-47 */ + TEMPLATE_FIELD_SPM3 = 4, /* Source portmask ports 48-56 */ + TEMPLATE_FIELD_DMAC0 = 5, /* Destination MAC [15:0] */ + TEMPLATE_FIELD_DMAC1 = 6, /* Destination MAC [31:16] */ + TEMPLATE_FIELD_DMAC2 = 7, /* Destination MAC [47:32] */ + TEMPLATE_FIELD_SMAC0 = 8, /* Source MAC [15:0] */ + TEMPLATE_FIELD_SMAC1 = 9, /* Source MAC [31:16] */ + TEMPLATE_FIELD_SMAC2 = 10, /* Source MAC [47:32] */ + TEMPLATE_FIELD_ETHERTYPE = 11, /* Ethernet frame type field */ + /* Field-ID 12 is not used */ TEMPLATE_FIELD_OTAG = 13, TEMPLATE_FIELD_ITAG = 14, TEMPLATE_FIELD_SIP0 = 15, @@ -88,7 +88,7 @@ enum template_field_id { TEMPLATE_FIELD_DIP7 = 61, }; -// Number of fixed templates predefined in the SoC +/* Number of fixed templates predefined in the SoC */ #define N_FIXED_TEMPLATES 5 static enum template_field_id fixed_templates[N_FIXED_TEMPLATES][N_FIXED_FIELDS] = { @@ -163,7 +163,7 @@ static inline int rtl839x_tbl_access_data_0(int i) static void rtl839x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info) { u32 u, v, w; - // Read VLAN table (0) via register 0 + /* Read VLAN table (0) via register 0 */ struct table_reg *r = rtl_table_get(RTL8390_TBL_0, 0); rtl_table_read(r, vlan); @@ -179,7 +179,7 @@ static void rtl839x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info) info->hash_uc_fid = !!(w & BIT(3)); info->fid = (v >> 3) & 0xff; - // Read UNTAG table (0) via table register 1 + /* Read UNTAG table (0) via table register 1 */ r = rtl_table_get(RTL8390_TBL_1, 0); rtl_table_read(r, vlan); u = sw_r32(rtl_table_data(r, 0)); @@ -193,7 +193,7 @@ static void rtl839x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info) static void rtl839x_vlan_set_tagged(u32 vlan, struct rtl838x_vlan_info *info) { u32 u, v, w; - // Access VLAN table (0) via register 0 + /* Access VLAN table (0) via register 0 */ struct table_reg *r = rtl_table_get(RTL8390_TBL_0, 0); u = info->tagged_ports >> 21; @@ -216,7 +216,7 @@ static void rtl839x_vlan_set_untagged(u32 vlan, u64 portmask) { u32 u, v; - // Access UNTAG table (0) via table register 1 + /* Access UNTAG table (0) via table register 1 */ struct table_reg *r = rtl_table_get(RTL8390_TBL_1, 0); u = portmask >> 21; @@ -349,7 +349,7 @@ static void rtl839x_fill_l2_entry(u32 r[], struct rtl838x_l2_entry *e) e->mc_portmask_index = (r[2] >> 6) & 0xfff; e->vid = e->rvid; } - } else { // IPv4 and IPv6 multicast + } else { /* IPv4 and IPv6 multicast */ e->vid = e->rvid = (r[0] << 20) & 0xfff; e->mc_gip = r[1]; e->mc_portmask_index = (r[2] >> 6) & 0xfff; @@ -362,7 +362,7 @@ static void rtl839x_fill_l2_entry(u32 r[], struct rtl838x_l2_entry *e) e->valid = true; e->type = IP6_MULTICAST; } - // pr_info("%s: vid %d, rvid: %d\n", __func__, e->vid, e->rvid); + /* pr_info("%s: vid %d, rvid: %d\n", __func__, e->vid, e->rvid); */ } /* Fills the 3 SoC table registers r[] with the information in the rtl838x_l2_entry */ @@ -385,7 +385,7 @@ static void rtl839x_fill_l2_row(u32 r[], struct rtl838x_l2_entry *e) r[1] |= ((u32)e->mac[4]) << 12; r[1] |= ((u32)e->mac[5]) << 4; - if (!(e->mac[0] & 1)) { // Not multicast + if (!(e->mac[0] & 1)) { /* Not multicast */ r[2] |= e->is_static ? BIT(18) : 0; r[0] |= ((u32)e->rvid) << 20; r[2] |= e->port << 24; @@ -401,11 +401,11 @@ static void rtl839x_fill_l2_row(u32 r[], struct rtl838x_l2_entry *e) r[2] |= e->vid << 4; } pr_debug("Write L2 NH: %08x %08x %08x\n", r[0], r[1], r[2]); - } else { // L2 Multicast + } else { /* L2 Multicast */ r[0] |= ((u32)e->rvid) << 20; r[2] |= ((u32)e->mc_portmask_index) << 6; } - } else { // IPv4 or IPv6 MC entry + } else { /* IPv4 or IPv6 MC entry */ r[0] = ((u32)e->rvid) << 20; r[1] = e->mc_gip; r[2] |= ((u32)e->mc_portmask_index) << 6; @@ -420,7 +420,7 @@ static u64 rtl839x_read_l2_entry_using_hash(u32 hash, u32 pos, struct rtl838x_l2 { u32 r[3]; struct table_reg *q = rtl_table_get(RTL8390_TBL_L2, 0); - u32 idx = (0 << 14) | (hash << 2) | pos; // Search SRAM, with hash and at pos in bucket + u32 idx = (0 << 14) | (hash << 2) | pos; /* Search SRAM, with hash and at pos in bucket */ int i; rtl_table_read(q, idx); @@ -442,7 +442,7 @@ static void rtl839x_write_l2_entry_using_hash(u32 hash, u32 pos, struct rtl838x_ struct table_reg *q = rtl_table_get(RTL8390_TBL_L2, 0); int i; - u32 idx = (0 << 14) | (hash << 2) | pos; // Access SRAM, with hash and at pos in bucket + u32 idx = (0 << 14) | (hash << 2) | pos; /* Access SRAM, with hash and at pos in bucket */ rtl839x_fill_l2_row(r, e); @@ -456,7 +456,7 @@ static void rtl839x_write_l2_entry_using_hash(u32 hash, u32 pos, struct rtl838x_ static u64 rtl839x_read_cam(int idx, struct rtl838x_l2_entry *e) { u32 r[3]; - struct table_reg *q = rtl_table_get(RTL8390_TBL_L2, 1); // Access L2 Table 1 + struct table_reg *q = rtl_table_get(RTL8390_TBL_L2, 1); /* Access L2 Table 1 */ int i; rtl_table_read(q, idx); @@ -471,14 +471,14 @@ static u64 rtl839x_read_cam(int idx, struct rtl838x_l2_entry *e) pr_debug("Found in CAM: R1 %x R2 %x R3 %x\n", r[0], r[1], r[2]); - // Return MAC with concatenated VID ac concatenated ID + /* Return MAC with concatenated VID ac concatenated ID */ return rtl839x_l2_hash_seed(ether_addr_to_u64(&e->mac[0]), e->rvid); } static void rtl839x_write_cam(int idx, struct rtl838x_l2_entry *e) { u32 r[3]; - struct table_reg *q = rtl_table_get(RTL8390_TBL_L2, 1); // Access L2 Table 1 + struct table_reg *q = rtl_table_get(RTL8390_TBL_L2, 1); /* Access L2 Table 1 */ int i; rtl839x_fill_l2_row(r, e); @@ -493,14 +493,14 @@ static void rtl839x_write_cam(int idx, struct rtl838x_l2_entry *e) static u64 rtl839x_read_mcast_pmask(int idx) { u64 portmask; - // Read MC_PMSK (2) via register RTL8390_TBL_L2 + /* Read MC_PMSK (2) via register RTL8390_TBL_L2 */ struct table_reg *q = rtl_table_get(RTL8390_TBL_L2, 2); rtl_table_read(q, idx); portmask = sw_r32(rtl_table_data(q, 0)); portmask <<= 32; portmask |= sw_r32(rtl_table_data(q, 1)); - portmask >>= 11; // LSB is bit 11 in data registers + portmask >>= 11; /* LSB is bit 11 in data registers */ rtl_table_release(q); return portmask; @@ -508,10 +508,10 @@ static u64 rtl839x_read_mcast_pmask(int idx) static void rtl839x_write_mcast_pmask(int idx, u64 portmask) { - // Access MC_PMSK (2) via register RTL8380_TBL_L2 + /* Access MC_PMSK (2) via register RTL8380_TBL_L2 */ struct table_reg *q = rtl_table_get(RTL8390_TBL_L2, 2); - portmask <<= 11; // LSB is bit 11 in data registers + portmask <<= 11; /* LSB is bit 11 in data registers */ sw_w32((u32)(portmask >> 32), rtl_table_data(q, 0)); sw_w32((u32)((portmask & 0xfffff800)), rtl_table_data(q, 1)); rtl_table_write(q, idx); @@ -523,8 +523,8 @@ static void rtl839x_vlan_profile_setup(int profile) u32 p[2]; u32 pmask_id = UNKNOWN_MC_PMASK; - p[0] = pmask_id; // Use portmaks 0xfff for unknown IPv6 MC flooding - // Enable L2 Learning BIT 0, portmask UNKNOWN_MC_PMASK for IP/L2-MC traffic flooding + p[0] = pmask_id; /* Use portmaks 0xfff for unknown IPv6 MC flooding */ + /* Enable L2 Learning BIT 0, portmask UNKNOWN_MC_PMASK for IP/L2-MC traffic flooding */ p[1] = 1 | pmask_id << 1 | pmask_id << 13; sw_w32(p[0], RTL839X_VLAN_PROFILE(profile)); @@ -560,16 +560,16 @@ static void rtl839x_l2_learning_setup(void) * also for multicast flooding */ sw_w32(UNKNOWN_MC_PMASK << 12 | UNKNOWN_MC_PMASK, RTL839X_L2_FLD_PMSK); - // Limit learning to maximum: 32k entries, after that just flood (bits 0-1) + /* Limit learning to maximum: 32k entries, after that just flood (bits 0-1) */ sw_w32((0x7fff << 2) | 0, RTL839X_L2_LRN_CONSTRT); - // Do not trap ARP packets to CPU_PORT + /* Do not trap ARP packets to CPU_PORT */ sw_w32(0, RTL839X_SPCL_TRAP_ARP_CTRL); } static void rtl839x_enable_learning(int port, bool enable) { - // Limit learning to maximum: 32k entries + /* Limit learning to maximum: 32k entries */ sw_w32_mask(0x7fff << 2, enable ? (0x7fff << 2) : 0, RTL839X_L2_PORT_LRN_CONSTRT + (port << 2)); @@ -620,7 +620,7 @@ irqreturn_t rtl839x_switch_irq(int irq, void *dev_id) return IRQ_HANDLED; } -// TODO: unused +/* TODO: unused */ int rtl8390_sds_power(int mac, int val) { u32 offset = (mac == 48) ? 0x0 : 0x100; @@ -633,7 +633,7 @@ int rtl8390_sds_power(int mac, int val) return -1; } - // Set bit 1003. 1000 starts at 7c + /* Set bit 1003. 1000 starts at 7c */ sw_w32_mask(BIT(11), mode << 11, RTL839X_SDS12_13_PWR0 + offset); return 0; @@ -660,7 +660,7 @@ int rtl839x_read_phy(u32 port, u32 page, u32 reg, u32 *val) if (port > 63 || page > 4095 || reg > 31) return -ENOTSUPP; - // Take bug on RTL839x Rev <= C into account + /* Take bug on RTL839x Rev <= C into account */ if (port >= RTL839X_CPU_PORT) return -EIO; @@ -696,13 +696,13 @@ int rtl839x_write_phy(u32 port, u32 page, u32 reg, u32 val) if (port > 63 || page > 4095 || reg > 31) return -ENOTSUPP; - // Take bug on RTL839x Rev <= C into account + /* Take bug on RTL839x Rev <= C into account */ if (port >= RTL839X_CPU_PORT) return -EIO; mutex_lock(&smi_lock); - // Set PHY to access + /* Set PHY to access */ rtl839x_set_port_reg_le(BIT_ULL(port), RTL839X_PHYREG_PORT_CTRL); sw_w32_mask(0xffff0000, val << 16, RTL839X_PHYREG_DATA_CTRL); @@ -734,26 +734,26 @@ int rtl839x_read_mmd_phy(u32 port, u32 devnum, u32 regnum, u32 *val) int err = 0; u32 v; - // Take bug on RTL839x Rev <= C into account + /* Take bug on RTL839x Rev <= C into account */ if (port >= RTL839X_CPU_PORT) return -EIO; mutex_lock(&smi_lock); - // Set PHY to access + /* Set PHY to access */ sw_w32_mask(0xffff << 16, port << 16, RTL839X_PHYREG_DATA_CTRL); - // Set MMD device number and register to write to + /* Set MMD device number and register to write to */ sw_w32(devnum << 16 | (regnum & 0xffff), RTL839X_PHYREG_MMD_CTRL); - v = BIT(2) | BIT(0); // MMD-access | EXEC + v = BIT(2) | BIT(0); /* MMD-access | EXEC */ sw_w32(v, RTL839X_PHYREG_ACCESS_CTRL); err = rtl839x_smi_wait_op(100000); if (err) goto errout; - // There is no error-checking via BIT 1 of v, as it does not seem to be set correctly + /* There is no error-checking via BIT 1 of v, as it does not seem to be set correctly */ *val = (sw_r32(RTL839X_PHYREG_DATA_CTRL) & 0xffff); pr_debug("%s: port %d, regnum: %x, val: %x (err %d)\n", __func__, port, regnum, *val, err); @@ -769,22 +769,22 @@ int rtl839x_write_mmd_phy(u32 port, u32 devnum, u32 regnum, u32 val) int err = 0; u32 v; - // Take bug on RTL839x Rev <= C into account + /* Take bug on RTL839x Rev <= C into account */ if (port >= RTL839X_CPU_PORT) return -EIO; mutex_lock(&smi_lock); - // Set PHY to access + /* Set PHY to access */ rtl839x_set_port_reg_le(BIT_ULL(port), RTL839X_PHYREG_PORT_CTRL); - // Set data to write + /* Set data to write */ sw_w32_mask(0xffff << 16, val << 16, RTL839X_PHYREG_DATA_CTRL); - // Set MMD device number and register to write to + /* Set MMD device number and register to write to */ sw_w32(devnum << 16 | (regnum & 0xffff), RTL839X_PHYREG_MMD_CTRL); - v = BIT(3) | BIT(2) | BIT(0); // WRITE | MMD-access | EXEC + v = BIT(3) | BIT(2) | BIT(0); /* WRITE | MMD-access | EXEC */ sw_w32(v, RTL839X_PHYREG_ACCESS_CTRL); err = rtl839x_smi_wait_op(100000); @@ -859,7 +859,7 @@ void rtl839x_port_eee_set(struct rtl838x_switch_priv *priv, int port, bool enabl { u32 v; - // This works only for Ethernet ports, and on the RTL839X, ports above 47 are SFP + /* This works only for Ethernet ports, and on the RTL839X, ports above 47 are SFP */ if (port >= 48) return; @@ -867,10 +867,10 @@ void rtl839x_port_eee_set(struct rtl838x_switch_priv *priv, int port, bool enabl pr_debug("In %s: setting port %d to %d\n", __func__, port, enable); v = enable ? 0xf : 0x0; - // Set EEE for 100, 500, 1000MBit and 10GBit + /* Set EEE for 100, 500, 1000MBit and 10GBit */ sw_w32_mask(0xf << 8, v << 8, rtl839x_mac_force_mode_ctrl(port)); - // Set TX/RX EEE state + /* Set TX/RX EEE state */ v = enable ? 0x3 : 0x0; sw_w32(v, RTL839X_EEE_CTRL(port)); @@ -912,14 +912,14 @@ static void rtl839x_init_eee(struct rtl838x_switch_priv *priv, bool enable) pr_info("Setting up EEE, state: %d\n", enable); - // Set wake timer for TX and pause timer both to 0x21 + /* Set wake timer for TX and pause timer both to 0x21 */ sw_w32_mask(0xff << 20| 0xff, 0x21 << 20| 0x21, RTL839X_EEE_TX_TIMER_GELITE_CTRL); - // Set pause wake timer for GIGA-EEE to 0x11 + /* Set pause wake timer for GIGA-EEE to 0x11 */ sw_w32_mask(0xff << 20, 0x11 << 20, RTL839X_EEE_TX_TIMER_GIGA_CTRL); - // Set pause wake timer for 10GBit ports to 0x11 + /* Set pause wake timer for 10GBit ports to 0x11 */ sw_w32_mask(0xff << 20, 0x11 << 20, RTL839X_EEE_TX_TIMER_10G_CTRL); - // Setup EEE on all ports + /* Setup EEE on all ports */ for (i = 0; i < priv->cpu_port; i++) { if (priv->ports[i].phy) rtl839x_port_eee_set(priv, i, enable); @@ -942,10 +942,10 @@ static int rtl839x_pie_rule_del(struct rtl838x_switch_priv *priv, int index_from pr_debug("%s: from %d to %d\n", __func__, index_from, index_to); mutex_lock(&priv->reg_mutex); - // Write from-to and execute bit into control register + /* Write from-to and execute bit into control register */ sw_w32(v, RTL839X_ACL_CLR_CTRL); - // Wait until command has completed + /* Wait until command has completed */ do { } while (sw_r32(RTL839X_ACL_CLR_CTRL) & BIT(0)); @@ -1111,7 +1111,7 @@ static void rtl839x_write_pie_templated(u32 r[], struct pie_rule *pr, enum templ pr_info("%s: unknown field %d\n", __func__, field_type); } - // On the RTL8390, the mask fields are not word aligned! + /* On the RTL8390, the mask fields are not word aligned! */ if (!(i % 2)) { r[5 - i / 2] = data; r[12 - i / 2] |= ((u32)data_m << 8); @@ -1213,7 +1213,7 @@ void rtl839x_read_pie_templated(u32 r[], struct pie_rule *pr, enum template_fiel break; case TEMPLATE_FIELD_SIP2: pr->is_ipv6 = true; - // Make use of limitiations on the position of the match values + /* Make use of limitiations on the position of the match values */ ipv6_addr_set(&pr->sip6, pr->sip, r[5 - i / 2], r[4 - i / 2], r[3 - i / 2]); ipv6_addr_set(&pr->sip6_m, pr->sip_m, r[5 - i / 2], @@ -1344,7 +1344,7 @@ static void rtl839x_write_pie_fixed_fields(u32 r[], struct pie_rule *pr) static void rtl839x_write_pie_action(u32 r[], struct pie_rule *pr) { if (pr->drop) { - r[13] |= 0x9; // Set ACT_MASK_FWD & FWD_ACT = DROP + r[13] |= 0x9; /* Set ACT_MASK_FWD & FWD_ACT = DROP */ r[13] |= BIT(3); } else { r[13] |= pr->fwd_sel ? BIT(3) : 0; @@ -1380,7 +1380,7 @@ static void rtl839x_write_pie_action(u32 r[], struct pie_rule *pr) static void rtl839x_read_pie_action(u32 r[], struct pie_rule *pr) { - if (r[13] & BIT(3)) { // ACT_MASK_FWD set, is it a drop? + if (r[13] & BIT(3)) { /* ACT_MASK_FWD set, is it a drop? */ if ((r[14] & 0x7) == 1) { pr->drop = true; } else { @@ -1398,7 +1398,7 @@ static void rtl839x_read_pie_action(u32 r[], struct pie_rule *pr) pr->mir_sel = r[13] & BIT(5); pr->log_sel = r[13] & BIT(4); - // TODO: Read in data fields + /* TODO: Read in data fields */ pr->bypass_all = r[16] & BIT(9); pr->bypass_igr_stp = r[16] & BIT(8); @@ -1432,7 +1432,7 @@ void rtl839x_pie_rule_dump(struct pie_rule *pr) static int rtl839x_pie_rule_read(struct rtl838x_switch_priv *priv, int idx, struct pie_rule *pr) { - // Read IACL table (2) via register 0 + /* Read IACL table (2) via register 0 */ struct table_reg *q = rtl_table_get(RTL8380_TBL_0, 2); u32 r[17]; int i; @@ -1462,7 +1462,7 @@ static int rtl839x_pie_rule_read(struct rtl838x_switch_priv *priv, int idx, stru static int rtl839x_pie_rule_write(struct rtl838x_switch_priv *priv, int idx, struct pie_rule *pr) { - // Access IACL table (2) via register 0 + /* Access IACL table (2) via register 0 */ struct table_reg *q = rtl_table_get(RTL8390_TBL_0, 2); u32 r[17]; int i; @@ -1486,7 +1486,7 @@ static int rtl839x_pie_rule_write(struct rtl838x_switch_priv *priv, int idx, str rtl839x_write_pie_action(r, pr); -// rtl839x_pie_rule_dump_raw(r); +/* rtl839x_pie_rule_dump_raw(r); */ for (i = 0; i < 17; i++) sw_w32(r[i], rtl_table_data(q, i)); @@ -1543,7 +1543,7 @@ static int rtl839x_pie_verify_template(struct rtl838x_switch_priv *priv, if (ether_addr_to_u64(pr->dmac) && !rtl839x_pie_templ_has(t, TEMPLATE_FIELD_DMAC0)) return -1; - // TODO: Check more + /* TODO: Check more */ i = find_first_zero_bit(&priv->pie_use_bm[block * 4], PIE_BLOCK_SIZE); @@ -1585,7 +1585,7 @@ static int rtl839x_pie_rule_add(struct rtl838x_switch_priv *priv, struct pie_rul set_bit(idx, priv->pie_use_bm); pr->valid = true; - pr->tid = j; // Mapped to template number + pr->tid = j; /* Mapped to template number */ pr->tid_m = 0x3; pr->id = idx; @@ -1612,45 +1612,45 @@ static void rtl839x_pie_init(struct rtl838x_switch_priv *priv) mutex_init(&priv->pie_mutex); - // Power on all PIE blocks + /* Power on all PIE blocks */ for (i = 0; i < priv->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 - sw_w32_mask(0x1f, 9, RTL839X_ACL_CTRL); // Writes 9 to cutline field + /* Set ingress and egress ACL blocks to 50/50: first Egress block is 9 */ + sw_w32_mask(0x1f, 9, RTL839X_ACL_CTRL); /* Writes 9 to cutline field */ - // Include IPG in metering + /* Include IPG in metering */ sw_w32(1, RTL839X_METER_GLB_CTRL); - // Delete all present rules + /* Delete all present rules */ rtl839x_pie_rule_del(priv, 0, priv->n_pie_blocks * PIE_BLOCK_SIZE - 1); - // Enable predefined templates 0, 1 for blocks 0-2 + /* Enable predefined templates 0, 1 for blocks 0-2 */ template_selectors = 0 | (1 << 3); for (i = 0; i < 3; i++) sw_w32(template_selectors, RTL839X_ACL_BLK_TMPLTE_CTRL(i)); - // Enable predefined templates 2, 3 for blocks 3-5 + /* Enable predefined templates 2, 3 for blocks 3-5 */ template_selectors = 2 | (3 << 3); for (i = 3; i < 6; i++) sw_w32(template_selectors, RTL839X_ACL_BLK_TMPLTE_CTRL(i)); - // Enable predefined templates 1, 4 for blocks 6-8 + /* Enable predefined templates 1, 4 for blocks 6-8 */ template_selectors = 2 | (3 << 3); for (i = 6; i < 9; i++) sw_w32(template_selectors, RTL839X_ACL_BLK_TMPLTE_CTRL(i)); - // Enable predefined templates 0, 1 for blocks 9-11 + /* Enable predefined templates 0, 1 for blocks 9-11 */ template_selectors = 0 | (1 << 3); for (i = 9; i < 12; i++) sw_w32(template_selectors, RTL839X_ACL_BLK_TMPLTE_CTRL(i)); - // Enable predefined templates 2, 3 for blocks 12-14 + /* Enable predefined templates 2, 3 for blocks 12-14 */ template_selectors = 2 | (3 << 3); for (i = 12; i < 15; i++) sw_w32(template_selectors, RTL839X_ACL_BLK_TMPLTE_CTRL(i)); - // Enable predefined templates 1, 4 for blocks 15-17 + /* Enable predefined templates 1, 4 for blocks 15-17 */ template_selectors = 2 | (3 << 3); for (i = 15; i < 18; i++) sw_w32(template_selectors, RTL839X_ACL_BLK_TMPLTE_CTRL(i)); @@ -1660,13 +1660,13 @@ static u32 rtl839x_packet_cntr_read(int counter) { u32 v; - // Read LOG table (4) via register RTL8390_TBL_0 + /* Read LOG table (4) via register RTL8390_TBL_0 */ struct table_reg *r = rtl_table_get(RTL8390_TBL_0, 4); pr_debug("In %s, id %d\n", __func__, counter); rtl_table_read(r, counter / 2); - // The table has a size of 2 registers + /* The table has a size of 2 registers */ if (counter % 2) v = sw_r32(rtl_table_data(r, 0)); else @@ -1679,11 +1679,11 @@ static u32 rtl839x_packet_cntr_read(int counter) static void rtl839x_packet_cntr_clear(int counter) { - // Access LOG table (4) via register RTL8390_TBL_0 + /* Access LOG table (4) via register RTL8390_TBL_0 */ struct table_reg *r = rtl_table_get(RTL8390_TBL_0, 4); pr_debug("In %s, id %d\n", __func__, counter); - // The table has a size of 2 registers + /* The table has a size of 2 registers */ if (counter % 2) sw_w32(0, rtl_table_data(r, 0)); else @@ -1697,13 +1697,13 @@ static void rtl839x_packet_cntr_clear(int counter) static void rtl839x_route_read(int idx, struct rtl83xx_route *rt) { u64 v; - // Read ROUTING table (2) via register RTL8390_TBL_1 + /* Read ROUTING table (2) via register RTL8390_TBL_1 */ struct table_reg *r = rtl_table_get(RTL8390_TBL_1, 2); pr_debug("In %s\n", __func__); rtl_table_read(r, idx); - // The table has a size of 2 registers + /* The table has a size of 2 registers */ v = sw_r32(rtl_table_data(r, 0)); v <<= 32; v |= sw_r32(rtl_table_data(r, 1)); @@ -1717,7 +1717,7 @@ static void rtl839x_route_write(int idx, struct rtl83xx_route *rt) { u32 v; - // Read ROUTING table (2) via register RTL8390_TBL_1 + /* Read ROUTING table (2) via register RTL8390_TBL_1 */ struct table_reg *r = rtl_table_get(RTL8390_TBL_1, 2); pr_debug("In %s\n", __func__); @@ -1742,7 +1742,7 @@ static void rtl839x_setup_port_macs(struct rtl838x_switch_priv *priv) mac = ether_addr_to_u64(dev->dev_addr); for (i = 0; i < 15; i++) { - mac++; // BUG: VRRP for testing + mac++; /* BUG: VRRP for testing */ sw_w32(mac >> 32, RTL839X_ROUTING_SA_CTRL + i * 8); sw_w32(mac, RTL839X_ROUTING_SA_CTRL + i * 8 + 4); } diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl930x.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl930x.c index 6cd0c6b814..384b33b0ba 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl930x.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl930x.c @@ -26,15 +26,15 @@ extern struct rtl83xx_soc_info soc_info; /* Definition of the RTL930X-specific template field IDs as used in the PIE */ enum template_field_id { - TEMPLATE_FIELD_SPM0 = 0, // Source portmask ports 0-15 - TEMPLATE_FIELD_SPM1 = 1, // Source portmask ports 16-31 - TEMPLATE_FIELD_DMAC0 = 2, // Destination MAC [15:0] - TEMPLATE_FIELD_DMAC1 = 3, // Destination MAC [31:16] - TEMPLATE_FIELD_DMAC2 = 4, // Destination MAC [47:32] - TEMPLATE_FIELD_SMAC0 = 5, // Source MAC [15:0] - TEMPLATE_FIELD_SMAC1 = 6, // Source MAC [31:16] - TEMPLATE_FIELD_SMAC2 = 7, // Source MAC [47:32] - TEMPLATE_FIELD_ETHERTYPE = 8, // Ethernet frame type field + TEMPLATE_FIELD_SPM0 = 0, /* Source portmask ports 0-15 */ + TEMPLATE_FIELD_SPM1 = 1, /* Source portmask ports 16-31 */ + TEMPLATE_FIELD_DMAC0 = 2, /* Destination MAC [15:0] */ + TEMPLATE_FIELD_DMAC1 = 3, /* Destination MAC [31:16] */ + TEMPLATE_FIELD_DMAC2 = 4, /* Destination MAC [47:32] */ + TEMPLATE_FIELD_SMAC0 = 5, /* Source MAC [15:0] */ + TEMPLATE_FIELD_SMAC1 = 6, /* Source MAC [31:16] */ + TEMPLATE_FIELD_SMAC2 = 7, /* Source MAC [47:32] */ + TEMPLATE_FIELD_ETHERTYPE = 8, /* Ethernet frame type field */ TEMPLATE_FIELD_OTAG = 9, TEMPLATE_FIELD_ITAG = 10, TEMPLATE_FIELD_SIP0 = 11, @@ -71,7 +71,7 @@ enum template_field_id { TEMPLATE_FIELD_SNAP_OUI = 42, TEMPLATE_FIELD_FWD_VID = 43, TEMPLATE_FIELD_RANGE_CHK = 44, - TEMPLATE_FIELD_VLAN_GMSK = 45, // VLAN Group Mask/IP range check + TEMPLATE_FIELD_VLAN_GMSK = 45, /* VLAN Group Mask/IP range check */ TEMPLATE_FIELD_DLP = 46, TEMPLATE_FIELD_META_DATA = 47, TEMPLATE_FIELD_SRC_FWD_VID = 48, @@ -83,9 +83,9 @@ enum template_field_id { */ #define TEMPLATE_FIELD_VLAN TEMPLATE_FIELD_ITAG -// Number of fixed templates predefined in the RTL9300 SoC +/* Number of fixed templates predefined in the RTL9300 SoC */ #define N_FIXED_TEMPLATES 5 -// RTL9300 specific predefined templates +/* RTL9300 specific predefined templates */ static enum template_field_id fixed_templates[N_FIXED_TEMPLATES][N_FIXED_FIELDS] = { { @@ -152,7 +152,7 @@ static inline int rtl930x_l2_port_new_salrn(int p) static inline int rtl930x_l2_port_new_sa_fwd(int p) { - // TODO: The definition of the fields changed, because of the master-cpu in a stack + /* TODO: The definition of the fields changed, because of the master-cpu in a stack */ return RTL930X_L2_PORT_NEW_SA_FWD(p); } @@ -164,7 +164,7 @@ inline static int rtl930x_trk_mbr_ctr(int group) static void rtl930x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info) { u32 v, w; - // Read VLAN table (1) via register 0 + /* Read VLAN table (1) via register 0 */ struct table_reg *r = rtl_table_get(RTL9300_TBL_0, 1); rtl_table_read(r, vlan); @@ -179,7 +179,7 @@ static void rtl930x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info) info->hash_uc_fid = !!(w & BIT(28)); info->fid = ((v & 0x7) << 3) | ((w >> 29) & 0x7); - // Read UNTAG table via table register 2 + /* Read UNTAG table via table register 2 */ r = rtl_table_get(RTL9300_TBL_2, 0); rtl_table_read(r, vlan); v = sw_r32(rtl_table_data(r, 0)); @@ -191,7 +191,7 @@ static void rtl930x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info) static void rtl930x_vlan_set_tagged(u32 vlan, struct rtl838x_vlan_info *info) { u32 v, w; - // Access VLAN table (1) via register 0 + /* Access VLAN table (1) via register 0 */ struct table_reg *r = rtl_table_get(RTL9300_TBL_0, 1); v = info->tagged_ports << 3; @@ -245,7 +245,7 @@ static void rtl930x_vlan_set_untagged(u32 vlan, u64 portmask) /* Sets the L2 forwarding to be based on either the inner VLAN tag or the outer */ static void rtl930x_vlan_fwd_on_inner(int port, bool is_set) { - // Always set all tag modes to fwd based on either inner or outer tag + /* Always set all tag modes to fwd based on either inner or outer tag */ if (is_set) sw_w32_mask(0, 0xf, RTL930X_VLAN_PORT_FWD + (port << 2)); else @@ -260,11 +260,11 @@ static void rtl930x_vlan_profile_setup(int profile) p[0] = sw_r32(RTL930X_VLAN_PROFILE_SET(profile)); p[1] = sw_r32(RTL930X_VLAN_PROFILE_SET(profile) + 4); - // Enable routing of Ipv4/6 Unicast and IPv4/6 Multicast traffic + /* Enable routing of Ipv4/6 Unicast and IPv4/6 Multicast traffic */ p[0] |= BIT(17) | BIT(16) | BIT(13) | BIT(12); - p[2] = 0x1fffffff; // L2 unknown MC flooding portmask all ports, including the CPU-port - p[3] = 0x1fffffff; // IPv4 unknown MC flooding portmask - p[4] = 0x1fffffff; // IPv6 unknown MC flooding portmask + p[2] = 0x1fffffff; /* L2 unknown MC flooding portmask all ports, including the CPU-port */ + p[3] = 0x1fffffff; /* IPv4 unknown MC flooding portmask */ + p[4] = 0x1fffffff; /* IPv6 unknown MC flooding portmask */ sw_w32(p[0], RTL930X_VLAN_PROFILE_SET(profile)); sw_w32(p[1], RTL930X_VLAN_PROFILE_SET(profile) + 4); @@ -275,13 +275,13 @@ static void rtl930x_vlan_profile_setup(int profile) static void rtl930x_l2_learning_setup(void) { - // Portmask for flooding broadcast traffic + /* Portmask for flooding broadcast traffic */ sw_w32(0x1fffffff, RTL930X_L2_BC_FLD_PMSK); - // Portmask for flooding unicast traffic with unknown destination + /* Portmask for flooding unicast traffic with unknown destination */ sw_w32(0x1fffffff, RTL930X_L2_UNKN_UC_FLD_PMSK); - // Limit learning to maximum: 32k entries, after that just flood (bits 0-1) + /* Limit learning to maximum: 32k entries, after that just flood (bits 0-1) */ sw_w32((0x7fff << 2) | 0, RTL930X_L2_LRN_CONSTRT_CTRL); } @@ -366,7 +366,7 @@ static u32 rtl930x_l2_hash_key(struct rtl838x_switch_priv *priv, u64 seed) h1 ^ (seed & 0x7ff)); - // Algorithm choice for block 0 + /* Algorithm choice for block 0 */ if (sw_r32(RTL930X_L2_CTRL) & BIT(0)) h = k1; else @@ -398,7 +398,7 @@ static void rtl930x_fill_l2_entry(u32 r[], struct rtl838x_l2_entry *e) e->is_ip_mc = false; e->is_ipv6_mc = false; - // TODO: Is there not a function to copy directly MAC memory? + /* TODO: Is there not a function to copy directly MAC memory? */ e->mac[0] = (r[0] >> 24); e->mac[1] = (r[0] >> 16); e->mac[2] = (r[0] >> 8); @@ -414,7 +414,7 @@ static void rtl930x_fill_l2_entry(u32 r[], struct rtl838x_l2_entry *e) e->type = L2_UNICAST; e->is_static = !!(r[2] & BIT(14)); e->port = (r[2] >> 20) & 0x3ff; - // Check for trunk port + /* Check for trunk port */ if (r[2] & BIT(30)) { e->is_trunk = true; e->stack_dev = (e->port >> 9) & 1; @@ -430,7 +430,7 @@ static void rtl930x_fill_l2_entry(u32 r[], struct rtl838x_l2_entry *e) e->suspended = !!(r[2] & BIT(13)); e->age = (r[2] >> 17) & 3; e->valid = true; - // the UC_VID field in hardware is used for the VID or for the route id + /* the UC_VID field in hardware is used for the VID or for the route id */ if (e->next_hop) { e->nh_route_id = r[2] & 0x7ff; e->vid = 0; @@ -455,7 +455,7 @@ static void rtl930x_fill_l2_row(u32 r[], struct rtl838x_l2_entry *e) return; } - r[2] = BIT(31); // Set valid bit + r[2] = BIT(31); /* Set valid bit */ r[0] = ((u32)e->mac[0]) << 24 | ((u32)e->mac[1]) << 16 | @@ -482,12 +482,12 @@ static void rtl930x_fill_l2_row(u32 r[], struct rtl838x_l2_entry *e) r[2] |= e->block_sa ? BIT(17) : 0; r[2] |= e->suspended ? BIT(13) : 0; r[2] |= (e->age & 0x3) << 17; - // the UC_VID field in hardware is used for the VID or for the route id + /* the UC_VID field in hardware is used for the VID or for the route id */ if (e->next_hop) r[2] |= e->nh_route_id & 0x7ff; else r[2] |= e->vid & 0xfff; - } else { // L2_MULTICAST + } else { /* L2_MULTICAST */ r[2] |= (e->mc_portmask_index & 0x3ff) << 16; r[2] |= e->mc_mac_index & 0x7ff; } @@ -519,7 +519,7 @@ static u64 rtl930x_read_l2_entry_using_hash(u32 hash, u32 pos, struct rtl838x_l2 hash &= 0xffff; } - idx = (0 << 14) | (hash << 2) | pos; // Search SRAM, with hash and at pos in bucket + idx = (0 << 14) | (hash << 2) | pos; /* Search SRAM, with hash and at pos in bucket */ pr_debug("%s: NOW hash %08x, pos: %d\n", __func__, hash, pos); rtl_table_read(q, idx); @@ -544,7 +544,7 @@ static u64 rtl930x_read_l2_entry_using_hash(u32 hash, u32 pos, struct rtl838x_l2 seed = rtl930x_l2_hash_seed(mac, e->rvid); pr_debug("%s: mac %016llx, seed %016llx\n", __func__, mac, seed); - // return vid with concatenated mac as unique id + /* return vid with concatenated mac as unique id */ return seed; } @@ -552,7 +552,7 @@ static void rtl930x_write_l2_entry_using_hash(u32 hash, u32 pos, struct rtl838x_ { u32 r[3]; struct table_reg *q = rtl_table_get(RTL9300_TBL_L2, 0); - u32 idx = (0 << 14) | (hash << 2) | pos; // Access SRAM, with hash and at pos in bucket + u32 idx = (0 << 14) | (hash << 2) | pos; /* Access SRAM, with hash and at pos in bucket */ int i; pr_debug("%s: hash %d, pos %d\n", __func__, hash, pos); @@ -584,14 +584,14 @@ static u64 rtl930x_read_cam(int idx, struct rtl838x_l2_entry *e) if (!e->valid) return 0; - // return mac with concatenated vid as unique id + /* return mac with concatenated vid as unique id */ return ((u64)r[0] << 28) | ((r[1] & 0xffff0000) >> 4) | e->vid; } static void rtl930x_write_cam(int idx, struct rtl838x_l2_entry *e) { u32 r[3]; - struct table_reg *q = rtl_table_get(RTL9300_TBL_L2, 1); // Access L2 Table 1 + struct table_reg *q = rtl_table_get(RTL9300_TBL_L2, 1); /* Access L2 Table 1 */ int i; rtl930x_fill_l2_row(r, e); @@ -606,7 +606,7 @@ static void rtl930x_write_cam(int idx, struct rtl838x_l2_entry *e) static u64 rtl930x_read_mcast_pmask(int idx) { u32 portmask; - // Read MC_PORTMASK (2) via register RTL9300_TBL_L2 + /* Read MC_PORTMASK (2) via register RTL9300_TBL_L2 */ struct table_reg *q = rtl_table_get(RTL9300_TBL_L2, 2); rtl_table_read(q, idx); @@ -623,7 +623,7 @@ static void rtl930x_write_mcast_pmask(int idx, u64 portmask) { u32 pm = portmask; - // Access MC_PORTMASK (2) via register RTL9300_TBL_L2 + /* Access MC_PORTMASK (2) via register RTL9300_TBL_L2 */ struct table_reg *q = rtl_table_get(RTL9300_TBL_L2, 2); pr_debug("%s: Index idx %d has portmask %08x\n", __func__, idx, pm); @@ -790,16 +790,16 @@ int rtl930x_write_mmd_phy(u32 port, u32 devnum, u32 regnum, u32 val) mutex_lock(&smi_lock); - // Set PHY to access + /* Set PHY to access */ sw_w32(BIT(port), RTL930X_SMI_ACCESS_PHY_CTRL_0); - // Set data to write + /* Set data to write */ sw_w32_mask(0xffff << 16, val << 16, RTL930X_SMI_ACCESS_PHY_CTRL_2); - // Set MMD device number and register to write to + /* Set MMD device number and register to write to */ sw_w32(devnum << 16 | (regnum & 0xffff), RTL930X_SMI_ACCESS_PHY_CTRL_3); - v = BIT(2) | BIT(1) | BIT(0); // WRITE | MMD-access | EXEC + v = BIT(2) | BIT(1) | BIT(0); /* WRITE | MMD-access | EXEC */ sw_w32(v, RTL930X_SMI_ACCESS_PHY_CTRL_1); do { @@ -819,19 +819,19 @@ int rtl930x_read_mmd_phy(u32 port, u32 devnum, u32 regnum, u32 *val) mutex_lock(&smi_lock); - // Set PHY to access + /* Set PHY to access */ sw_w32_mask(0xffff << 16, port << 16, RTL930X_SMI_ACCESS_PHY_CTRL_2); - // Set MMD device number and register to write to + /* Set MMD device number and register to write to */ sw_w32(devnum << 16 | (regnum & 0xffff), RTL930X_SMI_ACCESS_PHY_CTRL_3); - v = BIT(1) | BIT(0); // MMD-access | EXEC + v = BIT(1) | BIT(0); /* MMD-access | EXEC */ sw_w32(v, RTL930X_SMI_ACCESS_PHY_CTRL_1); do { v = sw_r32(RTL930X_SMI_ACCESS_PHY_CTRL_1); } while (v & BIT(0)); - // There is no error-checking via BIT 25 of v, as it does not seem to be set correctly + /* There is no error-checking via BIT 25 of v, as it does not seem to be set correctly */ *val = (sw_r32(RTL930X_SMI_ACCESS_PHY_CTRL_2) & 0xffff); pr_debug("%s: port %d, regnum: %x, val: %x (err %d)\n", __func__, port, regnum, *val, err); @@ -868,7 +868,7 @@ u32 rtl930x_hash(struct rtl838x_switch_priv *priv, u64 seed) h1 ^ (seed & 0x7ff)); - // Algorithm choice for block 0 + /* Algorithm choice for block 0 */ if (sw_r32(RTL930X_L2_CTRL) & BIT(0)) h = k1; else @@ -893,17 +893,17 @@ void rtl930x_port_eee_set(struct rtl838x_switch_priv *priv, int port, bool enabl { u32 v; - // This works only for Ethernet ports, and on the RTL930X, ports from 26 are SFP + /* This works only for Ethernet ports, and on the RTL930X, ports from 26 are SFP */ if (port >= 26) return; pr_debug("In %s: setting port %d to %d\n", __func__, port, enable); v = enable ? 0x3f : 0x0; - // Set EEE/EEEP state for 100, 500, 1000MBit and 2.5, 5 and 10GBit + /* Set EEE/EEEP state for 100, 500, 1000MBit and 2.5, 5 and 10GBit */ sw_w32_mask(0, v << 10, rtl930x_mac_force_mode_ctrl(port)); - // Set TX/RX EEE state + /* Set TX/RX EEE state */ v = enable ? 0x3 : 0x0; sw_w32(v, RTL930X_EEE_CTRL(port)); @@ -951,7 +951,7 @@ int rtl930x_eee_port_ability(struct rtl838x_switch_priv *priv, struct ethtool_ee e->lp_advertised |= ADVERTISED_10000baseT_Full; } - // Read 2x to clear latched state + /* Read 2x to clear latched state */ a = sw_r32(RTL930X_EEEP_PORT_CTRL(port)); a = sw_r32(RTL930X_EEEP_PORT_CTRL(port)); pr_info("%s RTL930X_EEEP_PORT_CTRL: %08x\n", __func__, a); @@ -965,7 +965,7 @@ static void rtl930x_init_eee(struct rtl838x_switch_priv *priv, bool enable) pr_info("Setting up EEE, state: %d\n", enable); - // Setup EEE on all ports + /* Setup EEE on all ports */ for (i = 0; i < priv->cpu_port; i++) { if (priv->ports[i].phy) rtl930x_port_eee_set(priv, i, enable); @@ -1062,11 +1062,11 @@ static void rtl930x_route_read(int idx, struct rtl83xx_route *rt) bool host_route, default_route; struct in6_addr ip6_m; - // Read L3_PREFIX_ROUTE_IPUC table (2) via register RTL9300_TBL_1 + /* Read L3_PREFIX_ROUTE_IPUC table (2) via register RTL9300_TBL_1 */ struct table_reg *r = rtl_table_get(RTL9300_TBL_1, 2); rtl_table_read(r, idx); - // The table has a size of 11 registers + /* The table has a size of 11 registers */ rt->attr.valid = !!(sw_r32(rtl_table_data(r, 0)) & BIT(31)); if (!rt->attr.valid) goto out; @@ -1080,7 +1080,7 @@ static void rtl930x_route_read(int idx, struct rtl83xx_route *rt) pr_info("%s: host route %d, default_route %d\n", __func__, host_route, default_route); switch (rt->attr.type) { - case 0: // IPv4 Unicast route + case 0: /* IPv4 Unicast route */ rt->dst_ip = sw_r32(rtl_table_data(r, 4)); ip4_m = sw_r32(rtl_table_data(r, 9)); pr_info("%s: Read ip4 mask: %08x\n", __func__, ip4_m); @@ -1089,7 +1089,7 @@ static void rtl930x_route_read(int idx, struct rtl83xx_route *rt) if (rt->prefix_len < 0) rt->prefix_len = inet_mask_len(ip4_m); break; - case 2: // IPv6 Unicast route + case 2: /* IPv6 Unicast route */ ipv6_addr_set(&rt->dst_ip6, sw_r32(rtl_table_data(r, 1)), sw_r32(rtl_table_data(r, 2)), sw_r32(rtl_table_data(r, 3)), sw_r32(rtl_table_data(r, 4))); @@ -1102,8 +1102,8 @@ static void rtl930x_route_read(int idx, struct rtl83xx_route *rt) rt->prefix_len = find_last_bit((unsigned long int *)&ip6_m.s6_addr32, 128); break; - case 1: // IPv4 Multicast route - case 3: // IPv6 Multicast route + case 1: /* IPv4 Multicast route */ + case 3: /* IPv6 Multicast route */ pr_warn("%s: route type not supported\n", __func__); goto out; } @@ -1128,7 +1128,7 @@ out: static void rtl930x_net6_mask(int prefix_len, struct in6_addr *ip6_m) { int o, b; - // Define network mask + /* Define network mask */ o = prefix_len >> 3; b = prefix_len & 0x7; memset(ip6_m->s6_addr, 0xff, o); @@ -1141,30 +1141,30 @@ static void rtl930x_net6_mask(int prefix_len, struct in6_addr *ip6_m) static void rtl930x_host_route_read(int idx, struct rtl83xx_route *rt) { u32 v; - // Read L3_HOST_ROUTE_IPUC table (1) via register RTL9300_TBL_1 + /* Read L3_HOST_ROUTE_IPUC table (1) via register RTL9300_TBL_1 */ struct table_reg *r = rtl_table_get(RTL9300_TBL_1, 1); idx = ((idx / 6) * 8) + (idx % 6); pr_debug("In %s, physical index %d\n", __func__, idx); rtl_table_read(r, idx); - // The table has a size of 5 (for UC, 11 for MC) registers + /* The table has a size of 5 (for UC, 11 for MC) registers */ v = sw_r32(rtl_table_data(r, 0)); rt->attr.valid = !!(v & BIT(31)); if (!rt->attr.valid) goto out; rt->attr.type = (v >> 29) & 0x3; switch (rt->attr.type) { - case 0: // IPv4 Unicast route + case 0: /* IPv4 Unicast route */ rt->dst_ip = sw_r32(rtl_table_data(r, 4)); break; - case 2: // IPv6 Unicast route + case 2: /* IPv6 Unicast route */ ipv6_addr_set(&rt->dst_ip6, sw_r32(rtl_table_data(r, 3)), sw_r32(rtl_table_data(r, 2)), sw_r32(rtl_table_data(r, 1)), sw_r32(rtl_table_data(r, 0))); break; - case 1: // IPv4 Multicast route - case 3: // IPv6 Multicast route + case 1: /* IPv4 Multicast route */ + case 3: /* IPv6 Multicast route */ pr_warn("%s: route type not supported\n", __func__); goto out; } @@ -1193,9 +1193,9 @@ out: static void rtl930x_host_route_write(int idx, struct rtl83xx_route *rt) { u32 v; - // Access L3_HOST_ROUTE_IPUC table (1) via register RTL9300_TBL_1 + /* Access L3_HOST_ROUTE_IPUC table (1) via register RTL9300_TBL_1 */ struct table_reg *r = rtl_table_get(RTL9300_TBL_1, 1); - // The table has a size of 5 (for UC, 11 for MC) registers + /* The table has a size of 5 (for UC, 11 for MC) registers */ idx = ((idx / 6) * 8) + (idx % 6); @@ -1205,7 +1205,7 @@ static void rtl930x_host_route_write(int idx, struct rtl83xx_route *rt) rt->attr.dst_null); pr_debug("%s: GW: %pI4, prefix_len: %d\n", __func__, &rt->dst_ip, rt->prefix_len); - v = BIT(31); // Entry is valid + v = BIT(31); /* Entry is valid */ v |= (rt->attr.type & 0x3) << 29; v |= rt->attr.hit ? BIT(20) : 0; v |= rt->attr.dst_null ? BIT(19) : 0; @@ -1218,20 +1218,20 @@ static void rtl930x_host_route_write(int idx, struct rtl83xx_route *rt) sw_w32(v, rtl_table_data(r, 0)); switch (rt->attr.type) { - case 0: // IPv4 Unicast route + case 0: /* IPv4 Unicast route */ sw_w32(0, rtl_table_data(r, 1)); sw_w32(0, rtl_table_data(r, 2)); sw_w32(0, rtl_table_data(r, 3)); sw_w32(rt->dst_ip, rtl_table_data(r, 4)); break; - case 2: // IPv6 Unicast route + case 2: /* IPv6 Unicast route */ sw_w32(rt->dst_ip6.s6_addr32[0], rtl_table_data(r, 1)); sw_w32(rt->dst_ip6.s6_addr32[1], rtl_table_data(r, 2)); sw_w32(rt->dst_ip6.s6_addr32[2], rtl_table_data(r, 3)); sw_w32(rt->dst_ip6.s6_addr32[3], rtl_table_data(r, 4)); break; - case 1: // IPv4 Multicast route - case 3: // IPv6 Multicast route + case 1: /* IPv4 Multicast route */ + case 3: /* IPv6 Multicast route */ pr_warn("%s: route type not supported\n", __func__); goto out; } @@ -1251,16 +1251,16 @@ static int rtl930x_route_lookup_hw(struct rtl83xx_route *rt) struct in6_addr ip6_m; int i; - if (rt->attr.type == 1 || rt->attr.type == 3) // Hardware only supports UC routes + if (rt->attr.type == 1 || rt->attr.type == 3) /* Hardware only supports UC routes */ return -1; sw_w32_mask(0x3 << 19, rt->attr.type, RTL930X_L3_HW_LU_KEY_CTRL); - if (rt->attr.type) { // IPv6 + if (rt->attr.type) { /* IPv6 */ rtl930x_net6_mask(rt->prefix_len, &ip6_m); for (i = 0; i < 4; i++) sw_w32(rt->dst_ip6.s6_addr32[0] & ip6_m.s6_addr32[0], RTL930X_L3_HW_LU_KEY_IP_CTRL + (i << 2)); - } else { // IPv4 + } else { /* IPv4 */ ip4_m = inet_make_mask(rt->prefix_len); sw_w32(0, RTL930X_L3_HW_LU_KEY_IP_CTRL); sw_w32(0, RTL930X_L3_HW_LU_KEY_IP_CTRL + 4); @@ -1270,17 +1270,17 @@ static int rtl930x_route_lookup_hw(struct rtl83xx_route *rt) sw_w32(v, RTL930X_L3_HW_LU_KEY_IP_CTRL + 12); } - // Execute CAM lookup in SoC + /* Execute CAM lookup in SoC */ sw_w32(BIT(15), RTL930X_L3_HW_LU_CTRL); - // Wait until execute bit clears and result is ready + /* Wait until execute bit clears and result is ready */ do { v = sw_r32(RTL930X_L3_HW_LU_CTRL); } while (v & BIT(15)); pr_info("%s: found: %d, index: %d\n", __func__, !!(v & BIT(14)), v & 0x1ff); - // Test if search successful (BIT 14 set) + /* Test if search successful (BIT 14 set) */ if (v & BIT(14)) return v & 0x1ff; @@ -1293,7 +1293,7 @@ static int rtl930x_find_l3_slot(struct rtl83xx_route *rt, bool must_exist) u32 hash; struct rtl83xx_route route_entry; - // IPv6 entries take up 3 slots + /* IPv6 entries take up 3 slots */ slot_width = (rt->attr.type == 0) || (rt->attr.type == 2) ? 1 : 3; for (t = 0; t < 2; t++) { @@ -1328,8 +1328,8 @@ static void rtl930x_route_write(int idx, struct rtl83xx_route *rt) { u32 v, ip4_m; struct in6_addr ip6_m; - // Access L3_PREFIX_ROUTE_IPUC table (2) via register RTL9300_TBL_1 - // The table has a size of 11 registers (20 for MC) + /* Access L3_PREFIX_ROUTE_IPUC table (2) via register RTL9300_TBL_1 */ + /* The table has a size of 11 registers (20 for MC) */ struct table_reg *r = rtl_table_get(RTL9300_TBL_1, 2); pr_debug("%s: index %d is valid: %d\n", __func__, idx, rt->attr.valid); @@ -1350,32 +1350,32 @@ static void rtl930x_route_write(int idx, struct rtl83xx_route *rt) v |= rt->attr.dst_null ? BIT(6) : 0; v |= rt->attr.qos_as ? BIT(6) : 0; v |= rt->attr.qos_prio & 0x7; - v |= rt->prefix_len == 0 ? BIT(20) : 0; // set default route bit + v |= rt->prefix_len == 0 ? BIT(20) : 0; /* set default route bit */ - // set bit mask for entry type always to 0x3 + /* set bit mask for entry type always to 0x3 */ sw_w32(0x3 << 29, rtl_table_data(r, 5)); switch (rt->attr.type) { - case 0: // IPv4 Unicast route + case 0: /* IPv4 Unicast route */ sw_w32(0, rtl_table_data(r, 1)); sw_w32(0, rtl_table_data(r, 2)); sw_w32(0, rtl_table_data(r, 3)); sw_w32(rt->dst_ip, rtl_table_data(r, 4)); - v |= rt->prefix_len == 32 ? BIT(21) : 0; // set host-route bit + v |= rt->prefix_len == 32 ? BIT(21) : 0; /* set host-route bit */ ip4_m = inet_make_mask(rt->prefix_len); sw_w32(0, rtl_table_data(r, 6)); sw_w32(0, rtl_table_data(r, 7)); sw_w32(0, rtl_table_data(r, 8)); sw_w32(ip4_m, rtl_table_data(r, 9)); break; - case 2: // IPv6 Unicast route + case 2: /* IPv6 Unicast route */ sw_w32(rt->dst_ip6.s6_addr32[0], rtl_table_data(r, 1)); sw_w32(rt->dst_ip6.s6_addr32[1], rtl_table_data(r, 2)); sw_w32(rt->dst_ip6.s6_addr32[2], rtl_table_data(r, 3)); sw_w32(rt->dst_ip6.s6_addr32[3], rtl_table_data(r, 4)); - v |= rt->prefix_len == 128 ? BIT(21) : 0; // set host-route bit + v |= rt->prefix_len == 128 ? BIT(21) : 0; /* set host-route bit */ rtl930x_net6_mask(rt->prefix_len, &ip6_m); @@ -1384,8 +1384,8 @@ static void rtl930x_route_write(int idx, struct rtl83xx_route *rt) sw_w32(ip6_m.s6_addr32[2], rtl_table_data(r, 8)); sw_w32(ip6_m.s6_addr32[3], rtl_table_data(r, 9)); break; - case 1: // IPv4 Multicast route - case 3: // IPv6 Multicast route + case 1: /* IPv4 Multicast route */ + case 3: /* IPv6 Multicast route */ pr_warn("%s: route type not supported\n", __func__); rtl_table_release(r); return; @@ -1409,11 +1409,11 @@ static void rtl930x_route_write(int idx, struct rtl83xx_route *rt) static void rtl930x_get_l3_nexthop(int idx, u16 *dmac_id, u16 *interface) { u32 v; - // Read L3_NEXTHOP table (3) via register RTL9300_TBL_1 + /* Read L3_NEXTHOP table (3) via register RTL9300_TBL_1 */ struct table_reg *r = rtl_table_get(RTL9300_TBL_1, 3); rtl_table_read(r, idx); - // The table has a size of 1 register + /* The table has a size of 1 register */ v = sw_r32(rtl_table_data(r, 0)); rtl_table_release(r); @@ -1442,7 +1442,7 @@ static int rtl930x_l3_mtu_add(struct rtl838x_switch_priv *priv, int mtu) int i, free_mtu; int mtu_id; - // Try to find an existing mtu-value or a free slot + /* Try to find an existing mtu-value or a free slot */ free_mtu = MAX_INTF_MTUS; for (i = 0; i < MAX_INTF_MTUS && priv->intf_mtus[i] != mtu; i++) { if ((!priv->intf_mtu_count[i]) && (free_mtu == MAX_INTF_MTUS)) @@ -1458,7 +1458,7 @@ static int rtl930x_l3_mtu_add(struct rtl838x_switch_priv *priv, int mtu) priv->intf_mtus[i] = mtu; pr_info("Writing MTU %d to slot %d\n", priv->intf_mtus[i], i); - // Set MTU-value of the slot TODO: distinguish between IPv4/IPv6 routes / slots + /* Set MTU-value of the slot TODO: distinguish between IPv4/IPv6 routes / slots */ sw_w32_mask(0xffff << ((i % 2) * 16), priv->intf_mtus[i] << ((i % 2) * 16), RTL930X_L3_IP_MTU_CTRL(i)); sw_w32_mask(0xffff << ((i % 2) * 16), priv->intf_mtus[i] << ((i % 2) * 16), @@ -1473,9 +1473,9 @@ static int rtl930x_l3_mtu_add(struct rtl838x_switch_priv *priv, int mtu) static int rtl930x_l3_intf_add(struct rtl838x_switch_priv *priv, struct rtl838x_l3_intf *intf) { int i, intf_id, mtu_id; - // number of MTU-values < 16384 + /* number of MTU-values < 16384 */ - // Use the same IPv6 mtu as the ip4 mtu for this route if unset + /* Use the same IPv6 mtu as the ip4 mtu for this route if unset */ intf->ip6_mtu = intf->ip6_mtu ? intf->ip6_mtu : intf->ip4_mtu; mtu_id = rtl930x_l3_mtu_add(priv, intf->ip4_mtu); @@ -1510,7 +1510,7 @@ static int rtl930x_l3_intf_add(struct rtl838x_switch_priv *priv, struct rtl838x_ */ static void rtl930x_set_l3_nexthop(int idx, u16 dmac_id, u16 interface) { - // Access L3_NEXTHOP table (3) via register RTL9300_TBL_1 + /* Access L3_NEXTHOP table (3) via register RTL9300_TBL_1 */ struct table_reg *r = rtl_table_get(RTL9300_TBL_1, 3); pr_info("%s: Writing to L3_NEXTHOP table, index %d, dmac_id %d, interface %d\n", @@ -1685,7 +1685,7 @@ static void rtl930x_write_pie_templated(u32 r[], struct pie_rule *pr, enum templ pr_info("%s: unknown field %d\n", __func__, field_type); } - // On the RTL9300, the mask fields are not word aligned! + /* On the RTL9300, the mask fields are not word aligned! */ if (!(i % 2)) { r[5 - i / 2] = data; r[12 - i / 2] |= ((u32)data_m << 8); @@ -1787,15 +1787,15 @@ static void rtl930x_write_pie_fixed_fields(u32 r[], struct pie_rule *pr) static void rtl930x_write_pie_action(u32 r[], struct pie_rule *pr) { - // Either drop or forward + /* Either drop or forward */ if (pr->drop) { - r[14] |= BIT(24) | BIT(25) | BIT(26); // Do Green, Yellow and Red drops - // Actually DROP, not PERMIT in Green / Yellow / Red + r[14] |= BIT(24) | BIT(25) | BIT(26); /* Do Green, Yellow and Red drops */ + /* Actually DROP, not PERMIT in Green / Yellow / Red */ r[14] |= BIT(23) | BIT(22) | BIT(20); } else { r[14] |= pr->fwd_sel ? BIT(27) : 0; r[14] |= pr->fwd_act << 18; - r[14] |= BIT(14); // We overwrite any drop + r[14] |= BIT(14); /* We overwrite any drop */ } if (pr->phase == PHASE_VACL) r[14] |= pr->fwd_sa_lrn ? BIT(15) : 0; @@ -1844,7 +1844,7 @@ void rtl930x_pie_rule_dump_raw(u32 r[]) static int rtl930x_pie_rule_write(struct rtl838x_switch_priv *priv, int idx, struct pie_rule *pr) { - // Access IACL table (2) via register 0 + /* Access IACL table (2) via register 0 */ struct table_reg *q = rtl_table_get(RTL9300_TBL_0, 2); u32 r[19]; int i; @@ -1868,7 +1868,7 @@ static int rtl930x_pie_rule_write(struct rtl838x_switch_priv *priv, int idx, str rtl930x_write_pie_action(r, pr); -// rtl930x_pie_rule_dump_raw(r); +/* rtl930x_pie_rule_dump_raw(r); */ for (i = 0; i < 19; i++) sw_w32(r[i], rtl_table_data(q, i)); @@ -1929,7 +1929,7 @@ static int rtl930x_pie_verify_template(struct rtl838x_switch_priv *priv, if (ether_addr_to_u64(pr->dmac) && !rtl930x_pie_templ_has(t, TEMPLATE_FIELD_DMAC0)) return -1; - // TODO: Check more + /* TODO: Check more */ i = find_first_zero_bit(&priv->pie_use_bm[block * 4], PIE_BLOCK_SIZE); @@ -1976,7 +1976,7 @@ static int rtl930x_pie_rule_add(struct rtl838x_switch_priv *priv, struct pie_rul set_bit(idx, priv->pie_use_bm); pr->valid = true; - pr->tid = j; // Mapped to template number + pr->tid = j; /* Mapped to template number */ pr->tid_m = 0x1; pr->id = idx; @@ -1995,10 +1995,10 @@ static int rtl930x_pie_rule_del(struct rtl838x_switch_priv *priv, int index_from pr_debug("%s: from %d to %d\n", __func__, index_from, index_to); mutex_lock(&priv->reg_mutex); - // Write from-to and execute bit into control register + /* Write from-to and execute bit into control register */ sw_w32(v, RTL930X_PIE_CLR_CTRL); - // Wait until command has completed + /* Wait until command has completed */ do { } while (sw_r32(RTL930X_PIE_CLR_CTRL) & BIT(0)); @@ -2022,35 +2022,35 @@ static void rtl930x_pie_init(struct rtl838x_switch_priv *priv) mutex_init(&priv->pie_mutex); pr_info("%s\n", __func__); - // Enable ACL lookup on all ports, including CPU_PORT + /* Enable ACL lookup on all ports, including CPU_PORT */ for (i = 0; i <= priv->cpu_port; i++) sw_w32(1, RTL930X_ACL_PORT_LOOKUP_CTRL(i)); - // Include IPG in metering + /* Include IPG in metering */ sw_w32_mask(0, 1, RTL930X_METER_GLB_CTRL); - // Delete all present rules, block size is 128 on all SoC families + /* Delete all present rules, block size is 128 on all SoC families */ rtl930x_pie_rule_del(priv, 0, priv->n_pie_blocks * 128 - 1); - // Assign blocks 0-7 to VACL phase (bit = 0), blocks 8-15 to IACL (bit = 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 + /* Enable predefined templates 0, 1 for first quarter of all blocks */ template_selectors = 0 | (1 << 4); for (i = 0; i < priv->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 + /* Enable predefined templates 2, 3 for second quarter of all blocks */ template_selectors = 2 | (3 << 4); for (i = priv->n_pie_blocks / 4; i < priv->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 + /* Enable predefined templates 0, 1 for third half of all blocks */ template_selectors = 0 | (1 << 4); for (i = priv->n_pie_blocks / 2; i < priv->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 + /* Enable predefined templates 2, 3 for fourth quater of all blocks */ template_selectors = 2 | (3 << 4); for (i = priv->n_pie_blocks * 3 / 4; i < priv->n_pie_blocks; i++) sw_w32(template_selectors, RTL930X_PIE_BLK_TMPLTE_CTRL(i)); @@ -2066,10 +2066,10 @@ static void rtl930x_pie_init(struct rtl838x_switch_priv *priv) static void rtl930x_set_l3_egress_intf(int idx, struct rtl838x_l3_intf *intf) { u32 u, v; - // Read L3_EGR_INTF table (4) via register RTL9300_TBL_1 + /* Read L3_EGR_INTF table (4) via register RTL9300_TBL_1 */ struct table_reg *r = rtl_table_get(RTL9300_TBL_1, 4); - // The table has 2 registers + /* The table has 2 registers */ u = (intf->vid & 0xfff) << 9; u |= (intf->smac_idx & 0x3f) << 3; u |= (intf->ip4_mtu_id & 0x7); @@ -2097,11 +2097,11 @@ static void rtl930x_set_l3_egress_intf(int idx, struct rtl838x_l3_intf *intf) static void rtl930x_get_l3_router_mac(u32 idx, struct rtl93xx_rt_mac *m) { u32 v, w; - // Read L3_ROUTER_MAC table (0) via register RTL9300_TBL_1 + /* Read L3_ROUTER_MAC table (0) via register RTL9300_TBL_1 */ struct table_reg *r = rtl_table_get(RTL9300_TBL_1, 0); rtl_table_read(r, idx); - // The table has a size of 7 registers, 64 entries + /* The table has a size of 7 registers, 64 entries */ v = sw_r32(rtl_table_data(r, 0)); w = sw_r32(rtl_table_data(r, 3)); m->valid = !!(v & BIT(20)); @@ -2109,7 +2109,7 @@ static void rtl930x_get_l3_router_mac(u32 idx, struct rtl93xx_rt_mac *m) goto out; m->p_type = !!(v & BIT(19)); - m->p_id = (v >> 13) & 0x3f; // trunk id of port + m->p_id = (v >> 13) & 0x3f; /* trunk id of port */ m->vid = v & 0xfff; m->vid_mask = w & 0xfff; m->action = sw_r32(rtl_table_data(r, 6)) & 0x7; @@ -2117,7 +2117,7 @@ static void rtl930x_get_l3_router_mac(u32 idx, struct rtl93xx_rt_mac *m) (sw_r32(rtl_table_data(r, 4))); m->mac = ((((u64)sw_r32(rtl_table_data(r, 1))) << 32) & 0xffffffffffffULL) | (sw_r32(rtl_table_data(r, 2))); - // Bits L3_INTF and BMSK_L3_INTF are 0 + /* Bits L3_INTF and BMSK_L3_INTF are 0 */ out: rtl_table_release(r); @@ -2130,13 +2130,13 @@ out: static void rtl930x_set_l3_router_mac(u32 idx, struct rtl93xx_rt_mac *m) { u32 v, w; - // Read L3_ROUTER_MAC table (0) via register RTL9300_TBL_1 + /* Read L3_ROUTER_MAC table (0) via register RTL9300_TBL_1 */ struct table_reg *r = rtl_table_get(RTL9300_TBL_1, 0); - // The table has a size of 7 registers, 64 entries - v = BIT(20); // mac entry valid, port type is 0: individual + /* The table has a size of 7 registers, 64 entries */ + v = BIT(20); /* mac entry valid, port type is 0: individual */ v |= (m->p_id & 0x3f) << 13; - v |= (m->vid & 0xfff); // Set the interface_id to the vlan id + v |= (m->vid & 0xfff); /* Set the interface_id to the vlan id */ w = m->vid_mask; w |= (m->p_id_mask & 0x3f) << 13; @@ -2144,11 +2144,11 @@ static void rtl930x_set_l3_router_mac(u32 idx, struct rtl93xx_rt_mac *m) sw_w32(v, rtl_table_data(r, 0)); sw_w32(w, rtl_table_data(r, 3)); - // Set MAC address, L3_INTF (bit 12 in register 1) needs to be 0 + /* Set MAC address, L3_INTF (bit 12 in register 1) needs to be 0 */ sw_w32((u32)(m->mac), rtl_table_data(r, 2)); sw_w32(m->mac >> 32, rtl_table_data(r, 1)); - // Set MAC address mask, BMSK_L3_INTF (bit 12 in register 5) needs to be 0 + /* Set MAC address mask, BMSK_L3_INTF (bit 12 in register 5) needs to be 0 */ sw_w32((u32)(m->mac_mask >> 32), rtl_table_data(r, 4)); sw_w32((u32)m->mac_mask, rtl_table_data(r, 5)); @@ -2170,11 +2170,11 @@ static void rtl930x_set_l3_router_mac(u32 idx, struct rtl93xx_rt_mac *m) static u64 rtl930x_get_l3_egress_mac(u32 idx) { u64 mac; - // Read L3_EGR_INTF_MAC table (2) via register RTL9300_TBL_2 + /* Read L3_EGR_INTF_MAC table (2) via register RTL9300_TBL_2 */ struct table_reg *r = rtl_table_get(RTL9300_TBL_2, 2); rtl_table_read(r, idx); - // The table has a size of 2 registers + /* The table has a size of 2 registers */ mac = sw_r32(rtl_table_data(r, 0)); mac <<= 32; mac |= sw_r32(rtl_table_data(r, 1)); @@ -2189,10 +2189,10 @@ static u64 rtl930x_get_l3_egress_mac(u32 idx) */ static void rtl930x_set_l3_egress_mac(u32 idx, u64 mac) { - // Access L3_EGR_INTF_MAC table (2) via register RTL9300_TBL_2 + /* Access L3_EGR_INTF_MAC table (2) via register RTL9300_TBL_2 */ struct table_reg *r = rtl_table_get(RTL9300_TBL_2, 2); - // The table has a size of 2 registers + /* The table has a size of 2 registers */ sw_w32(mac >> 32, rtl_table_data(r, 0)); sw_w32(mac, rtl_table_data(r, 1)); @@ -2211,11 +2211,11 @@ int rtl930x_l3_setup(struct rtl838x_switch_priv *priv) { int i; - // Setup MTU with id 0 for default interface + /* Setup MTU with id 0 for default interface */ for (i = 0; i < MAX_INTF_MTUS; i++) priv->intf_mtu_count[i] = priv->intf_mtus[i] = 0; - priv->intf_mtu_count[0] = 0; // Needs to stay forever + priv->intf_mtu_count[0] = 0; /* Needs to stay forever */ priv->intf_mtus[0] = DEFAULT_MTU; sw_w32_mask(0xffff, DEFAULT_MTU, RTL930X_L3_IP_MTU_CTRL(0)); sw_w32_mask(0xffff, DEFAULT_MTU, RTL930X_L3_IP6_MTU_CTRL(0)); @@ -2228,13 +2228,13 @@ int rtl930x_l3_setup(struct rtl838x_switch_priv *priv) sw_w32_mask(0xffff0000, DEFAULT_MTU << 16, RTL930X_L3_IP_MTU_CTRL(1)); sw_w32_mask(0xffff0000, DEFAULT_MTU << 16, RTL930X_L3_IP6_MTU_CTRL(1)); - // Clear all source port MACs + /* Clear all source port MACs */ for (i = 0; i < MAX_SMACS; i++) rtl930x_set_l3_egress_mac(L3_EGRESS_DMACS + i, 0ULL); - // Configure the default L3 hash algorithm - sw_w32_mask(BIT(2), 0, RTL930X_L3_HOST_TBL_CTRL); // Algorithm selection 0 = 0 - sw_w32_mask(0, BIT(3), RTL930X_L3_HOST_TBL_CTRL); // Algorithm selection 1 = 1 + /* Configure the default L3 hash algorithm */ + sw_w32_mask(BIT(2), 0, RTL930X_L3_HOST_TBL_CTRL); /* Algorithm selection 0 = 0 */ + sw_w32_mask(0, BIT(3), RTL930X_L3_HOST_TBL_CTRL); /* Algorithm selection 1 = 1 */ pr_info("L3_IPUC_ROUTE_CTRL %08x, IPMC_ROUTE %08x, IP6UC_ROUTE %08x, IP6MC_ROUTE %08x\n", sw_r32(RTL930X_L3_IPUC_ROUTE_CTRL), sw_r32(RTL930X_L3_IPMC_ROUTE_CTRL), @@ -2253,13 +2253,13 @@ int rtl930x_l3_setup(struct rtl838x_switch_priv *priv) sw_r32(RTL930X_L3_IPUC_ROUTE_CTRL), sw_r32(RTL930X_L3_IPMC_ROUTE_CTRL), sw_r32(RTL930X_L3_IP6UC_ROUTE_CTRL), sw_r32(RTL930X_L3_IP6MC_ROUTE_CTRL)); - // Trap non-ip traffic to the CPU-port (e.g. ARP so we stay reachable) + /* Trap non-ip traffic to the CPU-port (e.g. ARP so we stay reachable) */ sw_w32_mask(0x3 << 8, 0x1 << 8, RTL930X_L3_IP_ROUTE_CTRL); pr_info("L3_IP_ROUTE_CTRL %08x\n", sw_r32(RTL930X_L3_IP_ROUTE_CTRL)); - // PORT_ISO_RESTRICT_ROUTE_CTRL ? + /* PORT_ISO_RESTRICT_ROUTE_CTRL? */ - // Do not use prefix route 0 because of HW limitations + /* Do not use prefix route 0 because of HW limitations */ set_bit(0, priv->route_use_bm); return 0; @@ -2269,7 +2269,7 @@ static u32 rtl930x_packet_cntr_read(int counter) { u32 v; - // Read LOG table (3) via register RTL9300_TBL_0 + /* Read LOG table (3) via register RTL9300_TBL_0 */ struct table_reg *r = rtl_table_get(RTL9300_TBL_0, 3); pr_debug("In %s, id %d\n", __func__, counter); @@ -2277,7 +2277,7 @@ static u32 rtl930x_packet_cntr_read(int counter) pr_debug("Registers: %08x %08x\n", sw_r32(rtl_table_data(r, 0)), sw_r32(rtl_table_data(r, 1))); - // The table has a size of 2 registers + /* The table has a size of 2 registers */ if (counter % 2) v = sw_r32(rtl_table_data(r, 0)); else @@ -2290,11 +2290,11 @@ static u32 rtl930x_packet_cntr_read(int counter) static void rtl930x_packet_cntr_clear(int counter) { - // Access LOG table (3) via register RTL9300_TBL_0 + /* Access LOG table (3) via register RTL9300_TBL_0 */ struct table_reg *r = rtl_table_get(RTL9300_TBL_0, 3); pr_info("In %s, id %d\n", __func__, counter); - // The table has a size of 2 registers + /* The table has a size of 2 registers */ if (counter % 2) sw_w32(0, rtl_table_data(r, 0)); else @@ -2447,10 +2447,10 @@ static void rtl930x_led_init(struct rtl838x_switch_priv *priv) sw_w32(v, RTL930X_LED_SET0_0_CTRL - i * 8); } - // Set LED mode to serial (0x1) + /* Set LED mode to serial (0x1) */ sw_w32_mask(0x3, 0x1, RTL930X_LED_GLB_CTRL); - // Set port type masks + /* Set port type masks */ sw_w32(pm, RTL930X_LED_PORT_COPR_MASK_CTRL); sw_w32(pm, RTL930X_LED_PORT_FIB_MASK_CTRL); sw_w32(pm, RTL930X_LED_PORT_COMBO_MASK_CTRL); @@ -2477,7 +2477,7 @@ const struct rtl838x_reg rtl930x_reg = { .l2_ctrl_1 = RTL930X_L2_AGE_CTRL, .l2_port_aging_out = RTL930X_L2_PORT_AGE_CTRL, .set_ageing_time = rtl930x_set_ageing_time, - .smi_poll_ctrl = RTL930X_SMI_POLL_CTRL, // TODO: Difference to RTL9300_SMI_PRVTE_POLLING_CTRL + .smi_poll_ctrl = RTL930X_SMI_POLL_CTRL, /* TODO: Difference to RTL9300_SMI_PRVTE_POLLING_CTRL */ .l2_tbl_flush_ctrl = RTL930X_L2_TBL_FLUSH_CTRL, .exec_tbl0_cmd = rtl930x_exec_tbl0_cmd, .exec_tbl1_cmd = rtl930x_exec_tbl1_cmd, diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl931x.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl931x.c index 802eecccd8..cd7c5edf51 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl931x.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl931x.c @@ -80,9 +80,9 @@ enum template_field_id { */ #define TEMPLATE_FIELD_VLAN TEMPLATE_FIELD_ITAG -// Number of fixed templates predefined in the RTL9300 SoC +/* Number of fixed templates predefined in the RTL9300 SoC */ #define N_FIXED_TEMPLATES 5 -// RTL931x specific predefined templates +/* RTL931x specific predefined templates */ static enum template_field_id fixed_templates[N_FIXED_TEMPLATES][N_FIXED_FIELDS_RTL931X] = { { @@ -188,7 +188,7 @@ inline static int rtl931x_trk_mbr_ctr(int group) static void rtl931x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info) { u32 v, w, x, y; - // Read VLAN table (3) via register 0 + /* Read VLAN table (3) via register 0 */ struct table_reg *r = rtl_table_get(RTL9310_TBL_0, 3); rtl_table_read(r, vlan); @@ -201,7 +201,7 @@ static void rtl931x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info) pr_debug("VLAN_READ %d: %08x %08x %08x %08x\n", vlan, v, w, x, y); info->tagged_ports = ((u64) v) << 25 | (w >> 7); info->profile_id = (x >> 16) & 0xf; - info->fid = w & 0x7f; // AKA MSTI depending on context + info->fid = w & 0x7f; /* AKA MSTI depending on context */ info->hash_uc_fid = !!(x & BIT(31)); info->hash_mc_fid = !!(x & BIT(30)); info->if_id = (x >> 20) & 0x3ff; @@ -215,7 +215,7 @@ static void rtl931x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info) info->tagged_ports, info->profile_id, info->hash_uc_fid, info->hash_mc_fid, info->if_id); - // Read UNTAG table via table register 3 + /* Read UNTAG table via table register 3 */ r = rtl_table_get(RTL9310_TBL_3, 0); rtl_table_read(r, vlan); v = ((u64)sw_r32(rtl_table_data(r, 0))) << 25; @@ -228,7 +228,7 @@ static void rtl931x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info) static void rtl931x_vlan_set_tagged(u32 vlan, struct rtl838x_vlan_info *info) { u32 v, w, x, y; - // Access VLAN table (1) via register 0 + /* Access VLAN table (1) via register 0 */ struct table_reg *r = rtl_table_get(RTL9310_TBL_0, 3); v = info->tagged_ports >> 25; @@ -302,7 +302,7 @@ irqreturn_t rtl931x_switch_irq(int irq, void *dev_id) pr_debug("RTL931X Link change: status: %x, ports %016llx\n", status, ports); link = rtl839x_get_port_reg_le(RTL931X_MAC_LINK_STS); - // Must re-read this to get correct status + /* Must re-read this to get correct status */ link = rtl839x_get_port_reg_le(RTL931X_MAC_LINK_STS); pr_debug("RTL931X Link change: status: %x, link status %016llx\n", status, link); @@ -402,20 +402,20 @@ int rtl931x_read_mmd_phy(u32 port, u32 devnum, u32 regnum, u32 *val) mutex_lock(&smi_lock); - // Set PHY to access via port-number + /* Set PHY to access via port-number */ sw_w32(port << 5, RTL931X_SMI_INDRT_ACCESS_BC_PHYID_CTRL); - // Set MMD device number and register to write to + /* Set MMD device number and register to write to */ sw_w32(devnum << 16 | mdiobus_c45_regad(regnum), RTL931X_SMI_INDRT_ACCESS_MMD_CTRL); - v = type << 2 | BIT(0); // MMD-access-type | EXEC + v = type << 2 | BIT(0); /* MMD-access-type | EXEC */ sw_w32(v, RTL931X_SMI_INDRT_ACCESS_CTRL_0); do { v = sw_r32(RTL931X_SMI_INDRT_ACCESS_CTRL_0); } while (v & BIT(0)); - // Check for error condition + /* Check for error condition */ if (v & BIT(1)) err = -EIO; @@ -439,18 +439,18 @@ int rtl931x_write_mmd_phy(u32 port, u32 devnum, u32 regnum, u32 val) mutex_lock(&smi_lock); - // Set PHY to access via port-mask + /* Set PHY to access via port-mask */ pm = (u64)1 << port; sw_w32((u32)pm, RTL931X_SMI_INDRT_ACCESS_CTRL_2); sw_w32((u32)(pm >> 32), RTL931X_SMI_INDRT_ACCESS_CTRL_2 + 4); - // Set data to write + /* Set data to write */ sw_w32_mask(0xffff, val, RTL931X_SMI_INDRT_ACCESS_CTRL_3); - // Set MMD device number and register to write to + /* Set MMD device number and register to write to */ sw_w32(devnum << 16 | mdiobus_c45_regad(regnum), RTL931X_SMI_INDRT_ACCESS_MMD_CTRL); - v = BIT(4) | type << 2 | BIT(0); // WRITE | MMD-access-type | EXEC + v = BIT(4) | type << 2 | BIT(0); /* WRITE | MMD-access-type | EXEC */ sw_w32(v, RTL931X_SMI_INDRT_ACCESS_CTRL_0); do { @@ -508,9 +508,9 @@ void rtl931x_set_receive_management_action(int port, rma_ctrl_t type, action_typ sw_w32_mask(7 << ((port % 10) * 3), value << ((port % 10) * 3), RTL931X_RMA_BPDU_CTRL + ((port / 10) << 2)); break; case PTP: - //udp + /* udp */ sw_w32_mask(3 << 2, value << 2, RTL931X_RMA_PTP_CTRL + (port << 2)); - //eth2 + /* eth2 */ sw_w32_mask(3, value, RTL931X_RMA_PTP_CTRL + (port << 2)); break; case PTP_UDP: @@ -609,7 +609,7 @@ static u32 rtl931x_l2_hash_key(struct rtl838x_switch_priv *priv, u64 seed) h4 = (seed >> 48) & 0xfff; k1 = h0 ^ h1 ^ h2 ^ h3 ^ h4; - // Algorithm choice for block 0 + /* Algorithm choice for block 0 */ if (sw_r32(RTL931X_L2_CTRL) & BIT(0)) h = k1; else @@ -659,7 +659,7 @@ static void rtl931x_fill_l2_entry(u32 r[], struct rtl838x_l2_entry *e) e->is_l2_tunnel = !!(r[2] & BIT(31)); e->is_static = !!(r[2] & BIT(13)); e->port = (r[2] >> 19) & 0x3ff; - // Check for trunk port + /* Check for trunk port */ if (r[2] & BIT(29)) { e->is_trunk = true; e->stack_dev = (e->port >> 9) & 1; @@ -675,7 +675,7 @@ static void rtl931x_fill_l2_entry(u32 r[], struct rtl838x_l2_entry *e) e->suspended = !!(r[2] & BIT(12)); e->age = (r[2] >> 16) & 3; - // the UC_VID field in hardware is used for the VID or for the route id + /* the UC_VID field in hardware is used for the VID or for the route id */ if (e->next_hop) { e->nh_route_id = r[2] & 0x7ff; e->vid = 0; @@ -685,7 +685,7 @@ static void rtl931x_fill_l2_entry(u32 r[], struct rtl838x_l2_entry *e) } if (e->is_l2_tunnel) e->l2_tunnel_id = ((r[2] & 0xff) << 4) | (r[3] >> 28); - // TODO: Implement VLAN conversion + /* TODO: Implement VLAN conversion */ } else { e->type = L2_MULTICAST; e->is_local_forward = !!(r[2] & BIT(31)); @@ -705,7 +705,7 @@ static void rtl931x_fill_l2_row(u32 r[], struct rtl838x_l2_entry *e) return; } - r[2] = BIT(31); // Set valid bit + r[2] = BIT(31); /* Set valid bit */ r[0] = ((u32)e->mac[0]) << 24 | ((u32)e->mac[1]) << 16 | @@ -732,12 +732,12 @@ static void rtl931x_fill_l2_row(u32 r[], struct rtl838x_l2_entry *e) r[2] |= e->block_sa ? BIT(17) : 0; r[2] |= e->suspended ? BIT(13) : 0; r[2] |= (e->age & 0x3) << 17; - // the UC_VID field in hardware is used for the VID or for the route id + /* the UC_VID field in hardware is used for the VID or for the route id */ if (e->next_hop) r[2] |= e->nh_route_id & 0x7ff; else r[2] |= e->vid & 0xfff; - } else { // L2_MULTICAST + } else { /* L2_MULTICAST */ r[2] |= (e->mc_portmask_index & 0x3ff) << 16; r[2] |= e->mc_mac_index & 0x7ff; } @@ -769,7 +769,7 @@ static u64 rtl931x_read_l2_entry_using_hash(u32 hash, u32 pos, struct rtl838x_l2 hash &= 0xffff; } - idx = (0 << 14) | (hash << 2) | pos; // Search SRAM, with hash and at pos in bucket + idx = (0 << 14) | (hash << 2) | pos; /* Search SRAM, with hash and at pos in bucket */ pr_debug("%s: NOW hash %08x, pos: %d\n", __func__, hash, pos); rtl_table_read(q, idx); @@ -794,7 +794,7 @@ static u64 rtl931x_read_l2_entry_using_hash(u32 hash, u32 pos, struct rtl838x_l2 seed = rtl931x_l2_hash_seed(mac, e->rvid); pr_debug("%s: mac %016llx, seed %016llx\n", __func__, mac, seed); - // return vid with concatenated mac as unique id + /* return vid with concatenated mac as unique id */ return seed; } @@ -811,7 +811,7 @@ static void rtl931x_write_l2_entry_using_hash(u32 hash, u32 pos, struct rtl838x_ { u32 r[4]; struct table_reg *q = rtl_table_get(RTL9310_TBL_0, 0); - u32 idx = (0 << 14) | (hash << 2) | pos; // Access SRAM, with hash and at pos in bucket + u32 idx = (0 << 14) | (hash << 2) | pos; /* Access SRAM, with hash and at pos in bucket */ int i; pr_info("%s: hash %d, pos %d\n", __func__, hash, pos); @@ -830,7 +830,7 @@ static void rtl931x_write_l2_entry_using_hash(u32 hash, u32 pos, struct rtl838x_ static void rtl931x_vlan_fwd_on_inner(int port, bool is_set) { - // Always set all tag modes to fwd based on either inner or outer tag + /* Always set all tag modes to fwd based on either inner or outer tag */ if (is_set) sw_w32_mask(0, 0xf, RTL931X_VLAN_PORT_FWD + (port << 2)); else @@ -849,15 +849,15 @@ static void rtl931x_vlan_profile_setup(int profile) p[0] = sw_r32(RTL931X_VLAN_PROFILE_SET(profile)); - // Enable routing of Ipv4/6 Unicast and IPv4/6 Multicast traffic - //p[0] |= BIT(17) | BIT(16) | BIT(13) | BIT(12); - p[0] |= 0x3 << 11; // COPY2CPU + /* Enable routing of Ipv4/6 Unicast and IPv4/6 Multicast traffic */ + /* p[0] |= BIT(17) | BIT(16) | BIT(13) | BIT(12); */ + p[0] |= 0x3 << 11; /* COPY2CPU */ - p[1] = 0x1FFFFFF; // L2 unknwon MC flooding portmask all ports, including the CPU-port + p[1] = 0x1FFFFFF; /* L2 unknwon MC flooding portmask all ports, including the CPU-port */ p[2] = 0xFFFFFFFF; - p[3] = 0x1FFFFFF; // IPv4 unknwon MC flooding portmask + p[3] = 0x1FFFFFF; /* IPv4 unknwon MC flooding portmask */ p[4] = 0xFFFFFFFF; - p[5] = 0x1FFFFFF; // IPv6 unknwon MC flooding portmask + p[5] = 0x1FFFFFF; /* IPv6 unknwon MC flooding portmask */ p[6] = 0xFFFFFFFF; for (int i = 0; i < 7; i++) @@ -867,20 +867,20 @@ static void rtl931x_vlan_profile_setup(int profile) static void rtl931x_l2_learning_setup(void) { - // Portmask for flooding broadcast traffic + /* Portmask for flooding broadcast traffic */ rtl839x_set_port_reg_be(0x1FFFFFFFFFFFFFF, RTL931X_L2_BC_FLD_PMSK); - // Portmask for flooding unicast traffic with unknown destination + /* Portmask for flooding unicast traffic with unknown destination */ rtl839x_set_port_reg_be(0x1FFFFFFFFFFFFFF, RTL931X_L2_UNKN_UC_FLD_PMSK); - // Limit learning to maximum: 64k entries, after that just flood (bits 0-2) + /* Limit learning to maximum: 64k entries, after that just flood (bits 0-2) */ sw_w32((0xffff << 3) | FORWARD, RTL931X_L2_LRN_CONSTRT_CTRL); } static u64 rtl931x_read_mcast_pmask(int idx) { u64 portmask; - // Read MC_PMSK (2) via register RTL9310_TBL_0 + /* Read MC_PMSK (2) via register RTL9310_TBL_0 */ struct table_reg *q = rtl_table_get(RTL9310_TBL_0, 2); rtl_table_read(q, idx); @@ -899,7 +899,7 @@ static void rtl931x_write_mcast_pmask(int idx, u64 portmask) { u64 pm = portmask; - // Access MC_PMSK (2) via register RTL9310_TBL_0 + /* Access MC_PMSK (2) via register RTL9310_TBL_0 */ struct table_reg *q = rtl_table_get(RTL9310_TBL_0, 2); pr_debug("%s: Index idx %d has portmask %016llx\n", __func__, idx, pm); @@ -928,7 +928,7 @@ static int rtl931x_set_ageing_time(unsigned long msec) } void rtl931x_sw_init(struct rtl838x_switch_priv *priv) { -// rtl931x_sds_init(priv); +/* rtl931x_sds_init(priv); */ } static void rtl931x_pie_lookup_enable(struct rtl838x_switch_priv *priv, int index) @@ -1109,7 +1109,7 @@ static void rtl931x_write_pie_templated(u32 r[], struct pie_rule *pr, enum templ for (i = 0; i < N_FIXED_FIELDS; i++) { rtl931x_pie_data_fill(t[i], pr, &data, &data_m); - // On the RTL9300, the mask fields are not word aligned! + /* On the RTL9300, the mask fields are not word aligned! */ if (!(i % 2)) { r[5 - i / 2] = data; r[12 - i / 2] |= ((u32)data_m << 8); @@ -1126,7 +1126,7 @@ static void rtl931x_read_pie_fixed_fields(u32 r[], struct pie_rule *pr) pr->mgnt_vlan = r[7] & BIT(31); if (pr->phase == PHASE_IACL) pr->dmac_hit_sw = r[7] & BIT(30); - else // TODO: EACL/VACL phase handling + else /* TODO: EACL/VACL phase handling */ pr->content_too_deep = r[7] & BIT(30); pr->not_first_frag = r[7] & BIT(29); pr->frame_type_l4 = (r[7] >> 26) & 7; @@ -1203,15 +1203,15 @@ static void rtl931x_write_pie_fixed_fields(u32 r[], struct pie_rule *pr) static void rtl931x_write_pie_action(u32 r[], struct pie_rule *pr) { - // Either drop or forward + /* Either drop or forward */ if (pr->drop) { - r[15] |= BIT(11) | BIT(12) | BIT(13); // Do Green, Yellow and Red drops - // Actually DROP, not PERMIT in Green / Yellow / Red + r[15] |= BIT(11) | BIT(12) | BIT(13); /* Do Green, Yellow and Red drops */ + /* Actually DROP, not PERMIT in Green / Yellow / Red */ r[16] |= BIT(27) | BIT(28) | BIT(29); } else { r[15] |= pr->fwd_sel ? BIT(14) : 0; r[16] |= pr->fwd_act << 24; - r[16] |= BIT(21); // We overwrite any drop + r[16] |= BIT(21); /* We overwrite any drop */ } if (pr->phase == PHASE_VACL) r[16] |= pr->fwd_sa_lrn ? BIT(22) : 0; @@ -1225,7 +1225,7 @@ static void rtl931x_write_pie_action(u32 r[], struct pie_rule *pr) r[15] |= pr->log_sel ? BIT(26) : 0; r[16] |= ((u32)(pr->fwd_data & 0xfff)) << 9; -// r[15] |= pr->log_octets ? BIT(31) : 0; +/* r[15] |= pr->log_octets ? BIT(31) : 0; */ r[15] |= (u32)(pr->meter_data) >> 2; r[16] |= (((u32)(pr->meter_data) >> 7) & 0x3) << 29; @@ -1261,7 +1261,7 @@ void rtl931x_pie_rule_dump_raw(u32 r[]) static int rtl931x_pie_rule_write(struct rtl838x_switch_priv *priv, int idx, struct pie_rule *pr) { - // Access IACL table (0) via register 1, the table size is 4096 + /* Access IACL table (0) via register 1, the table size is 4096 */ struct table_reg *q = rtl_table_get(RTL9310_TBL_1, 0); u32 r[22]; int i; @@ -1346,7 +1346,7 @@ static int rtl931x_pie_verify_template(struct rtl838x_switch_priv *priv, if (ether_addr_to_u64(pr->dmac) && !rtl931x_pie_templ_has(t, TEMPLATE_FIELD_DMAC0)) return -1; - // TODO: Check more + /* TODO: Check more */ i = find_first_zero_bit(&priv->pie_use_bm[block * 4], PIE_BLOCK_SIZE); @@ -1393,7 +1393,7 @@ static int rtl931x_pie_rule_add(struct rtl838x_switch_priv *priv, struct pie_rul set_bit(idx, priv->pie_use_bm); pr->valid = true; - pr->tid = j; // Mapped to template number + pr->tid = j; /* Mapped to template number */ pr->tid_m = 0x1; pr->id = idx; @@ -1413,10 +1413,10 @@ static int rtl931x_pie_rule_del(struct rtl838x_switch_priv *priv, int index_from pr_info("%s: from %d to %d\n", __func__, index_from, index_to); mutex_lock(&priv->reg_mutex); - // Write from-to and execute bit into control register + /* Write from-to and execute bit into control register */ sw_w32(v, RTL931X_PIE_CLR_CTRL); - // Wait until command has completed + /* Wait until command has completed */ do { } while (sw_r32(RTL931X_PIE_CLR_CTRL) & BIT(0)); @@ -1441,21 +1441,21 @@ static void rtl931x_pie_init(struct rtl838x_switch_priv *priv) mutex_init(&priv->pie_mutex); pr_info("%s\n", __func__); - // Enable ACL lookup on all ports, including CPU_PORT + /* Enable ACL lookup on all ports, including CPU_PORT */ for (i = 0; i <= priv->cpu_port; i++) sw_w32(1, RTL931X_ACL_PORT_LOOKUP_CTRL(i)); - // Include IPG in metering + /* Include IPG in metering */ sw_w32_mask(0, 1, RTL931X_METER_GLB_CTRL); - // Delete all present rules, block size is 128 on all SoC families + /* Delete all present rules, block size is 128 on all SoC families */ rtl931x_pie_rule_del(priv, 0, priv->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 + /* 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 (i = 0; i < priv->n_pie_blocks; i++) { int pos = (i % 10) * 3; u32 r = RTL931X_PIE_BLK_PHASE_CTRL + 4 * (i / 10); @@ -1466,22 +1466,22 @@ static void rtl931x_pie_init(struct rtl838x_switch_priv *priv) sw_w32_mask(0x7 << pos, 1 << pos, r); } - // Enable predefined templates 0, 1 for first quarter of all blocks + /* Enable predefined templates 0, 1 for first quarter of all blocks */ template_selectors = 0 | (1 << 4); for (i = 0; i < priv->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 + /* Enable predefined templates 2, 3 for second quarter of all blocks */ template_selectors = 2 | (3 << 4); for (i = priv->n_pie_blocks / 4; i < priv->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 + /* Enable predefined templates 0, 1 for third quater of all blocks */ template_selectors = 0 | (1 << 4); for (i = priv->n_pie_blocks / 2; i < priv->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 + /* Enable predefined templates 2, 3 for fourth quater of all blocks */ template_selectors = 2 | (3 << 4); for (i = priv->n_pie_blocks * 3 / 4; i < priv->n_pie_blocks; i++) sw_w32(template_selectors, RTL931X_PIE_BLK_TMPLTE_CTRL(i)); @@ -1595,7 +1595,7 @@ static void rtl931x_led_init(struct rtl838x_switch_priv *priv) if (!priv->ports[i].phy) continue; - v = 0x1; // Found on the EdgeCore, but we do not have any HW description + v = 0x1; /* Found on the EdgeCore, but we do not have any HW description */ sw_w32_mask(0x3 << pos, v << pos, RTL931X_LED_PORT_NUM_CTRL(i)); if (priv->ports[i].phy_is_integrated) @@ -1620,7 +1620,7 @@ static void rtl931x_led_init(struct rtl838x_switch_priv *priv) sw_w32(v, RTL931X_LED_SET0_0_CTRL - i * 8); } - // Set LED mode to serial (0x1) + /* Set LED mode to serial (0x1) */ sw_w32_mask(0x3, 0x1, RTL931X_LED_GLB_CTRL); rtl839x_set_port_reg_le(pm_copper, RTL931X_LED_PORT_COPR_MASK_CTRL); @@ -1640,7 +1640,7 @@ const struct rtl838x_reg rtl931x_reg = { .get_port_reg_le = rtl839x_get_port_reg_le, .stat_port_rst = RTL931X_STAT_PORT_RST, .stat_rst = RTL931X_STAT_RST, - .stat_port_std_mib = 0, // Not defined + .stat_port_std_mib = 0, /* Not defined */ .traffic_enable = rtl931x_traffic_enable, .traffic_disable = rtl931x_traffic_disable, .traffic_get = rtl931x_traffic_get, @@ -1649,7 +1649,7 @@ const struct rtl838x_reg rtl931x_reg = { .l2_ctrl_1 = RTL931X_L2_AGE_CTRL, .l2_port_aging_out = RTL931X_L2_PORT_AGE_CTRL, .set_ageing_time = rtl931x_set_ageing_time, - // .smi_poll_ctrl does not exist + /* .smi_poll_ctrl does not exist */ .l2_tbl_flush_ctrl = RTL931X_L2_TBL_FLUSH_CTRL, .exec_tbl0_cmd = rtl931x_exec_tbl0_cmd, .exec_tbl1_cmd = rtl931x_exec_tbl1_cmd, @@ -1657,7 +1657,7 @@ const struct rtl838x_reg rtl931x_reg = { .isr_glb_src = RTL931X_ISR_GLB_SRC, .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 + /* imr_glb does not exist on RTL931X */ .vlan_tables_read = rtl931x_vlan_tables_read, .vlan_set_tagged = rtl931x_vlan_set_tagged, .vlan_set_untagged = rtl931x_vlan_set_untagged, diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/tc.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/tc.c index 401fb4553c..2c2175922c 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/tc.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/tc.c @@ -69,7 +69,7 @@ static int rtl83xx_parse_flow_rule(struct rtl838x_switch_priv *priv, flow_rule_match_vlan(rule, &match); flow->rule.itag = match.key->vlan_id; flow->rule.itag_m = match.mask->vlan_id; - // TODO: What about match.key->vlan_priority ? + /* TODO: What about match.key->vlan_priority? */ } if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV4_ADDRS)) { @@ -105,7 +105,7 @@ static int rtl83xx_parse_flow_rule(struct rtl838x_switch_priv *priv, flow->rule.sport_m = match.mask->src; } - // TODO: ICMP + /* TODO: ICMP */ return 0; } @@ -173,7 +173,7 @@ static int rtl83xx_add_flow(struct rtl838x_switch_priv *priv, struct flow_cls_of case FLOW_ACTION_VLAN_PUSH: pr_debug("%s: VLAN_PUSH\n", __func__); -// TODO: act->vlan.proto +/* TODO: act->vlan.proto */ flow->rule.ivid_act = PIE_ACT_VID_ASSIGN; flow->rule.ivid_sel = true; flow->rule.ivid_data = htons(act->vlan.vid); @@ -268,9 +268,9 @@ rcu_unlock: goto out_free; } - rtl83xx_add_flow(priv, f, flow); // TODO: check error + rtl83xx_add_flow(priv, f, flow); /* TODO: check error */ - // Add log action to flow + /* Add log action to flow */ flow->rule.packet_cntr = rtl83xx_packet_cntr_alloc(priv); if (flow->rule.packet_cntr >= 0) { pr_debug("Using packet counter %d\n", flow->rule.packet_cntr); @@ -332,7 +332,7 @@ static int rtl83xx_stats_flower(struct rtl838x_switch_priv *priv, flow->rule.last_packet_cnt = total_packets; } - // TODO: We need a second PIE rule to count the bytes + /* TODO: We need a second PIE rule to count the bytes */ flow_stats_update(&cls_flower->stats, 100 * new_packets, new_packets, 0, lastused, FLOW_ACTION_HW_STATS_IMMEDIATE); |