dsa_priv.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. #ifndef __DSA_PRIV_H
  11. #define __DSA_PRIV_H
  12. #include <linux/list.h>
  13. #include <linux/phy.h>
  14. #include <linux/timer.h>
  15. #include <linux/workqueue.h>
  16. #include <net/dsa.h>
  17. struct dsa_switch {
  18. /*
  19. * Configuration data for the platform device that owns
  20. * this dsa switch instance.
  21. */
  22. struct dsa_platform_data *pd;
  23. /*
  24. * References to network device and mii bus to use.
  25. */
  26. struct net_device *master_netdev;
  27. struct mii_bus *master_mii_bus;
  28. /*
  29. * The used switch driver and frame tagging type.
  30. */
  31. struct dsa_switch_driver *drv;
  32. __be16 tag_protocol;
  33. /*
  34. * Slave mii_bus and devices for the individual ports.
  35. */
  36. int cpu_port;
  37. u32 valid_port_mask;
  38. struct mii_bus *slave_mii_bus;
  39. struct net_device *ports[DSA_MAX_PORTS];
  40. /*
  41. * Link state polling.
  42. */
  43. struct work_struct link_poll_work;
  44. struct timer_list link_poll_timer;
  45. };
  46. struct dsa_slave_priv {
  47. struct net_device *dev;
  48. struct dsa_switch *parent;
  49. int port;
  50. struct phy_device *phy;
  51. };
  52. struct dsa_switch_driver {
  53. struct list_head list;
  54. __be16 tag_protocol;
  55. int priv_size;
  56. /*
  57. * Probing and setup.
  58. */
  59. char *(*probe)(struct mii_bus *bus, int sw_addr);
  60. int (*setup)(struct dsa_switch *ds);
  61. int (*set_addr)(struct dsa_switch *ds, u8 *addr);
  62. /*
  63. * Access to the switch's PHY registers.
  64. */
  65. int (*phy_read)(struct dsa_switch *ds, int port, int regnum);
  66. int (*phy_write)(struct dsa_switch *ds, int port,
  67. int regnum, u16 val);
  68. /*
  69. * Link state polling and IRQ handling.
  70. */
  71. void (*poll_link)(struct dsa_switch *ds);
  72. /*
  73. * ethtool hardware statistics.
  74. */
  75. void (*get_strings)(struct dsa_switch *ds, int port, uint8_t *data);
  76. void (*get_ethtool_stats)(struct dsa_switch *ds,
  77. int port, uint64_t *data);
  78. int (*get_sset_count)(struct dsa_switch *ds);
  79. };
  80. /* dsa.c */
  81. extern char dsa_driver_version[];
  82. void register_switch_driver(struct dsa_switch_driver *type);
  83. void unregister_switch_driver(struct dsa_switch_driver *type);
  84. /* slave.c */
  85. void dsa_slave_mii_bus_init(struct dsa_switch *ds);
  86. struct net_device *dsa_slave_create(struct dsa_switch *ds,
  87. struct device *parent,
  88. int port, char *name);
  89. /* tag_dsa.c */
  90. int dsa_xmit(struct sk_buff *skb, struct net_device *dev);
  91. /* tag_edsa.c */
  92. int edsa_xmit(struct sk_buff *skb, struct net_device *dev);
  93. /* tag_trailer.c */
  94. int trailer_xmit(struct sk_buff *skb, struct net_device *dev);
  95. #endif