rocker.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * drivers/net/ethernet/rocker/rocker.h - Rocker switch device driver
  3. * Copyright (c) 2014-2016 Jiri Pirko <jiri@mellanox.com>
  4. * Copyright (c) 2014 Scott Feldman <sfeldma@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #ifndef _ROCKER_H
  12. #define _ROCKER_H
  13. #include <linux/kernel.h>
  14. #include <linux/types.h>
  15. #include <linux/netdevice.h>
  16. #include <linux/notifier.h>
  17. #include <net/neighbour.h>
  18. #include <net/switchdev.h>
  19. #include "rocker_hw.h"
  20. struct rocker_desc_info {
  21. char *data; /* mapped */
  22. size_t data_size;
  23. size_t tlv_size;
  24. struct rocker_desc *desc;
  25. dma_addr_t mapaddr;
  26. };
  27. struct rocker_dma_ring_info {
  28. size_t size;
  29. u32 head;
  30. u32 tail;
  31. struct rocker_desc *desc; /* mapped */
  32. dma_addr_t mapaddr;
  33. struct rocker_desc_info *desc_info;
  34. unsigned int type;
  35. };
  36. struct rocker;
  37. struct rocker_port {
  38. struct net_device *dev;
  39. struct rocker *rocker;
  40. void *wpriv;
  41. unsigned int port_number;
  42. u32 pport;
  43. struct napi_struct napi_tx;
  44. struct napi_struct napi_rx;
  45. struct rocker_dma_ring_info tx_ring;
  46. struct rocker_dma_ring_info rx_ring;
  47. };
  48. struct rocker_port *rocker_port_dev_lower_find(struct net_device *dev,
  49. struct rocker *rocker);
  50. struct rocker_world_ops;
  51. struct rocker {
  52. struct pci_dev *pdev;
  53. u8 __iomem *hw_addr;
  54. struct msix_entry *msix_entries;
  55. unsigned int port_count;
  56. struct rocker_port **ports;
  57. struct {
  58. u64 id;
  59. } hw;
  60. spinlock_t cmd_ring_lock; /* for cmd ring accesses */
  61. struct rocker_dma_ring_info cmd_ring;
  62. struct rocker_dma_ring_info event_ring;
  63. struct notifier_block fib_nb;
  64. struct rocker_world_ops *wops;
  65. struct workqueue_struct *rocker_owq;
  66. void *wpriv;
  67. };
  68. typedef int (*rocker_cmd_prep_cb_t)(const struct rocker_port *rocker_port,
  69. struct rocker_desc_info *desc_info,
  70. void *priv);
  71. typedef int (*rocker_cmd_proc_cb_t)(const struct rocker_port *rocker_port,
  72. const struct rocker_desc_info *desc_info,
  73. void *priv);
  74. int rocker_cmd_exec(struct rocker_port *rocker_port, bool nowait,
  75. rocker_cmd_prep_cb_t prepare, void *prepare_priv,
  76. rocker_cmd_proc_cb_t process, void *process_priv);
  77. int rocker_port_set_learning(struct rocker_port *rocker_port,
  78. bool learning);
  79. struct rocker_world_ops {
  80. const char *kind;
  81. size_t priv_size;
  82. size_t port_priv_size;
  83. u8 mode;
  84. int (*init)(struct rocker *rocker);
  85. void (*fini)(struct rocker *rocker);
  86. int (*port_pre_init)(struct rocker_port *rocker_port);
  87. int (*port_init)(struct rocker_port *rocker_port);
  88. void (*port_fini)(struct rocker_port *rocker_port);
  89. void (*port_post_fini)(struct rocker_port *rocker_port);
  90. int (*port_open)(struct rocker_port *rocker_port);
  91. void (*port_stop)(struct rocker_port *rocker_port);
  92. int (*port_attr_stp_state_set)(struct rocker_port *rocker_port,
  93. u8 state);
  94. int (*port_attr_bridge_flags_set)(struct rocker_port *rocker_port,
  95. unsigned long brport_flags,
  96. struct switchdev_trans *trans);
  97. int (*port_attr_bridge_flags_get)(const struct rocker_port *rocker_port,
  98. unsigned long *p_brport_flags);
  99. int (*port_attr_bridge_flags_support_get)(const struct rocker_port *
  100. rocker_port,
  101. unsigned long *
  102. p_brport_flags);
  103. int (*port_attr_bridge_ageing_time_set)(struct rocker_port *rocker_port,
  104. u32 ageing_time,
  105. struct switchdev_trans *trans);
  106. int (*port_obj_vlan_add)(struct rocker_port *rocker_port,
  107. const struct switchdev_obj_port_vlan *vlan);
  108. int (*port_obj_vlan_del)(struct rocker_port *rocker_port,
  109. const struct switchdev_obj_port_vlan *vlan);
  110. int (*port_obj_fdb_add)(struct rocker_port *rocker_port,
  111. u16 vid, const unsigned char *addr);
  112. int (*port_obj_fdb_del)(struct rocker_port *rocker_port,
  113. u16 vid, const unsigned char *addr);
  114. int (*port_master_linked)(struct rocker_port *rocker_port,
  115. struct net_device *master);
  116. int (*port_master_unlinked)(struct rocker_port *rocker_port,
  117. struct net_device *master);
  118. int (*port_neigh_update)(struct rocker_port *rocker_port,
  119. struct neighbour *n);
  120. int (*port_neigh_destroy)(struct rocker_port *rocker_port,
  121. struct neighbour *n);
  122. int (*port_ev_mac_vlan_seen)(struct rocker_port *rocker_port,
  123. const unsigned char *addr,
  124. __be16 vlan_id);
  125. int (*fib4_add)(struct rocker *rocker,
  126. const struct fib_entry_notifier_info *fen_info);
  127. int (*fib4_del)(struct rocker *rocker,
  128. const struct fib_entry_notifier_info *fen_info);
  129. void (*fib4_abort)(struct rocker *rocker);
  130. };
  131. extern struct rocker_world_ops rocker_ofdpa_ops;
  132. #endif