dsa.h 2.7 KB

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