Skip to content

Commit 523847d

Browse files
emuslndavem330
authored andcommitted
pds_core: add devcmd device interfaces
The devcmd interface is the basic connection to the device through the PCI BAR for low level identification and command services. This does the early device initialization and finds the identity data, and adds devcmd routines to be used by later driver bits. Signed-off-by: Shannon Nelson <[email protected]> Acked-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 55435ea commit 523847d

File tree

8 files changed

+699
-3
lines changed

8 files changed

+699
-3
lines changed

drivers/net/ethernet/amd/pds_core/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
obj-$(CONFIG_PDS_CORE) := pds_core.o
55

6-
pds_core-y := main.o
6+
pds_core-y := main.o \
7+
dev.o \
8+
core.o
79

810
pds_core-$(CONFIG_DEBUG_FS) += debugfs.o
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* Copyright(c) 2023 Advanced Micro Devices, Inc */
3+
4+
#include "core.h"
5+
6+
int pdsc_setup(struct pdsc *pdsc, bool init)
7+
{
8+
int err = 0;
9+
10+
if (init)
11+
err = pdsc_dev_init(pdsc);
12+
else
13+
err = pdsc_dev_reinit(pdsc);
14+
if (err)
15+
return err;
16+
17+
clear_bit(PDSC_S_FW_DEAD, &pdsc->state);
18+
return 0;
19+
}
20+
21+
void pdsc_teardown(struct pdsc *pdsc, bool removing)
22+
{
23+
pdsc_devcmd_reset(pdsc);
24+
25+
if (removing) {
26+
kfree(pdsc->intr_info);
27+
pdsc->intr_info = NULL;
28+
}
29+
30+
if (pdsc->kern_dbpage) {
31+
iounmap(pdsc->kern_dbpage);
32+
pdsc->kern_dbpage = NULL;
33+
}
34+
35+
set_bit(PDSC_S_FW_DEAD, &pdsc->state);
36+
}

drivers/net/ethernet/amd/pds_core/core.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99

1010
#include <linux/pds/pds_common.h>
1111
#include <linux/pds/pds_core_if.h>
12+
#include <linux/pds/pds_intr.h>
1213

1314
#define PDSC_DRV_DESCRIPTION "AMD/Pensando Core Driver"
15+
#define PDSC_TEARDOWN_RECOVERY false
16+
#define PDSC_TEARDOWN_REMOVING true
17+
#define PDSC_SETUP_RECOVERY false
18+
#define PDSC_SETUP_INIT true
1419

