1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2017 - 2019 Pensando Systems, Inc */
10 #include "ionic_dev.h"
11 #include "ionic_devlink.h"
13 #define IONIC_DRV_NAME "ionic"
14 #define IONIC_DRV_DESCRIPTION "Pensando Ethernet NIC Driver"
16 #define PCI_VENDOR_ID_PENSANDO 0x1dd8
18 #define PCI_DEVICE_ID_PENSANDO_IONIC_ETH_PF 0x1002
19 #define PCI_DEVICE_ID_PENSANDO_IONIC_ETH_VF 0x1003
21 #define IONIC_ASIC_TYPE_ELBA 2
23 #define DEVCMD_TIMEOUT 5
24 #define IONIC_ADMINQ_TIME_SLICE msecs_to_jiffies(100)
26 #define IONIC_PHC_UPDATE_NS 10000000000 /* 10s in nanoseconds */
27 #define NORMAL_PPB 1000000000 /* one billion parts per billion */
28 #define SCALED_PPM (1000000ull << 16) /* 2^16 million parts per 2^16 million */
39 struct ionic_lif_stats stats;
45 struct devlink_port dl_port;
46 struct ionic_dev idev;
47 struct mutex dev_cmd_lock; /* lock for dev_cmd operations */
48 struct dentry *dentry;
49 struct ionic_dev_bar bars[IONIC_BARS_MAX];
50 unsigned int num_bars;
51 struct ionic_identity ident;
52 struct workqueue_struct *wq;
53 struct ionic_lif *lif;
54 unsigned int nnqs_per_lif;
55 unsigned int neqs_per_lif;
56 unsigned int ntxqs_per_lif;
57 unsigned int nrxqs_per_lif;
59 DECLARE_BITMAP(intrs, IONIC_INTR_CTRL_REGS_MAX);
60 cpumask_var_t *affinity_masks;
61 struct delayed_work doorbell_check_dwork;
62 struct work_struct nb_work;
63 struct notifier_block nb;
64 struct rw_semaphore vf_op_lock; /* lock for VF operations */
67 struct timer_list watchdog_timer;
71 struct ionic_admin_ctx {
72 struct completion work;
73 union ionic_adminq_cmd cmd;
74 union ionic_adminq_comp comp;
77 int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
78 int ionic_adminq_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx,
79 const int err, const bool do_msg);
80 int ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
81 int ionic_adminq_post_wait_nomsg(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
82 void ionic_adminq_netdev_err_print(struct ionic_lif *lif, u8 opcode,
84 bool ionic_notifyq_service(struct ionic_cq *cq);
85 bool ionic_adminq_service(struct ionic_cq *cq);
87 int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_wait);
88 int ionic_dev_cmd_wait_nomsg(struct ionic *ionic, unsigned long max_wait);
89 void ionic_dev_cmd_dev_err_print(struct ionic *ionic, u8 opcode, u8 status,
91 int ionic_setup(struct ionic *ionic);
93 int ionic_identify(struct ionic *ionic);
94 int ionic_init(struct ionic *ionic);
95 int ionic_reset(struct ionic *ionic);
97 int ionic_port_identify(struct ionic *ionic);
98 int ionic_port_init(struct ionic *ionic);
99 int ionic_port_reset(struct ionic *ionic);
101 bool ionic_doorbell_wa(struct ionic *ionic);
103 #endif /* _IONIC_H_ */