rtl_table_release(r);
}
+/*
+ * Get the Destination-MAC of an L3 egress interface or the Source MAC for routed packets
+ * from the SoC's L3_EGR_INTF_MAC table. Indexes 0-2047 are DMACs, 2048+ are SMACs
+ */
+__maybe_unused
+static u64 otto_l3_930x_get_egress_mac(struct otto_l3_ctrl *ctrl, u32 idx)
+{
+ struct table_reg *r = rtl_table_get(RTL9300_TBL_2, 2);
+ u64 mac;
+
+ rtl_table_read(r, idx);
+ /* 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));
+ rtl_table_release(r);
+
+ return mac;
+}
+
/* Write a host route entry from the table using its index. Only unicast routes supported */
__maybe_unused
static void otto_l3_930x_host_route_write(struct otto_l3_ctrl *ctrl, int idx, struct otto_l3_route *rt)
mutex_lock(&priv->reg_mutex);
for (int i = 0; i < MAX_SMACS; i++) {
- m = priv->r->get_l3_egress_mac(L3_EGRESS_DMACS + i);
+ m = ctrl->cfg->get_egress_mac(ctrl, L3_EGRESS_DMACS + i);
if (free_mac < 0 && !m) {
free_mac = i;
continue;
const struct otto_l3_config otto_l3_930x_cfg = {
#ifdef CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD
+ .get_egress_mac = otto_l3_930x_get_egress_mac,
.host_route_write = otto_l3_930x_host_route_write,
.get_router_mac = otto_l3_930x_get_router_mac,
.set_router_mac = otto_l3_930x_set_router_mac,
struct otto_l3_config {
+ u64 (*get_egress_mac)(struct otto_l3_ctrl *ctrl, u32 idx);
void (*host_route_write)(struct otto_l3_ctrl *ctrl, int idx, struct otto_l3_route *rt);
void (*get_router_mac)(struct otto_l3_ctrl *ctrl, u32 idx, struct otto_l3_router_mac *m);
void (*set_router_mac)(struct otto_l3_ctrl *ctrl, u32 idx, struct otto_l3_router_mac *m);
u32 (*packet_cntr_read)(int counter);
void (*packet_cntr_clear)(int counter);
int (*l3_setup)(struct rtl838x_switch_priv *priv);
- u64 (*get_l3_egress_mac)(u32 idx);
void (*set_l3_egress_mac)(u32 idx, u64 mac);
int (*find_l3_slot)(struct otto_l3_route *rt, bool must_exist);
void (*set_l3_egress_intf)(int idx, struct rtl838x_l3_intf *intf);
rtl_table_release(r);
}
-/* Get the Destination-MAC of an L3 egress interface or the Source MAC for routed packets
- * from the SoC's L3_EGR_INTF_MAC table
- * Indexes 0-2047 are DMACs, 2048+ are SMACs
- */
-static u64 rtl930x_get_l3_egress_mac(u32 idx)
-{
- u64 mac;
- /* 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 */
- mac = sw_r32(rtl_table_data(r, 0));
- mac <<= 32;
- mac |= sw_r32(rtl_table_data(r, 1));
- rtl_table_release(r);
-
- return mac;
-}
-
/* Set the Destination-MAC of a route or the Source MAC of an L3 egress interface
* in the SoC's L3_EGR_INTF_MAC table
* Indexes 0-2047 are DMACs, 2048+ are SMACs
.packet_cntr_clear = rtl930x_packet_cntr_clear,
#ifdef CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD
.l3_setup = rtl930x_l3_setup,
- .get_l3_egress_mac = rtl930x_get_l3_egress_mac,
.set_l3_egress_mac = rtl930x_set_l3_egress_mac,
.find_l3_slot = rtl930x_find_l3_slot,
.set_l3_egress_intf = rtl930x_set_l3_egress_intf,