dsa_priv.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * net/dsa/dsa_priv.h - Hardware switch handling
  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 __DSA_PRIV_H
  11. #define __DSA_PRIV_H
  12. #include <linux/phy.h>
  13. #include <linux/netdevice.h>
  14. #include <linux/netpoll.h>
  15. #include <net/dsa.h>
  16. struct dsa_device_ops {
  17. struct sk_buff *(*xmit)(struct sk_buff *skb, struct net_device *dev);
  18. struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev,
  19. struct packet_type *pt,
  20. struct net_device *orig_dev);
  21. };
  22. struct dsa_slave_priv {
  23. struct sk_buff * (*xmit)(struct sk_buff *skb,
  24. struct net_device *dev);
  25. /* DSA port data, such as switch, port index, etc. */
  26. struct dsa_port *dp;
  27. /*
  28. * The phylib phy_device pointer for the PHY connected
  29. * to this port.
  30. */
  31. struct phy_device *phy;
  32. phy_interface_t phy_interface;
  33. int old_link;
  34. int old_pause;
  35. int old_duplex;
  36. #ifdef CONFIG_NET_POLL_CONTROLLER
  37. struct netpoll *netpoll;
  38. #endif
  39. /* TC context */
  40. struct list_head mall_tc_list;
  41. };
  42. /* dsa.c */
  43. int dsa_cpu_dsa_setup(struct dsa_switch *ds, struct device *dev,
  44. struct dsa_port *dport, int port);
  45. void dsa_cpu_dsa_destroy(struct dsa_port *dport);
  46. const struct dsa_device_ops *dsa_resolve_tag_protocol(int tag_protocol);
  47. int dsa_cpu_port_ethtool_setup(struct dsa_switch *ds);
  48. void dsa_cpu_port_ethtool_restore(struct dsa_switch *ds);
  49. /* legacy.c */
  50. int dsa_legacy_register(void);
  51. void dsa_legacy_unregister(void);
  52. /* port.c */
  53. int dsa_port_set_state(struct dsa_port *dp, u8 state,
  54. struct switchdev_trans *trans);
  55. void dsa_port_set_state_now(struct dsa_port *dp, u8 state);
  56. int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br);
  57. void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br);
  58. int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering,
  59. struct switchdev_trans *trans);
  60. int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock,
  61. struct switchdev_trans *trans);
  62. /* slave.c */
  63. extern const struct dsa_device_ops notag_netdev_ops;
  64. void dsa_slave_mii_bus_init(struct dsa_switch *ds);
  65. void dsa_cpu_port_ethtool_init(struct ethtool_ops *ops);
  66. int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
  67. int port, const char *name);
  68. void dsa_slave_destroy(struct net_device *slave_dev);
  69. int dsa_slave_suspend(struct net_device *slave_dev);
  70. int dsa_slave_resume(struct net_device *slave_dev);
  71. int dsa_slave_register_notifier(void);
  72. void dsa_slave_unregister_notifier(void);
  73. /* switch.c */
  74. int dsa_switch_register_notifier(struct dsa_switch *ds);
  75. void dsa_switch_unregister_notifier(struct dsa_switch *ds);
  76. /* tag_brcm.c */
  77. extern const struct dsa_device_ops brcm_netdev_ops;
  78. /* tag_dsa.c */
  79. extern const struct dsa_device_ops dsa_netdev_ops;
  80. /* tag_edsa.c */
  81. extern const struct dsa_device_ops edsa_netdev_ops;
  82. /* tag_lan9303.c */
  83. extern const struct dsa_device_ops lan9303_netdev_ops;
  84. /* tag_mtk.c */
  85. extern const struct dsa_device_ops mtk_netdev_ops;
  86. /* tag_qca.c */
  87. extern const struct dsa_device_ops qca_netdev_ops;
  88. /* tag_trailer.c */
  89. extern const struct dsa_device_ops trailer_netdev_ops;
  90. #endif