Skip to content

Commit 8d6198a

Browse files
shinas-marvelldavem330
authored andcommitted
octeon_ep: support to fetch firmware info
Add support to fetch firmware info such as heartbeat miss count, heartbeat interval. This shall be used for heartbeat monitor. Signed-off-by: Shinas Rasheed <srasheed@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d692873 commit 8d6198a

6 files changed

Lines changed: 77 additions & 17 deletions

File tree

drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
#define CTRL_MBOX_MAX_PF 128
1717
#define CTRL_MBOX_SZ ((size_t)(0x400000 / CTRL_MBOX_MAX_PF))
1818

19-
#define FW_HB_INTERVAL_IN_SECS 1
20-
#define FW_HB_MISS_COUNT 10
21-
2219
/* Names of Hardware non-queue generic interrupts */
2320
static char *cn93_non_ioq_msix_names[] = {
2421
"epf_ire_rint",
@@ -250,12 +247,11 @@ static void octep_init_config_cn93_pf(struct octep_device *oct)
250247
link = PCI_DEVFN(PCI_SLOT(oct->pdev->devfn), link);
251248
}
252249
conf->ctrl_mbox_cfg.barmem_addr = (void __iomem *)oct->mmio[2].hw_addr +
253-
(0x400000ull * 7) +
250+
CN93_PEM_BAR4_INDEX_OFFSET +
254251
(link * CTRL_MBOX_SZ);
255252

256-
conf->hb_interval = FW_HB_INTERVAL_IN_SECS;
257-
conf->max_hb_miss_cnt = FW_HB_MISS_COUNT;
258-
253+
conf->fw_info.hb_interval = OCTEP_DEFAULT_FW_HB_INTERVAL;
254+
conf->fw_info.hb_miss_count = OCTEP_DEFAULT_FW_HB_MISS_COUNT;
259255
}
260256

261257
/* Setup registers for a hardware Tx Queue */

drivers/net/ethernet/marvell/octeon_ep/octep_config.h

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
/* Default MTU */
5050
#define OCTEP_DEFAULT_MTU 1500
5151

52+
/* pf heartbeat interval in milliseconds */
53+
#define OCTEP_DEFAULT_FW_HB_INTERVAL 1000
54+
/* pf heartbeat miss count */
55+
#define OCTEP_DEFAULT_FW_HB_MISS_COUNT 20
56+
5257
/* Macros to get octeon config params */
5358
#define CFG_GET_IQ_CFG(cfg) ((cfg)->iq)
5459
#define CFG_GET_IQ_NUM_DESC(cfg) ((cfg)->iq.num_descs)
@@ -181,6 +186,16 @@ struct octep_ctrl_mbox_config {
181186
void __iomem *barmem_addr;
182187
};
183188

189+
/* Info from firmware */
190+
struct octep_fw_info {
191+
/* interface pkind */
192+
u16 pkind;
193+
/* heartbeat interval in milliseconds */
194+
u16 hb_interval;
195+
/* heartbeat miss count */
196+
u16 hb_miss_count;
197+
};
198+
184199
/* Data Structure to hold configuration limits and active config */
185200
struct octep_config {
186201
/* Input Queue attributes. */
@@ -201,10 +216,7 @@ struct octep_config {
201216
/* ctrl mbox config */
202217
struct octep_ctrl_mbox_config ctrl_mbox_cfg;
203218

204-
/* Configured maximum heartbeat miss count */
205-
u32 max_hb_miss_cnt;
206-
207-
/* Configured firmware heartbeat interval in secs */
208-
u32 hb_interval;
219+
/* fw info */
220+
struct octep_fw_info fw_info;
209221
};
210222
#endif /* _OCTEP_CONFIG_H_ */

drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static atomic_t ctrl_net_msg_id;
2626

2727
/* Control plane version in which OCTEP_CTRL_NET_H2F_CMD was added */
2828
static const u32 octep_ctrl_net_h2f_cmd_versions[OCTEP_CTRL_NET_H2F_CMD_MAX] = {
29-
[OCTEP_CTRL_NET_H2F_CMD_INVALID ... OCTEP_CTRL_NET_H2F_CMD_LINK_INFO] =
29+
[OCTEP_CTRL_NET_H2F_CMD_INVALID ... OCTEP_CTRL_NET_H2F_CMD_GET_INFO] =
3030
OCTEP_CP_VERSION(1, 0, 0)
3131
};
3232

@@ -353,6 +353,28 @@ void octep_ctrl_net_recv_fw_messages(struct octep_device *oct)
353353
}
354354
}
355355

