Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * net/dsa/dsa_priv.h - Hardware switch handling |
| 3 | * Copyright (c) 2008 Marvell Semiconductor |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | */ |
| 10 | |
| 11 | #ifndef __DSA_PRIV_H |
| 12 | #define __DSA_PRIV_H |
| 13 | |
| 14 | #include <linux/list.h> |
| 15 | #include <linux/phy.h> |
| 16 | #include <linux/timer.h> |
| 17 | #include <linux/workqueue.h> |
| 18 | #include <net/dsa.h> |
| 19 | |
| 20 | struct dsa_switch { |
| 21 | /* |
| 22 | * Configuration data for the platform device that owns |
| 23 | * this dsa switch instance. |
| 24 | */ |
| 25 | struct dsa_platform_data *pd; |
| 26 | |
| 27 | /* |
| 28 | * References to network device and mii bus to use. |
| 29 | */ |
| 30 | struct net_device *master_netdev; |
| 31 | struct mii_bus *master_mii_bus; |
| 32 | |
| 33 | /* |
| 34 | * The used switch driver and frame tagging type. |
| 35 | */ |
| 36 | struct dsa_switch_driver *drv; |
| 37 | __be16 tag_protocol; |
| 38 | |
| 39 | /* |
| 40 | * Slave mii_bus and devices for the individual ports. |
| 41 | */ |
| 42 | int cpu_port; |
| 43 | u32 valid_port_mask; |
| 44 | struct mii_bus *slave_mii_bus; |
| 45 | struct net_device *ports[DSA_MAX_PORTS]; |
| 46 | |
| 47 | /* |
| 48 | * Link state polling. |
| 49 | */ |
| 50 | struct work_struct link_poll_work; |
| 51 | struct timer_list link_poll_timer; |
| 52 | }; |
| 53 | |
| 54 | struct dsa_slave_priv { |
| 55 | struct net_device *dev; |
| 56 | struct dsa_switch *parent; |
| 57 | int port; |
| 58 | struct phy_device *phy; |
| 59 | }; |
| 60 | |
| 61 | struct dsa_switch_driver { |
| 62 | struct list_head list; |
| 63 | |
| 64 | __be16 tag_protocol; |
| 65 | int priv_size; |
| 66 | |
| 67 | /* |
| 68 | * Probing and setup. |
| 69 | */ |
| 70 | char *(*probe)(struct mii_bus *bus, int sw_addr); |
| 71 | int (*setup)(struct dsa_switch *ds); |
| 72 | int (*set_addr)(struct dsa_switch *ds, u8 *addr); |
| 73 | |
| 74 | /* |
| 75 | * Access to the switch's PHY registers. |
| 76 | */ |
| 77 | int (*phy_read)(struct dsa_switch *ds, int port, int regnum); |
| 78 | int (*phy_write)(struct dsa_switch *ds, int port, |
| 79 | int regnum, u16 val); |
| 80 | |
| 81 | /* |
| 82 | * Link state polling and IRQ handling. |
| 83 | */ |
| 84 | void (*poll_link)(struct dsa_switch *ds); |
| 85 | |
| 86 | /* |
| 87 | * ethtool hardware statistics. |
| 88 | */ |
| 89 | void (*get_strings)(struct dsa_switch *ds, int port, uint8_t *data); |
| 90 | void (*get_ethtool_stats)(struct dsa_switch *ds, |
| 91 | int port, uint64_t *data); |
| 92 | int (*get_sset_count)(struct dsa_switch *ds); |
| 93 | }; |
| 94 | |
| 95 | /* dsa.c */ |
| 96 | extern char dsa_driver_version[]; |
| 97 | void register_switch_driver(struct dsa_switch_driver *type); |
| 98 | void unregister_switch_driver(struct dsa_switch_driver *type); |
| 99 | |
| 100 | /* slave.c */ |
| 101 | void dsa_slave_mii_bus_init(struct dsa_switch *ds); |
| 102 | struct net_device *dsa_slave_create(struct dsa_switch *ds, |
| 103 | struct device *parent, |
| 104 | int port, char *name); |
| 105 | |
Lennert Buytenhek | cf85d08 | 2008-10-07 13:45:02 +0000 | [diff] [blame] | 106 | /* tag_dsa.c */ |
| 107 | int dsa_xmit(struct sk_buff *skb, struct net_device *dev); |
| 108 | |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 109 | /* tag_edsa.c */ |
| 110 | int edsa_xmit(struct sk_buff *skb, struct net_device *dev); |
| 111 | |
Lennert Buytenhek | 396138f0 | 2008-10-07 13:46:07 +0000 | [diff] [blame] | 112 | /* tag_trailer.c */ |
| 113 | int trailer_xmit(struct sk_buff *skb, struct net_device *dev); |
| 114 | |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 115 | |
| 116 | #endif |