1520
struct pdsc_dev_bar {
1621
void __iomem *vaddr;
@@ -19,6 +24,22 @@ struct pdsc_dev_bar {
1924
int res_index;
2025
};
2126

27+
struct pdsc_devinfo {
28+
u8 asic_type;
29+
u8 asic_rev;
30+
char fw_version[PDS_CORE_DEVINFO_FWVERS_BUFLEN + 1];
31+
char serial_num[PDS_CORE_DEVINFO_SERIAL_BUFLEN + 1];
32+
};
33+
34+
#define PDSC_INTR_NAME_MAX_SZ 32
35+
36+
struct pdsc_intr_info {
37+
char name[PDSC_INTR_NAME_MAX_SZ];
38+
unsigned int index;
39+
unsigned int vector;
40+
void *data;
41+
};
42+
2243
/* No state flags set means we are in a steady running state */
2344
enum pdsc_state_flags {
2445
PDSC_S_FW_DEAD, /* stopped, wait on startup or recovery */
@@ -38,7 +59,19 @@ struct pdsc {
3859
int uid;
3960

4061
unsigned long state;
62+
u8 fw_status;
63+
u8 fw_generation;
64+
unsigned long last_fw_time;
65+
u32 last_hb;
66+
67+
struct pdsc_devinfo dev_info;
68+
struct pds_core_dev_identity dev_ident;
69+
unsigned int nintrs;
70+
struct pdsc_intr_info *intr_info; /* array of nintrs elements */
4171

72+
unsigned int devcmd_timeout;
73+
struct mutex devcmd_lock; /* lock for dev_cmd operations */
74+
struct mutex config_lock; /* lock for configuration operations */
4275
struct pds_core_dev_info_regs __iomem *info_regs;
4376
struct pds_core_dev_cmd_regs __iomem *cmd_regs;
4477
struct pds_core_intr __iomem *intr_ctrl;
@@ -52,5 +85,22 @@ void pdsc_debugfs_create(void);
5285
void pdsc_debugfs_destroy(void);
5386
void pdsc_debugfs_add_dev(struct pdsc *pdsc);
5487
void pdsc_debugfs_del_dev(struct pdsc *pdsc);
88+
void pdsc_debugfs_add_ident(struct pdsc *pdsc);
89+
void pdsc_debugfs_add_irqs(struct pdsc *pdsc);
90+
91+
int pdsc_err_to_errno(enum pds_core_status_code code);
92+
bool pdsc_is_fw_running(struct pdsc *pdsc);
93+
bool pdsc_is_fw_good(struct pdsc *pdsc);
94+
int pdsc_devcmd(struct pdsc *pdsc, union pds_core_dev_cmd *cmd,
95+
union pds_core_dev_comp *comp, int max_seconds);
96+
int pdsc_devcmd_locked(struct pdsc *pdsc, union pds_core_dev_cmd *cmd,
97+
union pds_core_dev_comp *comp, int max_seconds);
98+
int pdsc_devcmd_init(struct pdsc *pdsc);
99+
int pdsc_devcmd_reset(struct pdsc *pdsc);
100+
int pdsc_dev_reinit(struct pdsc *pdsc);
101+
int pdsc_dev_init(struct pdsc *pdsc);
102+
103+
int pdsc_setup(struct pdsc *pdsc, bool init);
104+
void pdsc_teardown(struct pdsc *pdsc, bool removing);
55105

56106
#endif /* _PDSC_H_ */

drivers/net/ethernet/amd/pds_core/debugfs.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,41 @@ void pdsc_debugfs_del_dev(struct pdsc *pdsc)
2929
debugfs_remove_recursive(pdsc->dentry);
3030
pdsc->dentry = NULL;
3131
}
32+
33+
static int identity_show(struct seq_file *seq, void *v)
34+
{
35+
struct pdsc *pdsc = seq->private;
36+
struct pds_core_dev_identity *ident;
37+
int vt;
38+
39+
ident = &pdsc->dev_ident;
40+
41+
seq_printf(seq, "fw_heartbeat: 0x%x\n",
42+
ioread32(&pdsc->info_regs->fw_heartbeat));
43+
44+
seq_printf(seq, "nlifs: %d\n",
45+
le32_to_cpu(ident->nlifs));
46+
seq_printf(seq, "nintrs: %d\n",
47+
le32_to_cpu(ident->nintrs));
48+
seq_printf(seq, "ndbpgs_per_lif: %d\n",
49+
le32_to_cpu(ident->ndbpgs_per_lif));
50+
seq_printf(seq, "intr_coal_mult: %d\n",
51+
le32_to_cpu(ident->intr_coal_mult));
52+
seq_printf(seq, "intr_coal_div: %d\n",
53+
le32_to_cpu(ident->intr_coal_div));
54+
55+
seq_puts(seq, "vif_types: ");
56+
for (vt = 0; vt < PDS_DEV_TYPE_MAX; vt++)
57+
seq_printf(seq, "%d ",
58+
le16_to_cpu(pdsc->dev_ident.vif_types[vt]));
59+
seq_puts(seq, "\n");
60+
61+
return 0;
62+
}
63+
DEFINE_SHOW_ATTRIBUTE(identity);
64+
65+
void pdsc_debugfs_add_ident(struct pdsc *pdsc)
66+
{
67+
debugfs_create_file("identity", 0400, pdsc->dentry,
68+
pdsc, &identity_fops);
69+
}

0 commit comments

Comments
 (0)