forked from hwanju/linux-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnf10.h
More file actions
137 lines (122 loc) · 4.01 KB
/
nf10.h
File metadata and controls
137 lines (122 loc) · 4.01 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*******************************************************************************
*
* NetFPGA-10G http://www.netfpga.org
*
* File:
* nf10.h
*
* Project:
*
*
* Author:
* Hwanju Kim
*
* Description:
* This header file is the main header independent of DMA implmentation.
*
* This code is initially developed for the Network-as-a-Service (NaaS) project.
* (under development in https://github.com/NetFPGA-NewNIC/linux-driver)
*
* Copyright notice:
* Copyright (C) 2014 University of Cambridge
*
* Licence:
* This file is part of the NetFPGA 10G development base package.
*
* This file is free code: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 2.1 as
* published by the Free Software Foundation.
*
* This package is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the NetFPGA source package. If not, see
* http://www.gnu.org/licenses/.
*
*/
#ifndef _NF10_H
#define _NF10_H
#include <linux/version.h>
#include <linux/netdevice.h>
#include <linux/types.h>
#include <linux/ethtool.h>
#include <linux/pci.h>
#include <linux/cdev.h>
#include "nf10_lbuf.h"
#define NF10_VENDOR_ID 0x10ee
#define NF10_DEVICE_ID 0x4245
struct nf10_adapter {
struct napi_struct napi;
struct net_device *netdev[CONFIG_NR_PORTS];
struct pci_dev *pdev;
u8 __iomem *bar0;
u8 __iomem *bar2;
struct nf10_hw_ops *hw_ops;
u32 irq_period_usecs;
u16 msg_enable;
#ifdef CONFIG_PHY_INIT
atomic_t mdio_access_rdy;
#endif
/* direct user access (kernel bypass) */
struct nf10_user_ops *user_ops;
struct cdev cdev;
u32 user_flags;
unsigned int nr_user_mmap;
wait_queue_head_t user_rx_wq;
wait_queue_head_t user_tx_wq;
/* AXI register interface */
dma_addr_t axi_completion_dma_addr;
void *axi_completion_kern_addr;
};
#define default_netdev(adapter) (adapter->netdev[0])
struct nf10_netdev_priv {
struct nf10_adapter *adapter;
int port_num;
int port_up;
};
#define get_netdev_priv(netdev) ((struct nf10_netdev_priv *)netdev_priv(netdev))
#define netdev_adapter(netdev) (get_netdev_priv(netdev)->adapter)
#define netdev_port_num(netdev) (get_netdev_priv(netdev)->port_num)
#define netdev_port_up(netdev) (get_netdev_priv(netdev)->port_up)
/* interrupt control commands used for nf10_hw_ops->ctrl_irq */
enum {
IRQ_CTRL_ENABLE = 0,
IRQ_CTRL_DISABLE,
NR_IRQ_CTRL,
};
struct nf10_hw_ops {
int (*init)(struct nf10_adapter *adapter);
void (*free)(struct nf10_adapter *adapter);
int (*init_buffers)(struct nf10_adapter *adapter);
void (*free_buffers)(struct nf10_adapter *adapter);
void (*process_rx_irq)(struct nf10_adapter *adapter,
int *work_done, int budget);
netdev_tx_t (*start_xmit)(struct sk_buff *skb,
struct net_device *dev);
int (*clean_tx_irq)(struct nf10_adapter *adapter);
unsigned long (*ctrl_irq)(struct nf10_adapter *adapter, unsigned long cmd);
int (*set_irq_period)(struct nf10_adapter *adapter);
};
struct nf10_user_ops {
unsigned long (*init)(struct nf10_adapter *adapter, unsigned long arg);
unsigned long (*exit)(struct nf10_adapter *adapter, unsigned long arg);
unsigned long (*get_pfn)(struct nf10_adapter *adapter, unsigned long arg);
void (*prepare_rx_buffer)(struct nf10_adapter *adapter,
unsigned long size);
int (*start_xmit)(struct nf10_adapter *adapter, unsigned long arg);
};
static inline void nf10_writel(struct nf10_adapter *adapter, int off, u32 val)
{
writel(val, adapter->bar2 + off);
}
static inline void nf10_writeq(struct nf10_adapter *adapter, int off, u64 val)
{
writeq(val, adapter->bar2 + off);
}
extern void nf10_set_ethtool_ops(struct net_device *netdev);
void nf10_enable_irq(struct nf10_adapter *adapter);
void nf10_disable_irq(struct nf10_adapter *adapter);
#endif