aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ps3_gelic_net.h
diff options
context:
space:
mode:
authorMasakazu Mokuno <mokuno@sm.sony.co.jp>2008-02-07 05:58:42 -0500
committerJeff Garzik <jeff@garzik.org>2008-02-11 10:30:02 -0500
commit589866f9f1cb14273b644993d362ec7845007f94 (patch)
treefc36f14ed3b8d583e30264bcb1f9c35fc6818b51 /drivers/net/ps3_gelic_net.h
parent01fed4c284def58b8a9ee0b915c3956b93c670b7 (diff)
PS3: gelic: Add support for dual network interface
Add support for dual network (net_device) interface so that ethernet and wireless can own separate ethX interfaces. V2 - Fix the bug that bringing down and up the interface keeps rx disabled. - Make 'gelic_net_poll_controller()' extern , as David Woodhouse pointed out at the previous submission. - Fix weird usage of member names for the rx descriptor chain V1 - Export functions which are convenient for both interfaces - Move irq allocation/release code to driver probe/remove handlers because interfaces share interrupts. - Allocate skbs by using dev_alloc_skb() instead of netdev_alloc_skb() as the interfaces share the hardware rx queue. - Add gelic_port struct in order to abstract dual interface handling - Change handlers for hardware queues so that they can handle dual {source,destination} interfaces. - Use new NAPI functions This is a prerequisite for the new PS3 wireless support. Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/ps3_gelic_net.h')
-rw-r--r--drivers/net/ps3_gelic_net.h108
1 files changed, 93 insertions, 15 deletions
diff --git a/drivers/net/ps3_gelic_net.h b/drivers/net/ps3_gelic_net.h
index 957221fa5d55..46cfdcdcdbea 100644
--- a/drivers/net/ps3_gelic_net.h
+++ b/drivers/net/ps3_gelic_net.h
@@ -35,12 +35,11 @@
35#define GELIC_NET_MAX_MTU VLAN_ETH_FRAME_LEN 35#define GELIC_NET_MAX_MTU VLAN_ETH_FRAME_LEN
36#define GELIC_NET_MIN_MTU VLAN_ETH_ZLEN 36#define GELIC_NET_MIN_MTU VLAN_ETH_ZLEN
37#define GELIC_NET_RXBUF_ALIGN 128 37#define GELIC_NET_RXBUF_ALIGN 128
38#define GELIC_NET_RX_CSUM_DEFAULT 1 /* hw chksum */ 38#define GELIC_CARD_RX_CSUM_DEFAULT 1 /* hw chksum */
39#define GELIC_NET_WATCHDOG_TIMEOUT 5*HZ 39#define GELIC_NET_WATCHDOG_TIMEOUT 5*HZ
40#define GELIC_NET_NAPI_WEIGHT (GELIC_NET_RX_DESCRIPTORS) 40#define GELIC_NET_NAPI_WEIGHT (GELIC_NET_RX_DESCRIPTORS)
41#define GELIC_NET_BROADCAST_ADDR 0xffffffffffffL 41#define GELIC_NET_BROADCAST_ADDR 0xffffffffffffL
42#define GELIC_NET_VLAN_POS (VLAN_ETH_ALEN * 2) 42
43#define GELIC_NET_VLAN_MAX 4
44#define GELIC_NET_MC_COUNT_MAX 32 /* multicast address list */ 43#define GELIC_NET_MC_COUNT_MAX 32 /* multicast address list */
45 44
46/* virtual interrupt status register bits */ 45/* virtual interrupt status register bits */
@@ -206,6 +205,13 @@ enum gelic_lv1_vlan_index {
206 205
207/* size of hardware part of gelic descriptor */ 206/* size of hardware part of gelic descriptor */
208#define GELIC_DESCR_SIZE (32) 207#define GELIC_DESCR_SIZE (32)
208
209enum gelic_port_type {
210 GELIC_PORT_ETHERNET = 0,
211 GELIC_PORT_WIRELESS = 1,
212 GELIC_PORT_MAX
213};
214
209struct gelic_descr { 215struct gelic_descr {
210 /* as defined by the hardware */ 216 /* as defined by the hardware */
211 __be32 buf_addr; 217 __be32 buf_addr;
@@ -222,7 +228,6 @@ struct gelic_descr {
222 dma_addr_t bus_addr; 228 dma_addr_t bus_addr;
223 struct gelic_descr *next; 229 struct gelic_descr *next;
224 struct gelic_descr *prev; 230 struct gelic_descr *prev;
225 struct vlan_ethhdr vlan;
226} __attribute__((aligned(32))); 231} __attribute__((aligned(32)));
227 232
228struct gelic_descr_chain { 233struct gelic_descr_chain {
@@ -231,43 +236,116 @@ struct gelic_descr_chain {
231 struct gelic_descr *tail; 236 struct gelic_descr *tail;
232}; 237};
233 238
239struct gelic_vlan_id {
240 u16 tx;
241 u16 rx;
242};
243
234struct gelic_card { 244struct gelic_card {
235 struct net_device *netdev;
236 struct napi_struct napi; 245 struct napi_struct napi;
246 struct net_device *netdev[GELIC_PORT_MAX];
237 /* 247 /*
238 * hypervisor requires irq_status should be 248 * hypervisor requires irq_status should be
239 * 8 bytes aligned, but u64 member is 249 * 8 bytes aligned, but u64 member is
240 * always disposed in that manner 250 * always disposed in that manner
241 */ 251 */
242 u64 irq_status; 252 u64 irq_status;
243 u64 ghiintmask; 253 u64 irq_mask;
244 254
245 struct ps3_system_bus_device *dev; 255 struct ps3_system_bus_device *dev;
246 u32 vlan_id[GELIC_NET_VLAN_MAX]; 256 struct gelic_vlan_id vlan[GELIC_PORT_MAX];
247 int vlan_index; 257 int vlan_required;
248 258
249 struct gelic_descr_chain tx_chain; 259 struct gelic_descr_chain tx_chain;
250 struct gelic_descr_chain rx_chain; 260 struct gelic_descr_chain rx_chain;
251 int rx_dma_restart_required; 261 int rx_dma_restart_required;
252 /* gurad dmac descriptor chain*/
253 spinlock_t chain_lock;
254
255 int rx_csum; 262 int rx_csum;
256 /* guard tx_dma_progress */ 263 /*
257 spinlock_t tx_dma_lock; 264 * tx_lock guards tx descriptor list and
265 * tx_dma_progress.
266 */
267 spinlock_t tx_lock;
258 int tx_dma_progress; 268 int tx_dma_progress;
259 269
260 struct work_struct tx_timeout_task; 270 struct work_struct tx_timeout_task;
261 atomic_t tx_timeout_task_counter; 271 atomic_t tx_timeout_task_counter;
262 wait_queue_head_t waitq; 272 wait_queue_head_t waitq;
263 273
274 /* only first user should up the card */
275 struct semaphore updown_lock;
276 atomic_t users;
277
264 u64 ether_port_status; 278 u64 ether_port_status;
279 /* original address returned by kzalloc */
280 void *unalign;
265 281
282 /*
283 * each netdevice has copy of irq
284 */
285 unsigned int irq;
266 struct gelic_descr *tx_top, *rx_top; 286 struct gelic_descr *tx_top, *rx_top;
267 struct gelic_descr descr[0]; 287 struct gelic_descr descr[0]; /* must be the last */
268}; 288};
269 289
290struct gelic_port {
291 struct gelic_card *card;
292 struct net_device *netdev;
293 enum gelic_port_type type;
294 long priv[0]; /* long for alignment */
295};
270 296
271extern unsigned long p_to_lp(long pa); 297static inline struct gelic_card *port_to_card(struct gelic_port *p)
298{
299 return p->card;
300}
301static inline struct net_device *port_to_netdev(struct gelic_port *p)
302{
303 return p->netdev;
304}
305static inline struct gelic_card *netdev_card(struct net_device *d)
306{
307 return ((struct gelic_port *)netdev_priv(d))->card;
308}
309static inline struct gelic_port *netdev_port(struct net_device *d)
310{
311 return (struct gelic_port *)netdev_priv(d);
312}
313static inline struct device *ctodev(struct gelic_card *card)
314{
315 return &card->dev->core;
316}
317static inline u64 bus_id(struct gelic_card *card)
318{
319 return card->dev->bus_id;
320}
321static inline u64 dev_id(struct gelic_card *card)
322{
323 return card->dev->dev_id;
324}
325
326static inline void *port_priv(struct gelic_port *port)
327{
328 return port->priv;
329}
330
331extern int gelic_card_set_irq_mask(struct gelic_card *card, u64 mask);
332/* shared netdev ops */
333extern void gelic_card_up(struct gelic_card *card);
334extern void gelic_card_down(struct gelic_card *card);
335extern int gelic_net_open(struct net_device *netdev);
336extern int gelic_net_stop(struct net_device *netdev);
337extern int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev);
338extern void gelic_net_set_multi(struct net_device *netdev);
339extern void gelic_net_tx_timeout(struct net_device *netdev);
340extern int gelic_net_change_mtu(struct net_device *netdev, int new_mtu);
341extern int gelic_net_setup_netdev(struct net_device *netdev,
342 struct gelic_card *card);
343
344/* shared ethtool ops */
345extern void gelic_net_get_drvinfo(struct net_device *netdev,
346 struct ethtool_drvinfo *info);
347extern u32 gelic_net_get_rx_csum(struct net_device *netdev);
348extern int gelic_net_set_rx_csum(struct net_device *netdev, u32 data);
349extern void gelic_net_poll_controller(struct net_device *netdev);
272 350
273#endif /* _GELIC_NET_H */ 351#endif /* _GELIC_NET_H */