fcoe_sysfs.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2011-2012 Intel Corporation. All rights reserved.
  4. *
  5. * Maintained at www.Open-FCoE.org
  6. */
  7. #ifndef FCOE_SYSFS
  8. #define FCOE_SYSFS
  9. #include <linux/if_ether.h>
  10. #include <linux/device.h>
  11. #include <scsi/fc/fc_fcoe.h>
  12. struct fcoe_ctlr_device;
  13. struct fcoe_fcf_device;
  14. struct fcoe_sysfs_function_template {
  15. void (*get_fcoe_ctlr_link_fail)(struct fcoe_ctlr_device *);
  16. void (*get_fcoe_ctlr_vlink_fail)(struct fcoe_ctlr_device *);
  17. void (*get_fcoe_ctlr_miss_fka)(struct fcoe_ctlr_device *);
  18. void (*get_fcoe_ctlr_symb_err)(struct fcoe_ctlr_device *);
  19. void (*get_fcoe_ctlr_err_block)(struct fcoe_ctlr_device *);
  20. void (*get_fcoe_ctlr_fcs_error)(struct fcoe_ctlr_device *);
  21. void (*set_fcoe_ctlr_mode)(struct fcoe_ctlr_device *);
  22. int (*set_fcoe_ctlr_enabled)(struct fcoe_ctlr_device *);
  23. void (*get_fcoe_fcf_selected)(struct fcoe_fcf_device *);
  24. void (*get_fcoe_fcf_vlan_id)(struct fcoe_fcf_device *);
  25. };
  26. #define dev_to_ctlr(d) \
  27. container_of((d), struct fcoe_ctlr_device, dev)
  28. enum fip_conn_type {
  29. FIP_CONN_TYPE_UNKNOWN,
  30. FIP_CONN_TYPE_FABRIC,
  31. FIP_CONN_TYPE_VN2VN,
  32. };
  33. enum ctlr_enabled_state {
  34. FCOE_CTLR_ENABLED,
  35. FCOE_CTLR_DISABLED,
  36. FCOE_CTLR_UNUSED,
  37. };
  38. struct fcoe_ctlr_device {
  39. u32 id;
  40. struct device dev;
  41. struct fcoe_sysfs_function_template *f;
  42. struct list_head fcfs;
  43. char work_q_name[20];
  44. struct workqueue_struct *work_q;
  45. char devloss_work_q_name[20];
  46. struct workqueue_struct *devloss_work_q;
  47. struct mutex lock;
  48. int fcf_dev_loss_tmo;
  49. enum fip_conn_type mode;
  50. enum ctlr_enabled_state enabled;
  51. /* expected in host order for displaying */
  52. struct fcoe_fc_els_lesb lesb;
  53. };
  54. static inline void *fcoe_ctlr_device_priv(const struct fcoe_ctlr_device *ctlr)
  55. {
  56. return (void *)(ctlr + 1);
  57. }
  58. /* fcf states */
  59. enum fcf_state {
  60. FCOE_FCF_STATE_UNKNOWN,
  61. FCOE_FCF_STATE_DISCONNECTED,
  62. FCOE_FCF_STATE_CONNECTED,
  63. FCOE_FCF_STATE_DELETED,
  64. };
  65. struct fcoe_fcf_device {
  66. u32 id;
  67. struct device dev;
  68. struct list_head peers;
  69. struct work_struct delete_work;
  70. struct delayed_work dev_loss_work;
  71. u32 dev_loss_tmo;
  72. void *priv;
  73. enum fcf_state state;
  74. u64 fabric_name;
  75. u64 switch_name;
  76. u32 fc_map;
  77. u16 vfid;
  78. u8 mac[ETH_ALEN];
  79. u8 priority;
  80. u32 fka_period;
  81. u8 selected;
  82. u16 vlan_id;
  83. };
  84. #define dev_to_fcf(d) \
  85. container_of((d), struct fcoe_fcf_device, dev)
  86. /* parentage should never be missing */
  87. #define fcoe_fcf_dev_to_ctlr_dev(x) \
  88. dev_to_ctlr((x)->dev.parent)
  89. #define fcoe_fcf_device_priv(x) \
  90. ((x)->priv)
  91. struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
  92. struct fcoe_sysfs_function_template *f,
  93. int priv_size);
  94. void fcoe_ctlr_device_delete(struct fcoe_ctlr_device *);
  95. struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *,
  96. struct fcoe_fcf_device *);
  97. void fcoe_fcf_device_delete(struct fcoe_fcf_device *);
  98. int __init fcoe_sysfs_setup(void);
  99. void __exit fcoe_sysfs_teardown(void);
  100. #endif /* FCOE_SYSFS */