fcoe_sysfs.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * Copyright (c) 2011-2012 Intel Corporation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with
  14. * this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  16. *
  17. * Maintained at www.Open-FCoE.org
  18. */
  19. #ifndef FCOE_SYSFS
  20. #define FCOE_SYSFS
  21. #include <linux/if_ether.h>
  22. #include <linux/device.h>
  23. #include <scsi/fc/fc_fcoe.h>
  24. struct fcoe_ctlr_device;
  25. struct fcoe_fcf_device;
  26. struct fcoe_sysfs_function_template {
  27. void (*get_fcoe_ctlr_link_fail)(struct fcoe_ctlr_device *);
  28. void (*get_fcoe_ctlr_vlink_fail)(struct fcoe_ctlr_device *);
  29. void (*get_fcoe_ctlr_miss_fka)(struct fcoe_ctlr_device *);
  30. void (*get_fcoe_ctlr_symb_err)(struct fcoe_ctlr_device *);
  31. void (*get_fcoe_ctlr_err_block)(struct fcoe_ctlr_device *);
  32. void (*get_fcoe_ctlr_fcs_error)(struct fcoe_ctlr_device *);
  33. void (*set_fcoe_ctlr_mode)(struct fcoe_ctlr_device *);
  34. int (*set_fcoe_ctlr_enabled)(struct fcoe_ctlr_device *);
  35. void (*get_fcoe_fcf_selected)(struct fcoe_fcf_device *);
  36. void (*get_fcoe_fcf_vlan_id)(struct fcoe_fcf_device *);
  37. };
  38. #define dev_to_ctlr(d) \
  39. container_of((d), struct fcoe_ctlr_device, dev)
  40. enum fip_conn_type {
  41. FIP_CONN_TYPE_UNKNOWN,
  42. FIP_CONN_TYPE_FABRIC,
  43. FIP_CONN_TYPE_VN2VN,
  44. };
  45. enum ctlr_enabled_state {
  46. FCOE_CTLR_ENABLED,
  47. FCOE_CTLR_DISABLED,
  48. FCOE_CTLR_UNUSED,
  49. };
  50. struct fcoe_ctlr_device {
  51. u32 id;
  52. struct device dev;
  53. struct fcoe_sysfs_function_template *f;
  54. struct list_head fcfs;
  55. char work_q_name[20];
  56. struct workqueue_struct *work_q;
  57. char devloss_work_q_name[20];
  58. struct workqueue_struct *devloss_work_q;
  59. struct mutex lock;
  60. int fcf_dev_loss_tmo;
  61. enum fip_conn_type mode;
  62. enum ctlr_enabled_state enabled;
  63. /* expected in host order for displaying */
  64. struct fcoe_fc_els_lesb lesb;
  65. };
  66. static inline void *fcoe_ctlr_device_priv(const struct fcoe_ctlr_device *ctlr)
  67. {
  68. return (void *)(ctlr + 1);
  69. }
  70. /* fcf states */
  71. enum fcf_state {
  72. FCOE_FCF_STATE_UNKNOWN,
  73. FCOE_FCF_STATE_DISCONNECTED,
  74. FCOE_FCF_STATE_CONNECTED,
  75. FCOE_FCF_STATE_DELETED,
  76. };
  77. struct fcoe_fcf_device {
  78. u32 id;
  79. struct device dev;
  80. struct list_head peers;
  81. struct work_struct delete_work;
  82. struct delayed_work dev_loss_work;
  83. u32 dev_loss_tmo;
  84. void *priv;
  85. enum fcf_state state;
  86. u64 fabric_name;
  87. u64 switch_name;
  88. u32 fc_map;
  89. u16 vfid;
  90. u8 mac[ETH_ALEN];
  91. u8 priority;
  92. u32 fka_period;
  93. u8 selected;
  94. u16 vlan_id;
  95. };
  96. #define dev_to_fcf(d) \
  97. container_of((d), struct fcoe_fcf_device, dev)
  98. /* parentage should never be missing */
  99. #define fcoe_fcf_dev_to_ctlr_dev(x) \
  100. dev_to_ctlr((x)->dev.parent)
  101. #define fcoe_fcf_device_priv(x) \
  102. ((x)->priv)
  103. struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
  104. struct fcoe_sysfs_function_template *f,
  105. int priv_size);
  106. void fcoe_ctlr_device_delete(struct fcoe_ctlr_device *);
  107. struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *,
  108. struct fcoe_fcf_device *);
  109. void fcoe_fcf_device_delete(struct fcoe_fcf_device *);
  110. int __init fcoe_sysfs_setup(void);
  111. void __exit fcoe_sysfs_teardown(void);
  112. #endif /* FCOE_SYSFS */