1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) Meta Platforms, Inc. and affiliates. */
#ifndef _MPNIC_H_
#define _MPNIC_H_
#include <linux/interrupt.h>
#include <linux/io-64-nonatomic-lo-hi.h>
#include <linux/types.h>
#include <linux/workqueue.h>
#include "mpnic_csr.h"
#define MPNIC_DRV_NAME "mpnic"
#define MPNIC_MAX_TXQS 1024u
#define MPNIC_MAX_RXQS 1024u
/* misc IRQ entries are allocated before the completion queue IRQs */
enum {
MPNIC_FW_MSIX_ENTRY,
MPNIC_NON_NAPI_VECTORS
};
struct mpnic_dev {
struct device *dev;
struct net_device *netdev;
u32 __iomem *uc_addr0;
struct delayed_work service_task;
u16 num_irqs;
u64 dsn;
u32 mps;
u32 readrq;
u8 relaxed_ord;
};
u64 mpnic_rd64(struct mpnic_dev *mpd, u32 reg);
int mpnic_dev_init(struct mpnic_dev *mpd);
int mpnic_request_irq(struct mpnic_dev *mpd, int nr, irq_handler_t handler,
unsigned long flags, const char *name, void *data);
void mpnic_free_irq(struct mpnic_dev *mpd, int nr, void *data);
void mpnic_free_irqs(struct mpnic_dev *mpd);
int mpnic_alloc_irqs(struct mpnic_dev *mpd);
static inline void mpnic_wr64(struct mpnic_dev *mpd, u32 reg, u64 val)
{
u32 __iomem *csr = READ_ONCE(mpd->uc_addr0);
if (csr)
writeq(val, csr + reg);
}
static inline void mpnic_wrfl(struct mpnic_dev *mpd)
{
mpnic_rd64(mpd, MPNIC_BDQ_SPARE);
}
static inline bool mpnic_present(struct mpnic_dev *mpd)
{
return !!READ_ONCE(mpd->uc_addr0);
}
#endif /* _MPNIC_H_ */
|