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>
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.
15 #include <linux/kernel.h>
16 #include <linux/types.h>
17 #include <linux/netdevice.h>
18 #include <linux/notifier.h>
19 #include <net/neighbour.h>
20 #include <net/switchdev.h>
22 #include "rocker_hw.h"
24 struct rocker_desc_info
{
25 char *data
; /* mapped */
28 struct rocker_desc
*desc
;
32 struct rocker_dma_ring_info
{
36 struct rocker_desc
*desc
; /* mapped */
38 struct rocker_desc_info
*desc_info
;
45 struct net_device
*dev
;
46 struct rocker
*rocker
;
48 unsigned int port_number
;
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
;
56 struct rocker_port
*rocker_port_dev_lower_find(struct net_device
*dev
,
57 struct rocker
*rocker
);
59 struct rocker_world_ops
;
64 struct msix_entry
*msix_entries
;
65 unsigned int port_count
;
66 struct rocker_port
**ports
;
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
;
73 struct notifier_block fib_nb
;
74 struct rocker_world_ops
*wops
;
75 struct workqueue_struct
*rocker_owq
;
79 typedef int (*rocker_cmd_prep_cb_t
)(const struct rocker_port
*rocker_port
,
80 struct rocker_desc_info
*desc_info
,
83 typedef int (*rocker_cmd_proc_cb_t
)(const struct rocker_port
*rocker_port
,
84 const struct rocker_desc_info
*desc_info
,
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
);
91 int rocker_port_set_learning(struct rocker_port
*rocker_port
,
94 struct rocker_world_ops
{
97 size_t port_priv_size
;
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
,
109 int (*port_attr_bridge_flags_set
)(struct rocker_port
*rocker_port
,
110 unsigned long brport_flags
,
111 struct switchdev_trans
*trans
);
112 int (*port_attr_bridge_flags_support_get
)(const struct rocker_port
*
116 int (*port_attr_bridge_ageing_time_set
)(struct rocker_port
*rocker_port
,
118 struct switchdev_trans
*trans
);
119 int (*port_obj_vlan_add
)(struct rocker_port
*rocker_port
,
120 const struct switchdev_obj_port_vlan
*vlan
);
121 int (*port_obj_vlan_del
)(struct rocker_port
*rocker_port
,
122 const struct switchdev_obj_port_vlan
*vlan
);
123 int (*port_obj_fdb_add
)(struct rocker_port
*rocker_port
,
124 u16 vid
, const unsigned char *addr
);
125 int (*port_obj_fdb_del
)(struct rocker_port
*rocker_port
,
126 u16 vid
, const unsigned char *addr
);
127 int (*port_master_linked
)(struct rocker_port
*rocker_port
,
128 struct net_device
*master
);
129 int (*port_master_unlinked
)(struct rocker_port
*rocker_port
,
130 struct net_device
*master
);
131 int (*port_neigh_update
)(struct rocker_port
*rocker_port
,
132 struct neighbour
*n
);
133 int (*port_neigh_destroy
)(struct rocker_port
*rocker_port
,
134 struct neighbour
*n
);
135 int (*port_ev_mac_vlan_seen
)(struct rocker_port
*rocker_port
,
136 const unsigned char *addr
,
138 int (*fib4_add
)(struct rocker
*rocker
,
139 const struct fib_entry_notifier_info
*fen_info
);
140 int (*fib4_del
)(struct rocker
*rocker
,
141 const struct fib_entry_notifier_info
*fen_info
);
142 void (*fib4_abort
)(struct rocker
*rocker
);
145 extern struct rocker_world_ops rocker_ofdpa_ops
;