xref: /dpdk/drivers/net/ionic/ionic.h (revision 99a2dd955fba6e4cc23b77d590a033650ced9c45)
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  * Copyright(c) 2018-2019 Pensando Systems, Inc. All rights reserved.
3  */
4 
5 #ifndef _IONIC_H_
6 #define _IONIC_H_
7 
8 #include <stdint.h>
9 #include <inttypes.h>
10 
11 #include <rte_bus_pci.h>
12 
13 #include "ionic_dev.h"
14 #include "ionic_if.h"
15 #include "ionic_osdep.h"
16 
17 #define IONIC_DRV_NAME			"ionic"
18 #define IONIC_DRV_DESCRIPTION		"Pensando Ethernet NIC Driver"
19 #define IONIC_DRV_VERSION		"0.11.0-49"
20 
21 /* Vendor ID */
22 #define IONIC_PENSANDO_VENDOR_ID	0x1dd8
23 
24 /* Device IDs */
25 #define IONIC_DEV_ID_ETH_PF		0x1002
26 #define IONIC_DEV_ID_ETH_VF		0x1003
27 #define IONIC_DEV_ID_ETH_MGMT		0x1004
28 
29 enum ionic_mac_type {
30 	IONIC_MAC_UNKNOWN = 0,
31 	IONIC_MAC_CAPRI,
32 	IONIC_NUM_MACS
33 };
34 
35 struct ionic_mac_info {
36 	enum ionic_mac_type type;
37 };
38 
39 struct ionic_hw {
40 	struct ionic_mac_info mac;
41 	uint16_t device_id;
42 	uint16_t vendor_id;
43 };
44 
45 /*
46  * Structure to store private data for each driver instance (for each adapter).
47  */
48 struct ionic_adapter {
49 	struct ionic_hw hw;
50 	struct ionic_dev idev;
51 	const char *name;
52 	struct ionic_dev_bar bars[IONIC_BARS_MAX];
53 	struct ionic_identity	ident;
54 	struct ionic_lif *lif;
55 	uint32_t num_bars;
56 	uint32_t max_ntxqs_per_lif;
57 	uint32_t max_nrxqs_per_lif;
58 	uint32_t max_mac_addrs;
59 	uint32_t link_speed;
60 	uint32_t nintrs;
61 	bool intrs[IONIC_INTR_CTRL_REGS_MAX];
62 	bool link_up;
63 	char fw_version[IONIC_DEVINFO_FWVERS_BUFLEN];
64 	struct rte_pci_device *pci_dev;
65 	LIST_ENTRY(ionic_adapter) pci_adapters;
66 };
67 
68 /** ionic_admin_ctx - Admin command context.
69  * @pending_work:       Flag that indicates a completion.
70  * @cmd:                Admin command (64B) to be copied to the queue.
71  * @comp:               Admin completion (16B) copied from the queue.
72  */
73 struct ionic_admin_ctx {
74 	bool pending_work;
75 	union ionic_adminq_cmd cmd;
76 	union ionic_adminq_comp comp;
77 };
78 
79 int ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
80 
81 int ionic_dev_cmd_wait_check(struct ionic_dev *idev, unsigned long max_wait);
82 int ionic_setup(struct ionic_adapter *adapter);
83 
84 int ionic_identify(struct ionic_adapter *adapter);
85 int ionic_init(struct ionic_adapter *adapter);
86 int ionic_reset(struct ionic_adapter *adapter);
87 
88 int ionic_port_identify(struct ionic_adapter *adapter);
89 int ionic_port_init(struct ionic_adapter *adapter);
90 int ionic_port_reset(struct ionic_adapter *adapter);
91 
92 #endif /* _IONIC_H_ */
93