]>
Commit | Line | Data |
---|---|---|
de152192 JP |
1 | /* |
2 | * drivers/net/ethernet/rocker/rocker.h - Rocker switch device driver | |
3 | * Copyright (c) 2014-2016 Jiri Pirko <jiri@mellanox.com> | |
4 | * Copyright (c) 2014 Scott Feldman <sfeldma@gmail.com> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | */ | |
11 | ||
12 | #ifndef _ROCKER_H | |
13 | #define _ROCKER_H | |
14 | ||
e420114e | 15 | #include <linux/kernel.h> |
de152192 | 16 | #include <linux/types.h> |
e420114e | 17 | #include <linux/netdevice.h> |
936bd486 | 18 | #include <linux/notifier.h> |
e420114e JP |
19 | #include <net/neighbour.h> |
20 | #include <net/switchdev.h> | |
de152192 JP |
21 | |
22 | #include "rocker_hw.h" | |
23 | ||
24 | struct rocker_desc_info { | |
25 | char *data; /* mapped */ | |
26 | size_t data_size; | |
27 | size_t tlv_size; | |
28 | struct rocker_desc *desc; | |
29 | dma_addr_t mapaddr; | |
30 | }; | |
31 | ||
0514c4e8 JP |
32 | struct rocker_dma_ring_info { |
33 | size_t size; | |
34 | u32 head; | |
35 | u32 tail; | |
36 | struct rocker_desc *desc; /* mapped */ | |
37 | dma_addr_t mapaddr; | |
38 | struct rocker_desc_info *desc_info; | |
39 | unsigned int type; | |
40 | }; | |
41 | ||
42 | struct rocker; | |
43 | ||
0514c4e8 JP |
44 | struct rocker_port { |
45 | struct net_device *dev; | |
0514c4e8 | 46 | struct rocker *rocker; |
e420114e | 47 | void *wpriv; |
0514c4e8 JP |
48 | unsigned int port_number; |
49 | u32 pport; | |
0514c4e8 JP |
50 | struct napi_struct napi_tx; |
51 | struct napi_struct napi_rx; | |
52 | struct rocker_dma_ring_info tx_ring; | |
53 | struct rocker_dma_ring_info rx_ring; | |
54 | }; | |
55 | ||
936bd486 JP |
56 | struct rocker_port *rocker_port_dev_lower_find(struct net_device *dev, |
57 | struct rocker *rocker); | |
58 | ||
e420114e JP |
59 | struct rocker_world_ops; |
60 | ||
0514c4e8 JP |
61 | struct rocker { |
62 | struct pci_dev *pdev; | |
63 | u8 __iomem *hw_addr; | |
64 | struct msix_entry *msix_entries; | |
65 | unsigned int port_count; | |
66 | struct rocker_port **ports; | |
67 | struct { | |
68 | u64 id; | |
69 | } hw; | |
70 | spinlock_t cmd_ring_lock; /* for cmd ring accesses */ | |
71 | struct rocker_dma_ring_info cmd_ring; | |
72 | struct rocker_dma_ring_info event_ring; | |
936bd486 | 73 | struct notifier_block fib_nb; |
e420114e | 74 | struct rocker_world_ops *wops; |
c1bb279c | 75 | struct workqueue_struct *rocker_owq; |
e420114e | 76 | void *wpriv; |
0514c4e8 JP |
77 | }; |
78 | ||
3fbcdbf3 JP |
79 | typedef int (*rocker_cmd_prep_cb_t)(const struct rocker_port *rocker_port, |
80 | struct rocker_desc_info *desc_info, | |
81 | void *priv); | |
82 | ||
83 | typedef int (*rocker_cmd_proc_cb_t)(const struct rocker_port *rocker_port, | |
84 | const struct rocker_desc_info *desc_info, | |
85 | void *priv); | |
86 | ||
87 | int rocker_cmd_exec(struct rocker_port *rocker_port, bool nowait, | |
88 | rocker_cmd_prep_cb_t prepare, void *prepare_priv, | |
89 | rocker_cmd_proc_cb_t process, void *process_priv); | |
90 | ||
91 | int rocker_port_set_learning(struct rocker_port *rocker_port, | |
92 | bool learning); | |
93 | ||
e420114e JP |
94 | struct rocker_world_ops { |
95 | const char *kind; | |
96 | size_t priv_size; | |
97 | size_t port_priv_size; | |
98 | u8 mode; | |
99 | int (*init)(struct rocker *rocker); | |
100 | void (*fini)(struct rocker *rocker); | |
101 | int (*port_pre_init)(struct rocker_port *rocker_port); | |
102 | int (*port_init)(struct rocker_port *rocker_port); | |
103 | void (*port_fini)(struct rocker_port *rocker_port); | |
104 | void (*port_post_fini)(struct rocker_port *rocker_port); | |
105 | int (*port_open)(struct rocker_port *rocker_port); | |
106 | void (*port_stop)(struct rocker_port *rocker_port); | |
107 | int (*port_attr_stp_state_set)(struct rocker_port *rocker_port, | |
108 | u8 state, | |
109 | struct switchdev_trans *trans); | |
110 | int (*port_attr_bridge_flags_set)(struct rocker_port *rocker_port, | |
111 | unsigned long brport_flags, | |
112 | struct switchdev_trans *trans); | |
113 | int (*port_attr_bridge_flags_get)(const struct rocker_port *rocker_port, | |
114 | unsigned long *p_brport_flags); | |
115 | int (*port_attr_bridge_ageing_time_set)(struct rocker_port *rocker_port, | |
116 | u32 ageing_time, | |
117 | struct switchdev_trans *trans); | |
118 | int (*port_obj_vlan_add)(struct rocker_port *rocker_port, | |
119 | const struct switchdev_obj_port_vlan *vlan, | |
120 | struct switchdev_trans *trans); | |
121 | int (*port_obj_vlan_del)(struct rocker_port *rocker_port, | |
122 | const struct switchdev_obj_port_vlan *vlan); | |
123 | int (*port_obj_vlan_dump)(const struct rocker_port *rocker_port, | |
124 | struct switchdev_obj_port_vlan *vlan, | |
125 | switchdev_obj_dump_cb_t *cb); | |
e420114e JP |
126 | int (*port_obj_fdb_add)(struct rocker_port *rocker_port, |
127 | const struct switchdev_obj_port_fdb *fdb, | |
128 | struct switchdev_trans *trans); | |
129 | int (*port_obj_fdb_del)(struct rocker_port *rocker_port, | |
130 | const struct switchdev_obj_port_fdb *fdb); | |
131 | int (*port_obj_fdb_dump)(const struct rocker_port *rocker_port, | |
132 | struct switchdev_obj_port_fdb *fdb, | |
133 | switchdev_obj_dump_cb_t *cb); | |
134 | int (*port_master_linked)(struct rocker_port *rocker_port, | |
135 | struct net_device *master); | |
136 | int (*port_master_unlinked)(struct rocker_port *rocker_port, | |
137 | struct net_device *master); | |
138 | int (*port_neigh_update)(struct rocker_port *rocker_port, | |
139 | struct neighbour *n); | |
140 | int (*port_neigh_destroy)(struct rocker_port *rocker_port, | |
141 | struct neighbour *n); | |
142 | int (*port_ev_mac_vlan_seen)(struct rocker_port *rocker_port, | |
143 | const unsigned char *addr, | |
144 | __be16 vlan_id); | |
936bd486 JP |
145 | int (*fib4_add)(struct rocker *rocker, |
146 | const struct fib_entry_notifier_info *fen_info); | |
147 | int (*fib4_del)(struct rocker *rocker, | |
148 | const struct fib_entry_notifier_info *fen_info); | |
149 | void (*fib4_abort)(struct rocker *rocker); | |
e420114e JP |
150 | }; |
151 | ||
152 | extern struct rocker_world_ops rocker_ofdpa_ops; | |
153 | ||
de152192 | 154 | #endif |