356+
int octep_ctrl_net_get_info(struct octep_device *oct, int vfid,
357+
struct octep_fw_info *info)
358+
{
359+
struct octep_ctrl_net_wait_data d = {0};
360+
struct octep_ctrl_net_h2f_resp *resp;
361+
struct octep_ctrl_net_h2f_req *req;
362+
int err;
363+
364+
req = &d.data.req;
365+
init_send_req(&d.msg, req, 0, vfid);
366+
req->hdr.s.cmd = OCTEP_CTRL_NET_H2F_CMD_GET_INFO;
367+
req->link_info.cmd = OCTEP_CTRL_NET_CMD_GET;
368+
err = octep_send_mbox_req(oct, &d, true);
369+
if (err < 0)
370+
return err;
371+
372+
resp = &d.data.resp;
373+
memcpy(info, &resp->info.fw_info, sizeof(struct octep_fw_info));
374+
375+
return 0;
376+
}
377+
356378
int octep_ctrl_net_uninit(struct octep_device *oct)
357379
{
358380
struct octep_ctrl_net_wait_data *pos, *n;

drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ enum octep_ctrl_net_h2f_cmd {
4141
OCTEP_CTRL_NET_H2F_CMD_LINK_STATUS,
4242
OCTEP_CTRL_NET_H2F_CMD_RX_STATE,
4343
OCTEP_CTRL_NET_H2F_CMD_LINK_INFO,
44+
OCTEP_CTRL_NET_H2F_CMD_GET_INFO,
4445
OCTEP_CTRL_NET_H2F_CMD_MAX
4546
};
4647

@@ -161,6 +162,11 @@ struct octep_ctrl_net_h2f_resp_cmd_state {
161162
u16 state;
162163
};
163164

165+
/* get info request */
166+
struct octep_ctrl_net_h2f_resp_cmd_get_info {
167+
struct octep_fw_info fw_info;
168+
};
169+
164170
/* Host to fw response data */
165171
struct octep_ctrl_net_h2f_resp {
166172
union octep_ctrl_net_resp_hdr hdr;
@@ -171,6 +177,7 @@ struct octep_ctrl_net_h2f_resp {
171177
struct octep_ctrl_net_h2f_resp_cmd_state link;
172178
struct octep_ctrl_net_h2f_resp_cmd_state rx;
173179
struct octep_ctrl_net_link_info link_info;
180+
struct octep_ctrl_net_h2f_resp_cmd_get_info info;
174181
};
175182
} __packed;
176183

@@ -330,6 +337,17 @@ int octep_ctrl_net_set_link_info(struct octep_device *oct,
330337
*/
331338
void octep_ctrl_net_recv_fw_messages(struct octep_device *oct);
332339

340+
/** Get info from firmware.
341+
*
342+
* @param oct: non-null pointer to struct octep_device.
343+
* @param vfid: Index of virtual function.
344+
* @param info: non-null pointer to struct octep_fw_info.
345+
*
346+
* return value: 0 on success, -errno on failure.
347+
*/
348+
int octep_ctrl_net_get_info(struct octep_device *oct, int vfid,
349+
struct octep_fw_info *info);
350+
333351
/** Uninitialize data for ctrl net.
334352
*
335353
* @param oct: non-null pointer to struct octep_device.

drivers/net/ethernet/marvell/octeon_ep/octep_main.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -918,9 +918,9 @@ static void octep_hb_timeout_task(struct work_struct *work)
918918
int miss_cnt;
919919

920920
miss_cnt = atomic_inc_return(&oct->hb_miss_cnt);
921-
if (miss_cnt < oct->conf->max_hb_miss_cnt) {
921+
if (miss_cnt < oct->conf->fw_info.hb_miss_count) {
922922
queue_delayed_work(octep_wq, &oct->hb_task,
923-
msecs_to_jiffies(oct->conf->hb_interval * 1000));
923+
msecs_to_jiffies(oct->conf->fw_info.hb_interval));
924924
return;
925925
}
926926

@@ -1013,8 +1013,7 @@ int octep_device_setup(struct octep_device *oct)
10131013

10141014
atomic_set(&oct->hb_miss_cnt, 0);
10151015
INIT_DELAYED_WORK(&oct->hb_task, octep_hb_timeout_task);
1016-
queue_delayed_work(octep_wq, &oct->hb_task,
1017-
msecs_to_jiffies(oct->conf->hb_interval * 1000));
1016+
10181017
return 0;
10191018

10201019
unsupported_dev:
@@ -1143,6 +1142,15 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
11431142
dev_err(&pdev->dev, "Device setup failed\n");
11441143
goto err_octep_config;
11451144
}
1145+
1146+
octep_ctrl_net_get_info(octep_dev, OCTEP_CTRL_NET_INVALID_VFID,
1147+
&octep_dev->conf->fw_info);
1148+
dev_info(&octep_dev->pdev->dev, "Heartbeat interval %u msecs Heartbeat miss count %u\n",
1149+
octep_dev->conf->fw_info.hb_interval,
1150+
octep_dev->conf->fw_info.hb_miss_count);
1151+
queue_delayed_work(octep_wq, &octep_dev->hb_task,
1152+
msecs_to_jiffies(octep_dev->conf->fw_info.hb_interval));
1153+
11461154
INIT_WORK(&octep_dev->tx_timeout_task, octep_tx_timeout_task);
11471155
INIT_WORK(&octep_dev->ctrl_mbox_task, octep_ctrl_mbox_task);
11481156
INIT_DELAYED_WORK(&octep_dev->intr_poll_task, octep_intr_poll_task);

drivers/net/ethernet/marvell/octeon_ep/octep_regs_cn9k_pf.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,4 +370,8 @@
370370
/* bit 1 for firmware heartbeat interrupt */
371371
#define CN93_SDP_EPF_OEI_RINT_DATA_BIT_HBEAT BIT_ULL(1)
372372

373+
#define CN93_PEM_BAR4_INDEX 7
374+
#define CN93_PEM_BAR4_INDEX_SIZE 0x400000ULL
375+
#define CN93_PEM_BAR4_INDEX_OFFSET (CN93_PEM_BAR4_INDEX * CN93_PEM_BAR4_INDEX_SIZE)
376+
373377
#endif /* _OCTEP_REGS_CN9K_PF_H_ */

0 commit comments

Comments
 (0)