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