Re: [RFC PATCH net-next 1/4] net: ti: icssg-prueth: Add helper functions to configure FDB
From: Andrew Lunn <andrew@lunn.ch>
Date: 2023-09-04 14:02:37
Also in:
lkml
From: Andrew Lunn <andrew@lunn.ch>
Date: 2023-09-04 14:02:37
Also in:
lkml
+int icssg_send_fdb_msg(struct prueth_emac *emac, struct mgmt_cmd *cmd,
+ struct mgmt_cmd_rsp *rsp)
+{
+ struct prueth *prueth = emac->prueth;
+ int slice = prueth_emac_slice(emac);
+ int i = 10000;
+ int 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(prueth->shram.va + addr + 4, cmd, sizeof(*cmd));
+ icssg_queue_push(prueth, slice == 0 ?
+ ICSSG_CMD_PUSH_SLICE0 : ICSSG_CMD_PUSH_SLICE1, addr);
+ while (i--) {
+ addr = icssg_queue_pop(prueth, slice == 0 ?
+ ICSSG_RSP_POP_SLICE0 : ICSSG_RSP_POP_SLICE1);
+ if (addr < 0) {
+ usleep_range(1000, 2000);
+ continue;
+ }Please try to make use of include/linux/iopoll.h.
+ if (i <= 0) {
+ netdev_err(emac->ndev, "Timedout sending HWQ message\n");
+ return -EINVAL;
Using iopoll.h will fix this, but -ETIMEDOUT, not -EINVAL.
Andrew