fcoe_sysfs.h 3.1 KB

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