Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * include/net/dsa.h - Driver for Distributed Switch Architecture switch chips |
Lennert Buytenhek | e84665c | 2009-03-20 09:52:09 +0000 | [diff] [blame] | 3 | * Copyright (c) 2008-2009 Marvell Semiconductor |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 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 __LINUX_NET_DSA_H |
| 12 | #define __LINUX_NET_DSA_H |
| 13 | |
Ben Hutchings | cf50dcc | 2011-11-25 14:32:52 +0000 | [diff] [blame^] | 14 | #include <linux/timer.h> |
| 15 | #include <linux/workqueue.h> |
| 16 | |
Lennert Buytenhek | e84665c | 2009-03-20 09:52:09 +0000 | [diff] [blame] | 17 | #define DSA_MAX_SWITCHES 4 |
| 18 | #define DSA_MAX_PORTS 12 |
| 19 | |
| 20 | struct dsa_chip_data { |
| 21 | /* |
| 22 | * How to access the switch configuration registers. |
| 23 | */ |
| 24 | struct device *mii_bus; |
| 25 | int sw_addr; |
| 26 | |
| 27 | /* |
| 28 | * The names of the switch's ports. Use "cpu" to |
| 29 | * designate the switch port that the cpu is connected to, |
| 30 | * "dsa" to indicate that this port is a DSA link to |
| 31 | * another switch, NULL to indicate the port is unused, |
| 32 | * or any other string to indicate this is a physical port. |
| 33 | */ |
| 34 | char *port_names[DSA_MAX_PORTS]; |
| 35 | |
| 36 | /* |
| 37 | * An array (with nr_chips elements) of which element [a] |
| 38 | * indicates which port on this switch should be used to |
| 39 | * send packets to that are destined for switch a. Can be |
| 40 | * NULL if there is only one switch chip. |
| 41 | */ |
| 42 | s8 *rtable; |
| 43 | }; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 44 | |
| 45 | struct dsa_platform_data { |
| 46 | /* |
| 47 | * Reference to a Linux network interface that connects |
Lennert Buytenhek | e84665c | 2009-03-20 09:52:09 +0000 | [diff] [blame] | 48 | * to the root switch chip of the tree. |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 49 | */ |
| 50 | struct device *netdev; |
| 51 | |
| 52 | /* |
Lennert Buytenhek | e84665c | 2009-03-20 09:52:09 +0000 | [diff] [blame] | 53 | * Info structs describing each of the switch chips |
| 54 | * connected via this network interface. |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 55 | */ |
Lennert Buytenhek | e84665c | 2009-03-20 09:52:09 +0000 | [diff] [blame] | 56 | int nr_chips; |
| 57 | struct dsa_chip_data *chip; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
Ben Hutchings | cf50dcc | 2011-11-25 14:32:52 +0000 | [diff] [blame^] | 60 | struct dsa_switch_tree { |
| 61 | /* |
| 62 | * Configuration data for the platform device that owns |
| 63 | * this dsa switch tree instance. |
| 64 | */ |
| 65 | struct dsa_platform_data *pd; |
Lennert Buytenhek | cf85d08 | 2008-10-07 13:45:02 +0000 | [diff] [blame] | 66 | |
Ben Hutchings | cf50dcc | 2011-11-25 14:32:52 +0000 | [diff] [blame^] | 67 | /* |
| 68 | * Reference to network device to use, and which tagging |
| 69 | * protocol to use. |
| 70 | */ |
| 71 | struct net_device *master_netdev; |
| 72 | __be16 tag_protocol; |
| 73 | |
| 74 | /* |
| 75 | * The switch and port to which the CPU is attached. |
| 76 | */ |
| 77 | s8 cpu_switch; |
| 78 | s8 cpu_port; |
| 79 | |
| 80 | /* |
| 81 | * Link state polling. |
| 82 | */ |
| 83 | int link_poll_needed; |
| 84 | struct work_struct link_poll_work; |
| 85 | struct timer_list link_poll_timer; |
| 86 | |
| 87 | /* |
| 88 | * Data for the individual switch chips. |
| 89 | */ |
| 90 | struct dsa_switch *ds[DSA_MAX_SWITCHES]; |
| 91 | }; |
| 92 | |
| 93 | /* |
| 94 | * The original DSA tag format and some other tag formats have no |
| 95 | * ethertype, which means that we need to add a little hack to the |
| 96 | * networking receive path to make sure that received frames get |
| 97 | * the right ->protocol assigned to them when one of those tag |
| 98 | * formats is in use. |
| 99 | */ |
| 100 | static inline bool dsa_uses_dsa_tags(struct dsa_switch_tree *dst) |
| 101 | { |
| 102 | return !!(dst->tag_protocol == htons(ETH_P_DSA)); |
| 103 | } |
| 104 | |
| 105 | static inline bool dsa_uses_trailer_tags(struct dsa_switch_tree *dst) |
| 106 | { |
| 107 | return !!(dst->tag_protocol == htons(ETH_P_TRAILER)); |
| 108 | } |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 109 | |
| 110 | #endif |