rocker.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. void *wpriv;
  66. };
  67. typedef int (*rocker_cmd_prep_cb_t)(const struct rocker_port *rocker_port,
  68. struct rocker_desc_info *desc_info,
  69. void *priv);
  70. typedef int (*rocker_cmd_proc_cb_t)(const struct rocker_port *rocker_port,
  71. const struct rocker_desc_info *desc_info,
  72. void *priv);
  73. int rocker_cmd_exec(struct rocker_port *rocker_port, bool nowait,
  74. rocker_cmd_prep_cb_t prepare, void *prepare_priv,
  75. rocker_cmd_proc_cb_t process, void *process_priv);
  76. int rocker_port_set_learning(struct rocker_port *rocker_port,
  77. bool learning);
  78. struct rocker_world_ops {
  79. const char *kind;
  80. size_t priv_size;
  81. size_t port_priv_size;
  82. u8 mode;
  83. int (*init)(struct rocker *rocker);
  84. void (*fini)(struct rocker *rocker);
  85. int (*port_pre_init)(struct rocker_port *rocker_port);
  86. int (*port_init)(struct rocker_port *rocker_port);
  87. void (*port_fini)(struct rocker_port *rocker_port);
  88. void (*port_post_fini)(struct rocker_port *rocker_port);
  89. int (*port_open)(struct rocker_port *rocker_port);
  90. void (*port_stop)(struct rocker_port *rocker_port);
  91. int (*port_attr_stp_state_set)(struct rocker_port *rocker_port,
  92. u8 state,
  93. struct switchdev_trans *trans);
  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_ageing_time_set)(struct rocker_port *rocker_port,
  100. u32 ageing_time,
  101. struct switchdev_trans *trans);
  102. int (*port_obj_vlan_add)(struct rocker_port *rocker_port,
  103. const struct switchdev_obj_port_vlan *vlan,
  104. struct switchdev_trans *trans);
  105. int (*port_obj_vlan_del)(struct rocker_port *rocker_port,
  106. const struct switchdev_obj_port_vlan *vlan);
  107. int (*port_obj_vlan_dump)(const struct rocker_port *rocker_port,
  108. struct switchdev_obj_port_vlan *vlan,
  109. switchdev_obj_dump_cb_t *cb);
  110. int (*port_obj_fdb_add)(struct rocker_port *rocker_port,
  111. const struct switchdev_obj_port_fdb *fdb,
  112. struct switchdev_trans *trans);
  113. int (*port_obj_fdb_del)(struct rocker_port *rocker_port,
  114. const struct switchdev_obj_port_fdb *fdb);
  115. int (*port_obj_fdb_dump)(const struct rocker_port *rocker_port,
  116. struct switchdev_obj_port_fdb *fdb,
  117. switchdev_obj_dump_cb_t *cb);
  118. int (*port_master_linked)(struct rocker_port *rocker_port,
  119. struct net_device *master);
  120. int (*port_master_unlinked)(struct rocker_port *rocker_port,
  121. struct net_device *master);
  122. int (*port_neigh_update)(struct rocker_port *rocker_port,
  123. struct neighbour *n);
  124. int (*port_neigh_destroy)(struct rocker_port *rocker_port,
  125. struct neighbour *n);
  126. int (*port_ev_mac_vlan_seen)(struct rocker_port *rocker_port,
  127. const unsigned char *addr,
  128. __be16 vlan_id);
  129. int (*fib4_add)(struct rocker *rocker,
  130. const struct fib_entry_notifier_info *fen_info);
  131. int (*fib4_del)(struct rocker *rocker,
  132. const struct fib_entry_notifier_info *fen_info);
  133. void (*fib4_abort)(struct rocker *rocker);
  134. };
  135. extern struct rocker_world_ops rocker_ofdpa_ops;
  136. #endif