/* * include/net/dsa.h - Driver for Distributed Switch Architecture switch chips * Copyright (c) 2008-2009 Marvell Semiconductor * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ #ifndef __LINUX_NET_DSA_H #define __LINUX_NET_DSA_H #include #include #define DSA_MAX_SWITCHES 4 #define DSA_MAX_PORTS 12 struct dsa_chip_data { /* * How to access the switch configuration registers. */ struct device *mii_bus; int sw_addr; /* * The names of the switch's ports. Use "cpu" to * designate the switch port that the cpu is connected to, * "dsa" to indicate that this port is a DSA link to * another switch, NULL to indicate the port is unused, * or any other string to indicate this is a physical port. */ char *port_names[DSA_MAX_PORTS]; /* * An array (with nr_chips elements) of which element [a] * indicates which port on this switch should be used to * send packets to that are destined for switch a. Can be * NULL if there is only one switch chip. */ s8 *rtable; }; struct dsa_platform_data { /* * Reference to a Linux network interface that connects * to the root switch chip of the tree. */ struct device *netdev; /* * Info structs describing each of the switch chips * connected via this network interface. */ int nr_chips; struct dsa_chip_data *chip; }; struct dsa_switch_tree { /* * Configuration data for the platform device that owns * this dsa switch tree instance. */ struct dsa_platform_data *pd; /* * Reference to network device to use, and which tagging * protocol to use. */ struct net_device *master_netdev; __be16 tag_protocol; /* * The switch and port to which the CPU is attached. */ s8 cpu_switch; s8 cpu_port; /* * Link state polling. */ int link_poll_needed; struct work_struct link_poll_work; struct timer_list link_poll_timer; /* * Data for the individual switch chips. */ struct dsa_switch *ds[DSA_MAX_SWITCHES]; }; /* * The original DSA tag format and some other tag formats have no * ethertype, which means that we need to add a little hack to the * networking receive path to make sure that received frames get * the right ->protocol assigned to them when one of those tag * formats is in use. */ static inline bool dsa_uses_dsa_tags(struct dsa_switch_tree *dst) { return !!(dst->tag_protocol == htons(ETH_P_DSA)); } static inline bool dsa_uses_trailer_tags(struct dsa_switch_tree *dst) { return !!(dst->tag_protocol == htons(ETH_P_TRAILER)); } #endif