]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: ti: icssg: Add support sending FDB command to update rx_flow_id
authorMD Danish Anwar <danishanwar@ti.com>
Thu, 4 Apr 2024 07:08:03 +0000 (12:38 +0530)
committerTom Rini <trini@konsulko.com>
Fri, 12 Apr 2024 19:54:43 +0000 (13:54 -0600)
ICSSG firmware supports FDB commands. Add support to send FDB commands
from driver. Once rx_flow_id is obtained from dma, let firmware know that
we are using this rx_flow_id by sending a FDB command.

Reviewed-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
Signed-off-by: MD Danish Anwar <danishanwar@ti.com>
drivers/net/ti/icssg_config.c
drivers/net/ti/icssg_config.h
drivers/net/ti/icssg_prueth.c
drivers/net/ti/icssg_prueth.h

index 7cf3f737af777b28653c060f0dfa6ad3e4a3743c..5f132d0525c61491942244ad63b4bea3a8348124 100644 (file)
@@ -9,6 +9,7 @@
 #include "icssg_switch_map.h"
 #include "icss_mii_rt.h"
 #include <dm/device_compat.h>
+#include <linux/iopoll.h>
 
 /* TX IPG Values to be set for 100M and 1G link speeds.  These values are
  * in ocp_clk cycles. So need change if ocp_clk is changed for a specific
@@ -404,3 +405,70 @@ int emac_set_port_state(struct prueth_priv *priv,
 
        return ret;
 }
+
+int icssg_send_fdb_msg(struct prueth_priv *priv, struct mgmt_cmd *cmd,
+                      struct mgmt_cmd_rsp *rsp)
+{
+       struct prueth *prueth = priv->prueth;
+       int slice = priv->port_id;
+       int ret, addr;
+
+       addr = icssg_queue_pop(prueth, slice == 0 ?
+                              ICSSG_CMD_POP_SLICE0 : ICSSG_CMD_POP_SLICE1);
+       if (addr < 0)
+               return addr;
+
+       /* First 4 bytes have FW owned buffer linking info which should
+        * not be touched
+        */
+       memcpy_toio((void __iomem *)prueth->shram.pa + addr + 4, cmd, sizeof(*cmd));
+       icssg_queue_push(prueth, slice == 0 ?
+                        ICSSG_CMD_PUSH_SLICE0 : ICSSG_CMD_PUSH_SLICE1, addr);
+       ret = read_poll_timeout(icssg_queue_pop, addr, addr >= 0,
+                               2000, 20000000, prueth, slice == 0 ?
+                               ICSSG_RSP_POP_SLICE0 : ICSSG_RSP_POP_SLICE1);
+
+       if (ret) {
+               dev_err(prueth->dev, "Timedout sending HWQ message\n");
+               return ret;
+       }
+
+       memcpy_fromio(rsp, (void __iomem *)prueth->shram.pa + addr, sizeof(*rsp));
+       /* Return buffer back for to pool */
+       icssg_queue_push(prueth, slice == 0 ?
+                        ICSSG_RSP_PUSH_SLICE0 : ICSSG_RSP_PUSH_SLICE1, addr);
+
+       return 0;
+}
+
+int emac_fdb_flow_id_updated(struct prueth_priv *priv)
+{
+       struct mgmt_cmd_rsp fdb_cmd_rsp = { 0 };
+       struct prueth *prueth = priv->prueth;
+       struct mgmt_cmd fdb_cmd = { 0 };
+       int slice = priv->port_id;
+       int ret = 0;
+
+       fdb_cmd.header = ICSSG_FW_MGMT_CMD_HEADER;
+       fdb_cmd.type   = ICSSG_FW_MGMT_FDB_CMD_TYPE_RX_FLOW;
+       fdb_cmd.seqnum = ++(prueth->icssg_hwcmdseq);
+       fdb_cmd.param  = 0;
+
+       fdb_cmd.param |= (slice << 4);
+       fdb_cmd.cmd_args[0] = 0;
+
+       ret = icssg_send_fdb_msg(priv, &fdb_cmd, &fdb_cmd_rsp);
+       if (ret)
+               return ret;
+
+       if (fdb_cmd.seqnum != fdb_cmd_rsp.seqnum) {
+               dev_err(prueth->dev, "seqnum doesn't match, cmd.seqnum %d != rsp.seqnum %d\n",
+                       fdb_cmd.seqnum, fdb_cmd_rsp.seqnum);
+               return -EINVAL;
+       }
+
+       if (fdb_cmd_rsp.status == 1)
+               return 0;
+
+       return -EINVAL;
+}
index e2859c7b511d22ec4a09cbd3d3ae9da7263f83b5..d388484c0358a13ca45d032ae320b24958e9317d 100644 (file)
@@ -80,6 +80,7 @@ struct icssg_rxq_ctx {
 #define ICSSG_FW_MGMT_FDB_CMD_TYPE     0x03
 #define ICSSG_FW_MGMT_CMD_TYPE         0x04
 #define ICSSG_FW_MGMT_PKT              0x80000000
+#define ICSSG_FW_MGMT_FDB_CMD_TYPE_RX_FLOW     0x05
 
 struct icssg_r30_cmd {
        u32 cmd[4];
@@ -156,6 +157,23 @@ struct icssg_setclock_desc {
        u32 CMP0_new;
 } __packed;
 
+struct mgmt_cmd {
+       u8 param;
+       u8 seqnum;
+       u8 type;
+       u8 header;
+       u32 cmd_args[3];
+} __packed;
+
+struct mgmt_cmd_rsp {
+       u32 reserved;
+       u8 status;
+       u8 seqnum;
+       u8 type;
+       u8 header;
+       u32 cmd_args[3];
+} __packed;
+
 #define ICSSG_CMD_POP_SLICE0   56
 #define ICSSG_CMD_POP_SLICE1   60
 
index 72007aabf2ef9badc6ea8eac2681940e718fcd1a..2639f96063197c75aca996a68b70574959aa38b3 100644 (file)
@@ -374,6 +374,12 @@ static int prueth_start(struct udevice *dev)
        dev_info(dev, "K3 ICSSG: rflow_id_base: %u, chn_name = %s\n",
                 dma_rx_cfg_data->flow_id_base, chn_name);
 
+       ret = emac_fdb_flow_id_updated(priv);
+       if (ret) {
+               dev_err(dev, "Failed to update Rx Flow ID %d", ret);
+               goto phy_fail;
+       }
+
        ret = phy_startup(priv->phydev);
        if (ret) {
                dev_err(dev, "phy_startup failed\n");
index 9d4b5ea5ec2b552afa8a86449e0c27ccc1e96dd3..c69cfd4f162215ed7c144bef5c97f0b438846364 100644 (file)
@@ -65,6 +65,7 @@ struct prueth {
        u8                      pru_core_id;
        u8                      rtu_core_id;
        u8                      txpru_core_id;
+       u8                      icssg_hwcmdseq;
 };
 
 struct prueth_priv {
@@ -88,4 +89,9 @@ int icssg_queue_pop(struct prueth *prueth, u8 queue);
 void icssg_queue_push(struct prueth *prueth, int queue, u16 addr);
 u32 icssg_queue_level(struct prueth *prueth, int queue);
 
+/* FDB helpers */
+int icssg_send_fdb_msg(struct prueth_priv *priv, struct mgmt_cmd *cmd,
+                      struct mgmt_cmd_rsp *rsp);
+int emac_fdb_flow_id_updated(struct prueth_priv *priv);
+
 #endif /* __NET_TI_ICSSG_PRUETH_H */