fcoe_sysfs.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 (*get_fcoe_ctlr_mode)(struct fcoe_ctlr_device *);
  34. void (*get_fcoe_fcf_selected)(struct fcoe_fcf_device *);
  35. void (*get_fcoe_fcf_vlan_id)(struct fcoe_fcf_device *);
  36. };
  37. #define dev_to_ctlr(d) \
  38. container_of((d), struct fcoe_ctlr_device, dev)
  39. enum fip_conn_type {
  40. FIP_CONN_TYPE_UNKNOWN,
  41. FIP_CONN_TYPE_FABRIC,
  42. FIP_CONN_TYPE_VN2VN,
  43. };
  44. struct fcoe_ctlr_device {
  45. u32 id;
  46. struct device dev;
  47. struct fcoe_sysfs_function_template *f;
  48. struct list_head fcfs;
  49. char work_q_name[20];
  50. struct workqueue_struct *work_q;
  51. char devloss_work_q_name[20];
  52. struct workqueue_struct *devloss_work_q;
  53. struct mutex lock;
  54. int fcf_dev_loss_tmo;
  55. enum fip_conn_type mode;
  56. /* expected in host order for displaying */
  57. struct fcoe_fc_els_lesb lesb;
  58. };
  59. static inline void *fcoe_ctlr_device_priv(const struct fcoe_ctlr_device *ctlr)
  60. {
  61. return (void *)(ctlr + 1);
  62. }
  63. /* fcf states */
  64. enum fcf_state {
  65. FCOE_FCF_STATE_UNKNOWN,
  66. FCOE_FCF_STATE_DISCONNECTED,
  67. FCOE_FCF_STATE_CONNECTED,
  68. FCOE_FCF_STATE_DELETED,
  69. };
  70. struct fcoe_fcf_device {
  71. u32 id;
  72. struct device dev;
  73. struct list_head peers;
  74. struct work_struct delete_work;
  75. struct delayed_work dev_loss_work;
  76. u32 dev_loss_tmo;
  77. void *priv;
  78. enum fcf_state state;
  79. u64 fabric_name;
  80. u64 switch_name;
  81. u32 fc_map;
  82. u16 vfid;
  83. u8 mac[ETH_ALEN];
  84. u8 priority;
  85. u32 fka_period;
  86. u8 selected;
  87. u16 vlan_id;
  88. };
  89. #define dev_to_fcf(d) \
  90. container_of((d), struct fcoe_fcf_device, dev)
  91. /* parentage should never be missing */
  92. #define fcoe_fcf_dev_to_ctlr_dev(x) \
  93. dev_to_ctlr((x)->dev.parent)
  94. #define fcoe_fcf_device_priv(x) \
  95. ((x)->priv)
  96. struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
  97. struct fcoe_sysfs_function_template *f,
  98. int priv_size);
  99. void fcoe_ctlr_device_delete(struct fcoe_ctlr_device *);
  100. struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *,
  101. struct fcoe_fcf_device *);
  102. void fcoe_fcf_device_delete(struct fcoe_fcf_device *);
  103. int __init fcoe_sysfs_setup(void);
  104. void __exit fcoe_sysfs_teardown(void);
  105. #endif /* FCOE_SYSFS */