xref: /openbmc/linux/drivers/scsi/snic/vnic_dev.h (revision 25879d7b)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright 2014 Cisco Systems, Inc.  All rights reserved. */
3 
4 #ifndef _VNIC_DEV_H_
5 #define _VNIC_DEV_H_
6 
7 #include "vnic_resource.h"
8 #include "vnic_devcmd.h"
9 
10 #ifndef VNIC_PADDR_TARGET
11 #define VNIC_PADDR_TARGET	0x0000000000000000ULL
12 #endif
13 
14 #ifndef readq
15 static inline u64 readq(void __iomem *reg)
16 {
17 	return ((u64)readl(reg + 0x4UL) << 32) | (u64)readl(reg);
18 }
19 
20 static inline void writeq(u64 val, void __iomem *reg)
21 {
22 	writel(lower_32_bits(val), reg);
23 	writel(upper_32_bits(val), reg + 0x4UL);
24 }
25 #endif
26 
27 enum vnic_dev_intr_mode {
28 	VNIC_DEV_INTR_MODE_UNKNOWN,
29 	VNIC_DEV_INTR_MODE_INTX,
30 	VNIC_DEV_INTR_MODE_MSI,
31 	VNIC_DEV_INTR_MODE_MSIX,
32 };
33 
34 struct vnic_dev_bar {
35 	void __iomem *vaddr;
36 	dma_addr_t bus_addr;
37 	unsigned long len;
38 };
39 
40 struct vnic_dev_ring {
41 	void *descs;
42 	size_t size;
43 	dma_addr_t base_addr;
44 	size_t base_align;
45 	void *descs_unaligned;
46 	size_t size_unaligned;
47 	dma_addr_t base_addr_unaligned;
48 	unsigned int desc_size;
49 	unsigned int desc_count;
50 	unsigned int desc_avail;
51 };
52 
53 struct vnic_dev;
54 struct vnic_stats;
55 
56 void *svnic_dev_priv(struct vnic_dev *vdev);
57 unsigned int svnic_dev_get_res_count(struct vnic_dev *vdev,
58 				    enum vnic_res_type type);
59 void __iomem *svnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type,
60 			       unsigned int index);
61 unsigned int svnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
62 				     unsigned int desc_count,
63 				     unsigned int desc_size);
64 void svnic_dev_clear_desc_ring(struct vnic_dev_ring *ring);
65 int svnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct vnic_dev_ring *ring,
66 			     unsigned int desc_count, unsigned int desc_size);
67 void svnic_dev_free_desc_ring(struct vnic_dev *vdev,
68 			     struct vnic_dev_ring *ring);
69 int svnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
70 		 u64 *a0, u64 *a1, int wait);
71 int svnic_dev_fw_info(struct vnic_dev *vdev,
72 		     struct vnic_devcmd_fw_info **fw_info);
73 int svnic_dev_spec(struct vnic_dev *vdev, unsigned int offset,
74 		  unsigned int size, void *value);
75 int svnic_dev_stats_clear(struct vnic_dev *vdev);
76 int svnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats);
77 int svnic_dev_notify_set(struct vnic_dev *vdev, u16 intr);
78 void svnic_dev_notify_unset(struct vnic_dev *vdev);
79 int svnic_dev_link_status(struct vnic_dev *vdev);
80 u32 svnic_dev_link_down_cnt(struct vnic_dev *vdev);
81 int svnic_dev_close(struct vnic_dev *vdev);
82 int svnic_dev_enable_wait(struct vnic_dev *vdev);
83 int svnic_dev_disable(struct vnic_dev *vdev);
84 int svnic_dev_open(struct vnic_dev *vdev, int arg);
85 int svnic_dev_open_done(struct vnic_dev *vdev, int *done);
86 int svnic_dev_init(struct vnic_dev *vdev, int arg);
87 struct vnic_dev *svnic_dev_alloc_discover(struct vnic_dev *vdev,
88 					 void *priv, struct pci_dev *pdev,
89 					 struct vnic_dev_bar *bar,
90 					 unsigned int num_bars);
91 void svnic_dev_set_intr_mode(struct vnic_dev *vdev,
92 			    enum vnic_dev_intr_mode intr_mode);
93 enum vnic_dev_intr_mode svnic_dev_get_intr_mode(struct vnic_dev *vdev);
94 void svnic_dev_unregister(struct vnic_dev *vdev);
95 int svnic_dev_cmd_init(struct vnic_dev *vdev, int fallback);
96 #endif /* _VNIC_DEV_H_ */
97