rtl_table_release(r);
}
+
+/* Destination MAC and L3 egress interface ID of a nexthop entry from the SoC's L3_NEXTHOP table */
+__maybe_unused
+static void otto_l3_930x_get_nexthop(struct otto_l3_ctrl *ctrl,
+ int idx, u16 *dmac_id, u16 *interface)
+{
+ struct table_reg *r = rtl_table_get(RTL9300_TBL_1, 3);
+ u32 v;
+
+ rtl_table_read(r, idx);
+ /* The table has a size of 1 register */
+ v = sw_r32(rtl_table_data(r, 0));
+ rtl_table_release(r);
+
+ *dmac_id = (v >> 7) & 0x7fff;
+ *interface = v & 0x7f;
+}
+
+/*
+ * Set the destination MAC and L3 egress interface ID for a nexthop entry in the SoC's L3_NEXTHOP
+ * table. The nexthop entry is identified by idx. dmac_id is the reference to the L2 entry in the
+ * L2 forwarding table, special values are
+ * 0x7ffe: TRAP2CPU
+ * 0x7ffd: TRAP2MASTERCPU
+ * 0x7fff: DMAC_ID_DROP
+ */
+__maybe_unused
+static void otto_l3_930x_set_nexthop(struct otto_l3_ctrl *ctrl,
+ int idx, u16 dmac_id, u16 interface)
+{
+ /* Access L3_NEXTHOP table (3) via register RTL9300_TBL_1 */
+ struct table_reg *r = rtl_table_get(RTL9300_TBL_1, 3);
+
+ dev_dbg(ctrl->dev, "Writing to L3_NEXTHOP table, index %d, dmac_id %d, interface %d\n",
+ idx, dmac_id, interface);
+ sw_w32(((dmac_id & 0x7fff) << 7) | (interface & 0x7f), rtl_table_data(r, 0));
+
+ dev_dbg(ctrl->dev, "value at index 0: %08x\n", sw_r32(rtl_table_data(r, 0)));
+ rtl_table_write(r, idx);
+ rtl_table_release(r);
+}
+
+
/* Read a prefix route entry from the L3_PREFIX_ROUTE_IPUC table
* We currently only support IPv4 and IPv6 unicast route
*/
r->pr.fwd_act = PIE_ACT_ROUTE_UC;
}
- if (priv->r->set_l3_nexthop)
- priv->r->set_l3_nexthop(r->nh.id, r->nh.l2_id, r->nh.if_id);
+ if (ctrl->cfg->set_nexthop)
+ ctrl->cfg->set_nexthop(ctrl, r->nh.id, r->nh.l2_id, r->nh.if_id);
if (r->pr.id < 0) {
r->pr.packet_cntr = rtl83xx_packet_cntr_alloc(priv);
const struct otto_l3_config otto_l3_930x_cfg = {
#ifdef CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD
+ .get_nexthop = otto_l3_930x_get_nexthop,
+ .set_nexthop = otto_l3_930x_set_nexthop,
.route_read = otto_l3_930x_route_read,
.route_write = otto_l3_930x_route_write,
#endif
#include "rtl-otto.h"
struct otto_l3_config {
+ void (*get_nexthop)(struct otto_l3_ctrl *ctrl, int idx, u16 *dmac_id, u16 *interface);
+ void (*set_nexthop)(struct otto_l3_ctrl *ctrl, int idx, u16 dmac_id, u16 interface);
void (*route_read)(struct otto_l3_ctrl *ctrl, int idx, struct otto_l3_route *rt);
void (*route_write)(struct otto_l3_ctrl *ctrl, int idx, struct otto_l3_route *rt);
};
void (*packet_cntr_clear)(int counter);
void (*host_route_write)(int idx, struct otto_l3_route *rt);
int (*l3_setup)(struct rtl838x_switch_priv *priv);
- void (*set_l3_nexthop)(int idx, u16 dmac_id, u16 interface);
- void (*get_l3_nexthop)(int idx, u16 *dmac_id, u16 *interface);
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);
return -1;
}
-/* Get the destination MAC and L3 egress interface ID of a nexthop entry from
- * the SoC's L3_NEXTHOP table
- */
-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 */
- struct table_reg *r = rtl_table_get(RTL9300_TBL_1, 3);
-
- rtl_table_read(r, idx);
- /* The table has a size of 1 register */
- v = sw_r32(rtl_table_data(r, 0));
- rtl_table_release(r);
-
- *dmac_id = (v >> 7) & 0x7fff;
- *interface = v & 0x7f;
-}
-
// Currently not used
// static int rtl930x_l3_mtu_del(struct rtl838x_switch_priv *priv, int mtu)
// {
// }
// }
-/* Set the destination MAC and L3 egress interface ID for a nexthop entry in the SoC's
- * L3_NEXTHOP table. The nexthop entry is identified by idx.
- * dmac_id is the reference to the L2 entry in the L2 forwarding table, special values are
- * 0x7ffe: TRAP2CPU
- * 0x7ffd: TRAP2MASTERCPU
- * 0x7fff: DMAC_ID_DROP
- */
-static void rtl930x_set_l3_nexthop(int idx, u16 dmac_id, u16 interface)
-{
- /* Access L3_NEXTHOP table (3) via register RTL9300_TBL_1 */
- struct table_reg *r = rtl_table_get(RTL9300_TBL_1, 3);
-
- pr_debug("%s: Writing to L3_NEXTHOP table, index %d, dmac_id %d, interface %d\n",
- __func__, idx, dmac_id, interface);
- sw_w32(((dmac_id & 0x7fff) << 7) | (interface & 0x7f), rtl_table_data(r, 0));
-
- pr_debug("%s: %08x\n", __func__, sw_r32(rtl_table_data(r, 0)));
- rtl_table_write(r, idx);
- rtl_table_release(r);
-}
-
#endif /* CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD */
static void rtl930x_pie_lookup_enable(struct rtl838x_switch_priv *priv, int index)
#ifdef CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD
.host_route_write = rtl930x_host_route_write,
.l3_setup = rtl930x_l3_setup,
- .set_l3_nexthop = rtl930x_set_l3_nexthop,
- .get_l3_nexthop = rtl930x_get_l3_nexthop,
.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,