blob: 32a1b49e8a8c20a8a403c218ba7f6c5bdc877650 [file] [log] [blame]
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001/*
2 * include/net/dsa.h - Driver for Distributed Switch Architecture switch chips
Lennert Buytenheke84665c2009-03-20 09:52:09 +00003 * Copyright (c) 2008-2009 Marvell Semiconductor
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00004 *
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 Hutchingscf50dcc2011-11-25 14:32:52 +000014#include <linux/timer.h>
15#include <linux/workqueue.h>
16
Lennert Buytenheke84665c2009-03-20 09:52:09 +000017#define DSA_MAX_SWITCHES 4
18#define DSA_MAX_PORTS 12
19
20struct 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 Buytenhek91da11f2008-10-07 13:44:02 +000044
45struct dsa_platform_data {
46 /*
47 * Reference to a Linux network interface that connects
Lennert Buytenheke84665c2009-03-20 09:52:09 +000048 * to the root switch chip of the tree.
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000049 */
50 struct device *netdev;
51
52 /*
Lennert Buytenheke84665c2009-03-20 09:52:09 +000053 * Info structs describing each of the switch chips
54 * connected via this network interface.
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000055 */
Lennert Buytenheke84665c2009-03-20 09:52:09 +000056 int nr_chips;
57 struct dsa_chip_data *chip;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000058};
59
Ben Hutchingscf50dcc2011-11-25 14:32:52 +000060struct 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 Buytenhekcf85d082008-10-07 13:45:02 +000066
Ben Hutchingscf50dcc2011-11-25 14:32:52 +000067 /*
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 */
100static inline bool dsa_uses_dsa_tags(struct dsa_switch_tree *dst)
101{
102 return !!(dst->tag_protocol == htons(ETH_P_DSA));
103}
104
105static inline bool dsa_uses_trailer_tags(struct dsa_switch_tree *dst)
106{
107 return !!(dst->tag_protocol == htons(ETH_P_TRAILER));
108}
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000109
110#endif